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