@adminide-stack/yantra-mobile 12.0.28-alpha.9 → 12.0.28-alpha.93

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.
Files changed (85) hide show
  1. package/lib/api/stt.js +54 -0
  2. package/lib/api/stt.js.map +1 -0
  3. package/lib/assets/icon.png +0 -0
  4. package/lib/components/CustomDrawer.js +479 -0
  5. package/lib/components/CustomDrawer.js.map +1 -0
  6. package/lib/components/GatewayConnector/GatewayConnector.js +18 -0
  7. package/lib/components/GatewayConnector/GatewayConnector.js.map +1 -0
  8. package/lib/components/GatewayToolbarButtonMobile.js +84 -0
  9. package/lib/components/GatewayToolbarButtonMobile.js.map +1 -0
  10. package/lib/components/NavigationHeader/NavigationHeader.js +214 -0
  11. package/lib/components/NavigationHeader/NavigationHeader.js.map +1 -0
  12. package/lib/components/ThinkingIndicator.js +55 -0
  13. package/lib/components/ThinkingIndicator.js.map +1 -0
  14. package/lib/components/YantraBrandLoader.js +94 -0
  15. package/lib/components/YantraBrandLoader.js.map +1 -0
  16. package/lib/compute.js +114 -5
  17. package/lib/compute.js.map +1 -1
  18. package/lib/config/constants.js +18 -0
  19. package/lib/config/constants.js.map +1 -0
  20. package/lib/config/env-config.js +75 -19
  21. package/lib/config/env-config.js.map +1 -1
  22. package/lib/contexts/CdecliConnectionContext.js +47 -0
  23. package/lib/contexts/CdecliConnectionContext.js.map +1 -0
  24. package/lib/contexts/GatewayContext.js +77 -0
  25. package/lib/contexts/GatewayContext.js.map +1 -0
  26. package/lib/features/audio-input/AudioRecorderPanel.js +220 -0
  27. package/lib/features/audio-input/AudioRecorderPanel.js.map +1 -0
  28. package/lib/features/audio-input/MicErrorBoundary.js +34 -0
  29. package/lib/features/audio-input/MicErrorBoundary.js.map +1 -0
  30. package/lib/features/audio-input/useAudioPermission.js +24 -0
  31. package/lib/features/audio-input/useAudioPermission.js.map +1 -0
  32. package/lib/graphql/agentGatewayDocuments.js +53 -0
  33. package/lib/graphql/agentGatewayDocuments.js.map +1 -0
  34. package/lib/hooks/useAccountDefaultSettings.js +38 -0
  35. package/lib/hooks/useAccountDefaultSettings.js.map +1 -0
  36. package/lib/hooks/useCdecliAutoConnect.js +244 -0
  37. package/lib/hooks/useCdecliAutoConnect.js.map +1 -0
  38. package/lib/hooks/useCdecliChannel.js +161 -0
  39. package/lib/hooks/useCdecliChannel.js.map +1 -0
  40. package/lib/hooks/useChatApi.js +386 -170
  41. package/lib/hooks/useChatApi.js.map +1 -1
  42. package/lib/hooks/useChatStream.js +179 -137
  43. package/lib/hooks/useChatStream.js.map +1 -1
  44. package/lib/hooks/useGatewayConnection.js +123 -0
  45. package/lib/hooks/useGatewayConnection.js.map +1 -0
  46. package/lib/hooks/useGatewayRegistry.js +28 -0
  47. package/lib/hooks/useGatewayRegistry.js.map +1 -0
  48. package/lib/hooks/usePrerequisiteIds.js +209 -0
  49. package/lib/hooks/usePrerequisiteIds.js.map +1 -0
  50. package/lib/hooks/useWorkspaceProvisioner.js +236 -0
  51. package/lib/hooks/useWorkspaceProvisioner.js.map +1 -0
  52. package/lib/index.js +1 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/routes.json +120 -5
  55. package/lib/screens/Chat/index.js +409 -0
  56. package/lib/screens/Chat/index.js.map +1 -0
  57. package/lib/screens/ChatHistory/index.js +56 -0
  58. package/lib/screens/ChatHistory/index.js.map +1 -0
  59. package/lib/screens/Home/HomeScreen.js +364 -144
  60. package/lib/screens/Home/HomeScreen.js.map +1 -1
  61. package/lib/screens/Home/components/ChatHistoryLanding.js +487 -0
  62. package/lib/screens/Home/components/ChatHistoryLanding.js.map +1 -0
  63. package/lib/screens/Home/components/DeepSearchModal.js +349 -0
  64. package/lib/screens/Home/components/DeepSearchModal.js.map +1 -0
  65. package/lib/screens/Home/deepSearchUtils.js +41 -0
  66. package/lib/screens/Home/deepSearchUtils.js.map +1 -0
  67. package/lib/screens/NewChat/index.js +43 -0
  68. package/lib/screens/NewChat/index.js.map +1 -0
  69. package/lib/services/agentSessionManager.js +451 -0
  70. package/lib/services/agentSessionManager.js.map +1 -0
  71. package/lib/services/gatewayApiKeyBridge.js +4 -0
  72. package/lib/services/gatewayApiKeyBridge.js.map +1 -0
  73. package/lib/services/gatewayClient.js +470 -0
  74. package/lib/services/gatewayClient.js.map +1 -0
  75. package/lib/theme/mobileTokens.js +18 -0
  76. package/lib/theme/mobileTokens.js.map +1 -0
  77. package/lib/utils/cdecodeUri.js +68 -0
  78. package/lib/utils/cdecodeUri.js.map +1 -0
  79. package/lib/utils/gatewaySelectionStorage.js +21 -0
  80. package/lib/utils/gatewaySelectionStorage.js.map +1 -0
  81. package/lib/utils/syncMobileOrgRouteContext.js +61 -0
  82. package/lib/utils/syncMobileOrgRouteContext.js.map +1 -0
  83. package/package.json +7 -3
  84. package/lib/api/chatApi.js +0 -102
  85. package/lib/api/chatApi.js.map +0 -1
