@adminide-stack/yantra-mobile 12.0.172-alpha.0 → 12.0.172-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/GatewayConnector/GatewayConnector.js +10 -4
- package/lib/components/GatewayConnector/GatewayConnector.js.map +1 -1
- package/lib/components/GatewayConnector/GatewayStatusSheet.js +174 -0
- package/lib/components/GatewayConnector/GatewayStatusSheet.js.map +1 -0
- package/lib/components/GatewayToolbarButtonMobile.js +6 -2
- package/lib/components/GatewayToolbarButtonMobile.js.map +1 -1
- package/lib/config/env-config.js +12 -3
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/apps/nativeAppHandoff.js +31 -13
- package/lib/features/apps/nativeAppHandoff.js.map +1 -1
- package/lib/features/chat/PromptFillBar.js +153 -0
- package/lib/features/chat/PromptFillBar.js.map +1 -0
- package/lib/features/chat/promptBlanks.js +120 -0
- package/lib/features/chat/promptBlanks.js.map +1 -0
- package/lib/features/chat/savedReply.js +11 -0
- package/lib/features/chat/savedReply.js.map +1 -0
- package/lib/features/games/GameInviteCard.js +93 -0
- package/lib/features/games/GameInviteCard.js.map +1 -0
- package/lib/features/games/cubeforge3D.js +75 -4
- package/lib/features/games/cubeforge3D.js.map +1 -1
- package/lib/features/games/cubeforgeFriends.js +112 -0
- package/lib/features/games/cubeforgeFriends.js.map +1 -0
- package/lib/features/games/gameInvite.js +13 -0
- package/lib/features/games/gameInvite.js.map +1 -0
- package/lib/features/games/useCubeforgeFriends.js +63 -0
- package/lib/features/games/useCubeforgeFriends.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js +68 -0
- package/lib/features/games/vendored/core/cubeforge/nativeWorlds.js.map +1 -0
- package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js +10 -0
- package/lib/features/games/vendored/core/cubeforge/sharedWorlds.js.map +1 -0
- package/lib/features/games/vendored/ui/GamesRoot.js +69 -5
- package/lib/features/games/vendored/ui/GamesRoot.js.map +1 -1
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js +296 -0
- package/lib/features/games/vendored/ui/screens/Cubeforge3DHomeScreen.js.map +1 -0
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js +1 -1
- package/lib/features/games/vendored/ui/screens/CubeforgeScreen.js.map +1 -1
- package/lib/features/messaging/ChatComponents.js +12 -4
- package/lib/features/messaging/ChatComponents.js.map +1 -1
- package/lib/features/messaging/messageCards.js +22 -0
- package/lib/features/messaging/messageCards.js.map +1 -0
- package/lib/features/travel/TravelAgentChatPane.js +9 -1
- package/lib/features/travel/TravelAgentChatPane.js.map +1 -1
- package/lib/hooks/useCdecliAutoConnect.js +8 -1
- package/lib/hooks/useCdecliAutoConnect.js.map +1 -1
- package/lib/hooks/useCdecliChannel.js +142 -49
- package/lib/hooks/useCdecliChannel.js.map +1 -1
- package/lib/hooks/useChatApi.js +21 -10
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/hooks/useChatStream.js +18 -5
- package/lib/hooks/useChatStream.js.map +1 -1
- package/lib/module.js +2 -1
- package/lib/module.js.map +1 -1
- package/lib/screens/Chat/index.js +23 -15
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/GamesNative/index.js +48 -3
- package/lib/screens/GamesNative/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +147 -33
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/HomeSuggestions.js +1 -1
- package/lib/screens/Home/components/HomeSuggestions.js.map +1 -1
- package/lib/screens/Home/components/homeCatalog.js +68 -16
- package/lib/screens/Home/components/homeCatalog.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {jsx}from'react/jsx-runtime';import React__default,{useCallback}from'react';import'react-native';import'common/graphql';import'../../config/env-config.js';import'../../hooks/usePrerequisiteIds.js';import'common';import'@react-native-async-storage/async-storage';import'expo-secure-store';import'../../features/messaging/yantraChatOrg.js';import {useCdecliConnection}from'../../contexts/cdecliConnection.js';import {useGatewayContext}from'../../contexts/GatewayContext.js';import {GatewayToolbarButtonMobile}from'../GatewayToolbarButtonMobile.js';function mapCdecliStatus(status) {
|
|
1
|
+
import {jsxs,Fragment,jsx}from'react/jsx-runtime';import React__default,{useState,useCallback}from'react';import {useColorScheme}from'react-native';import'common/graphql';import'../../config/env-config.js';import'../../hooks/usePrerequisiteIds.js';import'common';import'@react-native-async-storage/async-storage';import'expo-secure-store';import'../../features/messaging/yantraChatOrg.js';import {useCdecliConnection}from'../../contexts/cdecliConnection.js';import {useGatewayContext}from'../../contexts/GatewayContext.js';import {GatewayToolbarButtonMobile}from'../GatewayToolbarButtonMobile.js';import {GatewayStatusSheet}from'./GatewayStatusSheet.js';function mapCdecliStatus(status) {
|
|
2
2
|
if (status === "connecting") return "connecting";
|
|
3
3
|
if (status === "connected") return "connected";
|
|
4
4
|
if (status === "error") return "error";
|
|
@@ -15,8 +15,14 @@ const GatewayConnector = ({
|
|
|
15
15
|
} = useGatewayContext();
|
|
16
16
|
const gatewayStatus = mapCdecliStatus(cdecli.status);
|
|
17
17
|
const gatewayLabel = cdecli.status === "connecting" ? "Checking..." : void 0;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const deviceDark = useColorScheme() === "dark";
|
|
19
|
+
const gatewayName = (selectedGateway == null ? void 0 : selectedGateway.name) || "Yantra";
|
|
20
|
+
const [statusOpen, setStatusOpen] = useState(false);
|
|
21
|
+
const openStatus = useCallback(() => setStatusOpen(true), []);
|
|
22
|
+
const closeStatus = useCallback(() => setStatusOpen(false), []);
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
/* @__PURE__ */ jsx(GatewayToolbarButtonMobile, { gatewayStatus, gatewayError: cdecli.error, onToggleGateway: openStatus, disabled, statusLabel: gatewayLabel, gatewayName, tone, isDark }),
|
|
25
|
+
/* @__PURE__ */ jsx(GatewayStatusSheet, { visible: statusOpen, status: gatewayStatus, name: gatewayName, isDark: deviceDark, onReconnect: cdecli.reconnect, onClose: closeStatus })
|
|
26
|
+
] });
|
|
21
27
|
};
|
|
22
28
|
var GatewayConnector$1 = React__default.memo(GatewayConnector);export{GatewayConnector$1 as default};//# sourceMappingURL=GatewayConnector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayConnector.js","sources":["../../../src/components/GatewayConnector/GatewayConnector.tsx"],"sourcesContent":["/**\n * Gateway connector pill.\n *\n * Renders the visual CDeCLI status pill (`GatewayToolbarButtonMobile`) using\n * the shared `CdecliConnectionContext`. It is purely a consumer — the actual\n * `useCdecliAutoConnect` lifecycle lives in `CdecliConnectionProvider`\n * mounted once at the app root.\n *\n * This separation is intentional: the Chat screen also binds its `channelId`\n * to the same shared connection. If this component called its own\n * `useCdecliAutoConnect`, the two hooks would race their `gatewayConnect`\n * mutations and the agent session would lose its chat binding, producing the\n * \"agent did not return a response / API key may be missing\" fallback.\n */\nimport React, { useCallback } from 'react';\nimport { useCdecliConnection } from '../../contexts/CdecliConnectionContext';\nimport { useGatewayContext } from '../../contexts/GatewayContext';\nimport { GatewayToolbarButtonMobile } from '../GatewayToolbarButtonMobile';\n\nexport type GatewayConnectorStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\ninterface GatewayConnectorProps {\n /** Visual variant — defaults to the standard toolbar tone. */\n tone?: 'default' | 'provisioning' | 'workspace-error';\n /** Disable interaction
|
|
1
|
+
{"version":3,"file":"GatewayConnector.js","sources":["../../../src/components/GatewayConnector/GatewayConnector.tsx"],"sourcesContent":["/**\n * Gateway connector pill.\n *\n * Renders the visual CDeCLI status pill (`GatewayToolbarButtonMobile`) using\n * the shared `CdecliConnectionContext`. It is purely a consumer — the actual\n * `useCdecliAutoConnect` lifecycle lives in `CdecliConnectionProvider`\n * mounted once at the app root.\n *\n * This separation is intentional: the Chat screen also binds its `channelId`\n * to the same shared connection. If this component called its own\n * `useCdecliAutoConnect`, the two hooks would race their `gatewayConnect`\n * mutations and the agent session would lose its chat binding, producing the\n * \"agent did not return a response / API key may be missing\" fallback.\n */\nimport React, { useCallback, useState } from 'react';\nimport { useColorScheme } from 'react-native';\nimport { useCdecliConnection } from '../../contexts/CdecliConnectionContext';\nimport { useGatewayContext } from '../../contexts/GatewayContext';\nimport { GatewayToolbarButtonMobile } from '../GatewayToolbarButtonMobile';\nimport { GatewayStatusSheet } from './GatewayStatusSheet';\n\nexport type GatewayConnectorStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\ninterface GatewayConnectorProps {\n /** Visual variant — defaults to the standard toolbar tone. */\n tone?: 'default' | 'provisioning' | 'workspace-error';\n /** Disable interaction. */\n disabled?: boolean;\n /** The bar's ink, when it follows something other than the device (the home's sky). */\n isDark?: boolean;\n}\n\nfunction mapCdecliStatus(status: string | null | undefined): GatewayConnectorStatus {\n if (status === 'connecting') return 'connecting';\n if (status === 'connected') return 'connected';\n if (status === 'error') return 'error';\n return 'disconnected';\n}\n\nconst GatewayConnector: React.FC<GatewayConnectorProps> = ({ tone = 'default', disabled = false, isDark }) => {\n const cdecli = useCdecliConnection();\n const { selectedGateway } = useGatewayContext();\n\n const gatewayStatus = mapCdecliStatus(cdecli.status);\n const gatewayLabel = cdecli.status === 'connecting' ? 'Checking...' : undefined;\n\n const deviceDark = useColorScheme() === 'dark';\n const gatewayName = selectedGateway?.name || 'Yantra';\n const [statusOpen, setStatusOpen] = useState(false);\n const openStatus = useCallback(() => setStatusOpen(true), []);\n const closeStatus = useCallback(() => setStatusOpen(false), []);\n\n return (\n <>\n <GatewayToolbarButtonMobile\n gatewayStatus={gatewayStatus}\n gatewayError={cdecli.error}\n onToggleGateway={openStatus}\n disabled={disabled}\n statusLabel={gatewayLabel}\n gatewayName={gatewayName}\n tone={tone}\n isDark={isDark}\n />\n <GatewayStatusSheet\n visible={statusOpen}\n status={gatewayStatus}\n name={gatewayName}\n isDark={deviceDark}\n onReconnect={cdecli.reconnect}\n onClose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,MAAgB,EAAA,CAAA;AAAA,oBACvN,GAAA,CAAA,kBAAA,EAAA,EAAmB,OAAS,EAAA,UAAA,EAAY,QAAQ,aAAe,EAAA,IAAA,EAAM,WAAa,EAAA,MAAA,EAAQ,UAAY,EAAA,WAAA,EAAa,MAAO,CAAA,SAAA,EAAW,SAAS,WAAa,EAAA;AAAA,GAChK,EAAA,CAAA;AACR,CAAA;AACA,yBAAeA,cAAA,CAAM,KAAK,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {jsx,jsxs}from'react/jsx-runtime';import {Modal,View,StyleSheet,Pressable,ActivityIndicator}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {Text}from'@admin-layout/gluestack-ui-mobile';import {useSafeAreaInsets}from'react-native-safe-area-context';import {mobileColors}from'../../theme/mobileTokens.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
function gatewayStatusCopy(status, name) {
|
|
21
|
+
switch (status) {
|
|
22
|
+
case "connected":
|
|
23
|
+
return {
|
|
24
|
+
title: `${name} is connected`,
|
|
25
|
+
body: "Ready for whatever you ask next."
|
|
26
|
+
};
|
|
27
|
+
case "connecting":
|
|
28
|
+
return {
|
|
29
|
+
title: `Connecting to ${name}`,
|
|
30
|
+
body: "This usually takes a few seconds."
|
|
31
|
+
};
|
|
32
|
+
case "error":
|
|
33
|
+
return {
|
|
34
|
+
title: `Can't reach ${name} right now`,
|
|
35
|
+
body: "It keeps trying on its own. Check your connection, or try again now."
|
|
36
|
+
};
|
|
37
|
+
default:
|
|
38
|
+
return {
|
|
39
|
+
title: `${name} is not connected`,
|
|
40
|
+
body: "Connect to send messages from this phone."
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function statusTint(status, colors) {
|
|
45
|
+
if (status === "connected") return {
|
|
46
|
+
ink: colors.successText,
|
|
47
|
+
wash: colors.successSoft
|
|
48
|
+
};
|
|
49
|
+
if (status === "error") return {
|
|
50
|
+
ink: colors.dangerText,
|
|
51
|
+
wash: colors.dangerSoft
|
|
52
|
+
};
|
|
53
|
+
if (status === "connecting") return {
|
|
54
|
+
ink: colors.warningText,
|
|
55
|
+
wash: colors.warningSoft
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
ink: colors.textMuted,
|
|
59
|
+
wash: colors.surfaceMuted
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function GatewayStatusSheet({
|
|
63
|
+
visible,
|
|
64
|
+
status,
|
|
65
|
+
name,
|
|
66
|
+
isDark,
|
|
67
|
+
onReconnect,
|
|
68
|
+
onClose
|
|
69
|
+
}) {
|
|
70
|
+
const colors = mobileColors(isDark);
|
|
71
|
+
const insets = useSafeAreaInsets();
|
|
72
|
+
const {
|
|
73
|
+
title,
|
|
74
|
+
body
|
|
75
|
+
} = gatewayStatusCopy(status, name);
|
|
76
|
+
const offline = status === "error" || status === "disconnected";
|
|
77
|
+
const tint = statusTint(status, colors);
|
|
78
|
+
return /* @__PURE__ */ jsx(Modal, { visible, transparent: true, animationType: "slide", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles.scrimWrap, children: [
|
|
79
|
+
/* @__PURE__ */ jsx(Pressable, { style: styles.scrim, onPress: onClose, accessibilityLabel: "Close" }),
|
|
80
|
+
/* @__PURE__ */ jsxs(View, { accessibilityViewIsModal: true, style: [styles.sheet, {
|
|
81
|
+
backgroundColor: colors.surface,
|
|
82
|
+
paddingBottom: Math.max(insets.bottom, 16) + 8
|
|
83
|
+
}], children: [
|
|
84
|
+
/* @__PURE__ */ jsx(View, { style: [styles.grabber, {
|
|
85
|
+
backgroundColor: colors.border
|
|
86
|
+
}] }),
|
|
87
|
+
/* @__PURE__ */ jsxs(View, { style: styles.head, children: [
|
|
88
|
+
/* @__PURE__ */ jsx(View, { style: [styles.badge, {
|
|
89
|
+
backgroundColor: tint.wash
|
|
90
|
+
}], children: status === "connecting" ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: tint.ink }) : /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: status === "connected" ? "wifi" : "wifi-off", size: 20, color: tint.ink }) }),
|
|
91
|
+
/* @__PURE__ */ jsxs(View, { style: styles.flex, children: [
|
|
92
|
+
/* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles.title, {
|
|
93
|
+
color: colors.text
|
|
94
|
+
}], children: title }),
|
|
95
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.body, {
|
|
96
|
+
color: colors.textMuted
|
|
97
|
+
}], children: body })
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ jsx(Pressable, { onPress: onClose, hitSlop: 10, accessibilityRole: "button", accessibilityLabel: "Close", children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "close", size: 22, color: colors.textMuted }) })
|
|
100
|
+
] }),
|
|
101
|
+
offline ? /* @__PURE__ */ jsx(Pressable, { onPress: onReconnect, accessibilityRole: "button", style: ({
|
|
102
|
+
pressed
|
|
103
|
+
}) => [styles.action, {
|
|
104
|
+
backgroundColor: colors.primary
|
|
105
|
+
}, pressed && styles.pressed], children: /* @__PURE__ */ jsx(Text, { style: styles.actionText, children: "Try again" }) }) : null
|
|
106
|
+
] })
|
|
107
|
+
] }) });
|
|
108
|
+
}
|
|
109
|
+
const styles = StyleSheet.create({
|
|
110
|
+
scrimWrap: {
|
|
111
|
+
flex: 1,
|
|
112
|
+
justifyContent: "flex-end"
|
|
113
|
+
},
|
|
114
|
+
scrim: __spreadProps(__spreadValues({}, StyleSheet.absoluteFillObject), {
|
|
115
|
+
backgroundColor: "rgba(15,23,42,0.45)"
|
|
116
|
+
}),
|
|
117
|
+
sheet: {
|
|
118
|
+
width: "100%",
|
|
119
|
+
maxWidth: 560,
|
|
120
|
+
alignSelf: "center",
|
|
121
|
+
borderTopLeftRadius: 16,
|
|
122
|
+
borderTopRightRadius: 16
|
|
123
|
+
},
|
|
124
|
+
grabber: {
|
|
125
|
+
alignSelf: "center",
|
|
126
|
+
width: 36,
|
|
127
|
+
height: 4,
|
|
128
|
+
marginTop: 8,
|
|
129
|
+
borderRadius: 2
|
|
130
|
+
},
|
|
131
|
+
head: {
|
|
132
|
+
flexDirection: "row",
|
|
133
|
+
alignItems: "flex-start",
|
|
134
|
+
gap: 12,
|
|
135
|
+
paddingHorizontal: 20,
|
|
136
|
+
paddingTop: 14,
|
|
137
|
+
paddingBottom: 10
|
|
138
|
+
},
|
|
139
|
+
badge: {
|
|
140
|
+
width: 40,
|
|
141
|
+
height: 40,
|
|
142
|
+
borderRadius: 12,
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center"
|
|
145
|
+
},
|
|
146
|
+
flex: {
|
|
147
|
+
flex: 1
|
|
148
|
+
},
|
|
149
|
+
title: {
|
|
150
|
+
fontSize: 17,
|
|
151
|
+
fontWeight: "700"
|
|
152
|
+
},
|
|
153
|
+
body: {
|
|
154
|
+
fontSize: 14,
|
|
155
|
+
lineHeight: 20,
|
|
156
|
+
marginTop: 2
|
|
157
|
+
},
|
|
158
|
+
action: {
|
|
159
|
+
marginHorizontal: 20,
|
|
160
|
+
marginTop: 8,
|
|
161
|
+
height: 48,
|
|
162
|
+
borderRadius: 12,
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
justifyContent: "center"
|
|
165
|
+
},
|
|
166
|
+
actionText: {
|
|
167
|
+
color: "#ffffff",
|
|
168
|
+
fontSize: 16,
|
|
169
|
+
fontWeight: "700"
|
|
170
|
+
},
|
|
171
|
+
pressed: {
|
|
172
|
+
opacity: 0.8
|
|
173
|
+
}
|
|
174
|
+
});export{GatewayStatusSheet,gatewayStatusCopy};//# sourceMappingURL=GatewayStatusSheet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GatewayStatusSheet.js","sources":["../../../src/components/GatewayConnector/GatewayStatusSheet.tsx"],"sourcesContent":["/**\n * What the header's Yantra pill opens: whether this phone is connected, in words, and a way to try\n * again when it is not. The connection itself is automatic (CdecliConnectionProvider), so there is\n * nothing to switch on or off here, only something to see and, when it failed, to retry.\n */\nimport React from 'react';\nimport { ActivityIndicator, Modal, Pressable, StyleSheet, View } from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { Text } from '@admin-layout/gluestack-ui-mobile';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\nimport { mobileColors } from '../../theme/mobileTokens';\n\nexport type GatewaySheetStatus = 'connecting' | 'connected' | 'disconnected' | 'error';\n\nexport function gatewayStatusCopy(status: GatewaySheetStatus, name: string): { title: string; body: string } {\n switch (status) {\n case 'connected':\n return { title: `${name} is connected`, body: 'Ready for whatever you ask next.' };\n case 'connecting':\n return { title: `Connecting to ${name}`, body: 'This usually takes a few seconds.' };\n case 'error':\n return {\n title: `Can't reach ${name} right now`,\n body: 'It keeps trying on its own. Check your connection, or try again now.',\n };\n default:\n return { title: `${name} is not connected`, body: 'Connect to send messages from this phone.' };\n }\n}\n\nfunction statusTint(status: GatewaySheetStatus, colors: ReturnType<typeof mobileColors>) {\n if (status === 'connected') return { ink: colors.successText, wash: colors.successSoft };\n if (status === 'error') return { ink: colors.dangerText, wash: colors.dangerSoft };\n if (status === 'connecting') return { ink: colors.warningText, wash: colors.warningSoft };\n return { ink: colors.textMuted, wash: colors.surfaceMuted };\n}\n\nexport interface GatewayStatusSheetProps {\n visible: boolean;\n status: GatewaySheetStatus;\n name: string;\n isDark: boolean;\n onReconnect: () => void;\n onClose: () => void;\n}\n\nexport function GatewayStatusSheet({ visible, status, name, isDark, onReconnect, onClose }: GatewayStatusSheetProps) {\n const colors = mobileColors(isDark);\n const insets = useSafeAreaInsets();\n const { title, body } = gatewayStatusCopy(status, name);\n const offline = status === 'error' || status === 'disconnected';\n const tint = statusTint(status, colors);\n\n return (\n <Modal visible={visible} transparent animationType=\"slide\" onRequestClose={onClose}>\n <View style={styles.scrimWrap}>\n <Pressable style={styles.scrim} onPress={onClose} accessibilityLabel=\"Close\" />\n <View\n accessibilityViewIsModal\n style={[\n styles.sheet,\n { backgroundColor: colors.surface, paddingBottom: Math.max(insets.bottom, 16) + 8 },\n ]}\n >\n <View style={[styles.grabber, { backgroundColor: colors.border }]} />\n <View style={styles.head}>\n <View style={[styles.badge, { backgroundColor: tint.wash }]}>\n {status === 'connecting' ? (\n <ActivityIndicator size=\"small\" color={tint.ink} />\n ) : (\n <MaterialCommunityIcons\n name={status === 'connected' ? 'wifi' : 'wifi-off'}\n size={20}\n color={tint.ink}\n />\n )}\n </View>\n <View style={styles.flex}>\n <Text accessibilityRole=\"header\" style={[styles.title, { color: colors.text }]}>\n {title}\n </Text>\n <Text style={[styles.body, { color: colors.textMuted }]}>{body}</Text>\n </View>\n <Pressable onPress={onClose} hitSlop={10} accessibilityRole=\"button\" accessibilityLabel=\"Close\">\n <MaterialCommunityIcons name=\"close\" size={22} color={colors.textMuted} />\n </Pressable>\n </View>\n {offline ? (\n <Pressable\n onPress={onReconnect}\n accessibilityRole=\"button\"\n style={({ pressed }) => [\n styles.action,\n { backgroundColor: colors.primary },\n pressed && styles.pressed,\n ]}\n >\n <Text style={styles.actionText}>Try again</Text>\n </Pressable>\n ) : null}\n </View>\n </View>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n scrimWrap: { flex: 1, justifyContent: 'flex-end' },\n scrim: { ...StyleSheet.absoluteFillObject, backgroundColor: 'rgba(15,23,42,0.45)' },\n sheet: {\n width: '100%',\n maxWidth: 560,\n alignSelf: 'center',\n borderTopLeftRadius: 16,\n borderTopRightRadius: 16,\n },\n grabber: { alignSelf: 'center', width: 36, height: 4, marginTop: 8, borderRadius: 2 },\n head: {\n flexDirection: 'row',\n alignItems: 'flex-start',\n gap: 12,\n paddingHorizontal: 20,\n paddingTop: 14,\n paddingBottom: 10,\n },\n badge: { width: 40, height: 40, borderRadius: 12, alignItems: 'center', justifyContent: 'center' },\n flex: { flex: 1 },\n title: { fontSize: 17, fontWeight: '700' },\n body: { fontSize: 14, lineHeight: 20, marginTop: 2 },\n action: {\n marginHorizontal: 20,\n marginTop: 8,\n height: 48,\n borderRadius: 12,\n alignItems: 'center',\n justifyContent: 'center',\n },\n actionText: { color: '#ffffff', fontSize: 16, fontWeight: '700' },\n pressed: { opacity: 0.8 },\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAYgB,SAAA,iBAAA,CAAkB,QAA4B,IAG5D,EAAA;AACA,EAAA,QAAQ,MAAQ;AAAA,IACd,KAAK,WAAA;AACH,MAAO,OAAA;AAAA,QACL,KAAA,EAAO,GAAG,IAAI,CAAA,aAAA,CAAA;AAAA,QACd,IAAM,EAAA;AAAA,OACR;AAAA,IACF,KAAK,YAAA;AACH,MAAO,OAAA;AAAA,QACL,KAAA,EAAO,iBAAiB,IAAI,CAAA,CAAA;AAAA,QAC5B,IAAM,EAAA;AAAA,OACR;AAAA,IACF,KAAK,OAAA;AACH,MAAO,OAAA;AAA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,MAAQ,EAAA,EAAA;AAAA,IACR,YAAc,EAAA,EAAA;AAAA,IACd,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,UAAY,EAAA;AAAA,IACV,KAAO,EAAA,SAAA;AAAA,IACP,QAAU,EAAA,EAAA;AAAA,IACV,UAAY,EAAA;AAAA,GACd;AAAA,EACA,OAAS,EAAA;AAAA,IACP,OAAS,EAAA;AAAA;AAEb,CAAC,CAAA"}
|
|
@@ -6,9 +6,13 @@ import {jsx,jsxs}from'react/jsx-runtime';import {useColorScheme,View,StyleSheet,
|
|
|
6
6
|
if (status === "error") return isDark ? "#f87171" : "#dc2626";
|
|
7
7
|
return isDark ? "#94a3b8" : "#64748b";
|
|
8
8
|
}
|
|
9
|
+
function pillTitle(status, name) {
|
|
10
|
+
if (status === "connected") return `${name} is connected. Show status`;
|
|
11
|
+
if (status === "connecting") return `Connecting to ${name}. Show status`;
|
|
12
|
+
return `${name} is not connected. Show status`;
|
|
13
|
+
}
|
|
9
14
|
function GatewayToolbarButtonMobile({
|
|
10
15
|
gatewayStatus,
|
|
11
|
-
gatewayError,
|
|
12
16
|
onToggleGateway,
|
|
13
17
|
disabled,
|
|
14
18
|
statusLabel,
|
|
@@ -20,7 +24,7 @@ function GatewayToolbarButtonMobile({
|
|
|
20
24
|
const isDark = isDarkProp != null ? isDarkProp : deviceDark;
|
|
21
25
|
const color = iconColor(gatewayStatus, tone, isDark);
|
|
22
26
|
const labelColor = isDark ? "#e2e8f0" : mobileTokens.color.text;
|
|
23
|
-
const mainTitle = gatewayStatus
|
|
27
|
+
const mainTitle = pillTitle(gatewayStatus, gatewayName);
|
|
24
28
|
return /* @__PURE__ */ jsx(View, { style: styles.wrap, children: /* @__PURE__ */ jsxs(Pressable, { onPress: onToggleGateway, disabled, accessibilityLabel: mainTitle, style: ({
|
|
25
29
|
pressed
|
|
26
30
|
}) => [styles.mainBtn, pressed && styles.pressed, disabled && styles.disabled], children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GatewayToolbarButtonMobile.js","sources":["../../src/components/GatewayToolbarButtonMobile.tsx"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"GatewayToolbarButtonMobile.js","sources":["../../src/components/GatewayToolbarButtonMobile.tsx"],"sourcesContent":["/**\n * The header's connection status, named for the selected gateway. On a phone the connection is\n * automatic, so tapping it shows the status (GatewayStatusSheet) rather than toggling it.\n *\n * Connection state lives in the icon color (green / amber / red), not a filled\n * pill. The label is the selected gateway name (\"Yantra\"), same as the browser.\n */\n\nimport React from 'react';\nimport { ActivityIndicator, Pressable, StyleSheet, Text, View, useColorScheme } from 'react-native';\nimport { MaterialCommunityIcons } from '@expo/vector-icons';\nimport { mobileTokens } from '../theme/mobileTokens';\n\nexport type GatewayToolbarMobileStatus = 'connected' | 'connecting' | 'disconnected' | 'error';\n\nexport interface GatewayToolbarButtonMobileProps {\n /** Overrides the device scheme, for a bar with its own ink. */\n isDark?: boolean;\n gatewayStatus: GatewayToolbarMobileStatus;\n gatewayError?: string | null;\n onToggleGateway: () => void;\n disabled?: boolean;\n /** Replaces the gateway name, e.g. \"Checking...\" */\n statusLabel?: string;\n /** Selected gateway display name from the registry. */\n gatewayName?: string;\n /** Visual override when workspace (not link status) is provisioning / error */\n tone?: 'default' | 'provisioning' | 'workspace-error';\n}\n\nfunction iconColor(status: GatewayToolbarMobileStatus, tone: GatewayToolbarButtonMobileProps['tone'], isDark: boolean) {\n if (tone === 'provisioning') return isDark ? '#60a5fa' : '#2563eb';\n if (tone === 'workspace-error') return mobileTokens.color.dangerText;\n if (status === 'connected') return isDark ? '#4ade80' : '#16a34a';\n if (status === 'connecting') return isDark ? '#fbbf24' : '#ca8a04';\n if (status === 'error') return isDark ? '#f87171' : '#dc2626';\n return isDark ? '#94a3b8' : '#64748b';\n}\n\nfunction pillTitle(status: GatewayToolbarMobileStatus, name: string): string {\n if (status === 'connected') return `${name} is connected. Show status`;\n if (status === 'connecting') return `Connecting to ${name}. Show status`;\n return `${name} is not connected. Show status`;\n}\n\nexport function GatewayToolbarButtonMobile({\n gatewayStatus,\n onToggleGateway,\n disabled,\n statusLabel,\n gatewayName = 'Yantra',\n tone = 'default',\n isDark: isDarkProp,\n}: GatewayToolbarButtonMobileProps) {\n const deviceDark = useColorScheme() === 'dark';\n const isDark = isDarkProp ?? deviceDark;\n const color = iconColor(gatewayStatus, tone, isDark);\n const labelColor = isDark ? '#e2e8f0' : mobileTokens.color.text;\n\n const mainTitle = pillTitle(gatewayStatus, gatewayName);\n\n return (\n <View style={styles.wrap}>\n <Pressable\n onPress={onToggleGateway}\n disabled={disabled}\n accessibilityLabel={mainTitle}\n style={({ pressed }) => [styles.mainBtn, pressed && styles.pressed, disabled && styles.disabled]}\n >\n {gatewayStatus === 'connecting' ? (\n <ActivityIndicator size=\"small\" color={color} />\n ) : (\n <MaterialCommunityIcons\n name={gatewayStatus === 'connected' ? 'wifi' : 'wifi-off'}\n size={16}\n color={color}\n />\n )}\n <Text style={[styles.label, { color: labelColor }]}>{statusLabel ?? gatewayName}</Text>\n </Pressable>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: { flexShrink: 0 },\n mainBtn: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n height: 36,\n paddingHorizontal: 6,\n borderRadius: 10,\n justifyContent: 'flex-start',\n },\n pressed: { opacity: 0.7 },\n disabled: { opacity: 0.45 },\n label: { fontSize: 13, fontWeight: '600', letterSpacing: -0.2 },\n});\n"],"names":[],"mappings":"gPA2BA,SAAS,SAAA,CAAU,MAAoC,EAAA,IAAA,EAA+C,MAAiB,EAAA;AACrH,EAAA,IAAI,IAAS,KAAA,cAAA,EAAuB,OAAA,MAAA,GAAS,SAAY,GAAA,SAAA;AACzD,EAAA,IAAI,IAAS,KAAA,iBAAA,EAA0B,OAAA,YAAA,CAAa,KAAM,CAAA,UAAA;AAC1D,EAAA,IAAI,MAAW,KAAA,WAAA,EAAoB,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A"}
|
package/lib/config/env-config.js
CHANGED
|
@@ -78,6 +78,14 @@ const baseConfig = cleanEnv(env, {
|
|
|
78
78
|
CHARACTERS_SUBGRAPH_URL: str({
|
|
79
79
|
default: ""
|
|
80
80
|
}),
|
|
81
|
+
/**
|
|
82
|
+
* Games subgraph GraphQL URL (shared Cubeforge worlds). Empty by default ->
|
|
83
|
+
* DERIVED the same way as the character subgraph (`games-subgraph.x.y`).
|
|
84
|
+
* Set explicitly only to pin a non-standard origin.
|
|
85
|
+
*/
|
|
86
|
+
GAMES_SUBGRAPH_URL: str({
|
|
87
|
+
default: ""
|
|
88
|
+
}),
|
|
81
89
|
/**
|
|
82
90
|
* Fitness backend GraphQL URL (health sync from Apple Health / Health
|
|
83
91
|
* Connect). Empty by default -> DERIVED from SURFACE_URL_TEMPLATE
|
|
@@ -156,7 +164,7 @@ function resolveCharactersManifestUrl(explicit, template) {
|
|
|
156
164
|
const base = (template || "https://{slug}-surface.yantra-app-v1.cdebase.dev/").replace("{slug}", "characters-native").replace(/\/+$/, "");
|
|
157
165
|
return `${base}/native/characters.json`;
|
|
158
166
|
}
|
|
159
|
-
function
|
|
167
|
+
function resolveSubgraphUrl(label, explicit, graphqlUrl, canvasBackend) {
|
|
160
168
|
if (explicit) return explicit;
|
|
161
169
|
const isLocal = /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/i.test((graphqlUrl || "").trim());
|
|
162
170
|
const backend = isLocal ? canvasBackend : graphqlUrl;
|
|
@@ -164,7 +172,7 @@ function resolveCharacterSubgraphUrl(explicit, graphqlUrl, canvasBackend) {
|
|
|
164
172
|
if (!match) return "";
|
|
165
173
|
const labels = match[2].split(".");
|
|
166
174
|
if (labels.length < 3) return "";
|
|
167
|
-
return `${match[1]}
|
|
175
|
+
return `${match[1]}//${label}.${labels.slice(1).join(".")}/graphql`;
|
|
168
176
|
}
|
|
169
177
|
function resolveAgentGatewayGraphqlUrl() {
|
|
170
178
|
if (baseConfig.USE_PROXY_STAGING_GATEWAY && baseConfig.PROXY_STAGING_GATEWAY_URL) {
|
|
@@ -186,7 +194,8 @@ const clampedCdecliTimeoutSec = Math.min(600, Math.max(15, Math.round(baseConfig
|
|
|
186
194
|
const config = __spreadProps(__spreadValues({}, baseConfig), {
|
|
187
195
|
CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: clampedCdecliTimeoutSec,
|
|
188
196
|
CHARACTERS_NATIVE_MANIFEST_URL: resolveCharactersManifestUrl(baseConfig.CHARACTERS_NATIVE_MANIFEST_URL, baseConfig.SURFACE_URL_TEMPLATE),
|
|
189
|
-
CHARACTERS_SUBGRAPH_URL:
|
|
197
|
+
CHARACTERS_SUBGRAPH_URL: resolveSubgraphUrl("character-subgraph", baseConfig.CHARACTERS_SUBGRAPH_URL, baseConfig.GRAPHQL_URL, baseConfig.CANVAS_BACKEND_GRAPHQL_URL),
|
|
198
|
+
GAMES_SUBGRAPH_URL: resolveSubgraphUrl("games-subgraph", baseConfig.GAMES_SUBGRAPH_URL, baseConfig.GRAPHQL_URL, baseConfig.CANVAS_BACKEND_GRAPHQL_URL),
|
|
190
199
|
FITNESS_BACKEND_GRAPHQL_URL: resolveFitnessGraphqlUrl(baseConfig.FITNESS_BACKEND_GRAPHQL_URL, baseConfig.SURFACE_URL_TEMPLATE),
|
|
191
200
|
EXPENSES_GRAPHQL_URL: resolveExpensesGraphqlUrl(baseConfig.EXPENSES_GRAPHQL_URL, baseConfig.SURFACE_URL_TEMPLATE),
|
|
192
201
|
AGENT_GATEWAY_GRAPHQL_URL: agentGatewayGraphqlUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-config.js","sources":["../../src/config/env-config.ts"],"sourcesContent":["import { str, cleanEnv, bool, num } from 'envalid';\nimport { resolveExpensesGraphqlUrl } from '../features/expenses/expensesEndpoint';\nimport { resolveFitnessGraphqlUrl } from '../features/health/fitnessClient';\n\nconst env = (process as { APP_ENV?: NodeJS.ProcessEnv; env?: NodeJS.ProcessEnv }).APP_ENV || process.env;\n\nconst baseConfig = cleanEnv(env, {\n GRAPHQL_URL: str({ default: 'http://localhost:8080/graphql' }),\n CLIENT_URL: str({ default: 'http://localhost:3000' }),\n /** Standalone Web Builder surface embedded in the mobile WebView shell. */\n WEB_BUILDER_URL: str({ default: 'http://localhost:5174/' }),\n /** Standalone Design surface — local vite is 5174/4174 next to canvas 5175. */\n DESIGN_SURFACE_URL: str({ default: 'http://localhost:5174/' }),\n /** Standalone Canvas surface embedded in the same WebView shell. */\n CANVAS_SURFACE_URL: str({ default: 'http://localhost:5175/' }),\n /**\n * GraphQL backend whose JWT keys the canvas index will verify.\n * Must stay in lockstep with canvas-surface `.env.development`\n * (`VITE_BACKEND_GRAPHQL_URL` / `VITE_SURFACE_INDEX_URL`). A locally\n * minted token 401s against `surface-index-backend.yantra-app-v1`.\n */\n CANVAS_BACKEND_GRAPHQL_URL: str({ default: 'https://ideback.yantra-app-v1.cdebase.dev/graphql' }),\n /** Explicit canvas index GraphQL URL. Empty → derived from the canvas auth backend. */\n SURFACE_INDEX_URL: str({ default: '' }),\n /**\n * Origin template for every other deployed surface: `{slug}` is the app's\n * `surfaceSlug`. One var instead of 20+ near-identical URLs, and it keeps the\n * environment (dev cluster / prod) in one place.\n */\n SURFACE_URL_TEMPLATE: str({ default: 'https://{slug}-surface.yantra-app-v1.cdebase.dev/' }),\n /**\n * Characters gallery manifest (`characters.json`). Empty by default →\n * DERIVED from SURFACE_URL_TEMPLATE + the wipe-immune `characters-native`\n * slug (see below), so a prod build reads prod and a dev build reads dev\n * with no per-profile URL to maintain. Set explicitly only to pin a\n * non-standard origin.\n */\n CHARACTERS_NATIVE_MANIFEST_URL: str({ default: '' }),\n /**\n * Character community subgraph GraphQL URL the federated character studio\n * reads (Discover feed, publish/edit). Empty by default → DERIVED from the\n * same backend the surface token is minted against (swap the first DNS label\n * `ideback.x.y` → `character-subgraph.x.y`, the convention the character\n * surfaces use). Set explicitly only to pin a non-standard origin.\n */\n CHARACTERS_SUBGRAPH_URL: str({ default: '' }),\n /**\n * Fitness backend GraphQL URL (health sync from Apple Health / Health\n * Connect). Empty by default -> DERIVED from SURFACE_URL_TEMPLATE\n * (`fitness-backend.<surface domain>`), so dev builds talk to dev and prod\n * builds to prod. Set explicitly only to pin a non-standard origin.\n */\n FITNESS_BACKEND_GRAPHQL_URL: str({ default: '' }),\n /**\n * Expenses subgraph GraphQL URL (native Expenses). Empty by default ->\n * DERIVED from SURFACE_URL_TEMPLATE (`enterprise-backend.<surface domain>`),\n * so dev builds read dev books and prod builds prod. Set explicitly only to\n * pin a non-standard origin.\n */\n EXPENSES_GRAPHQL_URL: str({ default: '' }),\n /**\n * CDN origin for uploaded files (public-config `AWS_CDN_URL`). Web Builder\n * joins a build screenshot's object key to it when the post did not store\n * its own origin - the web surface's `VITE_AWS_CDN_URL`.\n */\n AWS_CDN_URL: str({ default: '' }),\n /**\n * The platform's domain in front of e2b cloud sandbox previews (public-config\n * `E2B_SANDBOX_DOMAIN`; kube-orchestration e2b-custom-domain): prod's\n * `sb.yantra.app` by default, `sandbox.cdebase.dev` on dev (eas.json). Web Builder\n * shows and saves preview links as `https://<port>-<sandboxId>.<this>` instead\n * of e2b.dev / e2b.app (features/webbuilder/sandboxPublicHost.ts). `e2b.dev`\n * here means no proxy: e2b's host is kept. Not the e2b SDK domain\n * (`modelConfig.domain`), which stays the API host.\n */\n E2B_SANDBOX_DOMAIN: str({ default: 'sb.yantra.app' }),\n APP_NAME: str({ default: 'Yantra' }),\n /** Where Account > Support writes to, as the web's. */\n SUPPORT_EMAIL: str({ default: 'support@yantra.app' }),\n GROQ_API_KEY: str({ default: '' }),\n CDECLI_AGENT_ENDPOINT: str({ default: 'https://cdecli-agent.cdebase.dev' }),\n CDECLI_AGENT_AUTH_TOKEN: str({ default: '' }),\n /** Seconds to wait for CDeCLI stream completion before timing out (then fallback chat API runs). Min 15, max 600. */\n /** Aligned with web `useCdecliChannel` (120s). Mobile hook uses the same constant inline. */\n CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: num({ default: 120 }),\n BACKEND_URL: str({ default: '' }),\n USE_PROXY_STAGING_GATEWAY: bool({ default: false }),\n /** Yantra Chat registration: offer \"Continue with test OTP\" (123456, no SMS). Never on App Store builds. */\n CHAT_ALLOW_TEST_OTP: bool({ default: false }),\n PROXY_STAGING_GATEWAY_URL: str({ default: '' }),\n});\n\n/**\n * Where the app fetches the characters gallery manifest.\n *\n * Mirrors metro.federation.js `charactersRemoteUrl()`: the manifest lives on\n * the dedicated `characters-native` artifacts slug, NOT `character-surface`.\n * The bulk web-surface republish redeploys character-surface from its pinned\n * web bundle and wipes anything hand-added under /native, so the gallery data\n * (like the federated remote) must ride the wipe-immune slug. The origin\n * DERIVES from SURFACE_URL_TEMPLATE, so prod builds read prod and dev builds\n * read dev automatically. An explicit CHARACTERS_NATIVE_MANIFEST_URL still\n * wins for a one-off pin.\n */\nfunction resolveCharactersManifestUrl(explicit: string, template: string): string {\n if (explicit) return explicit;\n const base = (template || 'https://{slug}-surface.yantra-app-v1.cdebase.dev/')\n .replace('{slug}', 'characters-native')\n .replace(/\\/+$/, '');\n return `${base}/native/characters.json`;\n}\n\n/**\n * Character community subgraph URL. Derives from the SAME backend the surface\n * session token is minted against, so it stays authoritative across dev/prod and\n * matches the token's audience: a locally minted token is scoped to\n * CANVAS_BACKEND_GRAPHQL_URL (the cluster backend), so a local GRAPHQL_URL uses\n * that cluster host too - a subgraph on localhost would 401 the same JWT.\n */\nfunction resolveCharacterSubgraphUrl(explicit: string, graphqlUrl: string, canvasBackend: string): string {\n if (explicit) return explicit;\n const isLocal = /^https?:\\/\\/(localhost|127\\.0\\.0\\.1|\\[::1\\])(:|\\/|$)/i.test((graphqlUrl || '').trim());\n const backend = isLocal ? canvasBackend : graphqlUrl;\n const match = (backend || '').trim().match(/^(https?:)\\/\\/([^/]+)/i);\n if (!match) return '';\n const labels = match[2].split('.');\n if (labels.length < 3) return '';\n return `${match[1]}//character-subgraph.${labels.slice(1).join('.')}/graphql`;\n}\n\nfunction resolveAgentGatewayGraphqlUrl(): string {\n if (baseConfig.USE_PROXY_STAGING_GATEWAY && baseConfig.PROXY_STAGING_GATEWAY_URL) {\n return baseConfig.PROXY_STAGING_GATEWAY_URL;\n }\n if (baseConfig.GRAPHQL_URL) return baseConfig.GRAPHQL_URL;\n if (baseConfig.BACKEND_URL) return `${baseConfig.BACKEND_URL.replace(/\\/$/, '')}/graphql`;\n return '/graphql';\n}\n\nfunction resolveBaseWsUrl(graphqlUrl: string): string {\n const base = graphqlUrl.replace(/\\/graphql$/, '');\n return base.replace(/^http/, 'ws');\n}\n\nfunction resolveAgentGatewayWsUrl(graphqlUrl: string): string {\n return `${resolveBaseWsUrl(graphqlUrl)}/ws/openclaw-chat`;\n}\n\nconst agentGatewayGraphqlUrl = resolveAgentGatewayGraphqlUrl();\n\nconst clampedCdecliTimeoutSec = Math.min(600, Math.max(15, Math.round(baseConfig.CDECLI_CHAT_RESPONSE_TIMEOUT_SEC)));\n\nexport const config = {\n ...baseConfig,\n CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: clampedCdecliTimeoutSec,\n CHARACTERS_NATIVE_MANIFEST_URL: resolveCharactersManifestUrl(\n baseConfig.CHARACTERS_NATIVE_MANIFEST_URL,\n baseConfig.SURFACE_URL_TEMPLATE,\n ),\n CHARACTERS_SUBGRAPH_URL: resolveCharacterSubgraphUrl(\n baseConfig.CHARACTERS_SUBGRAPH_URL,\n baseConfig.GRAPHQL_URL,\n baseConfig.CANVAS_BACKEND_GRAPHQL_URL,\n ),\n FITNESS_BACKEND_GRAPHQL_URL: resolveFitnessGraphqlUrl(\n baseConfig.FITNESS_BACKEND_GRAPHQL_URL,\n baseConfig.SURFACE_URL_TEMPLATE,\n ),\n EXPENSES_GRAPHQL_URL: resolveExpensesGraphqlUrl(baseConfig.EXPENSES_GRAPHQL_URL, baseConfig.SURFACE_URL_TEMPLATE),\n AGENT_GATEWAY_GRAPHQL_URL: agentGatewayGraphqlUrl,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IAAO,GAAA,UAAA,CAAW,OAAQ,CAAA,YAAA,EAAc,EAAE,CAAA;AAChD,EAAO,OAAA,IAAA,CAAK,OAAQ,CAAA,OAAA,EAAS,IAAI,CAAA;AACnC;AACA,SAAS,yBAAyB,UAA4B,EAAA;AAC5D,EAAO,OAAA,CAAA,EAAG,gBAAiB,CAAA,UAAU,CAAC,CAAA,iBAAA,CAAA;AACxC;AACA,MAAM,yBAAyB,6BAA8B,EAAA;AAC7D,MAAM,uBAA0B,GAAA,IAAA,CAAK,GAAI,CAAA,GAAA,EAAK,IAAK,CAAA,GAAA,CAAI,EAAI,EAAA,IAAA,CAAK,KAAM,CAAA,UAAA,CAAW,gCAAgC,CAAC,CAAC,CAAA;AACtG,MAAA,MAAA,GAAS,iCACjB,UADiB,CAAA,EAAA;AAAA,EAEpB,gCAAkC,EAAA,uBAAA;AAAA,EAClC,8BAAgC,EAAA,4BAAA,CAA6B,UAAW,CAAA,8BAAA,EAAgC,WAAW,oBAAoB,CAAA;AAAA,EACvI,yBAAyB,2BAA4B,CAAA,UAAA,CAAW,yBAAyB,UAAW,CAAA,WAAA,EAAa,WAAW,0BAA0B,CAAA;AAAA,EACtJ,2BAA6B,EAAA,wBAAA,CAAyB,UAAW,CAAA,2BAAA,EAA6B,WAAW,oBAAoB,CAAA;AAAA,EAC7H,oBAAsB,EAAA,yBAAA,CAA0B,UAAW,CAAA,oBAAA,EAAsB,WAAW,oBAAoB,CAAA;AAAA,EAChH,yBAA2B,EAAA,sBAAA;AAAA,EAC3B,oBAAA,EAAsB,yBAAyB,sBAAsB;AACvE,CAAA"}
|
|
1
|
+
{"version":3,"file":"env-config.js","sources":["../../src/config/env-config.ts"],"sourcesContent":["import { str, cleanEnv, bool, num } from 'envalid';\nimport { resolveExpensesGraphqlUrl } from '../features/expenses/expensesEndpoint';\nimport { resolveFitnessGraphqlUrl } from '../features/health/fitnessClient';\n\nconst env = (process as { APP_ENV?: NodeJS.ProcessEnv; env?: NodeJS.ProcessEnv }).APP_ENV || process.env;\n\nconst baseConfig = cleanEnv(env, {\n GRAPHQL_URL: str({ default: 'http://localhost:8080/graphql' }),\n CLIENT_URL: str({ default: 'http://localhost:3000' }),\n /** Standalone Web Builder surface embedded in the mobile WebView shell. */\n WEB_BUILDER_URL: str({ default: 'http://localhost:5174/' }),\n /** Standalone Design surface — local vite is 5174/4174 next to canvas 5175. */\n DESIGN_SURFACE_URL: str({ default: 'http://localhost:5174/' }),\n /** Standalone Canvas surface embedded in the same WebView shell. */\n CANVAS_SURFACE_URL: str({ default: 'http://localhost:5175/' }),\n /**\n * GraphQL backend whose JWT keys the canvas index will verify.\n * Must stay in lockstep with canvas-surface `.env.development`\n * (`VITE_BACKEND_GRAPHQL_URL` / `VITE_SURFACE_INDEX_URL`). A locally\n * minted token 401s against `surface-index-backend.yantra-app-v1`.\n */\n CANVAS_BACKEND_GRAPHQL_URL: str({ default: 'https://ideback.yantra-app-v1.cdebase.dev/graphql' }),\n /** Explicit canvas index GraphQL URL. Empty → derived from the canvas auth backend. */\n SURFACE_INDEX_URL: str({ default: '' }),\n /**\n * Origin template for every other deployed surface: `{slug}` is the app's\n * `surfaceSlug`. One var instead of 20+ near-identical URLs, and it keeps the\n * environment (dev cluster / prod) in one place.\n */\n SURFACE_URL_TEMPLATE: str({ default: 'https://{slug}-surface.yantra-app-v1.cdebase.dev/' }),\n /**\n * Characters gallery manifest (`characters.json`). Empty by default →\n * DERIVED from SURFACE_URL_TEMPLATE + the wipe-immune `characters-native`\n * slug (see below), so a prod build reads prod and a dev build reads dev\n * with no per-profile URL to maintain. Set explicitly only to pin a\n * non-standard origin.\n */\n CHARACTERS_NATIVE_MANIFEST_URL: str({ default: '' }),\n /**\n * Character community subgraph GraphQL URL the federated character studio\n * reads (Discover feed, publish/edit). Empty by default → DERIVED from the\n * same backend the surface token is minted against (swap the first DNS label\n * `ideback.x.y` → `character-subgraph.x.y`, the convention the character\n * surfaces use). Set explicitly only to pin a non-standard origin.\n */\n CHARACTERS_SUBGRAPH_URL: str({ default: '' }),\n /**\n * Games subgraph GraphQL URL (shared Cubeforge worlds). Empty by default ->\n * DERIVED the same way as the character subgraph (`games-subgraph.x.y`).\n * Set explicitly only to pin a non-standard origin.\n */\n GAMES_SUBGRAPH_URL: str({ default: '' }),\n /**\n * Fitness backend GraphQL URL (health sync from Apple Health / Health\n * Connect). Empty by default -> DERIVED from SURFACE_URL_TEMPLATE\n * (`fitness-backend.<surface domain>`), so dev builds talk to dev and prod\n * builds to prod. Set explicitly only to pin a non-standard origin.\n */\n FITNESS_BACKEND_GRAPHQL_URL: str({ default: '' }),\n /**\n * Expenses subgraph GraphQL URL (native Expenses). Empty by default ->\n * DERIVED from SURFACE_URL_TEMPLATE (`enterprise-backend.<surface domain>`),\n * so dev builds read dev books and prod builds prod. Set explicitly only to\n * pin a non-standard origin.\n */\n EXPENSES_GRAPHQL_URL: str({ default: '' }),\n /**\n * CDN origin for uploaded files (public-config `AWS_CDN_URL`). Web Builder\n * joins a build screenshot's object key to it when the post did not store\n * its own origin - the web surface's `VITE_AWS_CDN_URL`.\n */\n AWS_CDN_URL: str({ default: '' }),\n /**\n * The platform's domain in front of e2b cloud sandbox previews (public-config\n * `E2B_SANDBOX_DOMAIN`; kube-orchestration e2b-custom-domain): prod's\n * `sb.yantra.app` by default, `sandbox.cdebase.dev` on dev (eas.json). Web Builder\n * shows and saves preview links as `https://<port>-<sandboxId>.<this>` instead\n * of e2b.dev / e2b.app (features/webbuilder/sandboxPublicHost.ts). `e2b.dev`\n * here means no proxy: e2b's host is kept. Not the e2b SDK domain\n * (`modelConfig.domain`), which stays the API host.\n */\n E2B_SANDBOX_DOMAIN: str({ default: 'sb.yantra.app' }),\n APP_NAME: str({ default: 'Yantra' }),\n /** Where Account > Support writes to, as the web's. */\n SUPPORT_EMAIL: str({ default: 'support@yantra.app' }),\n GROQ_API_KEY: str({ default: '' }),\n CDECLI_AGENT_ENDPOINT: str({ default: 'https://cdecli-agent.cdebase.dev' }),\n CDECLI_AGENT_AUTH_TOKEN: str({ default: '' }),\n /** Seconds to wait for CDeCLI stream completion before timing out (then fallback chat API runs). Min 15, max 600. */\n /** Aligned with web `useCdecliChannel` (120s). Mobile hook uses the same constant inline. */\n CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: num({ default: 120 }),\n BACKEND_URL: str({ default: '' }),\n USE_PROXY_STAGING_GATEWAY: bool({ default: false }),\n /** Yantra Chat registration: offer \"Continue with test OTP\" (123456, no SMS). Never on App Store builds. */\n CHAT_ALLOW_TEST_OTP: bool({ default: false }),\n PROXY_STAGING_GATEWAY_URL: str({ default: '' }),\n});\n\n/**\n * Where the app fetches the characters gallery manifest.\n *\n * Mirrors metro.federation.js `charactersRemoteUrl()`: the manifest lives on\n * the dedicated `characters-native` artifacts slug, NOT `character-surface`.\n * The bulk web-surface republish redeploys character-surface from its pinned\n * web bundle and wipes anything hand-added under /native, so the gallery data\n * (like the federated remote) must ride the wipe-immune slug. The origin\n * DERIVES from SURFACE_URL_TEMPLATE, so prod builds read prod and dev builds\n * read dev automatically. An explicit CHARACTERS_NATIVE_MANIFEST_URL still\n * wins for a one-off pin.\n */\nfunction resolveCharactersManifestUrl(explicit: string, template: string): string {\n if (explicit) return explicit;\n const base = (template || 'https://{slug}-surface.yantra-app-v1.cdebase.dev/')\n .replace('{slug}', 'characters-native')\n .replace(/\\/+$/, '');\n return `${base}/native/characters.json`;\n}\n\n/**\n * A subgraph's URL (`<label>.<rest of the backend host>`). Derives from the SAME backend the surface\n * session token is minted against, so it stays authoritative across dev/prod and\n * matches the token's audience: a locally minted token is scoped to\n * CANVAS_BACKEND_GRAPHQL_URL (the cluster backend), so a local GRAPHQL_URL uses\n * that cluster host too - a subgraph on localhost would 401 the same JWT.\n */\nfunction resolveSubgraphUrl(label: string, explicit: string, graphqlUrl: string, canvasBackend: string): string {\n if (explicit) return explicit;\n const isLocal = /^https?:\\/\\/(localhost|127\\.0\\.0\\.1|\\[::1\\])(:|\\/|$)/i.test((graphqlUrl || '').trim());\n const backend = isLocal ? canvasBackend : graphqlUrl;\n const match = (backend || '').trim().match(/^(https?:)\\/\\/([^/]+)/i);\n if (!match) return '';\n const labels = match[2].split('.');\n if (labels.length < 3) return '';\n return `${match[1]}//${label}.${labels.slice(1).join('.')}/graphql`;\n}\n\nfunction resolveAgentGatewayGraphqlUrl(): string {\n if (baseConfig.USE_PROXY_STAGING_GATEWAY && baseConfig.PROXY_STAGING_GATEWAY_URL) {\n return baseConfig.PROXY_STAGING_GATEWAY_URL;\n }\n if (baseConfig.GRAPHQL_URL) return baseConfig.GRAPHQL_URL;\n if (baseConfig.BACKEND_URL) return `${baseConfig.BACKEND_URL.replace(/\\/$/, '')}/graphql`;\n return '/graphql';\n}\n\nfunction resolveBaseWsUrl(graphqlUrl: string): string {\n const base = graphqlUrl.replace(/\\/graphql$/, '');\n return base.replace(/^http/, 'ws');\n}\n\nfunction resolveAgentGatewayWsUrl(graphqlUrl: string): string {\n return `${resolveBaseWsUrl(graphqlUrl)}/ws/openclaw-chat`;\n}\n\nconst agentGatewayGraphqlUrl = resolveAgentGatewayGraphqlUrl();\n\nconst clampedCdecliTimeoutSec = Math.min(600, Math.max(15, Math.round(baseConfig.CDECLI_CHAT_RESPONSE_TIMEOUT_SEC)));\n\nexport const config = {\n ...baseConfig,\n CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: clampedCdecliTimeoutSec,\n CHARACTERS_NATIVE_MANIFEST_URL: resolveCharactersManifestUrl(\n baseConfig.CHARACTERS_NATIVE_MANIFEST_URL,\n baseConfig.SURFACE_URL_TEMPLATE,\n ),\n CHARACTERS_SUBGRAPH_URL: resolveSubgraphUrl(\n 'character-subgraph',\n baseConfig.CHARACTERS_SUBGRAPH_URL,\n baseConfig.GRAPHQL_URL,\n baseConfig.CANVAS_BACKEND_GRAPHQL_URL,\n ),\n GAMES_SUBGRAPH_URL: resolveSubgraphUrl(\n 'games-subgraph',\n baseConfig.GAMES_SUBGRAPH_URL,\n baseConfig.GRAPHQL_URL,\n baseConfig.CANVAS_BACKEND_GRAPHQL_URL,\n ),\n FITNESS_BACKEND_GRAPHQL_URL: resolveFitnessGraphqlUrl(\n baseConfig.FITNESS_BACKEND_GRAPHQL_URL,\n baseConfig.SURFACE_URL_TEMPLATE,\n ),\n EXPENSES_GRAPHQL_URL: resolveExpensesGraphqlUrl(baseConfig.EXPENSES_GRAPHQL_URL, baseConfig.SURFACE_URL_TEMPLATE),\n AGENT_GATEWAY_GRAPHQL_URL: agentGatewayGraphqlUrl,\n AGENT_GATEWAY_WS_URL: resolveAgentGatewayWsUrl(agentGatewayGraphqlUrl),\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAM,GAAA,GAAO,OAGV,CAAA,OAAA,IAAW,OAAQ,CAAA,GAAA;AACtB,MAAM,UAAA,GAAa,SAAS,GAAK,EAAA;AAAA,EAC/B,aAAa,GAAI,CAAA;AAAA,IACf,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,YAAY,GAAI,CAAA;AAAA,IACd,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA,EAED,iBAAiB,GAAI,CAAA;AAAA,IACnB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA,EAED,oBAAoB,GAAI,CAAA;AAAA,IACtB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA,EAED,oBAAoB,GAAI,CAAA;AAAA,IACtB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOD,4BAA4B,GAAI,CAAA;AAAA,IAC9B,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA,EAED,mBAAmB,GAAI,CAAA;AAAA,IACrB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMD,sBAAsB,GAAI,CAAA;AAAA,IACxB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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,UAAA,CAAW,oBAAoB,UAAW,CAAA,WAAA,EAAa,WAAW,0BAA0B,CAAA;AAAA,EACrJ,2BAA6B,EAAA,wBAAA,CAAyB,UAAW,CAAA,2BAAA,EAA6B,WAAW,oBAAoB,CAAA;AAAA,EAC7H,oBAAsB,EAAA,yBAAA,CAA0B,UAAW,CAAA,oBAAA,EAAsB,WAAW,oBAAoB,CAAA;AAAA,EAChH,yBAA2B,EAAA,sBAAA;AAAA,EAC3B,oBAAA,EAAsB,yBAAyB,sBAAsB;AACvE,CAAA"}
|
|
@@ -9,6 +9,14 @@ import {classifyIntentViaBrain}from'../../services/brainQuickReply.js';const NAT
|
|
|
9
9
|
inbox: "MainStack.InboxNative",
|
|
10
10
|
notebook: "MainStack.StudyNative"
|
|
11
11
|
};
|
|
12
|
+
const NATIVE_ROUTE_BY_INTENT = new Map(Object.entries(NATIVE_APP_ROUTES).map(([intent, route]) => [intent.toLowerCase(), route]));
|
|
13
|
+
const SHOP_ROUTE = "MainStack.ShoppingNative";
|
|
14
|
+
function appHandoffForIntent(intent) {
|
|
15
|
+
const native = NATIVE_ROUTE_BY_INTENT.get((intent != null ? intent : "").trim().toLowerCase());
|
|
16
|
+
return native ? {
|
|
17
|
+
route: native
|
|
18
|
+
} : null;
|
|
19
|
+
}
|
|
12
20
|
const NATIVE_APP_CONNECTORS = {
|
|
13
21
|
"yantra-webbuilder": NATIVE_APP_ROUTES.webbuilder,
|
|
14
22
|
"yantra-flight-search": NATIVE_APP_ROUTES.travel,
|
|
@@ -30,14 +38,11 @@ function nativeRouteForConnectors(connectors) {
|
|
|
30
38
|
}
|
|
31
39
|
const HANDOFF_MIN_CONFIDENCE = 0.8;
|
|
32
40
|
const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;
|
|
33
|
-
const CLASSIFY_TIMEOUT_MS =
|
|
41
|
+
const CLASSIFY_TIMEOUT_MS = 3e3;
|
|
34
42
|
const SHARED_FOR_MS = 3e4;
|
|
35
|
-
function
|
|
36
|
-
if (!intent) return
|
|
37
|
-
|
|
38
|
-
if (!route || typeof intent.confidence !== "number") return null;
|
|
39
|
-
const bar = opts.followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE;
|
|
40
|
-
return intent.confidence >= bar ? route : null;
|
|
43
|
+
function confidentEnough(intent, followUp) {
|
|
44
|
+
if (!intent || typeof intent.confidence !== "number") return false;
|
|
45
|
+
return intent.confidence >= (followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE);
|
|
41
46
|
}
|
|
42
47
|
const shared = /* @__PURE__ */ new Map();
|
|
43
48
|
function classifyTypedAsk(text, now = Date.now()) {
|
|
@@ -59,13 +64,26 @@ function classifyTypedAsk(text, now = Date.now()) {
|
|
|
59
64
|
});
|
|
60
65
|
return verdict;
|
|
61
66
|
}
|
|
62
|
-
|
|
67
|
+
const CONVERSATIONAL_INTENTS = /* @__PURE__ */ new Set(["general", "search", "code"]);
|
|
68
|
+
const intentKey = (intent) => (intent != null ? intent : "").trim().toLowerCase();
|
|
69
|
+
async function resolveAppHandoff(text, opts) {
|
|
63
70
|
if (opts.mode !== "chat" || !text.trim()) return null;
|
|
71
|
+
let verdict = null;
|
|
64
72
|
try {
|
|
65
|
-
|
|
66
|
-
followUp: opts.followUp
|
|
67
|
-
});
|
|
73
|
+
verdict = await classifyTypedAsk(text);
|
|
68
74
|
} catch (e) {
|
|
69
|
-
|
|
75
|
+
verdict = null;
|
|
76
|
+
}
|
|
77
|
+
if (confidentEnough(verdict, opts.followUp)) {
|
|
78
|
+
const intent = intentKey(verdict.intent);
|
|
79
|
+
const fromBrain = appHandoffForIntent(intent);
|
|
80
|
+
if (fromBrain) return fromBrain;
|
|
81
|
+
if (!CONVERSATIONAL_INTENTS.has(intent) && intent !== intentKey(opts.fallbackApp)) return null;
|
|
70
82
|
}
|
|
71
|
-
|
|
83
|
+
if (!opts.fallbackApp || opts.followUp) return null;
|
|
84
|
+
if (intentKey(opts.fallbackApp) === "shopping") return {
|
|
85
|
+
route: SHOP_ROUTE,
|
|
86
|
+
shop: true
|
|
87
|
+
};
|
|
88
|
+
return appHandoffForIntent(opts.fallbackApp);
|
|
89
|
+
}export{FOLLOWUP_HANDOFF_MIN_CONFIDENCE,HANDOFF_MIN_CONFIDENCE,NATIVE_APP_CONNECTORS,NATIVE_APP_ROUTES,SHOP_ROUTE,appHandoffForIntent,classifyTypedAsk,nativeRouteForConnectors,resolveAppHandoff};//# sourceMappingURL=nativeAppHandoff.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nativeAppHandoff.js","sources":["../../../src/features/apps/nativeAppHandoff.ts"],"sourcesContent":["/**\n * A typed ask the brain routes to an app that has a native screen here opens\n * that screen, with the ask handed to its agent.\n *\n * The decision is the brain's: the same `yantra-brain` classify the web chat\n * runs (`/resources/yantra-brain-classify`, whose intent ids are the web\n * registry's app ids), gated the way the web intent router gates it - a first\n * turn needs the app's ordinary bar, a follow-up in a conversation needs\n * near-certainty. Nothing here reads the words of the ask. Opening the screen\n * is nativeAppNavigation's job, kept apart so this stays free of navigation.\n */\nimport { classifyIntentViaBrain, type BrainIntent } from '../../services/brainQuickReply';\n\n/**\n * Brain intent (web registry app id, `FEATURE_ROUTING` key) -> the native screen\n * that serves it on the phone. Every native app whose screen takes a handed-off\n * ask (`initialAgentQuery`) is here; Shop has its own hand-off (openShopNative).\n */\nexport const NATIVE_APP_ROUTES: Readonly<Record<string, string>> = {\n 'local-services': 'MainStack.LocalServicesNative',\n movies: 'MainStack.MoviesNative',\n expenses: 'MainStack.ExpensesNative',\n webbuilder: 'MainStack.WebBuilderNative',\n travel: 'MainStack.TravelNative',\n jobSearch: 'MainStack.JobSearchNative',\n resume: 'MainStack.ResumeNative',\n inbox: 'MainStack.InboxNative',\n notebook: 'MainStack.StudyNative',\n};\n\n/**\n * Connector -> the native screen whose agent works it. When the brain missed\n * an ask and the chat's own agent starts on one of these, the turn belongs in\n * that app (Chat hands it over mid-turn; see nativeRouteForConnectors).\n */\nexport const NATIVE_APP_CONNECTORS: Readonly<Record<string, string>> = {\n 'yantra-webbuilder': NATIVE_APP_ROUTES.webbuilder,\n 'yantra-flight-search': NATIVE_APP_ROUTES.travel,\n 'yantra-resortifi': NATIVE_APP_ROUTES.travel,\n 'yantra-job-search': NATIVE_APP_ROUTES.jobSearch,\n 'yantra-resume-builder': NATIVE_APP_ROUTES.resume,\n 'yantra-mailer-inbox': NATIVE_APP_ROUTES.inbox,\n 'yantra-notebook': NATIVE_APP_ROUTES.notebook,\n 'yantra-local-services': NATIVE_APP_ROUTES['local-services'],\n 'yantra-movies': NATIVE_APP_ROUTES.movies,\n 'yantra-expenses': NATIVE_APP_ROUTES.expenses,\n};\n\n/** The native screen for the first app connector a turn ran on, or null when it ran on none. */\nexport function nativeRouteForConnectors(connectors: Iterable<string | null | undefined>): string | null {\n for (const connector of connectors) {\n const route = connector ? NATIVE_APP_CONNECTORS[connector] : undefined;\n if (route) return route;\n }\n return null;\n}\n\n/** The web router's DEFAULT_MIN_CONFIDENCE and FOLLOWUP_MIN_CONFIDENCE (services/intentRouter.ts). */\nexport const HANDOFF_MIN_CONFIDENCE = 0.8;\nexport const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;\n\nconst CLASSIFY_TIMEOUT_MS = 2000;\nconst SHARED_FOR_MS = 30_000;\n\n/** The native route a classification opens, or null when it names no native app or is not sure enough. */\nexport function nativeHandoffRoute(intent: BrainIntent | null, opts: { followUp?: boolean } = {}): string | null {\n if (!intent) return null;\n const route = NATIVE_APP_ROUTES[intent.intent];\n if (!route || typeof intent.confidence !== 'number') return null;\n const bar = opts.followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE;\n return intent.confidence >= bar ? route : null;\n}\n\nconst shared = new Map<string, { at: number; verdict: Promise<BrainIntent | null> }>();\n\n/**\n * One brain classification per typed ask, shared by every hand-off check that\n * turn (Shop's and this one), so asking twice costs one request.\n */\nexport function classifyTypedAsk(text: string, now = Date.now()): Promise<BrainIntent | null> {\n const key = text.trim();\n if (!key) return Promise.resolve(null);\n for (const [k, entry] of shared) if (now - entry.at > SHARED_FOR_MS) shared.delete(k);\n const hit = shared.get(key);\n if (hit) return hit.verdict;\n const verdict = classifyIntentViaBrain(key, { timeoutMs: CLASSIFY_TIMEOUT_MS }).catch(() => null);\n const entry = { at: now, verdict };\n shared.set(key, entry);\n // A timeout or a failed call is not a verdict: the next check asks again.\n void verdict.then((answer) => {\n if (!answer && shared.get(key) === entry) shared.delete(key);\n });\n return verdict;\n}\n\n/** TEST-ONLY */\nexport function __resetTypedAskCache(): void {\n shared.clear();\n}\n\n/**\n * The native screen a typed ask belongs on, or null to keep it in chat. Build\n * and deep-search turns are modes the person chose, so they never leave chat.\n */\nexport async function resolveNativeHandoff(\n text: string,\n opts: { mode: 'chat' | 'deep-search' | 'build'; followUp?: boolean },\n): Promise<string | null> {\n if (opts.mode !== 'chat' || !text.trim()) return null;\n try {\n return nativeHandoffRoute(await classifyTypedAsk(text), { followUp: opts.followUp });\n } catch {\n return null;\n }\n}\n"],"names":["entry"],"mappings":"uEAkBO,MAAM,iBAAsD,GAAA;AAAA,EACjE,gBAAkB,EAAA,+BAAA;AAAA,EAClB,MAAQ,EAAA,wBAAA;AAAA,EACR,QAAU,EAAA,0BAAA;AAAA,EACV,UAAY,EAAA,4BAAA;AAAA,EACZ,MAAQ,EAAA,wBAAA;AAAA,EACR,SAAW,EAAA,2BAAA;AAAA,EACX,MAAQ,EAAA,wBAAA;AAAA,EACR,KAAO,EAAA,uBAAA;AAAA,EACP,QAAU,EAAA;AACZ;AAOO,MAAM,qBAA0D,GAAA;AAAA,EACrE,qBAAqB,iBAAkB,CAAA,UAAA;AAAA,EACvC,wBAAwB,iBAAkB,CAAA,MAAA;AAAA,EAC1C,oBAAoB,iBAAkB,CAAA,MAAA;AAAA,EACtC,qBAAqB,iBAAkB,CAAA,SAAA;A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cesContent":["/**\n * A typed ask the brain routes to an app with a native screen opens that screen,\n * with the ask handed to its agent.\n *\n * Apps with only a web surface keep the ask in chat, where the agent does the\n * work: a surface opened in the WebView shell does not take an ask (only the Web\n * Builder's reads `?message=`), so opening one dropped what the person wrote.\n *\n * The decision is the brain's: the same `yantra-brain` classify the web chat\n * runs (`/resources/yantra-brain-classify`, whose intent ids are the web\n * registry's app ids), gated the way the web intent router gates it - a first\n * turn needs the app's ordinary bar, a follow-up in a conversation needs\n * near-certainty. Nothing here reads the words of the ask. A Home shortcut adds\n * the app it was made for, which opens when the brain does not name another\n * one (the web's suggestions open their `panel` the same way). Opening the\n * screen is nativeAppNavigation's job, kept apart so this stays free of\n * navigation.\n */\nimport { classifyIntentViaBrain, type BrainIntent } from '../../services/brainQuickReply';\n\n/**\n * Brain intent (web registry app id, `FEATURE_ROUTING` key) -> the native screen\n * that serves it on the phone. Every native app whose screen takes a handed-off\n * ask (`initialAgentQuery`) is here; Shop has its own hand-off (openShopNative).\n */\nexport const NATIVE_APP_ROUTES: Readonly<Record<string, string>> = {\n 'local-services': 'MainStack.LocalServicesNative',\n movies: 'MainStack.MoviesNative',\n expenses: 'MainStack.ExpensesNative',\n webbuilder: 'MainStack.WebBuilderNative',\n travel: 'MainStack.TravelNative',\n jobSearch: 'MainStack.JobSearchNative',\n resume: 'MainStack.ResumeNative',\n inbox: 'MainStack.InboxNative',\n notebook: 'MainStack.StudyNative',\n};\n\n/**\n * The brain's intent ids are the registry's, in its casing (`jobSearch`), but\n * the client lowercases what it reads back. Matched case-blind: an exact-case\n * lookup made \"find me a job\" stay in chat although the brain named Job Search.\n */\nconst NATIVE_ROUTE_BY_INTENT: ReadonlyMap<string, string> = new Map(\n Object.entries(NATIVE_APP_ROUTES).map(([intent, route]) => [intent.toLowerCase(), route]),\n);\n\n/** Shop's screen. A brain verdict for Shop goes through Shop's own check; only a shortcut opens it from here. */\nexport const SHOP_ROUTE = 'MainStack.ShoppingNative';\n\n/** Where a handed-off ask opens. */\nexport interface AppHandoff {\n /** The stack route to open. */\n route: string;\n /** Shop: opened through its own hand-off (openShopNative), which reads the ask itself. */\n shop?: boolean;\n}\n\n/**\n * The native screen an intent opens on the phone, or null to keep the ask in chat\n * (Shop, which has its own hand-off; conversational intents; apps with no native\n * screen that takes an ask).\n */\nexport function appHandoffForIntent(intent: string | null | undefined): AppHandoff | null {\n const native = NATIVE_ROUTE_BY_INTENT.get((intent ?? '').trim().toLowerCase());\n return native ? { route: native } : null;\n}\n\n/**\n * Connector -> the native screen whose agent works it. When the brain missed\n * an ask and the chat's own agent starts on one of these, the turn belongs in\n * that app (Chat hands it over mid-turn; see nativeRouteForConnectors).\n */\nexport const NATIVE_APP_CONNECTORS: Readonly<Record<string, string>> = {\n 'yantra-webbuilder': NATIVE_APP_ROUTES.webbuilder,\n 'yantra-flight-search': NATIVE_APP_ROUTES.travel,\n 'yantra-resortifi': NATIVE_APP_ROUTES.travel,\n 'yantra-job-search': NATIVE_APP_ROUTES.jobSearch,\n 'yantra-resume-builder': NATIVE_APP_ROUTES.resume,\n 'yantra-mailer-inbox': NATIVE_APP_ROUTES.inbox,\n 'yantra-notebook': NATIVE_APP_ROUTES.notebook,\n 'yantra-local-services': NATIVE_APP_ROUTES['local-services'],\n 'yantra-movies': NATIVE_APP_ROUTES.movies,\n 'yantra-expenses': NATIVE_APP_ROUTES.expenses,\n};\n\n/** The native screen for the first app connector a turn ran on, or null when it ran on none. */\nexport function nativeRouteForConnectors(connectors: Iterable<string | null | undefined>): string | null {\n for (const connector of connectors) {\n const route = connector ? NATIVE_APP_CONNECTORS[connector] : undefined;\n if (route) return route;\n }\n return null;\n}\n\n/** The web router's DEFAULT_MIN_CONFIDENCE and FOLLOWUP_MIN_CONFIDENCE (services/intentRouter.ts). */\nexport const HANDOFF_MIN_CONFIDENCE = 0.8;\nexport const FOLLOWUP_HANDOFF_MIN_CONFIDENCE = 0.95;\n\n/**\n * How long a send waits for the brain before it stays in chat. Measured 11/07: prod\n * classify 0.5-2.0s (Notion 2.0s), dev 2.8s. At 2s a slow answer silently kept the\n * ask in chat; the message is on screen meanwhile, so waiting a little longer only\n * delays the app opening.\n */\nconst CLASSIFY_TIMEOUT_MS = 3000;\nconst SHARED_FOR_MS = 30_000;\n\n/** Whether a classification clears the bar for leaving the chat. */\nfunction confidentEnough(intent: BrainIntent | null, followUp?: boolean): intent is BrainIntent {\n if (!intent || typeof intent.confidence !== 'number') return false;\n return intent.confidence >= (followUp ? FOLLOWUP_HANDOFF_MIN_CONFIDENCE : HANDOFF_MIN_CONFIDENCE);\n}\n\n/** The native route a classification opens, or null when it names no native app or is not sure enough. */\nexport function nativeHandoffRoute(intent: BrainIntent | null, opts: { followUp?: boolean } = {}): string | null {\n if (!confidentEnough(intent, opts.followUp)) return null;\n return NATIVE_ROUTE_BY_INTENT.get(intent.intent.trim().toLowerCase()) ?? null;\n}\n\nconst shared = new Map<string, { at: number; verdict: Promise<BrainIntent | null> }>();\n\n/**\n * One brain classification per typed ask, shared by every hand-off check that\n * turn (Shop's and this one), so asking twice costs one request.\n */\nexport function classifyTypedAsk(text: string, now = Date.now()): Promise<BrainIntent | null> {\n const key = text.trim();\n if (!key) return Promise.resolve(null);\n for (const [k, entry] of shared) if (now - entry.at > SHARED_FOR_MS) shared.delete(k);\n const hit = shared.get(key);\n if (hit) return hit.verdict;\n const verdict = classifyIntentViaBrain(key, { timeoutMs: CLASSIFY_TIMEOUT_MS }).catch(() => null);\n const entry = { at: now, verdict };\n shared.set(key, entry);\n // A timeout or a failed call is not a verdict: the next check asks again.\n void verdict.then((answer) => {\n if (!answer && shared.get(key) === entry) shared.delete(key);\n });\n return verdict;\n}\n\n/** TEST-ONLY */\nexport function __resetTypedAskCache(): void {\n shared.clear();\n}\n\n/** The brain's built-in intents (yantraBrainClassify BUILTIN_INTENTS): they name no app. */\nconst CONVERSATIONAL_INTENTS: ReadonlySet<string> = new Set(['general', 'search', 'code']);\n\nconst intentKey = (intent: string | null | undefined) => (intent ?? '').trim().toLowerCase();\n\nexport interface AppHandoffOptions {\n mode: 'chat' | 'deep-search' | 'build';\n followUp?: boolean;\n /** The app a Home shortcut was made for (a registry intent id), opened when the brain names no other. */\n fallbackApp?: string | null;\n}\n\n/**\n * Where a typed ask opens, or null to keep it in chat. Build and deep-search\n * turns are modes the person chose, so they never leave chat.\n */\nexport async function resolveAppHandoff(text: string, opts: AppHandoffOptions): Promise<AppHandoff | null> {\n if (opts.mode !== 'chat' || !text.trim()) return null;\n let verdict: BrainIntent | null = null;\n try {\n verdict = await classifyTypedAsk(text);\n } catch {\n verdict = null;\n }\n if (confidentEnough(verdict, opts.followUp)) {\n const intent = intentKey(verdict.intent);\n const fromBrain = appHandoffForIntent(intent);\n if (fromBrain) return fromBrain;\n // Sure the ask is for another app (Shop, or one not handed off here): the\n // shortcut's own app must not override what the person turned it into.\n if (!CONVERSATIONAL_INTENTS.has(intent) && intent !== intentKey(opts.fallbackApp)) return null;\n }\n // Unsure, slow, or conversational: a shortcut still opens the app it was made for.\n if (!opts.fallbackApp || opts.followUp) return null;\n if (intentKey(opts.fallbackApp) === 'shopping') return { route: SHOP_ROUTE, shop: true };\n return appHandoffForIntent(opts.fallbackApp);\n}\n"],"names":["entry"],"mappings":"uEAyBO,MAAM,iBAAsD,GAAA;AAAA,EACjE,gBAAkB,EAAA,+BAAA;AAAA,EAClB,MAAQ,EAAA,wBAAA;AAAA,EACR,QAAU,EAAA,0BAAA;AAAA,EACV,UAAY,EAAA,4BAAA;AAAA,EACZ,MAAQ,EAAA,wBAAA;AAAA,EACR,SAAW,EAAA,2BAAA;AAAA,EACX,MAAQ,EAAA,wBAAA;AAAA,EACR,KAAO,EAAA,uBAAA;AAAA,EACP,QAAU,EAAA;AACZ;AAOA,MAAM,yBAAsD,IAAI,GAAA,CAAI,OAAO,OAAQ,CAAA,iBAAiB,EAAE,GAAI,CAAA,CAAC,CAAC,MAAQ,EAAA,KAAK,MAAM,CAAC,MAAA,CAAO,aAAe,EAAA,KAAK,CAAC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