@adminide-stack/yantra-mobile 12.0.28-alpha.51 → 12.0.28-alpha.58
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/assets/icon.png +0 -0
- package/lib/components/CustomDrawer.js +358 -0
- package/lib/components/CustomDrawer.js.map +1 -0
- package/lib/components/GatewayToolbarButtonMobile.js +84 -0
- package/lib/components/GatewayToolbarButtonMobile.js.map +1 -0
- package/lib/components/YantraBrandLoader.js +94 -0
- package/lib/components/YantraBrandLoader.js.map +1 -0
- package/lib/compute.js +37 -5
- package/lib/compute.js.map +1 -1
- package/lib/config/constants.js +16 -0
- package/lib/config/constants.js.map +1 -0
- package/lib/config/env-config.js +74 -19
- package/lib/config/env-config.js.map +1 -1
- package/lib/contexts/GatewayContext.js +77 -0
- package/lib/contexts/GatewayContext.js.map +1 -0
- package/lib/graphql/agentGatewayDocuments.js +53 -0
- package/lib/graphql/agentGatewayDocuments.js.map +1 -0
- package/lib/hooks/useCdecliAutoConnect.js +219 -0
- package/lib/hooks/useCdecliAutoConnect.js.map +1 -0
- package/lib/hooks/useCdecliChannel.js +226 -0
- package/lib/hooks/useCdecliChannel.js.map +1 -0
- package/lib/hooks/useChatApi.js +220 -170
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/hooks/useChatStream.js +232 -58
- package/lib/hooks/useChatStream.js.map +1 -1
- package/lib/hooks/useGatewayConnection.js +123 -0
- package/lib/hooks/useGatewayConnection.js.map +1 -0
- package/lib/hooks/useGatewayRegistry.js +28 -0
- package/lib/hooks/useGatewayRegistry.js.map +1 -0
- package/lib/hooks/usePrerequisiteIds.js +122 -0
- package/lib/hooks/usePrerequisiteIds.js.map +1 -0
- package/lib/hooks/useWorkspaceProvisioner.js +236 -0
- package/lib/hooks/useWorkspaceProvisioner.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/routes.json +8 -5
- package/lib/screens/Home/HomeScreen.js +420 -97
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/ChatHistoryLanding.js +229 -0
- package/lib/screens/Home/components/ChatHistoryLanding.js.map +1 -0
- package/lib/screens/Home/components/DeepSearchModal.js +334 -0
- package/lib/screens/Home/components/DeepSearchModal.js.map +1 -0
- package/lib/screens/Home/deepSearchUtils.js +41 -0
- package/lib/screens/Home/deepSearchUtils.js.map +1 -0
- package/lib/screens/NewChat/index.js +75 -0
- package/lib/screens/NewChat/index.js.map +1 -0
- package/lib/services/agentSessionManager.js +451 -0
- package/lib/services/agentSessionManager.js.map +1 -0
- package/lib/services/gatewayApiKeyBridge.js +4 -0
- package/lib/services/gatewayApiKeyBridge.js.map +1 -0
- package/lib/services/gatewayClient.js +470 -0
- package/lib/services/gatewayClient.js.map +1 -0
- package/lib/utils/gatewaySelectionStorage.js +21 -0
- package/lib/utils/gatewaySelectionStorage.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {useRef,useCallback,useEffect}from'react';import {useGatewaySendMessageMutation,useMessengerStreamDeltaSubscription,useGatewayInboundMessageByChannelSubscription}from'common/graphql';import {config}from'../config/env-config.js';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
const CDECLI_RESPONSE_WAIT_MS = config.CDECLI_CHAT_RESPONSE_TIMEOUT_SEC * 1e3;
|
|
18
|
+
function stripModelCostHeader(content) {
|
|
19
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
20
|
+
return normalized.replace(/^\s*(?:[^\w\n]+\s*)?[a-z0-9][a-z0-9._-]*\s*\(\s*\$[\d.]+\s*\/\s*MTok\s+in\s*\)\s*\n+/i, "");
|
|
21
|
+
}
|
|
22
|
+
function useCdecliChannel(enabled, isConnected, accountId, channelId, callbacks, model, skill) {
|
|
23
|
+
const [sendMutation] = useGatewaySendMessageMutation();
|
|
24
|
+
const cbRef = useRef(callbacks);
|
|
25
|
+
cbRef.current = callbacks;
|
|
26
|
+
const pendingRef = useRef(null);
|
|
27
|
+
const sendNonceSeqRef = useRef(0);
|
|
28
|
+
const lastInboundNonceHandledRef = useRef(0);
|
|
29
|
+
const hasReceivedDeltasRef = useRef(false);
|
|
30
|
+
const reconnectedStreamRef = useRef(false);
|
|
31
|
+
const streamCompletedRef = useRef(false);
|
|
32
|
+
const accumulatedLenRef = useRef(0);
|
|
33
|
+
const lastAccumulatedFullTextRef = useRef("");
|
|
34
|
+
const timeoutRef = useRef(null);
|
|
35
|
+
const streamSkip = !channelId;
|
|
36
|
+
const streamChannelId = channelId || accountId;
|
|
37
|
+
useMessengerStreamDeltaSubscription({
|
|
38
|
+
variables: {
|
|
39
|
+
channelId: streamChannelId
|
|
40
|
+
},
|
|
41
|
+
skip: !enabled || streamSkip,
|
|
42
|
+
onData: ({
|
|
43
|
+
data
|
|
44
|
+
}) => {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
const delta = (_a = data == null ? void 0 : data.data) == null ? void 0 : _a.messengerStreamDelta;
|
|
47
|
+
if (!delta) return;
|
|
48
|
+
if (delta.isFinal) {
|
|
49
|
+
if (streamCompletedRef.current) return;
|
|
50
|
+
const fromDelta = stripModelCostHeader((_b = delta.text) != null ? _b : "");
|
|
51
|
+
const fullText2 = fromDelta.trim().length > 0 ? fromDelta : lastAccumulatedFullTextRef.current;
|
|
52
|
+
if (!fullText2.trim()) {
|
|
53
|
+
if (pendingRef.current) {
|
|
54
|
+
streamCompletedRef.current = true;
|
|
55
|
+
cbRef.current.onError("CDeCLI returned an empty response.");
|
|
56
|
+
pendingRef.current = null;
|
|
57
|
+
hasReceivedDeltasRef.current = false;
|
|
58
|
+
lastAccumulatedFullTextRef.current = "";
|
|
59
|
+
if (timeoutRef.current) {
|
|
60
|
+
clearTimeout(timeoutRef.current);
|
|
61
|
+
timeoutRef.current = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
streamCompletedRef.current = true;
|
|
67
|
+
if (!hasReceivedDeltasRef.current) {
|
|
68
|
+
cbRef.current.onChunk(fullText2);
|
|
69
|
+
}
|
|
70
|
+
cbRef.current.onComplete(fullText2);
|
|
71
|
+
pendingRef.current = null;
|
|
72
|
+
hasReceivedDeltasRef.current = false;
|
|
73
|
+
reconnectedStreamRef.current = false;
|
|
74
|
+
accumulatedLenRef.current = 0;
|
|
75
|
+
lastAccumulatedFullTextRef.current = "";
|
|
76
|
+
if (timeoutRef.current) {
|
|
77
|
+
clearTimeout(timeoutRef.current);
|
|
78
|
+
timeoutRef.current = null;
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (streamCompletedRef.current) return;
|
|
83
|
+
if (!pendingRef.current) {
|
|
84
|
+
if (!reconnectedStreamRef.current) {
|
|
85
|
+
reconnectedStreamRef.current = true;
|
|
86
|
+
accumulatedLenRef.current = 0;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
hasReceivedDeltasRef.current = true;
|
|
90
|
+
const fullText = stripModelCostHeader((_c = delta.text) != null ? _c : "");
|
|
91
|
+
lastAccumulatedFullTextRef.current = fullText;
|
|
92
|
+
const newChunk = fullText.substring(accumulatedLenRef.current);
|
|
93
|
+
accumulatedLenRef.current = fullText.length;
|
|
94
|
+
if (newChunk) {
|
|
95
|
+
cbRef.current.onChunk(newChunk);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
onError: (err) => {
|
|
99
|
+
console.error("[useCdecliChannel] stream delta subscription error:", err);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
useGatewayInboundMessageByChannelSubscription({
|
|
103
|
+
variables: {
|
|
104
|
+
channelId: streamChannelId
|
|
105
|
+
},
|
|
106
|
+
skip: !enabled || !isConnected || streamSkip,
|
|
107
|
+
onData: ({
|
|
108
|
+
data
|
|
109
|
+
}) => {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
const msg = (_a = data == null ? void 0 : data.data) == null ? void 0 : _a.gatewayInboundMessageByChannel;
|
|
112
|
+
if (!msg) return;
|
|
113
|
+
const pending = pendingRef.current;
|
|
114
|
+
const nonce = pending == null ? void 0 : pending.nonce;
|
|
115
|
+
if (nonce == null) return;
|
|
116
|
+
if (lastInboundNonceHandledRef.current === nonce) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
lastInboundNonceHandledRef.current = nonce;
|
|
120
|
+
const sanitizedText = stripModelCostHeader((_b = msg.text) != null ? _b : "");
|
|
121
|
+
const effectiveText = sanitizedText.trim().length > 0 ? sanitizedText : lastAccumulatedFullTextRef.current;
|
|
122
|
+
if (!effectiveText.trim()) {
|
|
123
|
+
if (pendingRef.current) {
|
|
124
|
+
streamCompletedRef.current = true;
|
|
125
|
+
cbRef.current.onError("CDeCLI returned an empty response.");
|
|
126
|
+
pendingRef.current = null;
|
|
127
|
+
hasReceivedDeltasRef.current = false;
|
|
128
|
+
lastAccumulatedFullTextRef.current = "";
|
|
129
|
+
if (timeoutRef.current) {
|
|
130
|
+
clearTimeout(timeoutRef.current);
|
|
131
|
+
timeoutRef.current = null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!hasReceivedDeltasRef.current) {
|
|
137
|
+
cbRef.current.onChunk(effectiveText);
|
|
138
|
+
}
|
|
139
|
+
cbRef.current.onComplete(effectiveText);
|
|
140
|
+
pendingRef.current = null;
|
|
141
|
+
hasReceivedDeltasRef.current = false;
|
|
142
|
+
reconnectedStreamRef.current = false;
|
|
143
|
+
streamCompletedRef.current = true;
|
|
144
|
+
accumulatedLenRef.current = 0;
|
|
145
|
+
lastAccumulatedFullTextRef.current = "";
|
|
146
|
+
if (timeoutRef.current) {
|
|
147
|
+
clearTimeout(timeoutRef.current);
|
|
148
|
+
timeoutRef.current = null;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
onError: (err) => {
|
|
152
|
+
console.error("[useCdecliChannel] subscription error:", err);
|
|
153
|
+
cbRef.current.onError(err.message || "CDeCLI subscription error");
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const sendMessage = useCallback(async (text, chatId = "messenger") => {
|
|
157
|
+
var _a;
|
|
158
|
+
if (!enabled || !isConnected) return false;
|
|
159
|
+
sendNonceSeqRef.current += 1;
|
|
160
|
+
pendingRef.current = {
|
|
161
|
+
text,
|
|
162
|
+
sentAt: Date.now(),
|
|
163
|
+
nonce: sendNonceSeqRef.current
|
|
164
|
+
};
|
|
165
|
+
hasReceivedDeltasRef.current = false;
|
|
166
|
+
reconnectedStreamRef.current = false;
|
|
167
|
+
streamCompletedRef.current = false;
|
|
168
|
+
accumulatedLenRef.current = 0;
|
|
169
|
+
lastAccumulatedFullTextRef.current = "";
|
|
170
|
+
try {
|
|
171
|
+
const result = await sendMutation({
|
|
172
|
+
variables: {
|
|
173
|
+
input: __spreadValues({
|
|
174
|
+
channelType: "cdecli-serve",
|
|
175
|
+
accountId,
|
|
176
|
+
chatId,
|
|
177
|
+
text
|
|
178
|
+
}, model || skill ? {
|
|
179
|
+
metadata: __spreadValues(__spreadValues({}, model && {
|
|
180
|
+
model
|
|
181
|
+
}), skill && {
|
|
182
|
+
skill
|
|
183
|
+
})
|
|
184
|
+
} : {})
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const payload = (_a = result.data) == null ? void 0 : _a.gatewaySendMessage;
|
|
188
|
+
if (!(payload == null ? void 0 : payload.success)) {
|
|
189
|
+
const errMsg = (payload == null ? void 0 : payload.error) || "CDeCLI send failed";
|
|
190
|
+
cbRef.current.onError(errMsg);
|
|
191
|
+
pendingRef.current = null;
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
timeoutRef.current = setTimeout(() => {
|
|
195
|
+
if (pendingRef.current) {
|
|
196
|
+
pendingRef.current = null;
|
|
197
|
+
hasReceivedDeltasRef.current = false;
|
|
198
|
+
timeoutRef.current = null;
|
|
199
|
+
const sec = Math.round(CDECLI_RESPONSE_WAIT_MS / 1e3);
|
|
200
|
+
cbRef.current.onError(`CDeCLI agent did not respond within ${sec}s. Trying the backup chat provider\u2026`);
|
|
201
|
+
}
|
|
202
|
+
}, CDECLI_RESPONSE_WAIT_MS);
|
|
203
|
+
return true;
|
|
204
|
+
} catch (err) {
|
|
205
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
206
|
+
cbRef.current.onError(msg);
|
|
207
|
+
pendingRef.current = null;
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}, [enabled, isConnected, accountId, channelId, sendMutation, model, skill]);
|
|
211
|
+
useEffect(() => () => {
|
|
212
|
+
pendingRef.current = null;
|
|
213
|
+
hasReceivedDeltasRef.current = false;
|
|
214
|
+
reconnectedStreamRef.current = false;
|
|
215
|
+
streamCompletedRef.current = false;
|
|
216
|
+
accumulatedLenRef.current = 0;
|
|
217
|
+
lastAccumulatedFullTextRef.current = "";
|
|
218
|
+
if (timeoutRef.current) {
|
|
219
|
+
clearTimeout(timeoutRef.current);
|
|
220
|
+
timeoutRef.current = null;
|
|
221
|
+
}
|
|
222
|
+
}, []);
|
|
223
|
+
return {
|
|
224
|
+
sendMessage
|
|
225
|
+
};
|
|
226
|
+
}export{useCdecliChannel};//# sourceMappingURL=useCdecliChannel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCdecliChannel.js","sources":["../../src/hooks/useCdecliChannel.ts"],"sourcesContent":["/**\n * Wires cdecli-serve messenger-gateway into the mobile chat UI (same as account/browser).\n */\n\nimport { useCallback, useEffect, useRef } from 'react';\nimport {\n useGatewaySendMessageMutation,\n useGatewayInboundMessageByChannelSubscription,\n useMessengerStreamDeltaSubscription,\n} from 'common/graphql';\nimport { config } from '../config/env-config';\n\nconst CDECLI_RESPONSE_WAIT_MS = config.CDECLI_CHAT_RESPONSE_TIMEOUT_SEC * 1000;\n\nfunction stripModelCostHeader(content: string): string {\n const normalized = content.replace(/\\r\\n/g, '\\n');\n return normalized.replace(\n /^\\s*(?:[^\\w\\n]+\\s*)?[a-z0-9][a-z0-9._-]*\\s*\\(\\s*\\$[\\d.]+\\s*\\/\\s*MTok\\s+in\\s*\\)\\s*\\n+/i,\n '',\n );\n}\n\nexport interface CdecliChannelCallbacks {\n onChunk: (text: string) => void;\n onComplete: (text: string) => void;\n onError: (error: string) => void;\n}\n\nexport function useCdecliChannel(\n /** When false, no WS subscriptions (e.g. Groq mode). */\n enabled: boolean,\n isConnected: boolean,\n accountId: string,\n channelId: string | undefined,\n callbacks: CdecliChannelCallbacks,\n model?: string,\n skill?: string,\n) {\n const [sendMutation] = useGatewaySendMessageMutation();\n const cbRef = useRef(callbacks);\n cbRef.current = callbacks;\n\n const pendingRef = useRef<{ text: string; sentAt: number; nonce: number } | null>(null);\n const sendNonceSeqRef = useRef(0);\n /** Dedupes duplicate inbound deliveries for the same outbound send (Apollo can invoke `onData` twice). */\n const lastInboundNonceHandledRef = useRef<number>(0);\n const hasReceivedDeltasRef = useRef(false);\n const reconnectedStreamRef = useRef(false);\n const streamCompletedRef = useRef(false);\n const accumulatedLenRef = useRef(0);\n /** Latest full accumulated assistant text from non-final deltas (for isFinal / empty inbound completion). */\n const lastAccumulatedFullTextRef = useRef('');\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const streamSkip = !channelId;\n const streamChannelId = channelId || accountId;\n\n useMessengerStreamDeltaSubscription({\n variables: { channelId: streamChannelId },\n skip: !enabled || streamSkip,\n onData: ({ data }) => {\n const delta = data?.data?.messengerStreamDelta;\n if (!delta) return;\n\n if (delta.isFinal) {\n if (streamCompletedRef.current) return;\n const fromDelta = stripModelCostHeader(delta.text ?? '');\n const fullText = fromDelta.trim().length > 0 ? fromDelta : lastAccumulatedFullTextRef.current;\n if (!fullText.trim()) {\n if (pendingRef.current) {\n streamCompletedRef.current = true;\n cbRef.current.onError('CDeCLI returned an empty response.');\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n lastAccumulatedFullTextRef.current = '';\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n }\n return;\n }\n\n streamCompletedRef.current = true;\n if (!hasReceivedDeltasRef.current) {\n cbRef.current.onChunk(fullText);\n }\n cbRef.current.onComplete(fullText);\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n reconnectedStreamRef.current = false;\n accumulatedLenRef.current = 0;\n lastAccumulatedFullTextRef.current = '';\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n return;\n }\n\n if (streamCompletedRef.current) return;\n if (!pendingRef.current) {\n if (!reconnectedStreamRef.current) {\n reconnectedStreamRef.current = true;\n accumulatedLenRef.current = 0;\n }\n }\n hasReceivedDeltasRef.current = true;\n const fullText = stripModelCostHeader(delta.text ?? '');\n lastAccumulatedFullTextRef.current = fullText;\n const newChunk = fullText.substring(accumulatedLenRef.current);\n accumulatedLenRef.current = fullText.length;\n if (newChunk) {\n cbRef.current.onChunk(newChunk);\n }\n },\n onError: (err) => {\n console.error('[useCdecliChannel] stream delta subscription error:', err);\n },\n });\n\n useGatewayInboundMessageByChannelSubscription({\n variables: { channelId: streamChannelId },\n skip: !enabled || !isConnected || streamSkip,\n onData: ({ data }) => {\n const msg = data?.data?.gatewayInboundMessageByChannel;\n if (!msg) return;\n\n const pending = pendingRef.current;\n const nonce = pending?.nonce;\n if (nonce == null) return;\n if (lastInboundNonceHandledRef.current === nonce) {\n return;\n }\n lastInboundNonceHandledRef.current = nonce;\n\n const sanitizedText = stripModelCostHeader(msg.text ?? '');\n const effectiveText = sanitizedText.trim().length > 0 ? sanitizedText : lastAccumulatedFullTextRef.current;\n if (!effectiveText.trim()) {\n if (pendingRef.current) {\n streamCompletedRef.current = true;\n cbRef.current.onError('CDeCLI returned an empty response.');\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n lastAccumulatedFullTextRef.current = '';\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n }\n return;\n }\n\n if (!hasReceivedDeltasRef.current) {\n cbRef.current.onChunk(effectiveText);\n }\n cbRef.current.onComplete(effectiveText);\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n reconnectedStreamRef.current = false;\n streamCompletedRef.current = true;\n accumulatedLenRef.current = 0;\n lastAccumulatedFullTextRef.current = '';\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n },\n onError: (err) => {\n console.error('[useCdecliChannel] subscription error:', err);\n cbRef.current.onError(err.message || 'CDeCLI subscription error');\n },\n });\n\n const sendMessage = useCallback(\n async (text: string, chatId = 'messenger'): Promise<boolean> => {\n if (!enabled || !isConnected) return false;\n sendNonceSeqRef.current += 1;\n pendingRef.current = { text, sentAt: Date.now(), nonce: sendNonceSeqRef.current };\n hasReceivedDeltasRef.current = false;\n reconnectedStreamRef.current = false;\n streamCompletedRef.current = false;\n accumulatedLenRef.current = 0;\n lastAccumulatedFullTextRef.current = '';\n\n try {\n const result = await sendMutation({\n variables: {\n input: {\n channelType: 'cdecli-serve',\n accountId,\n chatId,\n text,\n ...(model || skill\n ? { metadata: { ...(model && { model }), ...(skill && { skill }) } }\n : {}),\n },\n },\n });\n\n const payload = result.data?.gatewaySendMessage;\n if (!payload?.success) {\n const errMsg = payload?.error || 'CDeCLI send failed';\n cbRef.current.onError(errMsg);\n pendingRef.current = null;\n return false;\n }\n\n timeoutRef.current = setTimeout(() => {\n if (pendingRef.current) {\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n timeoutRef.current = null;\n const sec = Math.round(CDECLI_RESPONSE_WAIT_MS / 1000);\n cbRef.current.onError(\n `CDeCLI agent did not respond within ${sec}s. Trying the backup chat provider…`,\n );\n }\n }, CDECLI_RESPONSE_WAIT_MS);\n\n return true;\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n cbRef.current.onError(msg);\n pendingRef.current = null;\n return false;\n }\n },\n [enabled, isConnected, accountId, channelId, sendMutation, model, skill],\n );\n\n useEffect(\n () => () => {\n pendingRef.current = null;\n hasReceivedDeltasRef.current = false;\n reconnectedStreamRef.current = false;\n streamCompletedRef.current = false;\n accumulatedLenRef.current = 0;\n lastAccumulatedFullTextRef.current = '';\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n },\n [],\n );\n\n return { sendMessage };\n}\n"],"names":["fullText"],"mappings":";;;;;;;;;;;;;;;;AAOA,MAAM,uBAAA,GAA0B,OAAO,gCAAmC,GAAA,GAAA;AAC1E,SAAS,qBAAqB,OAAyB,EAAA;AACrD,EAAA,MAAM,UAAa,GAAA,OAAA,CAAQ,OAAQ,CAAA,OAAA,EAAS,IAAI,CAAA;AAChD,EAAO,OAAA,UAAA,CAAW,OAAQ,CAAA,uFAAA,EAAyF,EAAE,CAAA;AACvH;AAMO,SAAS,iBAChB,OAAkB,EAAA,WAAA,EAAsB,WAAmB,SAA+B,EAAA,SAAA,EAAmC,OAAgB,KAAgB,EAAA;AAC3J,EAAM,MAAA,CAAC,YAAY,CAAA,GAAI,6BAA8B,EAAA;AACrD,EAAM,MAAA,KAAA,GAAQ,OA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