@elqnt/agents 3.4.0 → 4.0.0
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/README.md +6 -0
- package/SKILL.md +724 -0
- package/dist/{agent-models-D6WgsFMZ.d.mts → agent-models-B-wTMdwF.d.mts} +44 -9
- package/dist/{agent-models-D6WgsFMZ.d.ts → agent-models-B-wTMdwF.d.ts} +44 -9
- package/dist/api/index.d.mts +6 -6
- package/dist/api/index.d.ts +6 -6
- package/dist/api/index.js +3 -4
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +1 -2
- package/dist/api/server.d.mts +3 -3
- package/dist/api/server.d.ts +3 -3
- package/dist/api/server.js +6 -8
- package/dist/api/server.js.map +1 -1
- package/dist/api/server.mjs +5 -7
- package/dist/api/server.mjs.map +1 -1
- package/dist/{chunk-XQ7LOAN3.js → chunk-2FZZW4O4.js} +7 -5
- package/dist/chunk-2FZZW4O4.js.map +1 -0
- package/dist/{chunk-3EHE4O57.mjs → chunk-6FKG2JBT.mjs} +1 -3
- package/dist/{chunk-3EHE4O57.mjs.map → chunk-6FKG2JBT.mjs.map} +1 -1
- package/dist/{chunk-TY57JG3P.mjs → chunk-CCQNGD3U.mjs} +5 -3
- package/dist/chunk-CCQNGD3U.mjs.map +1 -0
- package/dist/{chunk-ZS7DRNCT.js → chunk-DQATIIAV.js} +2 -4
- package/dist/chunk-DQATIIAV.js.map +1 -0
- package/dist/{chunk-L5FLJB3H.mjs → chunk-NHIVBTLU.mjs} +5 -7
- package/dist/chunk-NHIVBTLU.mjs.map +1 -0
- package/dist/{chunk-3PFZRJ4A.js → chunk-QH234LAO.js} +6 -8
- package/dist/chunk-QH234LAO.js.map +1 -0
- package/dist/{chunk-2JDVRL35.js → chunk-QXMZEZRM.js} +2 -4
- package/dist/chunk-QXMZEZRM.js.map +1 -0
- package/dist/{chunk-HYR7PXFU.mjs → chunk-YQFBZW6F.mjs} +1 -3
- package/dist/{chunk-HYR7PXFU.mjs.map → chunk-YQFBZW6F.mjs.map} +1 -1
- package/dist/hooks/index.d.mts +354 -142
- package/dist/hooks/index.d.ts +354 -142
- package/dist/hooks/index.js +1094 -6
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1107 -19
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +5 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -38
- package/dist/models/index.d.mts +2 -2
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.js +6 -3
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs +5 -2
- package/dist/{sandbox-DOxoM2Ge.d.ts → sandbox-Djb8gA7e.d.mts} +32 -2
- package/dist/{sandbox-DOxoM2Ge.d.mts → sandbox-Djb8gA7e.d.ts} +32 -2
- package/dist/transport/index.d.mts +3 -3
- package/dist/transport/index.d.ts +3 -3
- package/dist/transport/index.js +3 -4
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +1 -2
- package/dist/{types-BBPz_6kK.d.ts → types-BzNzXaqk.d.ts} +2 -2
- package/dist/{types-BtfxlyHk.d.mts → types-CSyY6Qv7.d.mts} +2 -2
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +3 -4
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -2
- package/package.json +9 -8
- package/dist/chunk-2JDVRL35.js.map +0 -1
- package/dist/chunk-3PFZRJ4A.js.map +0 -1
- package/dist/chunk-43FTKGM6.mjs +0 -1114
- package/dist/chunk-43FTKGM6.mjs.map +0 -1
- package/dist/chunk-L5FLJB3H.mjs.map +0 -1
- package/dist/chunk-RG42SHBX.js +0 -1114
- package/dist/chunk-RG42SHBX.js.map +0 -1
- package/dist/chunk-TY57JG3P.mjs.map +0 -1
- package/dist/chunk-XQ7LOAN3.js.map +0 -1
- package/dist/chunk-ZS7DRNCT.js.map +0 -1
package/dist/chunk-43FTKGM6.mjs
DELETED
|
@@ -1,1114 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
checkBackgroundAgentStatusApi,
|
|
4
|
-
completeSchedulerTaskApi,
|
|
5
|
-
connectIntegrationApi,
|
|
6
|
-
createAgentApi,
|
|
7
|
-
createAgentJobApi,
|
|
8
|
-
createSandboxApi,
|
|
9
|
-
createScheduleApi,
|
|
10
|
-
createSchedulerTaskApi,
|
|
11
|
-
createSkillApi,
|
|
12
|
-
createSubAgentApi,
|
|
13
|
-
createToolDefinitionApi,
|
|
14
|
-
createWidgetApi,
|
|
15
|
-
deleteAgentApi,
|
|
16
|
-
deleteAgentJobApi,
|
|
17
|
-
deleteSandboxApi,
|
|
18
|
-
deleteScheduleApi,
|
|
19
|
-
deleteSchedulerTaskApi,
|
|
20
|
-
deleteSkillApi,
|
|
21
|
-
deleteSkillUserConfigApi,
|
|
22
|
-
deleteSubAgentApi,
|
|
23
|
-
deleteToolDefinitionApi,
|
|
24
|
-
deleteWidgetApi,
|
|
25
|
-
disconnectIntegrationApi,
|
|
26
|
-
exportAgentApi,
|
|
27
|
-
getAgentApi,
|
|
28
|
-
getAgentCSATAnalyticsApi,
|
|
29
|
-
getAgentChatsAnalyticsApi,
|
|
30
|
-
getAgentJobApi,
|
|
31
|
-
getAgentListAnalyticsApi,
|
|
32
|
-
getDefaultAgentApi,
|
|
33
|
-
getDefaultWidgetApi,
|
|
34
|
-
getIntegrationApi,
|
|
35
|
-
getSandboxApi,
|
|
36
|
-
getScheduleApi,
|
|
37
|
-
getSchedulerTaskApi,
|
|
38
|
-
getSkillApi,
|
|
39
|
-
getSkillCategoriesApi,
|
|
40
|
-
getSkillUserConfigApi,
|
|
41
|
-
getSubAgentApi,
|
|
42
|
-
getTaskOutcomesApi,
|
|
43
|
-
getToolDefinitionApi,
|
|
44
|
-
getToolDefinitionsByIdsApi,
|
|
45
|
-
getWidgetApi,
|
|
46
|
-
importAgentApi,
|
|
47
|
-
listAgentJobsApi,
|
|
48
|
-
listAgentsApi,
|
|
49
|
-
listAgentsSummaryApi,
|
|
50
|
-
listIntegrationsApi,
|
|
51
|
-
listSandboxesApi,
|
|
52
|
-
listSchedulerTasksApi,
|
|
53
|
-
listSchedulesApi,
|
|
54
|
-
listSkillUserConfigsApi,
|
|
55
|
-
listSkillsApi,
|
|
56
|
-
listSubAgentsApi,
|
|
57
|
-
listToolDefinitionsApi,
|
|
58
|
-
listWidgetsApi,
|
|
59
|
-
pauseAgentJobApi,
|
|
60
|
-
pauseScheduleApi,
|
|
61
|
-
refreshIntegrationApi,
|
|
62
|
-
resolveSkillConfigApi,
|
|
63
|
-
resumeAgentJobApi,
|
|
64
|
-
resumeScheduleApi,
|
|
65
|
-
runEmailTriageApi,
|
|
66
|
-
runScheduleApi,
|
|
67
|
-
setDefaultWidgetApi,
|
|
68
|
-
snoozeSchedulerTaskApi,
|
|
69
|
-
startSchedulerTaskApi,
|
|
70
|
-
structuredOutputApi,
|
|
71
|
-
triggerBackgroundAgentApi,
|
|
72
|
-
updateAgentApi,
|
|
73
|
-
updateAgentJobApi,
|
|
74
|
-
updateIntegrationTriageApi,
|
|
75
|
-
updateSandboxApi,
|
|
76
|
-
updateScheduleApi,
|
|
77
|
-
updateSchedulerTaskApi,
|
|
78
|
-
updateSkillApi,
|
|
79
|
-
updateSkillUserConfigApi,
|
|
80
|
-
updateSubAgentApi,
|
|
81
|
-
updateToolDefinitionApi,
|
|
82
|
-
updateWidgetApi
|
|
83
|
-
} from "./chunk-L5FLJB3H.mjs";
|
|
84
|
-
import {
|
|
85
|
-
createBGAgentTransport
|
|
86
|
-
} from "./chunk-3EHE4O57.mjs";
|
|
87
|
-
|
|
88
|
-
// hooks/use-agents.ts
|
|
89
|
-
import { useMemo } from "react";
|
|
90
|
-
import { useApiAsync } from "@elqnt/api-client/hooks";
|
|
91
|
-
|
|
92
|
-
// hooks/use-options-ref.ts
|
|
93
|
-
import { useRef, useEffect } from "react";
|
|
94
|
-
function useOptionsRef(options) {
|
|
95
|
-
const optionsRef = useRef(options);
|
|
96
|
-
useEffect(() => {
|
|
97
|
-
optionsRef.current = options;
|
|
98
|
-
}, [options]);
|
|
99
|
-
return optionsRef;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// hooks/use-agents.ts
|
|
103
|
-
function useAgents(options) {
|
|
104
|
-
const optionsRef = useOptionsRef(options);
|
|
105
|
-
const { execute: listAgents, loading: listLoading, error: listError } = useApiAsync(
|
|
106
|
-
() => listAgentsApi(optionsRef.current),
|
|
107
|
-
(data) => data.agents,
|
|
108
|
-
[]
|
|
109
|
-
);
|
|
110
|
-
const { execute: listAgentSummaries, loading: listSummaryLoading, error: listSummaryError } = useApiAsync(
|
|
111
|
-
() => listAgentsSummaryApi(optionsRef.current),
|
|
112
|
-
(data) => data.agents,
|
|
113
|
-
[]
|
|
114
|
-
);
|
|
115
|
-
const { execute: getAgent, loading: getLoading, error: getError } = useApiAsync(
|
|
116
|
-
(agentId) => getAgentApi(agentId, optionsRef.current),
|
|
117
|
-
(data) => data.agent || null,
|
|
118
|
-
null
|
|
119
|
-
);
|
|
120
|
-
const { execute: createAgent, loading: createLoading, error: createError } = useApiAsync(
|
|
121
|
-
(agent) => createAgentApi(agent, optionsRef.current),
|
|
122
|
-
(data) => data.agent || null,
|
|
123
|
-
null
|
|
124
|
-
);
|
|
125
|
-
const { execute: updateAgent, loading: updateLoading, error: updateError } = useApiAsync(
|
|
126
|
-
(agentId, agent) => updateAgentApi(agentId, agent, optionsRef.current),
|
|
127
|
-
(data) => data.agent || null,
|
|
128
|
-
null
|
|
129
|
-
);
|
|
130
|
-
const { execute: deleteAgent, loading: deleteLoading, error: deleteError } = useApiAsync(
|
|
131
|
-
(agentId) => deleteAgentApi(agentId, optionsRef.current),
|
|
132
|
-
() => true,
|
|
133
|
-
false
|
|
134
|
-
);
|
|
135
|
-
const { execute: getDefaultAgent, loading: defaultLoading, error: defaultError } = useApiAsync(
|
|
136
|
-
() => getDefaultAgentApi(optionsRef.current),
|
|
137
|
-
(data) => data.agent || null,
|
|
138
|
-
null
|
|
139
|
-
);
|
|
140
|
-
const exportAgent = async (agentId) => {
|
|
141
|
-
const agent = await exportAgentApi(agentId, optionsRef.current);
|
|
142
|
-
const json = JSON.stringify(agent, null, 2);
|
|
143
|
-
const blob = new Blob([json], { type: "application/json" });
|
|
144
|
-
const url = URL.createObjectURL(blob);
|
|
145
|
-
const a = document.createElement("a");
|
|
146
|
-
a.href = url;
|
|
147
|
-
a.download = `${agent.name || "agent"}.agent.json`;
|
|
148
|
-
a.click();
|
|
149
|
-
URL.revokeObjectURL(url);
|
|
150
|
-
return agent;
|
|
151
|
-
};
|
|
152
|
-
const { execute: importAgent, loading: importLoading, error: importError } = useApiAsync(
|
|
153
|
-
(agent) => importAgentApi(agent, optionsRef.current),
|
|
154
|
-
(data) => data.agent || null,
|
|
155
|
-
null
|
|
156
|
-
);
|
|
157
|
-
const loading = listLoading || listSummaryLoading || getLoading || createLoading || updateLoading || deleteLoading || defaultLoading || importLoading;
|
|
158
|
-
const error = listError || listSummaryError || getError || createError || updateError || deleteError || defaultError || importError;
|
|
159
|
-
return useMemo(
|
|
160
|
-
() => ({
|
|
161
|
-
loading,
|
|
162
|
-
error,
|
|
163
|
-
listAgents,
|
|
164
|
-
listAgentSummaries,
|
|
165
|
-
getAgent,
|
|
166
|
-
createAgent,
|
|
167
|
-
updateAgent,
|
|
168
|
-
deleteAgent,
|
|
169
|
-
getDefaultAgent,
|
|
170
|
-
exportAgent,
|
|
171
|
-
importAgent
|
|
172
|
-
}),
|
|
173
|
-
[loading, error, listAgents, listAgentSummaries, getAgent, createAgent, updateAgent, deleteAgent, getDefaultAgent, exportAgent, importAgent]
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// hooks/use-skills.ts
|
|
178
|
-
import { useMemo as useMemo2 } from "react";
|
|
179
|
-
import { useApiAsync as useApiAsync2 } from "@elqnt/api-client/hooks";
|
|
180
|
-
function useSkills(options) {
|
|
181
|
-
const optionsRef = useOptionsRef(options);
|
|
182
|
-
const { execute: listSkills, loading: listLoading, error: listError } = useApiAsync2(
|
|
183
|
-
() => listSkillsApi(optionsRef.current),
|
|
184
|
-
(data) => data.skills,
|
|
185
|
-
[]
|
|
186
|
-
);
|
|
187
|
-
const { execute: getSkill, loading: getLoading, error: getError } = useApiAsync2(
|
|
188
|
-
(skillId) => getSkillApi(skillId, optionsRef.current),
|
|
189
|
-
(data) => data.skill || null,
|
|
190
|
-
null
|
|
191
|
-
);
|
|
192
|
-
const { execute: createSkill, loading: createLoading, error: createError } = useApiAsync2(
|
|
193
|
-
(skill) => createSkillApi(skill, optionsRef.current),
|
|
194
|
-
(data) => data.skill || null,
|
|
195
|
-
null
|
|
196
|
-
);
|
|
197
|
-
const { execute: updateSkill, loading: updateLoading, error: updateError } = useApiAsync2(
|
|
198
|
-
(skillId, skill) => updateSkillApi(skillId, skill, optionsRef.current),
|
|
199
|
-
(data) => data.skill || null,
|
|
200
|
-
null
|
|
201
|
-
);
|
|
202
|
-
const { execute: deleteSkill, loading: deleteLoading, error: deleteError } = useApiAsync2(
|
|
203
|
-
(skillId) => deleteSkillApi(skillId, optionsRef.current),
|
|
204
|
-
() => true,
|
|
205
|
-
false
|
|
206
|
-
);
|
|
207
|
-
const { execute: getCategories, loading: categoriesLoading, error: categoriesError } = useApiAsync2(
|
|
208
|
-
() => getSkillCategoriesApi(optionsRef.current),
|
|
209
|
-
(data) => data.categories,
|
|
210
|
-
[]
|
|
211
|
-
);
|
|
212
|
-
const loading = listLoading || getLoading || createLoading || updateLoading || deleteLoading || categoriesLoading;
|
|
213
|
-
const error = listError || getError || createError || updateError || deleteError || categoriesError;
|
|
214
|
-
return useMemo2(
|
|
215
|
-
() => ({
|
|
216
|
-
loading,
|
|
217
|
-
error,
|
|
218
|
-
listSkills,
|
|
219
|
-
getSkill,
|
|
220
|
-
createSkill,
|
|
221
|
-
updateSkill,
|
|
222
|
-
deleteSkill,
|
|
223
|
-
getCategories
|
|
224
|
-
}),
|
|
225
|
-
[loading, error, listSkills, getSkill, createSkill, updateSkill, deleteSkill, getCategories]
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// hooks/use-sub-agents.ts
|
|
230
|
-
import { useMemo as useMemo3 } from "react";
|
|
231
|
-
import { useApiAsync as useApiAsync3 } from "@elqnt/api-client/hooks";
|
|
232
|
-
function useSubAgents(options) {
|
|
233
|
-
const optionsRef = useOptionsRef(options);
|
|
234
|
-
const { execute: listSubAgents, loading: listLoading, error: listError } = useApiAsync3(
|
|
235
|
-
() => listSubAgentsApi(optionsRef.current),
|
|
236
|
-
(data) => data.subAgents,
|
|
237
|
-
[]
|
|
238
|
-
);
|
|
239
|
-
const { execute: getSubAgent, loading: getLoading, error: getError } = useApiAsync3(
|
|
240
|
-
(subAgentId) => getSubAgentApi(subAgentId, optionsRef.current),
|
|
241
|
-
(data) => data.subAgent || null,
|
|
242
|
-
null
|
|
243
|
-
);
|
|
244
|
-
const { execute: createSubAgent, loading: createLoading, error: createError } = useApiAsync3(
|
|
245
|
-
(subAgent) => createSubAgentApi(subAgent, optionsRef.current),
|
|
246
|
-
(data) => data.subAgent || null,
|
|
247
|
-
null
|
|
248
|
-
);
|
|
249
|
-
const { execute: updateSubAgent, loading: updateLoading, error: updateError } = useApiAsync3(
|
|
250
|
-
(subAgentId, subAgent) => updateSubAgentApi(subAgentId, subAgent, optionsRef.current),
|
|
251
|
-
(data) => data.subAgent || null,
|
|
252
|
-
null
|
|
253
|
-
);
|
|
254
|
-
const { execute: deleteSubAgent, loading: deleteLoading, error: deleteError } = useApiAsync3(
|
|
255
|
-
(subAgentId) => deleteSubAgentApi(subAgentId, optionsRef.current),
|
|
256
|
-
() => true,
|
|
257
|
-
false
|
|
258
|
-
);
|
|
259
|
-
const loading = listLoading || getLoading || createLoading || updateLoading || deleteLoading;
|
|
260
|
-
const error = listError || getError || createError || updateError || deleteError;
|
|
261
|
-
return useMemo3(
|
|
262
|
-
() => ({
|
|
263
|
-
loading,
|
|
264
|
-
error,
|
|
265
|
-
listSubAgents,
|
|
266
|
-
getSubAgent,
|
|
267
|
-
createSubAgent,
|
|
268
|
-
updateSubAgent,
|
|
269
|
-
deleteSubAgent
|
|
270
|
-
}),
|
|
271
|
-
[loading, error, listSubAgents, getSubAgent, createSubAgent, updateSubAgent, deleteSubAgent]
|
|
272
|
-
);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
// hooks/use-tool-definitions.ts
|
|
276
|
-
import { useMemo as useMemo4 } from "react";
|
|
277
|
-
import { useApiAsync as useApiAsync4 } from "@elqnt/api-client/hooks";
|
|
278
|
-
function useToolDefinitions(options) {
|
|
279
|
-
const optionsRef = useOptionsRef(options);
|
|
280
|
-
const { execute: listToolDefinitions, loading: listLoading, error: listError } = useApiAsync4(
|
|
281
|
-
() => listToolDefinitionsApi(optionsRef.current),
|
|
282
|
-
(data) => data.toolDefinitions,
|
|
283
|
-
[]
|
|
284
|
-
);
|
|
285
|
-
const { execute: getToolDefinition, loading: getLoading, error: getError } = useApiAsync4(
|
|
286
|
-
(toolDefId) => getToolDefinitionApi(toolDefId, optionsRef.current),
|
|
287
|
-
(data) => data.toolDefinition || null,
|
|
288
|
-
null
|
|
289
|
-
);
|
|
290
|
-
const { execute: getToolDefinitionsByIds, loading: getByIdsLoading, error: getByIdsError } = useApiAsync4(
|
|
291
|
-
(ids) => getToolDefinitionsByIdsApi(ids, optionsRef.current),
|
|
292
|
-
(data) => data.toolDefinitions,
|
|
293
|
-
[]
|
|
294
|
-
);
|
|
295
|
-
const { execute: createToolDefinition, loading: createLoading, error: createError } = useApiAsync4(
|
|
296
|
-
(toolDefinition) => createToolDefinitionApi(toolDefinition, optionsRef.current),
|
|
297
|
-
(data) => data.toolDefinition || null,
|
|
298
|
-
null
|
|
299
|
-
);
|
|
300
|
-
const { execute: updateToolDefinition, loading: updateLoading, error: updateError } = useApiAsync4(
|
|
301
|
-
(toolDefId, toolDefinition) => updateToolDefinitionApi(toolDefId, toolDefinition, optionsRef.current),
|
|
302
|
-
(data) => data.toolDefinition || null,
|
|
303
|
-
null
|
|
304
|
-
);
|
|
305
|
-
const { execute: deleteToolDefinition, loading: deleteLoading, error: deleteError } = useApiAsync4(
|
|
306
|
-
(toolDefId) => deleteToolDefinitionApi(toolDefId, optionsRef.current),
|
|
307
|
-
() => true,
|
|
308
|
-
false
|
|
309
|
-
);
|
|
310
|
-
const loading = listLoading || getLoading || getByIdsLoading || createLoading || updateLoading || deleteLoading;
|
|
311
|
-
const error = listError || getError || getByIdsError || createError || updateError || deleteError;
|
|
312
|
-
return useMemo4(
|
|
313
|
-
() => ({
|
|
314
|
-
loading,
|
|
315
|
-
error,
|
|
316
|
-
listToolDefinitions,
|
|
317
|
-
getToolDefinition,
|
|
318
|
-
getToolDefinitionsByIds,
|
|
319
|
-
createToolDefinition,
|
|
320
|
-
updateToolDefinition,
|
|
321
|
-
deleteToolDefinition
|
|
322
|
-
}),
|
|
323
|
-
[loading, error, listToolDefinitions, getToolDefinition, getToolDefinitionsByIds, createToolDefinition, updateToolDefinition, deleteToolDefinition]
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// hooks/use-agent-jobs.ts
|
|
328
|
-
import { useMemo as useMemo5 } from "react";
|
|
329
|
-
import { useApiAsync as useApiAsync5 } from "@elqnt/api-client/hooks";
|
|
330
|
-
function useAgentJobs(options) {
|
|
331
|
-
const optionsRef = useOptionsRef(options);
|
|
332
|
-
const { execute: listAgentJobs, loading: listLoading, error: listError } = useApiAsync5(
|
|
333
|
-
() => listAgentJobsApi(optionsRef.current),
|
|
334
|
-
(data) => data.jobs,
|
|
335
|
-
[]
|
|
336
|
-
);
|
|
337
|
-
const { execute: getAgentJob, loading: getLoading, error: getError } = useApiAsync5(
|
|
338
|
-
(jobId) => getAgentJobApi(jobId, optionsRef.current),
|
|
339
|
-
(data) => data.job || null,
|
|
340
|
-
null
|
|
341
|
-
);
|
|
342
|
-
const { execute: createAgentJob, loading: createLoading, error: createError } = useApiAsync5(
|
|
343
|
-
(job) => createAgentJobApi(job, optionsRef.current),
|
|
344
|
-
(data) => data.job || null,
|
|
345
|
-
null
|
|
346
|
-
);
|
|
347
|
-
const { execute: updateAgentJob, loading: updateLoading, error: updateError } = useApiAsync5(
|
|
348
|
-
(jobId, job) => updateAgentJobApi(jobId, job, optionsRef.current),
|
|
349
|
-
(data) => data.job || null,
|
|
350
|
-
null
|
|
351
|
-
);
|
|
352
|
-
const { execute: deleteAgentJob, loading: deleteLoading, error: deleteError } = useApiAsync5(
|
|
353
|
-
(jobId) => deleteAgentJobApi(jobId, optionsRef.current),
|
|
354
|
-
() => true,
|
|
355
|
-
false
|
|
356
|
-
);
|
|
357
|
-
const { execute: pauseAgentJob, loading: pauseLoading, error: pauseError } = useApiAsync5(
|
|
358
|
-
(jobId) => pauseAgentJobApi(jobId, optionsRef.current),
|
|
359
|
-
(data) => data.job || null,
|
|
360
|
-
null
|
|
361
|
-
);
|
|
362
|
-
const { execute: resumeAgentJob, loading: resumeLoading, error: resumeError } = useApiAsync5(
|
|
363
|
-
(jobId) => resumeAgentJobApi(jobId, optionsRef.current),
|
|
364
|
-
(data) => data.job || null,
|
|
365
|
-
null
|
|
366
|
-
);
|
|
367
|
-
const loading = listLoading || getLoading || createLoading || updateLoading || deleteLoading || pauseLoading || resumeLoading;
|
|
368
|
-
const error = listError || getError || createError || updateError || deleteError || pauseError || resumeError;
|
|
369
|
-
return useMemo5(
|
|
370
|
-
() => ({
|
|
371
|
-
loading,
|
|
372
|
-
error,
|
|
373
|
-
listAgentJobs,
|
|
374
|
-
getAgentJob,
|
|
375
|
-
createAgentJob,
|
|
376
|
-
updateAgentJob,
|
|
377
|
-
deleteAgentJob,
|
|
378
|
-
pauseAgentJob,
|
|
379
|
-
resumeAgentJob
|
|
380
|
-
}),
|
|
381
|
-
[loading, error, listAgentJobs, getAgentJob, createAgentJob, updateAgentJob, deleteAgentJob, pauseAgentJob, resumeAgentJob]
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
// hooks/use-widgets.ts
|
|
386
|
-
import { useMemo as useMemo6 } from "react";
|
|
387
|
-
import { useApiAsync as useApiAsync6 } from "@elqnt/api-client/hooks";
|
|
388
|
-
function useWidgets(options) {
|
|
389
|
-
const optionsRef = useOptionsRef(options);
|
|
390
|
-
const { execute: listWidgets, loading: listLoading, error: listError } = useApiAsync6(
|
|
391
|
-
() => listWidgetsApi(optionsRef.current.agentId, optionsRef.current),
|
|
392
|
-
(data) => data.widgets,
|
|
393
|
-
[]
|
|
394
|
-
);
|
|
395
|
-
const { execute: getWidget, loading: getLoading, error: getError } = useApiAsync6(
|
|
396
|
-
(widgetId) => getWidgetApi(widgetId, optionsRef.current),
|
|
397
|
-
(data) => data.widget || null,
|
|
398
|
-
null
|
|
399
|
-
);
|
|
400
|
-
const { execute: getDefaultWidget, loading: defaultLoading, error: defaultError } = useApiAsync6(
|
|
401
|
-
() => getDefaultWidgetApi(optionsRef.current.agentId, optionsRef.current),
|
|
402
|
-
(data) => data.widget || null,
|
|
403
|
-
null
|
|
404
|
-
);
|
|
405
|
-
const { execute: createWidget, loading: createLoading, error: createError } = useApiAsync6(
|
|
406
|
-
(widget) => createWidgetApi(optionsRef.current.agentId, widget, optionsRef.current),
|
|
407
|
-
(data) => data.widget || null,
|
|
408
|
-
null
|
|
409
|
-
);
|
|
410
|
-
const { execute: updateWidget, loading: updateLoading, error: updateError } = useApiAsync6(
|
|
411
|
-
(widgetId, widget) => updateWidgetApi(widgetId, widget, optionsRef.current),
|
|
412
|
-
(data) => data.widget || null,
|
|
413
|
-
null
|
|
414
|
-
);
|
|
415
|
-
const { execute: deleteWidget, loading: deleteLoading, error: deleteError } = useApiAsync6(
|
|
416
|
-
(widgetId) => deleteWidgetApi(widgetId, optionsRef.current),
|
|
417
|
-
() => true,
|
|
418
|
-
false
|
|
419
|
-
);
|
|
420
|
-
const { execute: setDefaultWidget, loading: setDefaultLoading, error: setDefaultError } = useApiAsync6(
|
|
421
|
-
(widgetId) => setDefaultWidgetApi(widgetId, optionsRef.current.agentId, optionsRef.current),
|
|
422
|
-
() => true,
|
|
423
|
-
false
|
|
424
|
-
);
|
|
425
|
-
const loading = listLoading || getLoading || defaultLoading || createLoading || updateLoading || deleteLoading || setDefaultLoading;
|
|
426
|
-
const error = listError || getError || defaultError || createError || updateError || deleteError || setDefaultError;
|
|
427
|
-
return useMemo6(
|
|
428
|
-
() => ({
|
|
429
|
-
loading,
|
|
430
|
-
error,
|
|
431
|
-
listWidgets,
|
|
432
|
-
getWidget,
|
|
433
|
-
getDefaultWidget,
|
|
434
|
-
createWidget,
|
|
435
|
-
updateWidget,
|
|
436
|
-
deleteWidget,
|
|
437
|
-
setDefaultWidget
|
|
438
|
-
}),
|
|
439
|
-
[loading, error, listWidgets, getWidget, getDefaultWidget, createWidget, updateWidget, deleteWidget, setDefaultWidget]
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// hooks/use-skill-user-config.ts
|
|
444
|
-
import { useMemo as useMemo7 } from "react";
|
|
445
|
-
import { useApiAsync as useApiAsync7 } from "@elqnt/api-client/hooks";
|
|
446
|
-
function useSkillUserConfig(options) {
|
|
447
|
-
const optionsRef = useOptionsRef(options);
|
|
448
|
-
const { execute: getSkillUserConfig, loading: getLoading, error: getError } = useApiAsync7(
|
|
449
|
-
(skillId, agentId) => getSkillUserConfigApi(skillId, { ...optionsRef.current, agentId }),
|
|
450
|
-
(data) => data.userConfig || null,
|
|
451
|
-
null
|
|
452
|
-
);
|
|
453
|
-
const { execute: updateSkillUserConfig, loading: updateLoading, error: updateError } = useApiAsync7(
|
|
454
|
-
(skillId, data) => updateSkillUserConfigApi(skillId, data, optionsRef.current),
|
|
455
|
-
(data) => data.userConfig || null,
|
|
456
|
-
null
|
|
457
|
-
);
|
|
458
|
-
const { execute: deleteSkillUserConfig, loading: deleteLoading, error: deleteError } = useApiAsync7(
|
|
459
|
-
(skillId, agentId) => deleteSkillUserConfigApi(skillId, { ...optionsRef.current, agentId }),
|
|
460
|
-
() => true,
|
|
461
|
-
false
|
|
462
|
-
);
|
|
463
|
-
const { execute: listSkillUserConfigs, loading: listLoading, error: listError } = useApiAsync7(
|
|
464
|
-
(params) => listSkillUserConfigsApi({ ...optionsRef.current, ...params }),
|
|
465
|
-
(data) => data.userConfigs || [],
|
|
466
|
-
[]
|
|
467
|
-
);
|
|
468
|
-
const { execute: resolveSkillConfig, loading: resolveLoading, error: resolveError } = useApiAsync7(
|
|
469
|
-
(skillId, agentId) => resolveSkillConfigApi(skillId, agentId, optionsRef.current),
|
|
470
|
-
(data) => data,
|
|
471
|
-
null
|
|
472
|
-
);
|
|
473
|
-
const loading = getLoading || updateLoading || deleteLoading || listLoading || resolveLoading;
|
|
474
|
-
const error = getError || updateError || deleteError || listError || resolveError;
|
|
475
|
-
return useMemo7(
|
|
476
|
-
() => ({
|
|
477
|
-
loading,
|
|
478
|
-
error,
|
|
479
|
-
getSkillUserConfig,
|
|
480
|
-
updateSkillUserConfig,
|
|
481
|
-
deleteSkillUserConfig,
|
|
482
|
-
listSkillUserConfigs,
|
|
483
|
-
resolveSkillConfig
|
|
484
|
-
}),
|
|
485
|
-
[loading, error, getSkillUserConfig, updateSkillUserConfig, deleteSkillUserConfig, listSkillUserConfigs, resolveSkillConfig]
|
|
486
|
-
);
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// hooks/use-analytics.ts
|
|
490
|
-
import { useMemo as useMemo8 } from "react";
|
|
491
|
-
import { useApiAsync as useApiAsync8 } from "@elqnt/api-client/hooks";
|
|
492
|
-
function useAnalytics(options) {
|
|
493
|
-
const optionsRef = useOptionsRef(options);
|
|
494
|
-
const { execute: getAgentChatsAnalytics, loading: chatsLoading, error: chatsError } = useApiAsync8(
|
|
495
|
-
(params) => getAgentChatsAnalyticsApi(params, optionsRef.current),
|
|
496
|
-
(data) => data.data,
|
|
497
|
-
[]
|
|
498
|
-
);
|
|
499
|
-
const { execute: getAgentCSATAnalytics, loading: csatLoading, error: csatError } = useApiAsync8(
|
|
500
|
-
(params) => getAgentCSATAnalyticsApi(params, optionsRef.current),
|
|
501
|
-
(data) => data.data,
|
|
502
|
-
[]
|
|
503
|
-
);
|
|
504
|
-
const { execute: getAgentListAnalytics, loading: listLoading, error: listError } = useApiAsync8(
|
|
505
|
-
() => getAgentListAnalyticsApi(optionsRef.current),
|
|
506
|
-
(data) => data.data,
|
|
507
|
-
[]
|
|
508
|
-
);
|
|
509
|
-
const { execute: getTaskOutcomes, loading: taskLoading, error: taskError } = useApiAsync8(
|
|
510
|
-
(params) => getTaskOutcomesApi(params, optionsRef.current),
|
|
511
|
-
(data) => data.data,
|
|
512
|
-
[]
|
|
513
|
-
);
|
|
514
|
-
const loading = chatsLoading || csatLoading || listLoading || taskLoading;
|
|
515
|
-
const error = chatsError || csatError || listError || taskError;
|
|
516
|
-
return useMemo8(
|
|
517
|
-
() => ({
|
|
518
|
-
loading,
|
|
519
|
-
error,
|
|
520
|
-
getAgentChatsAnalytics,
|
|
521
|
-
getAgentCSATAnalytics,
|
|
522
|
-
getAgentListAnalytics,
|
|
523
|
-
getTaskOutcomes
|
|
524
|
-
}),
|
|
525
|
-
[loading, error, getAgentChatsAnalytics, getAgentCSATAnalytics, getAgentListAnalytics, getTaskOutcomes]
|
|
526
|
-
);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// hooks/use-integrations.ts
|
|
530
|
-
import { useMemo as useMemo9 } from "react";
|
|
531
|
-
import { useApiAsync as useApiAsync9 } from "@elqnt/api-client/hooks";
|
|
532
|
-
function useIntegrations(options) {
|
|
533
|
-
const optionsRef = useOptionsRef(options);
|
|
534
|
-
const { execute: listIntegrations, loading: listLoading, error: listError } = useApiAsync9(
|
|
535
|
-
() => listIntegrationsApi(optionsRef.current),
|
|
536
|
-
(data) => data.integrations,
|
|
537
|
-
[]
|
|
538
|
-
);
|
|
539
|
-
const { execute: getIntegration, loading: getLoading, error: getError } = useApiAsync9(
|
|
540
|
-
(provider, integrationType) => getIntegrationApi(provider, integrationType, optionsRef.current),
|
|
541
|
-
(data) => data.integration || null,
|
|
542
|
-
null
|
|
543
|
-
);
|
|
544
|
-
const { execute: connectIntegration, loading: connectLoading, error: connectError } = useApiAsync9(
|
|
545
|
-
(params) => connectIntegrationApi(params, optionsRef.current),
|
|
546
|
-
(data) => ({ authUrl: data.auth_url, state: data.state }),
|
|
547
|
-
null
|
|
548
|
-
);
|
|
549
|
-
const { execute: disconnectIntegration, loading: disconnectLoading, error: disconnectError } = useApiAsync9(
|
|
550
|
-
(params) => disconnectIntegrationApi(params, optionsRef.current),
|
|
551
|
-
() => true,
|
|
552
|
-
false
|
|
553
|
-
);
|
|
554
|
-
const { execute: refreshIntegration, loading: refreshLoading, error: refreshError } = useApiAsync9(
|
|
555
|
-
(params) => refreshIntegrationApi(params, optionsRef.current),
|
|
556
|
-
(data) => data.integration || null,
|
|
557
|
-
null
|
|
558
|
-
);
|
|
559
|
-
const { execute: updateTriage, loading: updateTriageLoading, error: updateTriageError } = useApiAsync9(
|
|
560
|
-
(params) => updateIntegrationTriageApi(params, optionsRef.current),
|
|
561
|
-
(data) => data.integration || null,
|
|
562
|
-
null
|
|
563
|
-
);
|
|
564
|
-
const { execute: runEmailTriage, loading: runTriageLoading, error: runTriageError } = useApiAsync9(
|
|
565
|
-
() => runEmailTriageApi(optionsRef.current),
|
|
566
|
-
(data) => ({ success: data.success, emailsFound: data.emails_found, instancesCreated: data.instances_created }),
|
|
567
|
-
null
|
|
568
|
-
);
|
|
569
|
-
const loading = listLoading || getLoading || connectLoading || disconnectLoading || refreshLoading || updateTriageLoading || runTriageLoading;
|
|
570
|
-
const error = listError || getError || connectError || disconnectError || refreshError || updateTriageError || runTriageError;
|
|
571
|
-
return useMemo9(
|
|
572
|
-
() => ({
|
|
573
|
-
loading,
|
|
574
|
-
error,
|
|
575
|
-
listIntegrations,
|
|
576
|
-
getIntegration,
|
|
577
|
-
connectIntegration,
|
|
578
|
-
disconnectIntegration,
|
|
579
|
-
refreshIntegration,
|
|
580
|
-
updateTriage,
|
|
581
|
-
runEmailTriage
|
|
582
|
-
}),
|
|
583
|
-
[loading, error, listIntegrations, getIntegration, connectIntegration, disconnectIntegration, refreshIntegration, updateTriage, runEmailTriage]
|
|
584
|
-
);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
// hooks/use-sandbox.ts
|
|
588
|
-
import { useMemo as useMemo10 } from "react";
|
|
589
|
-
import { useApiAsync as useApiAsync10 } from "@elqnt/api-client/hooks";
|
|
590
|
-
function useSandbox(options) {
|
|
591
|
-
const optionsRef = useOptionsRef(options);
|
|
592
|
-
const { execute: createSandbox, loading: createLoading, error: createError } = useApiAsync10(
|
|
593
|
-
(request) => createSandboxApi(request, optionsRef.current),
|
|
594
|
-
(data) => ({ id: data.id, url: data.url, sandbox: data.sandbox }),
|
|
595
|
-
null
|
|
596
|
-
);
|
|
597
|
-
const { execute: getSandbox, loading: getLoading, error: getError } = useApiAsync10(
|
|
598
|
-
(sandboxId) => getSandboxApi(sandboxId, optionsRef.current),
|
|
599
|
-
(data) => data.sandbox || null,
|
|
600
|
-
null
|
|
601
|
-
);
|
|
602
|
-
const { execute: updateSandbox, loading: updateLoading, error: updateError } = useApiAsync10(
|
|
603
|
-
(sandboxId, request) => updateSandboxApi(sandboxId, request, optionsRef.current),
|
|
604
|
-
(data) => ({ id: data.id, url: data.url, sandbox: data.sandbox }),
|
|
605
|
-
null
|
|
606
|
-
);
|
|
607
|
-
const { execute: listSandboxes, loading: listLoading, error: listError } = useApiAsync10(
|
|
608
|
-
(limit) => listSandboxesApi({ ...optionsRef.current, limit }),
|
|
609
|
-
(data) => ({ sandboxes: data.sandboxes, total: data.total }),
|
|
610
|
-
{ sandboxes: [], total: 0 }
|
|
611
|
-
);
|
|
612
|
-
const { execute: deleteSandbox, loading: deleteLoading, error: deleteError } = useApiAsync10(
|
|
613
|
-
(sandboxId) => deleteSandboxApi(sandboxId, optionsRef.current),
|
|
614
|
-
(data) => data.success,
|
|
615
|
-
false
|
|
616
|
-
);
|
|
617
|
-
const loading = createLoading || getLoading || updateLoading || listLoading || deleteLoading;
|
|
618
|
-
const error = createError || getError || updateError || listError || deleteError;
|
|
619
|
-
return useMemo10(
|
|
620
|
-
() => ({
|
|
621
|
-
loading,
|
|
622
|
-
error,
|
|
623
|
-
createSandbox,
|
|
624
|
-
getSandbox,
|
|
625
|
-
updateSandbox,
|
|
626
|
-
listSandboxes,
|
|
627
|
-
deleteSandbox
|
|
628
|
-
}),
|
|
629
|
-
[loading, error, createSandbox, getSandbox, updateSandbox, listSandboxes, deleteSandbox]
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// hooks/use-structured-output.ts
|
|
634
|
-
import { useMemo as useMemo11 } from "react";
|
|
635
|
-
import { useApiAsync as useApiAsync11 } from "@elqnt/api-client/hooks";
|
|
636
|
-
function useStructuredOutput(options) {
|
|
637
|
-
const optionsRef = useOptionsRef(options);
|
|
638
|
-
const { execute: run, loading, error, clearError } = useApiAsync11(
|
|
639
|
-
(request) => structuredOutputApi(request, optionsRef.current),
|
|
640
|
-
(resp) => resp,
|
|
641
|
-
null
|
|
642
|
-
);
|
|
643
|
-
return useMemo11(
|
|
644
|
-
() => ({ run, loading, error, clearError }),
|
|
645
|
-
[run, loading, error, clearError]
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
// hooks/use-scheduler-tasks.ts
|
|
650
|
-
import { useMemo as useMemo12 } from "react";
|
|
651
|
-
import { useApiAsync as useApiAsync12 } from "@elqnt/api-client/hooks";
|
|
652
|
-
function useSchedulerTasks(options) {
|
|
653
|
-
const optionsRef = useOptionsRef(options);
|
|
654
|
-
const { execute: listTasks, loading: listLoading, error: listError } = useApiAsync12(
|
|
655
|
-
(params) => listSchedulerTasksApi({ ...optionsRef.current, ...params }),
|
|
656
|
-
(data) => data.tasks,
|
|
657
|
-
[]
|
|
658
|
-
);
|
|
659
|
-
const { execute: createTask, loading: createLoading, error: createError } = useApiAsync12(
|
|
660
|
-
(task) => createSchedulerTaskApi(task, optionsRef.current),
|
|
661
|
-
(data) => data.task || null,
|
|
662
|
-
null
|
|
663
|
-
);
|
|
664
|
-
const { execute: getTask, loading: getLoading, error: getError } = useApiAsync12(
|
|
665
|
-
(taskId) => getSchedulerTaskApi(taskId, optionsRef.current),
|
|
666
|
-
(data) => data.task || null,
|
|
667
|
-
null
|
|
668
|
-
);
|
|
669
|
-
const { execute: updateTask, loading: updateLoading, error: updateError } = useApiAsync12(
|
|
670
|
-
(taskId, task) => updateSchedulerTaskApi(taskId, task, optionsRef.current),
|
|
671
|
-
(data) => data.task || null,
|
|
672
|
-
null
|
|
673
|
-
);
|
|
674
|
-
const { execute: deleteTask, loading: deleteLoading, error: deleteError } = useApiAsync12(
|
|
675
|
-
(taskId) => deleteSchedulerTaskApi(taskId, optionsRef.current),
|
|
676
|
-
(data) => data.success,
|
|
677
|
-
false
|
|
678
|
-
);
|
|
679
|
-
const { execute: snoozeTask, loading: snoozeLoading, error: snoozeError } = useApiAsync12(
|
|
680
|
-
(taskId, delay) => snoozeSchedulerTaskApi(taskId, delay, optionsRef.current),
|
|
681
|
-
(data) => data.task || null,
|
|
682
|
-
null
|
|
683
|
-
);
|
|
684
|
-
const { execute: completeTask, loading: completeLoading, error: completeError } = useApiAsync12(
|
|
685
|
-
(taskId) => completeSchedulerTaskApi(taskId, optionsRef.current),
|
|
686
|
-
(data) => data.task || null,
|
|
687
|
-
null
|
|
688
|
-
);
|
|
689
|
-
const { execute: startTask, loading: startLoading, error: startError } = useApiAsync12(
|
|
690
|
-
(taskId) => startSchedulerTaskApi(taskId, optionsRef.current),
|
|
691
|
-
(data) => data.task || null,
|
|
692
|
-
null
|
|
693
|
-
);
|
|
694
|
-
const loading = listLoading || createLoading || getLoading || updateLoading || deleteLoading || snoozeLoading || completeLoading || startLoading;
|
|
695
|
-
const error = listError || createError || getError || updateError || deleteError || snoozeError || completeError || startError;
|
|
696
|
-
return useMemo12(
|
|
697
|
-
() => ({
|
|
698
|
-
loading,
|
|
699
|
-
error,
|
|
700
|
-
listTasks,
|
|
701
|
-
createTask,
|
|
702
|
-
getTask,
|
|
703
|
-
updateTask,
|
|
704
|
-
deleteTask,
|
|
705
|
-
snoozeTask,
|
|
706
|
-
completeTask,
|
|
707
|
-
startTask
|
|
708
|
-
}),
|
|
709
|
-
[loading, error, listTasks, createTask, getTask, updateTask, deleteTask, snoozeTask, completeTask, startTask]
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// hooks/use-scheduler-schedules.ts
|
|
714
|
-
import { useMemo as useMemo13 } from "react";
|
|
715
|
-
import { useApiAsync as useApiAsync13 } from "@elqnt/api-client/hooks";
|
|
716
|
-
function useSchedulerSchedules(options) {
|
|
717
|
-
const optionsRef = useOptionsRef(options);
|
|
718
|
-
const { execute: listSchedules, loading: listLoading, error: listError } = useApiAsync13(
|
|
719
|
-
(params) => listSchedulesApi({ ...optionsRef.current, ...params }),
|
|
720
|
-
(data) => data.schedules,
|
|
721
|
-
[]
|
|
722
|
-
);
|
|
723
|
-
const { execute: createSchedule, loading: createLoading, error: createError } = useApiAsync13(
|
|
724
|
-
(schedule) => createScheduleApi(schedule, optionsRef.current),
|
|
725
|
-
(data) => data.schedule || null,
|
|
726
|
-
null
|
|
727
|
-
);
|
|
728
|
-
const { execute: getSchedule, loading: getLoading, error: getError } = useApiAsync13(
|
|
729
|
-
(scheduleId) => getScheduleApi(scheduleId, optionsRef.current),
|
|
730
|
-
(data) => data.schedule || null,
|
|
731
|
-
null
|
|
732
|
-
);
|
|
733
|
-
const { execute: updateSchedule, loading: updateLoading, error: updateError } = useApiAsync13(
|
|
734
|
-
(scheduleId, schedule) => updateScheduleApi(scheduleId, schedule, optionsRef.current),
|
|
735
|
-
(data) => data.schedule || null,
|
|
736
|
-
null
|
|
737
|
-
);
|
|
738
|
-
const { execute: deleteSchedule, loading: deleteLoading, error: deleteError } = useApiAsync13(
|
|
739
|
-
(scheduleId) => deleteScheduleApi(scheduleId, optionsRef.current),
|
|
740
|
-
(data) => data.success,
|
|
741
|
-
false
|
|
742
|
-
);
|
|
743
|
-
const { execute: pauseSchedule, loading: pauseLoading, error: pauseError } = useApiAsync13(
|
|
744
|
-
(scheduleId) => pauseScheduleApi(scheduleId, optionsRef.current),
|
|
745
|
-
(data) => data.schedule || null,
|
|
746
|
-
null
|
|
747
|
-
);
|
|
748
|
-
const { execute: resumeSchedule, loading: resumeLoading, error: resumeError } = useApiAsync13(
|
|
749
|
-
(scheduleId) => resumeScheduleApi(scheduleId, optionsRef.current),
|
|
750
|
-
(data) => data.schedule || null,
|
|
751
|
-
null
|
|
752
|
-
);
|
|
753
|
-
const { execute: runSchedule, loading: runLoading, error: runError } = useApiAsync13(
|
|
754
|
-
(scheduleId) => runScheduleApi(scheduleId, optionsRef.current),
|
|
755
|
-
(data) => data.schedule || null,
|
|
756
|
-
null
|
|
757
|
-
);
|
|
758
|
-
const loading = listLoading || createLoading || getLoading || updateLoading || deleteLoading || pauseLoading || resumeLoading || runLoading;
|
|
759
|
-
const error = listError || createError || getError || updateError || deleteError || pauseError || resumeError || runError;
|
|
760
|
-
return useMemo13(
|
|
761
|
-
() => ({
|
|
762
|
-
loading,
|
|
763
|
-
error,
|
|
764
|
-
listSchedules,
|
|
765
|
-
createSchedule,
|
|
766
|
-
getSchedule,
|
|
767
|
-
updateSchedule,
|
|
768
|
-
deleteSchedule,
|
|
769
|
-
pauseSchedule,
|
|
770
|
-
resumeSchedule,
|
|
771
|
-
runSchedule
|
|
772
|
-
}),
|
|
773
|
-
[loading, error, listSchedules, createSchedule, getSchedule, updateSchedule, deleteSchedule, pauseSchedule, resumeSchedule, runSchedule]
|
|
774
|
-
);
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
// hooks/use-background-agents.ts
|
|
778
|
-
import { useState, useEffect as useEffect2, useRef as useRef2, useCallback, useMemo as useMemo14 } from "react";
|
|
779
|
-
import { useApiAsync as useApiAsync14 } from "@elqnt/api-client/hooks";
|
|
780
|
-
function useBackgroundAgents(options) {
|
|
781
|
-
const optionsRef = useOptionsRef(options);
|
|
782
|
-
const [liveStates, setLiveStates] = useState({});
|
|
783
|
-
const [watchedChats, setWatchedChats] = useState({});
|
|
784
|
-
const transportRef = useRef2(null);
|
|
785
|
-
const sseRef = useRef2(null);
|
|
786
|
-
const watchedChatKeyRef = useRef2(null);
|
|
787
|
-
useEffect2(() => {
|
|
788
|
-
const transport = createBGAgentTransport();
|
|
789
|
-
transport.connect({ streamBaseUrl: optionsRef.current.baseUrl });
|
|
790
|
-
transportRef.current = transport;
|
|
791
|
-
return () => {
|
|
792
|
-
transport.disconnect();
|
|
793
|
-
transportRef.current = null;
|
|
794
|
-
};
|
|
795
|
-
}, []);
|
|
796
|
-
const subscribedJobsRef = useRef2(/* @__PURE__ */ new Set());
|
|
797
|
-
const streamJob = useCallback((jobId) => {
|
|
798
|
-
const transport = transportRef.current;
|
|
799
|
-
if (!transport) return;
|
|
800
|
-
if (subscribedJobsRef.current.has(jobId)) return;
|
|
801
|
-
subscribedJobsRef.current.add(jobId);
|
|
802
|
-
setLiveStates((prev) => ({
|
|
803
|
-
...prev,
|
|
804
|
-
[jobId]: prev[jobId] || { status: "running", progressLog: [], latestMessage: "Starting..." }
|
|
805
|
-
}));
|
|
806
|
-
transport.on("bg_agent.round", (event) => {
|
|
807
|
-
if (event.jobId !== jobId || !event.content) return;
|
|
808
|
-
setLiveStates((prev) => {
|
|
809
|
-
const cur = prev[jobId] || { status: "running", progressLog: [], latestMessage: "" };
|
|
810
|
-
return {
|
|
811
|
-
...prev,
|
|
812
|
-
[jobId]: { ...cur, status: "running", progressLog: [...cur.progressLog, event.content], latestMessage: event.content }
|
|
813
|
-
};
|
|
814
|
-
});
|
|
815
|
-
});
|
|
816
|
-
transport.on("bg_agent.completed", (event) => {
|
|
817
|
-
if (event.jobId !== jobId) return;
|
|
818
|
-
subscribedJobsRef.current.delete(jobId);
|
|
819
|
-
setLiveStates((prev) => ({
|
|
820
|
-
...prev,
|
|
821
|
-
[jobId]: { ...prev[jobId] || { progressLog: [], latestMessage: "" }, status: "completed", result: event.result, latestMessage: event.result || "Completed" }
|
|
822
|
-
}));
|
|
823
|
-
});
|
|
824
|
-
transport.on("bg_agent.failed", (event) => {
|
|
825
|
-
if (event.jobId !== jobId) return;
|
|
826
|
-
subscribedJobsRef.current.delete(jobId);
|
|
827
|
-
setLiveStates((prev) => ({
|
|
828
|
-
...prev,
|
|
829
|
-
[jobId]: { ...prev[jobId] || { progressLog: [], latestMessage: "" }, status: "failed", error: event.error, latestMessage: event.error || "Failed" }
|
|
830
|
-
}));
|
|
831
|
-
});
|
|
832
|
-
transport.streamJob(jobId);
|
|
833
|
-
}, []);
|
|
834
|
-
const { execute: triggerAgent, loading: triggerLoading, error: triggerError } = useApiAsync14(
|
|
835
|
-
(request) => triggerBackgroundAgentApi(request, optionsRef.current),
|
|
836
|
-
(data) => data,
|
|
837
|
-
null
|
|
838
|
-
);
|
|
839
|
-
const { execute: checkStatus, loading: statusLoading, error: statusError } = useApiAsync14(
|
|
840
|
-
(jobId) => checkBackgroundAgentStatusApi(jobId, optionsRef.current),
|
|
841
|
-
(data) => data,
|
|
842
|
-
null
|
|
843
|
-
);
|
|
844
|
-
const { execute: listAgentSummaries, loading: summaryLoading, error: summaryError } = useApiAsync14(
|
|
845
|
-
() => listAgentsSummaryApi(optionsRef.current),
|
|
846
|
-
(data) => data.agents || [],
|
|
847
|
-
[]
|
|
848
|
-
);
|
|
849
|
-
const createTask = useCallback(async (prompt, attachments) => {
|
|
850
|
-
const { chatServiceUrl, orgId, userId } = optionsRef.current;
|
|
851
|
-
if (!chatServiceUrl) {
|
|
852
|
-
console.error("chatServiceUrl is required for createTask");
|
|
853
|
-
return null;
|
|
854
|
-
}
|
|
855
|
-
if (!userId) {
|
|
856
|
-
console.error("userId is required for createTask");
|
|
857
|
-
return null;
|
|
858
|
-
}
|
|
859
|
-
try {
|
|
860
|
-
const createResponse = await fetch(`${chatServiceUrl}/create`, {
|
|
861
|
-
method: "POST",
|
|
862
|
-
headers: { "Content-Type": "application/json" },
|
|
863
|
-
body: JSON.stringify({
|
|
864
|
-
orgId,
|
|
865
|
-
userId,
|
|
866
|
-
metadata: {
|
|
867
|
-
agentName: "background_agent",
|
|
868
|
-
background: true,
|
|
869
|
-
userId,
|
|
870
|
-
userEmail: userId,
|
|
871
|
-
originalPrompt: prompt
|
|
872
|
-
}
|
|
873
|
-
})
|
|
874
|
-
});
|
|
875
|
-
if (!createResponse.ok) {
|
|
876
|
-
const errorText = await createResponse.text();
|
|
877
|
-
console.error("Failed to create background chat:", errorText);
|
|
878
|
-
return null;
|
|
879
|
-
}
|
|
880
|
-
const createData = await createResponse.json();
|
|
881
|
-
const chatKey = createData.data?.chatKey || createData.chatKey;
|
|
882
|
-
if (!chatKey) {
|
|
883
|
-
console.error("No chatKey returned from create");
|
|
884
|
-
return null;
|
|
885
|
-
}
|
|
886
|
-
const sendResponse = await fetch(`${chatServiceUrl}/send`, {
|
|
887
|
-
method: "POST",
|
|
888
|
-
headers: { "Content-Type": "application/json" },
|
|
889
|
-
body: JSON.stringify({
|
|
890
|
-
orgId,
|
|
891
|
-
userId,
|
|
892
|
-
chatKey,
|
|
893
|
-
message: {
|
|
894
|
-
role: "user",
|
|
895
|
-
content: prompt,
|
|
896
|
-
attachments: attachments || void 0
|
|
897
|
-
}
|
|
898
|
-
})
|
|
899
|
-
});
|
|
900
|
-
if (!sendResponse.ok) {
|
|
901
|
-
const errorText = await sendResponse.text();
|
|
902
|
-
console.error("Failed to send message:", errorText);
|
|
903
|
-
}
|
|
904
|
-
return chatKey;
|
|
905
|
-
} catch (err) {
|
|
906
|
-
console.error("Failed to create background task:", err);
|
|
907
|
-
return null;
|
|
908
|
-
}
|
|
909
|
-
}, []);
|
|
910
|
-
const watchChat = useCallback(async (chatKey) => {
|
|
911
|
-
const { chatServiceUrl, orgId, userId } = optionsRef.current;
|
|
912
|
-
if (!chatServiceUrl) {
|
|
913
|
-
console.error("chatServiceUrl is required for watchChat");
|
|
914
|
-
return;
|
|
915
|
-
}
|
|
916
|
-
if (!userId) {
|
|
917
|
-
console.error("userId is required for watchChat");
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
if (sseRef.current && watchedChatKeyRef.current !== chatKey) {
|
|
921
|
-
sseRef.current.close();
|
|
922
|
-
sseRef.current = null;
|
|
923
|
-
}
|
|
924
|
-
watchedChatKeyRef.current = chatKey;
|
|
925
|
-
setWatchedChats((prev) => ({
|
|
926
|
-
...prev,
|
|
927
|
-
[chatKey]: { chatKey, messages: [], status: "loading", statusHistory: [] }
|
|
928
|
-
}));
|
|
929
|
-
try {
|
|
930
|
-
const loadResponse = await fetch(`${chatServiceUrl}/load`, {
|
|
931
|
-
method: "POST",
|
|
932
|
-
headers: { "Content-Type": "application/json" },
|
|
933
|
-
body: JSON.stringify({ orgId, chatKey, userId })
|
|
934
|
-
});
|
|
935
|
-
if (!loadResponse.ok) {
|
|
936
|
-
const errorText = await loadResponse.text();
|
|
937
|
-
setWatchedChats((prev) => ({
|
|
938
|
-
...prev,
|
|
939
|
-
[chatKey]: { chatKey, messages: [], status: "error", statusHistory: [], error: errorText || "Failed to load chat" }
|
|
940
|
-
}));
|
|
941
|
-
return;
|
|
942
|
-
}
|
|
943
|
-
const loadData = await loadResponse.json();
|
|
944
|
-
const chat = loadData.data?.chat || loadData.chat;
|
|
945
|
-
if (!chat) {
|
|
946
|
-
setWatchedChats((prev) => ({
|
|
947
|
-
...prev,
|
|
948
|
-
[chatKey]: { chatKey, messages: [], status: "error", statusHistory: [], error: "No chat data returned" }
|
|
949
|
-
}));
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
const bgStatus = chat.metadata?.backgroundStatus;
|
|
953
|
-
const bgMessage = chat.metadata?.backgroundStatusMessage;
|
|
954
|
-
let initialStatus = "active";
|
|
955
|
-
if (bgStatus === "completed") initialStatus = "completed";
|
|
956
|
-
else if (bgStatus === "failed") initialStatus = "error";
|
|
957
|
-
const initialStatusHistory = [];
|
|
958
|
-
setWatchedChats((prev) => ({
|
|
959
|
-
...prev,
|
|
960
|
-
[chatKey]: {
|
|
961
|
-
chatKey,
|
|
962
|
-
messages: chat.messages || [],
|
|
963
|
-
status: initialStatus,
|
|
964
|
-
title: chat.title,
|
|
965
|
-
metadata: chat.metadata,
|
|
966
|
-
backgroundStatus: bgStatus,
|
|
967
|
-
backgroundStatusMessage: bgMessage,
|
|
968
|
-
statusHistory: initialStatusHistory
|
|
969
|
-
}
|
|
970
|
-
}));
|
|
971
|
-
const sseUrl = `${chatServiceUrl}/stream?orgId=${orgId}&userId=${userId}&chatId=${chatKey}&clientType=customer`;
|
|
972
|
-
const sse = new EventSource(sseUrl);
|
|
973
|
-
sseRef.current = sse;
|
|
974
|
-
const processEventData = (data) => {
|
|
975
|
-
console.log("[useBackgroundAgents] SSE event received:", data.type, data);
|
|
976
|
-
if (data.type === "message" && data.message) {
|
|
977
|
-
setWatchedChats((prev) => {
|
|
978
|
-
const current = prev[chatKey];
|
|
979
|
-
if (!current) return prev;
|
|
980
|
-
const msg = data.message;
|
|
981
|
-
const exists = current.messages.some((m) => m.id === msg.id);
|
|
982
|
-
if (exists) return prev;
|
|
983
|
-
return {
|
|
984
|
-
...prev,
|
|
985
|
-
[chatKey]: {
|
|
986
|
-
...current,
|
|
987
|
-
messages: [...current.messages, msg]
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
});
|
|
991
|
-
}
|
|
992
|
-
const eventData = data.data;
|
|
993
|
-
if (data.type === "agent_context_update" && eventData?.backgroundStatus) {
|
|
994
|
-
const bgStatus2 = eventData.backgroundStatus;
|
|
995
|
-
const bgMessage2 = eventData.backgroundStatusMessage;
|
|
996
|
-
const timestamp = Date.now();
|
|
997
|
-
console.log("[useBackgroundAgents] Background status update:", bgStatus2, bgMessage2);
|
|
998
|
-
setWatchedChats((prev) => {
|
|
999
|
-
const current = prev[chatKey];
|
|
1000
|
-
if (!current) return prev;
|
|
1001
|
-
const newStatus = bgStatus2 === "completed" ? "completed" : bgStatus2 === "failed" ? "error" : current.status;
|
|
1002
|
-
const newHistory = [...current.statusHistory];
|
|
1003
|
-
const lastEntry = newHistory[newHistory.length - 1];
|
|
1004
|
-
if (!lastEntry || lastEntry.message !== bgMessage2 || lastEntry.status !== bgStatus2) {
|
|
1005
|
-
newHistory.push({
|
|
1006
|
-
status: bgStatus2,
|
|
1007
|
-
message: bgMessage2 || "",
|
|
1008
|
-
timestamp
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
return {
|
|
1012
|
-
...prev,
|
|
1013
|
-
[chatKey]: {
|
|
1014
|
-
...current,
|
|
1015
|
-
status: newStatus,
|
|
1016
|
-
backgroundStatus: bgStatus2,
|
|
1017
|
-
backgroundStatusMessage: bgMessage2,
|
|
1018
|
-
statusHistory: newHistory
|
|
1019
|
-
}
|
|
1020
|
-
};
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
if (data.type === "chat_ended" || data.type === "agent_done") {
|
|
1024
|
-
setWatchedChats((prev) => ({
|
|
1025
|
-
...prev,
|
|
1026
|
-
[chatKey]: { ...prev[chatKey], status: "completed" }
|
|
1027
|
-
}));
|
|
1028
|
-
}
|
|
1029
|
-
};
|
|
1030
|
-
sse.onmessage = (event) => {
|
|
1031
|
-
try {
|
|
1032
|
-
const data = JSON.parse(event.data);
|
|
1033
|
-
processEventData(data);
|
|
1034
|
-
} catch (err) {
|
|
1035
|
-
console.error("Failed to parse SSE event:", err);
|
|
1036
|
-
}
|
|
1037
|
-
};
|
|
1038
|
-
const customEventTypes = ["agent_context_update", "message", "chat_ended", "agent_done"];
|
|
1039
|
-
for (const eventType of customEventTypes) {
|
|
1040
|
-
sse.addEventListener(eventType, (event) => {
|
|
1041
|
-
try {
|
|
1042
|
-
const data = JSON.parse(event.data);
|
|
1043
|
-
processEventData(data);
|
|
1044
|
-
} catch (err) {
|
|
1045
|
-
console.error(`Failed to parse SSE ${eventType} event:`, err);
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
}
|
|
1049
|
-
sse.onerror = () => {
|
|
1050
|
-
console.warn("SSE connection error for chat:", chatKey);
|
|
1051
|
-
};
|
|
1052
|
-
} catch (err) {
|
|
1053
|
-
console.error("Failed to watch chat:", err);
|
|
1054
|
-
setWatchedChats((prev) => ({
|
|
1055
|
-
...prev,
|
|
1056
|
-
[chatKey]: { chatKey, messages: [], status: "error", statusHistory: [], error: String(err) }
|
|
1057
|
-
}));
|
|
1058
|
-
}
|
|
1059
|
-
}, []);
|
|
1060
|
-
const unwatchChat = useCallback((chatKey) => {
|
|
1061
|
-
if (watchedChatKeyRef.current === chatKey && sseRef.current) {
|
|
1062
|
-
sseRef.current.close();
|
|
1063
|
-
sseRef.current = null;
|
|
1064
|
-
watchedChatKeyRef.current = null;
|
|
1065
|
-
}
|
|
1066
|
-
setWatchedChats((prev) => {
|
|
1067
|
-
const next = { ...prev };
|
|
1068
|
-
delete next[chatKey];
|
|
1069
|
-
return next;
|
|
1070
|
-
});
|
|
1071
|
-
}, []);
|
|
1072
|
-
useEffect2(() => {
|
|
1073
|
-
return () => {
|
|
1074
|
-
if (sseRef.current) {
|
|
1075
|
-
sseRef.current.close();
|
|
1076
|
-
sseRef.current = null;
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
|
-
}, []);
|
|
1080
|
-
const loading = triggerLoading || statusLoading || summaryLoading;
|
|
1081
|
-
const error = triggerError || statusError || summaryError;
|
|
1082
|
-
return useMemo14(() => ({
|
|
1083
|
-
liveStates,
|
|
1084
|
-
streamJob,
|
|
1085
|
-
createTask,
|
|
1086
|
-
watchChat,
|
|
1087
|
-
unwatchChat,
|
|
1088
|
-
watchedChats,
|
|
1089
|
-
triggerAgent,
|
|
1090
|
-
checkStatus,
|
|
1091
|
-
listAgentSummaries,
|
|
1092
|
-
loading,
|
|
1093
|
-
error
|
|
1094
|
-
}), [liveStates, streamJob, createTask, watchChat, unwatchChat, watchedChats, triggerAgent, checkStatus, listAgentSummaries, loading, error]);
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
export {
|
|
1098
|
-
useOptionsRef,
|
|
1099
|
-
useAgents,
|
|
1100
|
-
useSkills,
|
|
1101
|
-
useSubAgents,
|
|
1102
|
-
useToolDefinitions,
|
|
1103
|
-
useAgentJobs,
|
|
1104
|
-
useWidgets,
|
|
1105
|
-
useSkillUserConfig,
|
|
1106
|
-
useAnalytics,
|
|
1107
|
-
useIntegrations,
|
|
1108
|
-
useSandbox,
|
|
1109
|
-
useStructuredOutput,
|
|
1110
|
-
useSchedulerTasks,
|
|
1111
|
-
useSchedulerSchedules,
|
|
1112
|
-
useBackgroundAgents
|
|
1113
|
-
};
|
|
1114
|
-
//# sourceMappingURL=chunk-43FTKGM6.mjs.map
|