package/lib/compute.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';
2
2
  const yantraMobilePageStore = [{
3
3
  key: "home",
4
- path: "/l/home",
4
+ path: "/:orgName/l/home",
5
5
  name: "Home",
6
6
  exact: true,
7
7
  index: true,
@@ -9,9 +9,26 @@ const yantraMobilePageStore = [{
9
9
  hideInMenu: true,
10
10
  auth: true,
11
11
  menu_position: "side",
12
+ importPaths: {
13
+ navigationHeader: "@adminide-stack/yantra-mobile/lib/components/NavigationHeader/NavigationHeader.js"
14
+ },
15
+ customHeader: {
16
+ name: "NavigationHeader",
17
+ component: "$.importPaths.navigationHeader",
18
+ props: {
19
+ showTitle: true,
20
+ showToggle: true,
21
+ showFilter: true,
22
+ isSearchBack: false,
23
+ showGateway: true,
24
+ showHistory: true,
25
+ showNewChat: true
26
+ }
27
+ },
12
28
  props: {
13
29
  initialParams: {
14
- initialSessionId: null
30
+ initialSessionId: null,
31
+ orgName: null
15
32
  },
16
33
  options: {
17
34
  title: "Yantra",
@@ -19,15 +36,107 @@ const yantraMobilePageStore = [{
19
36
  headerTitleStyle: {
20
37
  fontWeight: "bold"
21
38
  },
22
- drawerLabel: "Home",
39
+ drawerLabel: "Chat",
23
40
  headerTitleAlign: "left",
24
41
  gestureEnabled: false,
25
- swipeEnabled: false
42
+ swipeEnabled: false,
43
+ animation: "fade",
44
+ animationTypeForReplace: "pop"
26
45
  }
27
46
  },
28
47
  componentPath: "@adminide-stack/yantra-mobile/lib/screens/Home/index.js",
29
48
  hasComponent: true
49
+ }, {
50
+ key: "chat",
51
+ path: "/:orgName/chat/:channelId",
52
+ name: "Chat",
53
+ exact: false,
54
+ priority: 2,
55
+ hideInMenu: true,
56
+ auth: true,
57
+ importPaths: {
58
+ navigationHeader: "@adminide-stack/yantra-mobile/lib/components/NavigationHeader/NavigationHeader.js"
59
+ },
60
+ customHeader: {
61
+ name: "NavigationHeader",
62
+ component: "$.importPaths.navigationHeader",
63
+ props: {
64
+ showTitle: true,
65
+ showToggle: false,
66
+ showFilter: false,
67
+ isSearchBack: false,
68
+ showBack: true,
69
+ showGateway: true,
70
+ showHistory: false,
71
+ showNewChat: true
72
+ }
73
+ },
74
+ props: {
75
+ initialParams: {
76
+ channelId: null,
77
+ orgName: null
78
+ },
79
+ options: {
80
+ title: "Yantra",
81
+ headerTintColor: "black",
82
+ headerTitleStyle: {
83
+ fontWeight: "bold"
84
+ },
85
+ drawerLabel: "Chat",
86
+ headerTitleAlign: "left",
87
+ gestureEnabled: false,
88
+ swipeEnabled: false,
89
+ animation: "fade",
90
+ animationTypeForReplace: "pop"
91
+ }
92
+ },
93
+ componentPath: "@adminide-stack/yantra-mobile/lib/screens/Chat/index.js",
94
+ hasComponent: true
95
+ }, {
96
+ key: "chathistory",
97
+ path: "/:orgName/chathistory",
98
+ name: "ChatHistory",
99
+ exact: false,
100
+ priority: 3,
101
+ hideInMenu: true,
102
+ auth: true,
103
+ importPaths: {
104
+ navigationHeader: "@adminide-stack/yantra-mobile/lib/components/NavigationHeader/NavigationHeader.js"
105
+ },
106
+ customHeader: {
107
+ name: "NavigationHeader",
108
+ component: "$.importPaths.navigationHeader",
109
+ props: {
110
+ showTitle: true,
111
+ showToggle: false,
112
+ showFilter: false,
113
+ isSearchBack: false,
114
+ showBack: true,
115
+ showGateway: false,
116
+ showHistory: false,
117
+ showNewChat: true
118
+ }
119
+ },
120
+ props: {
121
+ initialParams: {
122
+ orgName: null
123
+ },
124
+ options: {
125
+ title: "Chat history",
126
+ headerTintColor: "black",
127
+ headerTitleStyle: {
128
+ fontWeight: "bold"
129
+ },
130
+ headerTitleAlign: "left",
131
+ gestureEnabled: false,
132
+ swipeEnabled: false,
133
+ animation: "fade",
134
+ animationTypeForReplace: "pop"
135
+ }
136
+ },
137
+ componentPath: "@adminide-stack/yantra-mobile/lib/screens/ChatHistory/index.js",
138
+ hasComponent: true
30
139
  }];
31
- const selectedRoutes = ["home"];
140
+ const selectedRoutes = ["home", "chat", "chathistory"];
32
141
  const filteredRoutes = getFilteredRoutes(yantraMobilePageStore, selectedRoutes);
33
142
  export { filteredRoutes, yantraMobilePageStore }; //# sourceMappingURL=compute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute.js","sources":["../src/compute.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';\nimport type { IRouteModule } from '@common-stack/core';\n\nexport const yantraMobilePageStore: IRouteModule[] = [\n {\n key: 'home',\n path: '/l/home',\n name: 'Home',\n exact: true,\n index: true,\n priority: 1,\n hideInMenu: true,\n auth: true,\n menu_position: 'side',\n component: () => import('./screens/Home'),\n props: {\n initialParams: { initialSessionId: null },\n options: {\n title: 'Yantra',\n headerTintColor: 'black',\n headerTitleStyle: {\n fontWeight: 'bold',\n },\n drawerLabel: 'Home',\n headerTitleAlign: 'left',\n gestureEnabled: false,\n swipeEnabled: false,\n },\n },\n },\n];\n\nconst selectedRoutes = ['home'];\n\nconst filteredRoutes = getFilteredRoutes(yantraMobilePageStore, selectedRoutes);\n\nexport { filteredRoutes };\n"],"names":[],"mappings":"uFAGO,MAAM,wBAAwC,CAAC;AAAA,EACpD,GAAK,EAAA,MAAA;AAAA,EACL,IAAM,EAAA,SAAA;AAAA,EACN,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,QAAU,EAAA,CAAA;AAAA,EACV,UAAY,EAAA,IAAA;AAAA,EACZ,IAAM,EAAA,IAAA;AAAA,EACN,aAAe,EAAA,MAAA;AAAA,EACf,SAAA,EAAW,MAAM,OAAO,yBAAgB,CAAA;AAAA,EACxC,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA,MACb,gBAAkB,EAAA;AAAA,KACpB;AAAA,IACA,OAAS,EAAA;AAAA,MACP,KAAO,EAAA,QAAA;AAAA,MACP,eAAiB,EAAA,OAAA;AAAA,MACjB,gBAAkB,EAAA;AAAA,QAChB,UAAY,EAAA;AAAA,OACd;AAAA,MACA,WAAa,EAAA,MAAA;AAAA,MACb,gBAAkB,EAAA,MAAA;AAAA,MAClB,cAAgB,EAAA,KAAA;AAAA,MAChB,YAAc,EAAA;AAAA;AAChB;AAEJ,CAAC;AACD,MAAM,cAAA,GAAiB,CAAC,MAAM,CAAA;AACxB,MAAA,cAAA,GAAiB,iBAAkB,CAAA,qBAAA,EAAuB,cAAc"}
1
+ {"version":3,"file":"compute.js","sources":["../src/compute.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\nimport { getFilteredRoutes } from '@common-stack/client-react/lib/utils/filteredRoutes.js';\nimport type { IRouteModule } from '@common-stack/core';\n\nexport const yantraMobilePageStore: IRouteModule[] = [\n {\n key: 'home',\n path: '/:orgName/l/home',\n name: 'Home',\n exact: true,\n index: true,\n priority: 1,\n hideInMenu: true,\n auth: true,\n menu_position: 'side',\n component: () => import('./screens/Home'),\n importPaths: {\n navigationHeader: () => import('./components/NavigationHeader/NavigationHeader'),\n },\n customHeader: {\n name: 'NavigationHeader',\n component: '$.importPaths.navigationHeader',\n props: {\n showTitle: true,\n showToggle: true,\n showFilter: true,\n isSearchBack: false,\n showGateway: true,\n showHistory: true,\n showNewChat: true,\n },\n },\n props: {\n initialParams: { initialSessionId: null, orgName: null },\n options: {\n title: 'Yantra',\n headerTintColor: 'black',\n headerTitleStyle: {\n fontWeight: 'bold',\n },\n drawerLabel: 'Chat',\n headerTitleAlign: 'left',\n gestureEnabled: false,\n swipeEnabled: false,\n animation: 'fade',\n animationTypeForReplace: 'pop',\n },\n },\n },\n {\n key: 'chat',\n path: '/:orgName/chat/:channelId',\n name: 'Chat',\n exact: false,\n priority: 2,\n hideInMenu: true,\n auth: true,\n component: () => import('./screens/Chat'),\n importPaths: {\n navigationHeader: () => import('./components/NavigationHeader/NavigationHeader'),\n },\n customHeader: {\n name: 'NavigationHeader',\n component: '$.importPaths.navigationHeader',\n props: {\n showTitle: true,\n showToggle: false,\n showFilter: false,\n isSearchBack: false,\n showBack: true,\n showGateway: true,\n showHistory: false,\n showNewChat: true,\n },\n },\n props: {\n initialParams: { channelId: null, orgName: null },\n options: {\n title: 'Yantra',\n headerTintColor: 'black',\n headerTitleStyle: {\n fontWeight: 'bold',\n },\n drawerLabel: 'Chat',\n headerTitleAlign: 'left',\n gestureEnabled: false,\n swipeEnabled: false,\n animation: 'fade',\n animationTypeForReplace: 'pop',\n },\n },\n },\n {\n key: 'chathistory',\n path: '/:orgName/chathistory',\n name: 'ChatHistory',\n exact: false,\n priority: 3,\n hideInMenu: true,\n auth: true,\n component: () => import('./screens/ChatHistory'),\n importPaths: {\n navigationHeader: () => import('./components/NavigationHeader/NavigationHeader'),\n },\n customHeader: {\n name: 'NavigationHeader',\n component: '$.importPaths.navigationHeader',\n props: {\n showTitle: true,\n showToggle: false,\n showFilter: false,\n isSearchBack: false,\n showBack: true,\n showGateway: false,\n showHistory: false,\n showNewChat: true,\n },\n },\n props: {\n initialParams: { orgName: null },\n options: {\n title: 'Chat history',\n headerTintColor: 'black',\n headerTitleStyle: {\n fontWeight: 'bold',\n },\n headerTitleAlign: 'left',\n gestureEnabled: false,\n swipeEnabled: false,\n animation: 'fade',\n animationTypeForReplace: 'pop',\n },\n },\n },\n];\n\nconst selectedRoutes = ['home', 'chat', 'chathistory'];\n\nconst filteredRoutes = getFilteredRoutes(yantraMobilePageStore, selectedRoutes);\n\nexport { filteredRoutes };\n"],"names":[],"mappings":"uFAGO,MAAM,wBAAwC,CAAC;AAAA,EACpD,GAAK,EAAA,MAAA;AAAA,EACL,IAAM,EAAA,kBAAA;AAAA,EACN,IAAM,EAAA,MAAA;AAAA,EACN,KAAO,EAAA,IAAA;AAAA,EACP,KAAO,EAAA,IAAA;AAAA,EACP,QAAU,EAAA,CAAA;AAAA,EACV,UAAY,EAAA,IAAA;AAAA,EACZ,IAAM,EAAA,IAAA;AAAA,EACN,aAAe,EAAA,MAAA;AAAA,EACf,SAAA,EAAW,MAAM,OAAO,yBAAgB,CAAA;AAAA,EACxC,WAAa,EAAA;AAAA,IACX,gBAAA,EAAkB,MAAM,OAAO,mDAAgD;AAAA,GACjF;AAAA,EACA,YAAc,EAAA;AAAA,IACZ,IAAM,EAAA,kBAAA;AAAA,IACN,SAAW,EAAA,gCAAA;AAAA,IACX,KAAO,EAAA;AAAA,MACL,SAAW,EAAA,IAAA;AAAA,MACX,UAAY,EAAA,IAAA;AAAA,MACZ,UAAY,EAAA,IAAA;AAAA,MACZ,YAAc,EAAA,KAAA;AAAA,MACd,WAAa,EAAA,IAAA;AAAA,MACb,WAAa,EAAA,IAAA;AAAA,MACb,WAAa,EAAA;AAAA;AACf,GACF;AAAA,EACA,KAAO,EAAA;AAAA,IACL,aAAe,EAAA;AAAA,MACb,gBAAkB,EAAA,IAAA;AAAA,MAClB,OAAS,EAAA;AAAA,KACX;AAAA,IACA,OAAS,EAAA;AAAA,MACP,KAAO,EAAA,QAAA;AAAA,MACP,eAAiB,EAAA,OAAA;AAAA,MACjB,gBAA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3B;AAEJ,CAAC;AACD,MAAM,cAAiB,GAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,aAAa,CAAA;AAC/C,MAAA,cAAA,GAAiB,iBAAkB,CAAA,qBAAA,EAAuB,cAAc"}
@@ -0,0 +1,18 @@
1
+ const CDECLI_GATEWAY = {
2
+ name: "CDeCLI",
3
+ description: "CDeCLI agent and skills",
4
+ channelType: "cdecli-serve",
5
+ extensionId: "",
6
+ icon: "terminal",
7
+ isBuiltin: true,
8
+ priority: 90,
9
+ /** Server persists chat posts via gateway — client must not call `saveMessages`. */
10
+ persistenceMode: "backend"
11
+ };
12
+ const BUILTIN_MOBILE_GATEWAYS = {
13
+ cdecli: CDECLI_GATEWAY
14
+ };
15
+ const STORAGE_KEYS = {
16
+ GATEWAY_SELECTION: "yantra_gateway_selection"
17
+ };
18
+ const MAX_CONCURRENT_TASKS = 3;export{BUILTIN_MOBILE_GATEWAYS,MAX_CONCURRENT_TASKS,STORAGE_KEYS};//# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../src/config/constants.ts"],"sourcesContent":["/** Minimal gateway types for mobile — aligned with account/browser. */\n\nexport type GatewayId = string;\n\nexport interface GatewayEntry {\n name: string;\n description: string;\n channelType: string;\n extensionId: string;\n icon: string;\n isBuiltin: boolean;\n priority: number;\n endpoint?: string;\n persistenceMode?: 'backend' | 'frontend';\n}\n\n/** CDeCLI / cdecli-serve (hosted agent). */\nconst CDECLI_GATEWAY: GatewayEntry = {\n name: 'CDeCLI',\n description: 'CDeCLI agent and skills',\n channelType: 'cdecli-serve',\n extensionId: '',\n icon: 'terminal',\n isBuiltin: true,\n priority: 90,\n /** Server persists chat posts via gateway — client must not call `saveMessages`. */\n persistenceMode: 'backend',\n};\n\n/** Built-in gateways when UiLayout settings are not loaded (e.g. React Native). */\nexport const BUILTIN_MOBILE_GATEWAYS: Record<string, GatewayEntry> = {\n cdecli: CDECLI_GATEWAY,\n};\n\nexport const STORAGE_KEYS = {\n GATEWAY_SELECTION: 'yantra_gateway_selection',\n} as const;\n\n/** Maximum concurrent agent tasks (same cap as browser). */\nexport const MAX_CONCURRENT_TASKS = 3;\n"],"names":[],"mappings":"AAgBA,MAAM,cAA+B,GAAA;AAAA,EACnC,IAAM,EAAA,QAAA;AAAA,EACN,WAAa,EAAA,yBAAA;AAAA,EACb,WAAa,EAAA,cAAA;AAAA,EACb,WAAa,EAAA,EAAA;AAAA,EACb,IAAM,EAAA,UAAA;AAAA,EACN,SAAW,EAAA,IAAA;AAAA,EACX,QAAU,EAAA,EAAA;AAAA;AAAA,EAEV,eAAiB,EAAA;AACnB,CAAA;AAGO,MAAM,uBAAwD,GAAA;AAAA,EACnE,MAAQ,EAAA;AACV;AACO,MAAM,YAAe,GAAA;AAAA,EAC1B,iBAAmB,EAAA;AACrB;AAGO,MAAM,oBAAuB,GAAA"}
@@ -1,20 +1,76 @@
1
- import {cleanEnv,str}from'envalid';const env = process.APP_ENV || process.env;
2
- const config = cleanEnv(
3
- env,
4
- /* start */
5
- {
6
- GRAPHQL_URL: str({
7
- default: "http://localhost:8080/graphql"
8
- }),
9
- CLIENT_URL: str({
10
- default: "http://localhost:3000"
11
- }),
12
- APP_NAME: str({
13
- default: "CDMBASE"
14
- }),
15
- GROQ_API_KEY: str({
16
- default: ""
17
- })
1
+ import {cleanEnv,str,bool,num}from'envalid';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
+ const env = process.APP_ENV || process.env;
21
+ const baseConfig = cleanEnv(env, {
22
+ GRAPHQL_URL: str({
23
+ default: "http://localhost:8080/graphql"
24
+ }),
25
+ CLIENT_URL: str({
26
+ default: "http://localhost:3000"
27
+ }),
28
+ APP_NAME: str({
29
+ default: "Yantra"
30
+ }),
31
+ GROQ_API_KEY: str({
32
+ default: ""
33
+ }),
34
+ CDECLI_AGENT_ENDPOINT: str({
35
+ default: "https://cdecli-agent.cdebase.dev"
36
+ }),
37
+ CDECLI_AGENT_AUTH_TOKEN: str({
38
+ default: ""
39
+ }),
40
+ /** Seconds to wait for CDeCLI stream completion before timing out (then fallback chat API runs). Min 15, max 600. */
41
+ /** Aligned with web `useCdecliChannel` (120s). Mobile hook uses the same constant inline. */
42
+ CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: num({
43
+ default: 120
44
+ }),
45
+ BACKEND_URL: str({
46
+ default: ""
47
+ }),
48
+ USE_PROXY_STAGING_GATEWAY: bool({
49
+ default: false
50
+ }),
51
+ PROXY_STAGING_GATEWAY_URL: str({
52
+ default: ""
53
+ })
54
+ });
55
+ function resolveAgentGatewayGraphqlUrl() {
56
+ if (baseConfig.USE_PROXY_STAGING_GATEWAY && baseConfig.PROXY_STAGING_GATEWAY_URL) {
57
+ return baseConfig.PROXY_STAGING_GATEWAY_URL;
18
58
  }
19
- /* end */
20
- );export{config};//# sourceMappingURL=env-config.js.map
59
+ if (baseConfig.GRAPHQL_URL) return baseConfig.GRAPHQL_URL;
60
+ if (baseConfig.BACKEND_URL) return `${baseConfig.BACKEND_URL.replace(/\/$/, "")}/graphql`;
61
+ return "/graphql";
62
+ }
63
+ function resolveBaseWsUrl(graphqlUrl) {
64
+ const base = graphqlUrl.replace(/\/graphql$/, "");
65
+ return base.replace(/^http/, "ws");
66
+ }
67
+ function resolveAgentGatewayWsUrl(graphqlUrl) {
68
+ return `${resolveBaseWsUrl(graphqlUrl)}/ws/openclaw-chat`;
69
+ }
70
+ const agentGatewayGraphqlUrl = resolveAgentGatewayGraphqlUrl();
71
+ const clampedCdecliTimeoutSec = Math.min(600, Math.max(15, Math.round(baseConfig.CDECLI_CHAT_RESPONSE_TIMEOUT_SEC)));
72
+ const config = __spreadProps(__spreadValues({}, baseConfig), {
73
+ CDECLI_CHAT_RESPONSE_TIMEOUT_SEC: clampedCdecliTimeoutSec,
74
+ AGENT_GATEWAY_GRAPHQL_URL: agentGatewayGraphqlUrl,
75
+ AGENT_GATEWAY_WS_URL: resolveAgentGatewayWsUrl(agentGatewayGraphqlUrl)
76
+ });export{config};//# sourceMappingURL=env-config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-config.js","sources":["../../src/config/env-config.ts"],"sourcesContent":["import { str, cleanEnv } from 'envalid';\n\nconst env = (process as any).APP_ENV || process.env;\n\nexport const config = cleanEnv(\n env,\n /* start */\n {\n GRAPHQL_URL: str({ default: 'http://localhost:8080/graphql' }),\n CLIENT_URL: str({ default: 'http://localhost:3000' }),\n APP_NAME: str({ default: 'CDMBASE' }),\n GROQ_API_KEY: str({ default: '' }),\n } /* end */,\n);\n"],"names":[],"mappings":"mCACA,MAAM,GAAA,GAAO,OAAgB,CAAA,OAAA,IAAW,OAAQ,CAAA,GAAA;AACzC,MAAM,MAAS,GAAA,QAAA;AAAA,EAAS,GAAA;AAAA;AAAA,EAC/B;AAAA,IACE,aAAa,GAAI,CAAA;AAAA,MACf,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,YAAY,GAAI,CAAA;AAAA,MACd,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,UAAU,GAAI,CAAA;AAAA,MACZ,OAAS,EAAA;AAAA,KACV,CAAA;AAAA,IACD,cAAc,GAAI,CAAA;AAAA,MAChB,OAAS,EAAA;AAAA,KACV;AAAA;AACH;AAAW"}
1
+ {"version":3,"file":"env-config.js","sources":["../../src/config/env-config.ts"],"sourcesContent":["import { str, cleanEnv, bool, num } from 'envalid';\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 APP_NAME: str({ default: 'Yantra' }),\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 PROXY_STAGING_GATEWAY_URL: str({ default: '' }),\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 AGENT_GATEWAY_GRAPHQL_URL: agentGatewayGraphqlUrl,\n AGENT_GATEWAY_WS_URL: resolveAgentGatewayWsUrl(agentGatewayGraphqlUrl),\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AACA,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,EACD,UAAU,GAAI,CAAA;AAAA,IACZ,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,cAAc,GAAI,CAAA;AAAA,IAChB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,uBAAuB,GAAI,CAAA;AAAA,IACzB,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,yBAAyB,GAAI,CAAA;AAAA,IAC3B,OAAS,EAAA;AAAA,GACV,CAAA;AAAA;AAAA;AAAA,EAGD,kCAAkC,GAAI,CAAA;AAAA,IACpC,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,aAAa,GAAI,CAAA;AAAA,IACf,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,2BAA2B,IAAK,CAAA;AAAA,IAC9B,OAAS,EAAA;AAAA,GACV,CAAA;AAAA,EACD,2BAA2B,GAAI,CAAA;AAAA,IAC7B,OAAS,EAAA;AAAA,GACV;AACH,CAAC,CAAA;AACD,SAAS,6BAAwC,GAAA;AAC/C,EAAI,IAAA,UAAA,CAAW,yBAA6B,IAAA,UAAA,CAAW,yBAA2B,EAAA;AAChF,IAAA,OAAO,UAAW,CAAA,yBAAA;AAAA;AAEpB,EAAI,IAAA,UAAA,CAAW,WAAa,EAAA,OAAO,UAAW,CAAA,WAAA;AAC9C,EAAI,IAAA,UAAA,CAAW,aAAoB,OAAA,CAAA,EAAG,WAAW,WAAY,CAAA,OAAA,CAAQ,KAAO,EAAA,EAAE,CAAC,CAAA,QAAA,CAAA;AAC/E,EAAO,OAAA,UAAA;AACT;AACA,SAAS,iBAAiB,UAA4B,EAAA;AACpD,EAAA,MAAM,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,yBAA2B,EAAA,sBAAA;AAAA,EAC3B,oBAAA,EAAsB,yBAAyB,sBAAsB;AACvE,CAAA"}
@@ -0,0 +1,47 @@
1
+ import {jsx}from'react/jsx-runtime';import {useContext,createContext,useState,useCallback,useMemo}from'react';import {useCdecliAutoConnect}from'../hooks/useCdecliAutoConnect.js';import {useGatewayContext}from'./GatewayContext.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
+ const CdecliConnectionContext = createContext(null);
21
+ CdecliConnectionContext.displayName = "CdecliConnectionContext";
22
+ function CdecliConnectionProvider({
23
+ children
24
+ }) {
25
+ const {
26
+ selectedGateway
27
+ } = useGatewayContext();
28
+ const cdecliSelected = (selectedGateway == null ? void 0 : selectedGateway.channelType) === "cdecli-serve";
29
+ const [activeChannelId, setActiveChannelIdState] = useState(void 0);
30
+ const setActiveChannelId = useCallback((channelId) => {
31
+ setActiveChannelIdState((prev) => prev === channelId ? prev : channelId);
32
+ }, []);
33
+ const connection = useCdecliAutoConnect(cdecliSelected, activeChannelId);
34
+ const value = useMemo(() => __spreadProps(__spreadValues({}, connection), {
35
+ cdecliSelected,
36
+ activeChannelId,
37
+ setActiveChannelId
38
+ }), [connection, cdecliSelected, activeChannelId, setActiveChannelId]);
39
+ return /* @__PURE__ */ jsx(CdecliConnectionContext.Provider, { value, children });
40
+ }
41
+ function useCdecliConnection() {
42
+ const ctx = useContext(CdecliConnectionContext);
43
+ if (!ctx) {
44
+ throw new Error("useCdecliConnection must be used within CdecliConnectionProvider");
45
+ }
46
+ return ctx;
47
+ }export{CdecliConnectionProvider,useCdecliConnection};//# sourceMappingURL=CdecliConnectionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CdecliConnectionContext.js","sources":["../../src/contexts/CdecliConnectionContext.tsx"],"sourcesContent":["/**\n * Single, app-wide owner of the CDeCLI auto-connect lifecycle.\n *\n * Previously every consumer that needed CDeCLI status (the header\n * `GatewayConnector`, the Chat screen for streaming routing, etc.) called\n * `useCdecliAutoConnect` directly. Each instance kept its own state, so they\n * raced each other: the header would mount and connect with `chatId=undefined`\n * while the Chat screen mounted and connected with `chatId=<channelId>`. The\n * backend `CdecliServeProvider.connect()` reuses the per-account session, so\n * the LAST `gatewayConnect` mutation wins — when the header's \"no chatId\"\n * connect lost the chat binding, the agent received messages without a chat\n * context and replied with the generic \"agent did not return a response /\n * API key may be missing\" fallback.\n *\n * The fix: lift `useCdecliAutoConnect` into a context that runs ONCE per app\n * mount. Screens that need to bind a specific chat call `setActiveChannelId`;\n * everyone else (header pill, status banners) just reads the live status.\n *\n * Mount this provider INSIDE `GatewayContextProvider` — the hook depends on\n * `useGatewayContext` for the current selection.\n */\nimport type { ReactNode } from 'react';\nimport React, { createContext, useCallback, useContext, useMemo, useState } from 'react';\nimport { useCdecliAutoConnect, type UseCdecliAutoConnectResult } from '../hooks/useCdecliAutoConnect';\nimport { useGatewayContext } from './GatewayContext';\n\nexport interface CdecliConnectionContextValue extends UseCdecliAutoConnectResult {\n /** Whether the CDeCLI gateway is the currently selected gateway. */\n cdecliSelected: boolean;\n /** Current chat binding for the gateway session (undefined on Home / Chat history). */\n activeChannelId: string | undefined;\n /**\n * Register / clear the chat binding for the gateway session.\n * Screens that own a channel (Chat) call this on mount with their channelId\n * and on unmount with `undefined` (or simply leave the last binding in\n * place — the gateway tolerates stale chatIds, individual messages still\n * pass their own chatId via `gatewaySendMessage`).\n */\n setActiveChannelId: (channelId: string | undefined) => void;\n}\n\nconst CdecliConnectionContext = createContext<CdecliConnectionContextValue | null>(null);\nCdecliConnectionContext.displayName = 'CdecliConnectionContext';\n\nexport function CdecliConnectionProvider({ children }: { children: ReactNode }) {\n const { selectedGateway } = useGatewayContext();\n const cdecliSelected = selectedGateway?.channelType === 'cdecli-serve';\n\n const [activeChannelId, setActiveChannelIdState] = useState<string | undefined>(undefined);\n\n const setActiveChannelId = useCallback((channelId: string | undefined) => {\n setActiveChannelIdState((prev) => (prev === channelId ? prev : channelId));\n }, []);\n\n const connection = useCdecliAutoConnect(cdecliSelected, activeChannelId);\n\n const value = useMemo<CdecliConnectionContextValue>(\n () => ({\n ...connection,\n cdecliSelected,\n activeChannelId,\n setActiveChannelId,\n }),\n [connection, cdecliSelected, activeChannelId, setActiveChannelId],\n );\n\n return <CdecliConnectionContext.Provider value={value}>{children}</CdecliConnectionContext.Provider>;\n}\n\nexport function useCdecliConnection(): CdecliConnectionContextValue {\n const ctx = useContext(CdecliConnectionContext);\n if (!ctx) {\n throw new Error('useCdecliConnection must be used within CdecliConnectionProvider');\n }\n return ctx;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,MAAM,uBAAA,GAA0B,cAAmD,IAAI,CAAA;AACvF,uBAAA,CAAwB,WAAc,GAAA,yBAAA;AAC/B,SAAS,wBAAyB,CAAA;AAAA,EACvC;AACF,CAEG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ;AAAA,MACE,iBAAkB,EAAA;AACtB,EAAM,MAAA,cAAA,GAAA,CAAiB,mDAAiB,WAAgB,MAAA,cAAA;AACxD,EAAA,MAAM,CAAC,eAAA,EAAiB,uBAAuB,CAAA,GAAI,SAA6B,MAAS,CAAA;AACzF,EAAM,MAAA,kBAAA,GAAqB,WAAY,CAAA,CAAC,SAAkC,KAAA;AACxE,IAAA,uBAAA,CAAwB,CAAQ,IAAA,KAAA,IAAA,KAAS,SAAY,GAAA,IAAA,GAAO,SAAS,CAAA;AAAA,GACvE,EAAG,EAAE,CAAA;AACL,EAAM,MAAA,UAAA,GAAa,oBAAqB,CAAA,cAAA,EAAgB,eAAe,CAAA;AACvE,EAAA,MAAM,KAAQ,GAAA,OAAA,CAAsC,MAAO,aAAA,CAAA,cAAA,CAAA,EAAA,EACtD,UADsD,CAAA,EAAA;AAAA,IAEzD,cAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,MACE,CAAC,UAAA,EAAY,cAAgB,EAAA,eAAA,EAAiB,kBAAkB,CAAC,CAAA;AACrE,EAAA,uBAAQ,GAAA,CAAA,uBAAA,CAAwB,QAAxB,EAAA,EAAiC,OAAe,QAAS,EAAA,CAAA;AACnE;AACO,SAAS,mBAAoD,GAAA;AAClE,EAAM,MAAA,GAAA,GAAM,WAAW,uBAAuB,CAAA;AAC9C,EAAA,IAAI,CAAC,GAAK,EAAA;AACR,IAAM,MAAA,IAAI,MAAM,kEAAkE,CAAA;AAAA;AAEpF,EAAO,OAAA,GAAA;AACT"}
@@ -0,0 +1,77 @@
1
+ import {jsx}from'react/jsx-runtime';import {createContext,useState,useEffect,useCallback,useMemo,useContext}from'react';import {useGatewayRegistry}from'../hooks/useGatewayRegistry.js';import {GatewaySelectionStorage}from'../utils/gatewaySelectionStorage.js';const GatewayContext = createContext(null);
2
+ GatewayContext.displayName = "GatewayContext";
3
+ function GatewayContextProvider({
4
+ children
5
+ }) {
6
+ const {
7
+ gateways,
8
+ gatewayList,
9
+ loading
10
+ } = useGatewayRegistry();
11
+ const safeGateways = gateways && typeof gateways === "object" ? gateways : {};
12
+ const safeGatewayList = Array.isArray(gatewayList) ? gatewayList : [];
13
+ const hasGateway = (gatewayId) => Object.prototype.hasOwnProperty.call(safeGateways, gatewayId);
14
+ const [selectedGatewayId, setGatewayId] = useState("cdecli");
15
+ const [activeSkill, setActiveSkill] = useState(null);
16
+ const [storageReady, setStorageReady] = useState(false);
17
+ useEffect(() => {
18
+ let cancelled = false;
19
+ GatewaySelectionStorage.load().then((s) => {
20
+ if (cancelled) return;
21
+ if (s.selectedGatewayId) {
22
+ setGatewayId(s.selectedGatewayId);
23
+ }
24
+ setStorageReady(true);
25
+ });
26
+ return () => {
27
+ cancelled = true;
28
+ };
29
+ }, []);
30
+ useEffect(() => {
31
+ var _a;
32
+ if (!storageReady || loading) return;
33
+ if (selectedGatewayId && hasGateway(selectedGatewayId)) return;
34
+ const fallbackId = hasGateway("cdecli") ? "cdecli" : ((_a = safeGatewayList[0]) == null ? void 0 : _a.id) || "";
35
+ if (fallbackId) {
36
+ setGatewayId(fallbackId);
37
+ GatewaySelectionStorage.save({
38
+ selectedGatewayId: fallbackId
39
+ });
40
+ }
41
+ }, [storageReady, loading, safeGateways, safeGatewayList, selectedGatewayId]);
42
+ const setSelectedGateway = useCallback((gatewayId) => {
43
+ if (!hasGateway(gatewayId)) return;
44
+ setGatewayId(gatewayId);
45
+ void GatewaySelectionStorage.save({
46
+ selectedGatewayId: gatewayId
47
+ });
48
+ setActiveSkill(null);
49
+ }, [safeGateways]);
50
+ const selectedGateway = selectedGatewayId && safeGateways[selectedGatewayId] || safeGatewayList[0] || {
51
+ name: "",
52
+ description: "",
53
+ channelType: "",
54
+ extensionId: "",
55
+ icon: "plug",
56
+ isBuiltin: false,
57
+ priority: 0
58
+ };
59
+ const value = useMemo(() => ({
60
+ selectedGatewayId,
61
+ selectedGateway,
62
+ gateways: safeGateways,
63
+ gatewayList: safeGatewayList,
64
+ setSelectedGateway,
65
+ loading,
66
+ activeSkill,
67
+ setActiveSkill
68
+ }), [selectedGatewayId, selectedGateway, safeGateways, safeGatewayList, setSelectedGateway, loading, activeSkill]);
69
+ return /* @__PURE__ */ jsx(GatewayContext.Provider, { value, children });
70
+ }
71
+ function useGatewayContext() {
72
+ const context = useContext(GatewayContext);
73
+ if (!context) {
74
+ throw new Error("useGatewayContext must be used within GatewayContextProvider");
75
+ }
76
+ return context;
77
+ }export{GatewayContextProvider,useGatewayContext};//# sourceMappingURL=GatewayContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayContext.js","sources":["../../src/contexts/GatewayContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport type { GatewayEntry, GatewayId } from '../config/constants';\nimport { useGatewayRegistry } from '../hooks/useGatewayRegistry';\nimport { GatewaySelectionStorage } from '../utils/gatewaySelectionStorage';\n\nexport interface GatewayContextValue {\n selectedGatewayId: GatewayId;\n selectedGateway: GatewayEntry;\n gateways: Record<string, GatewayEntry>;\n gatewayList: Array<{ id: string } & GatewayEntry>;\n setSelectedGateway: (gatewayId: GatewayId) => void;\n loading: boolean;\n activeSkill: string | null;\n setActiveSkill: (skill: string | null) => void;\n}\n\nconst GatewayContext = createContext<GatewayContextValue | null>(null);\nGatewayContext.displayName = 'GatewayContext';\n\nexport function GatewayContextProvider({ children }: { children: ReactNode }) {\n const { gateways, gatewayList, loading } = useGatewayRegistry();\n const safeGateways = gateways && typeof gateways === 'object' ? gateways : {};\n const safeGatewayList = Array.isArray(gatewayList) ? gatewayList : [];\n const hasGateway = (gatewayId: string) => Object.prototype.hasOwnProperty.call(safeGateways, gatewayId);\n\n const [selectedGatewayId, setGatewayId] = useState<GatewayId>('cdecli');\n const [activeSkill, setActiveSkill] = useState<string | null>(null);\n const [storageReady, setStorageReady] = useState(false);\n\n useEffect(() => {\n let cancelled = false;\n GatewaySelectionStorage.load().then((s) => {\n if (cancelled) return;\n if (s.selectedGatewayId) {\n setGatewayId(s.selectedGatewayId);\n }\n setStorageReady(true);\n });\n return () => {\n cancelled = true;\n };\n }, []);\n\n useEffect(() => {\n if (!storageReady || loading) return;\n if (selectedGatewayId && hasGateway(selectedGatewayId)) return;\n const fallbackId = hasGateway('cdecli') ? 'cdecli' : safeGatewayList[0]?.id || '';\n if (fallbackId) {\n setGatewayId(fallbackId);\n GatewaySelectionStorage.save({ selectedGatewayId: fallbackId });\n }\n }, [storageReady, loading, safeGateways, safeGatewayList, selectedGatewayId]);\n\n const setSelectedGateway = useCallback(\n (gatewayId: GatewayId) => {\n if (!hasGateway(gatewayId)) return;\n setGatewayId(gatewayId);\n void GatewaySelectionStorage.save({ selectedGatewayId: gatewayId });\n setActiveSkill(null);\n },\n [safeGateways],\n );\n\n const selectedGateway: GatewayEntry = (selectedGatewayId && safeGateways[selectedGatewayId]) ||\n safeGatewayList[0] || {\n name: '',\n description: '',\n channelType: '',\n extensionId: '',\n icon: 'plug',\n isBuiltin: false,\n priority: 0,\n };\n\n const value = useMemo<GatewayContextValue>(\n () => ({\n selectedGatewayId,\n selectedGateway,\n gateways: safeGateways,\n gatewayList: safeGatewayList,\n setSelectedGateway,\n loading,\n activeSkill,\n setActiveSkill,\n }),\n [selectedGatewayId, selectedGateway, safeGateways, safeGatewayList, setSelectedGateway, loading, activeSkill],\n );\n\n return <GatewayContext.Provider value={value}>{children}</GatewayContext.Provider>;\n}\n\nexport function useGatewayContext(): GatewayContextValue {\n const context = useContext(GatewayContext);\n if (!context) {\n throw new Error('useGatewayContext must be used within GatewayContextProvider');\n }\n return context;\n}\n"],"names":[],"mappings":"kQAiBA,MAAM,cAAA,GAAiB,cAA0C,IAAI,CAAA;AACrE,cAAA,CAAe,WAAc,GAAA,gBAAA;AACtB,SAAS,sBAAuB,CAAA;AAAA,EACrC;AACF,CAEG,EAAA;AACD,EAAM,MAAA;AAAA,IACJ,QAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,MACE,kBAAmB,EAAA;AACvB,EAAA,MAAM,eAAe,QAAY,IAAA,OAAO,QAAa,KAAA,QAAA,GAAW,WAAW,EAAC;AAC5E,EAAA,MAAM,kBAAkB,KAAM,CAAA,OAAA,CAAQ,WAAW,CAAA,GAAI,cAAc,EAAC;AACpE,EAAM,MAAA,UAAA,GAAa,CAAC,SAAsB,KAAA,MAAA,CAAO,UAAU,cAAe,CAAA,IAAA,CAAK,cAAc,SAAS,CAAA;AACtG,EAAA,MAAM,CAAC,iBAAA,EAAmB,YAAY,CAAA,GAAI,SAAoB,QAAQ,CAAA;AACtE,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAwB,IAAI,CAAA;AAClE,EAAA,MAAM,CA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