@burdenoff/microfe-botmanor 2026.1127.6 → 2026.1127.7
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/dist/botlit/components/BotVersionHistoryPanel.js +136 -128
- package/dist/botlit/components/BotVersionHistoryPanel.js.map +1 -1
- package/dist/botlit/components/VersionHistoryPanel.js +129 -110
- package/dist/botlit/components/VersionHistoryPanel.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +2 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +6 -2
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useAgents.d.ts +1 -6
- package/dist/botlit/hooks/useAgents.js +89 -123
- package/dist/botlit/hooks/useAgents.js.map +1 -1
- package/dist/botlit/hooks/useBotVersions.d.ts +2 -2
- package/dist/botlit/hooks/useBotVersions.js +20 -28
- package/dist/botlit/hooks/useBotVersions.js.map +1 -1
- package/dist/botlit/pages/AgentDetailPage.js +103 -103
- package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
- package/dist/botlit/pages/BotDetailPage.js +1 -1
- package/dist/botlit/pages/BotDetailPage.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +99 -0
- package/dist/generated/wspace-operations.js +31 -1
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useBotlit as
|
|
3
|
-
import { graphqlErrorMessage as
|
|
4
|
-
import { buildMutationInput as
|
|
5
|
-
import { useWorkspacePaginatedQuery as
|
|
6
|
-
import { useCallback as
|
|
7
|
-
import { gql as
|
|
8
|
-
import { useGatewayClient as
|
|
1
|
+
import { ListBotmanorAgentVersionsPageDocument as e, ListBotmanorAgentsPageDocument as t } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useBotlit as n } from "../providers/BotlitProvider.js";
|
|
3
|
+
import { graphqlErrorMessage as r } from "../utils/errors.js";
|
|
4
|
+
import { buildMutationInput as i, fieldsOf as a } from "./internal/mutationInput.js";
|
|
5
|
+
import { useWorkspacePaginatedQuery as o, useWorkspaceQuery as s } from "./internal/workspaceGateway.js";
|
|
6
|
+
import { useCallback as c, useEffect as l, useMemo as u, useState as d } from "react";
|
|
7
|
+
import { gql as f } from "@apollo/client";
|
|
8
|
+
import { useGatewayClient as p } from "@burdenoff/fe-libs/shared/graphql";
|
|
9
9
|
// src/botlit/hooks/useAgents.ts
|
|
10
|
-
var
|
|
10
|
+
var m = f`
|
|
11
11
|
query GetBotmanorAgent($id: ID!) {
|
|
12
12
|
getBotmanorAgent(id: $id) {
|
|
13
13
|
id
|
|
@@ -44,7 +44,7 @@ var p = d`
|
|
|
44
44
|
workspaceId
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
`,
|
|
47
|
+
`, h = f`
|
|
48
48
|
mutation CreateBotmanorAgent($input: CreateBotmanorAgentInput!) {
|
|
49
49
|
createBotmanorAgent(input: $input) {
|
|
50
50
|
id
|
|
@@ -69,7 +69,7 @@ var p = d`
|
|
|
69
69
|
workspaceId
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
`,
|
|
72
|
+
`, g = f`
|
|
73
73
|
mutation UpdateBotmanorAgent($id: ID!, $input: UpdateBotmanorAgentInput!) {
|
|
74
74
|
updateBotmanorAgent(id: $id, input: $input) {
|
|
75
75
|
id
|
|
@@ -99,26 +99,11 @@ var p = d`
|
|
|
99
99
|
workspaceId
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
`,
|
|
102
|
+
`, _ = f`
|
|
103
103
|
mutation DeleteBotmanorAgent($id: ID!) {
|
|
104
104
|
deleteBotmanorAgent(id: $id)
|
|
105
105
|
}
|
|
106
|
-
`,
|
|
107
|
-
query ListAgentVersions($agentId: ID!, $pagination: PaginationInput) {
|
|
108
|
-
listAgentVersions(agentId: $agentId, pagination: $pagination) {
|
|
109
|
-
id
|
|
110
|
-
agentId
|
|
111
|
-
version
|
|
112
|
-
status
|
|
113
|
-
changelog
|
|
114
|
-
config
|
|
115
|
-
createdById
|
|
116
|
-
createdAt
|
|
117
|
-
publishedById
|
|
118
|
-
publishedAt
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
`, v = d`
|
|
106
|
+
`, v = f`
|
|
122
107
|
mutation PublishAgentVersion($agentId: ID!, $versionId: ID!, $changelog: String) {
|
|
123
108
|
publishAgentVersion(agentId: $agentId, versionId: $versionId, changelog: $changelog) {
|
|
124
109
|
id
|
|
@@ -130,7 +115,7 @@ var p = d`
|
|
|
130
115
|
publishedAt
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
|
-
`, y =
|
|
118
|
+
`, y = f`
|
|
134
119
|
mutation RollbackAgentVersion($agentId: ID!, $targetVersionId: ID!) {
|
|
135
120
|
rollbackAgentVersion(agentId: $agentId, targetVersionId: $targetVersionId) {
|
|
136
121
|
id
|
|
@@ -142,7 +127,7 @@ var p = d`
|
|
|
142
127
|
publishedAt
|
|
143
128
|
}
|
|
144
129
|
}
|
|
145
|
-
`, b = 100, x = [], S =
|
|
130
|
+
`, b = 100, x = [], S = a({
|
|
146
131
|
avatar: !0,
|
|
147
132
|
bucketId: !0,
|
|
148
133
|
capabilities: !0,
|
|
@@ -168,8 +153,8 @@ var p = d`
|
|
|
168
153
|
workflowIds: !0
|
|
169
154
|
});
|
|
170
155
|
function C(e, t) {
|
|
171
|
-
let
|
|
172
|
-
if (
|
|
156
|
+
let n = e.error;
|
|
157
|
+
if (n != null) throw Error(r(n, t), { cause: n });
|
|
173
158
|
}
|
|
174
159
|
function w(e) {
|
|
175
160
|
return e;
|
|
@@ -183,11 +168,11 @@ function T(e, t) {
|
|
|
183
168
|
bucketId: t?.bucketId
|
|
184
169
|
};
|
|
185
170
|
}
|
|
186
|
-
function E(
|
|
187
|
-
let { workspaceId: i } =
|
|
188
|
-
return
|
|
189
|
-
document:
|
|
190
|
-
variables:
|
|
171
|
+
function E(e, r) {
|
|
172
|
+
let { workspaceId: i } = n(), a = u(() => ({ filters: T(i, e) }), [e, i]);
|
|
173
|
+
return o({
|
|
174
|
+
document: t,
|
|
175
|
+
variables: a,
|
|
191
176
|
pageSize: b,
|
|
192
177
|
extractRows: (e) => e?.listBotmanorAgentsPage.items ?? [],
|
|
193
178
|
extractNextOffset: (e) => e?.listBotmanorAgentsPage.nextOffset ?? null,
|
|
@@ -197,7 +182,7 @@ function E(n, r) {
|
|
|
197
182
|
errorMessage: "Failed to load agents"
|
|
198
183
|
});
|
|
199
184
|
}
|
|
200
|
-
var D =
|
|
185
|
+
var D = f`
|
|
201
186
|
query GetBotmanorAgentCounts {
|
|
202
187
|
getBotmanorAgentCounts {
|
|
203
188
|
total
|
|
@@ -210,17 +195,17 @@ var D = d`
|
|
|
210
195
|
}
|
|
211
196
|
`;
|
|
212
197
|
function O(e = !0) {
|
|
213
|
-
let { workspaceId:
|
|
214
|
-
return
|
|
198
|
+
let { workspaceId: t } = n(), r = u(() => ({}), []);
|
|
199
|
+
return s({
|
|
215
200
|
document: D,
|
|
216
201
|
variables: r,
|
|
217
202
|
select: (e) => e?.getBotmanorAgentCounts ?? null,
|
|
218
203
|
fallback: null,
|
|
219
|
-
enabled: e && !!
|
|
204
|
+
enabled: e && !!t,
|
|
220
205
|
errorMessage: "Failed to load agent counts"
|
|
221
206
|
});
|
|
222
207
|
}
|
|
223
|
-
var k =
|
|
208
|
+
var k = f`
|
|
224
209
|
query GetBotmanorAgentUsage($id: ID!) {
|
|
225
210
|
getBotmanorAgentUsage(id: $id) {
|
|
226
211
|
bots {
|
|
@@ -237,8 +222,8 @@ var k = d`
|
|
|
237
222
|
}
|
|
238
223
|
`;
|
|
239
224
|
function A() {
|
|
240
|
-
let e = w(
|
|
241
|
-
return
|
|
225
|
+
let e = w(p("workspace"));
|
|
226
|
+
return c(async (t) => {
|
|
242
227
|
let n = await e.query({
|
|
243
228
|
query: k,
|
|
244
229
|
variables: { id: t },
|
|
@@ -253,62 +238,62 @@ function A() {
|
|
|
253
238
|
}, [e]);
|
|
254
239
|
}
|
|
255
240
|
function j(e) {
|
|
256
|
-
let t = w(
|
|
241
|
+
let t = w(p("workspace")), [n, r] = d(null), [i, a] = d(!!e), [o, s] = d(), u = c(async () => {
|
|
257
242
|
if (!e) r(null), a(!1);
|
|
258
243
|
else {
|
|
259
|
-
a(!0),
|
|
244
|
+
a(!0), s(void 0);
|
|
260
245
|
try {
|
|
261
246
|
let n = await t.query({
|
|
262
|
-
query:
|
|
247
|
+
query: m,
|
|
263
248
|
variables: { id: e },
|
|
264
249
|
fetchPolicy: "network-only"
|
|
265
250
|
}), i = n.error;
|
|
266
251
|
if (i != null) throw i instanceof Error ? i : /* @__PURE__ */ Error("Failed to load agent");
|
|
267
252
|
r(n.data?.getBotmanorAgent ?? null);
|
|
268
253
|
} catch (e) {
|
|
269
|
-
r(null),
|
|
254
|
+
r(null), s(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load agent"));
|
|
270
255
|
} finally {
|
|
271
256
|
a(!1);
|
|
272
257
|
}
|
|
273
258
|
}
|
|
274
259
|
}, [e, t]);
|
|
275
|
-
return
|
|
276
|
-
|
|
277
|
-
}, [
|
|
260
|
+
return l(() => {
|
|
261
|
+
u();
|
|
262
|
+
}, [u]), {
|
|
278
263
|
data: n,
|
|
279
264
|
loading: i,
|
|
280
265
|
error: o,
|
|
281
|
-
refetch:
|
|
266
|
+
refetch: u
|
|
282
267
|
};
|
|
283
268
|
}
|
|
284
269
|
function M() {
|
|
285
|
-
let e = w(
|
|
270
|
+
let e = w(p("workspace")), [t, n] = d({
|
|
286
271
|
data: void 0,
|
|
287
272
|
loading: !1,
|
|
288
273
|
error: void 0
|
|
289
274
|
});
|
|
290
|
-
return [
|
|
291
|
-
|
|
275
|
+
return [c(async (t) => {
|
|
276
|
+
n({
|
|
292
277
|
data: void 0,
|
|
293
278
|
loading: !0,
|
|
294
279
|
error: void 0
|
|
295
280
|
});
|
|
296
281
|
try {
|
|
297
|
-
let
|
|
298
|
-
mutation:
|
|
282
|
+
let r = await e.mutate({
|
|
283
|
+
mutation: h,
|
|
299
284
|
variables: { input: t }
|
|
300
285
|
});
|
|
301
|
-
C(
|
|
302
|
-
let i =
|
|
286
|
+
C(r, "Failed to create agent");
|
|
287
|
+
let i = r.data?.createBotmanorAgent;
|
|
303
288
|
if (!i) throw Error("Failed to create agent");
|
|
304
|
-
return
|
|
289
|
+
return n({
|
|
305
290
|
data: i,
|
|
306
291
|
loading: !1,
|
|
307
292
|
error: void 0
|
|
308
293
|
}), i;
|
|
309
294
|
} catch (e) {
|
|
310
|
-
let t = Error(
|
|
311
|
-
throw
|
|
295
|
+
let t = Error(r(e, "Failed to create agent"), { cause: e });
|
|
296
|
+
throw n({
|
|
312
297
|
data: void 0,
|
|
313
298
|
loading: !1,
|
|
314
299
|
error: t
|
|
@@ -317,36 +302,36 @@ function M() {
|
|
|
317
302
|
}, [e]), t];
|
|
318
303
|
}
|
|
319
304
|
function N() {
|
|
320
|
-
let e = w(
|
|
305
|
+
let e = w(p("workspace")), [t, n] = d({
|
|
321
306
|
data: void 0,
|
|
322
307
|
loading: !1,
|
|
323
308
|
error: void 0
|
|
324
309
|
});
|
|
325
|
-
return [
|
|
326
|
-
|
|
310
|
+
return [c(async ({ agentId: t, input: a }) => {
|
|
311
|
+
n({
|
|
327
312
|
data: void 0,
|
|
328
313
|
loading: !0,
|
|
329
314
|
error: void 0
|
|
330
315
|
});
|
|
331
316
|
try {
|
|
332
|
-
let
|
|
333
|
-
mutation:
|
|
317
|
+
let r = await e.mutate({
|
|
318
|
+
mutation: g,
|
|
334
319
|
variables: {
|
|
335
320
|
id: t,
|
|
336
|
-
input:
|
|
321
|
+
input: i(a, S)
|
|
337
322
|
}
|
|
338
323
|
});
|
|
339
|
-
C(
|
|
340
|
-
let o =
|
|
324
|
+
C(r, "Failed to update agent");
|
|
325
|
+
let o = r.data?.updateBotmanorAgent;
|
|
341
326
|
if (!o) throw Error("Failed to update agent");
|
|
342
|
-
return
|
|
327
|
+
return n({
|
|
343
328
|
data: o,
|
|
344
329
|
loading: !1,
|
|
345
330
|
error: void 0
|
|
346
331
|
}), o;
|
|
347
332
|
} catch (e) {
|
|
348
|
-
let t = Error(
|
|
349
|
-
throw
|
|
333
|
+
let t = Error(r(e, "Failed to update agent"), { cause: e });
|
|
334
|
+
throw n({
|
|
350
335
|
data: void 0,
|
|
351
336
|
loading: !1,
|
|
352
337
|
error: t
|
|
@@ -355,32 +340,32 @@ function N() {
|
|
|
355
340
|
}, [e]), t];
|
|
356
341
|
}
|
|
357
342
|
function P() {
|
|
358
|
-
let e = w(
|
|
343
|
+
let e = w(p("workspace")), [t, n] = d({
|
|
359
344
|
data: void 0,
|
|
360
345
|
loading: !1,
|
|
361
346
|
error: void 0
|
|
362
347
|
});
|
|
363
|
-
return [
|
|
364
|
-
|
|
348
|
+
return [c(async (t) => {
|
|
349
|
+
n({
|
|
365
350
|
data: void 0,
|
|
366
351
|
loading: !0,
|
|
367
352
|
error: void 0
|
|
368
353
|
});
|
|
369
354
|
try {
|
|
370
|
-
let
|
|
371
|
-
mutation:
|
|
355
|
+
let r = await e.mutate({
|
|
356
|
+
mutation: _,
|
|
372
357
|
variables: { id: t }
|
|
373
358
|
});
|
|
374
|
-
C(
|
|
375
|
-
let i =
|
|
376
|
-
return
|
|
359
|
+
C(r, "Failed to delete agent");
|
|
360
|
+
let i = r.data?.deleteBotmanorAgent ?? !1;
|
|
361
|
+
return n({
|
|
377
362
|
data: i,
|
|
378
363
|
loading: !1,
|
|
379
364
|
error: void 0
|
|
380
365
|
}), i;
|
|
381
366
|
} catch (e) {
|
|
382
|
-
let t = Error(
|
|
383
|
-
throw
|
|
367
|
+
let t = Error(r(e, "Failed to delete agent"), { cause: e });
|
|
368
|
+
throw n({
|
|
384
369
|
data: void 0,
|
|
385
370
|
loading: !1,
|
|
386
371
|
error: t
|
|
@@ -388,47 +373,28 @@ function P() {
|
|
|
388
373
|
}
|
|
389
374
|
}, [e]), t];
|
|
390
375
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
},
|
|
406
|
-
fetchPolicy: "network-only"
|
|
407
|
-
})).data?.listAgentVersions ?? [];
|
|
408
|
-
r([...n].sort((e, t) => e.createdAt && t.createdAt ? t.createdAt.localeCompare(e.createdAt) : 0));
|
|
409
|
-
} catch (e) {
|
|
410
|
-
l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load agent versions"));
|
|
411
|
-
} finally {
|
|
412
|
-
a(!1);
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}, [e, t]);
|
|
416
|
-
return c(() => {
|
|
417
|
-
d();
|
|
418
|
-
}, [d]), {
|
|
419
|
-
data: n,
|
|
420
|
-
loading: i,
|
|
421
|
-
error: o,
|
|
422
|
-
refetch: d
|
|
423
|
-
};
|
|
376
|
+
var F = [];
|
|
377
|
+
function I(t) {
|
|
378
|
+
let n = u(() => ({ agentId: t }), [t]);
|
|
379
|
+
return o({
|
|
380
|
+
document: e,
|
|
381
|
+
variables: n,
|
|
382
|
+
pageSize: 50,
|
|
383
|
+
extractRows: (e) => e?.listBotmanorAgentVersionsPage.items,
|
|
384
|
+
extractNextOffset: (e) => e?.listBotmanorAgentVersionsPage.nextOffset ?? null,
|
|
385
|
+
select: (e) => [...e].sort((e, t) => t.createdAt.localeCompare(e.createdAt)),
|
|
386
|
+
fallback: F,
|
|
387
|
+
enabled: !!t,
|
|
388
|
+
errorMessage: "Failed to load agent versions"
|
|
389
|
+
});
|
|
424
390
|
}
|
|
425
|
-
function
|
|
426
|
-
let e = w(
|
|
391
|
+
function L() {
|
|
392
|
+
let e = w(p("workspace")), [t, n] = d({
|
|
427
393
|
data: void 0,
|
|
428
394
|
loading: !1,
|
|
429
395
|
error: void 0
|
|
430
396
|
});
|
|
431
|
-
return [
|
|
397
|
+
return [c(async ({ agentId: t, versionId: r, changelog: i }) => {
|
|
432
398
|
n({
|
|
433
399
|
data: void 0,
|
|
434
400
|
loading: !0,
|
|
@@ -459,13 +425,13 @@ function I() {
|
|
|
459
425
|
}
|
|
460
426
|
}, [e]), t];
|
|
461
427
|
}
|
|
462
|
-
function
|
|
463
|
-
let e = w(
|
|
428
|
+
function R() {
|
|
429
|
+
let e = w(p("workspace")), [t, n] = d({
|
|
464
430
|
data: void 0,
|
|
465
431
|
loading: !1,
|
|
466
432
|
error: void 0
|
|
467
433
|
});
|
|
468
|
-
return [
|
|
434
|
+
return [c(async ({ agentId: t, targetVersionId: r }) => {
|
|
469
435
|
n({
|
|
470
436
|
data: void 0,
|
|
471
437
|
loading: !0,
|
|
@@ -495,6 +461,6 @@ function L() {
|
|
|
495
461
|
}
|
|
496
462
|
}, [e]), t];
|
|
497
463
|
}
|
|
498
|
-
export { j as useAgent, O as useAgentCounts,
|
|
464
|
+
export { j as useAgent, O as useAgentCounts, I as useAgentVersions, E as useAgents, M as useCreateAgent, P as useDeleteAgent, A as useLoadAgentUsage, L as usePublishAgentVersion, R as useRollbackAgentVersion, N as useUpdateAgent };
|
|
499
465
|
|
|
500
466
|
//# sourceMappingURL=useAgents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAgents.js","names":["GET_AGENT_DOCUMENT","CREATE_AGENT_DOCUMENT","UPDATE_AGENT_DOCUMENT","DELETE_AGENT_DOCUMENT","LIST_AGENT_VERSIONS_DOCUMENT","PUBLISH_AGENT_VERSION_DOCUMENT","ROLLBACK_AGENT_VERSION_DOCUMENT","LIST_PAGE_SIZE","NO_AGENTS","UPDATE_AGENT_FIELDS","fieldsOf","throwOperationError","operationError","result","graphqlErrorMessage","fallback","getWorkspaceClient","client","buildAgentFilter","workspaceId","filter","useAgents","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","ListBotmanorAgentsPageDocument","data","rows","options","GET_AGENT_COUNTS_DOCUMENT","useAgentCounts","useWorkspaceQuery","enabled","GET_AGENT_USAGE_DOCUMENT","useLoadAgentUsage","useGatewayClient","useCallback","agentId","useAgent","setData","useState","loading","setLoading","error","setError","refetch","queryError","useEffect","useCreateAgent","state","setState","createdAgent","mutationError","useUpdateAgent","buildMutationInput","input","updatedAgent","useDeleteAgent","deleted","useAgentVersions","versions","a","b","usePublishAgentVersion","published","changelog","useRollbackAgentVersion","rolledBack"],"sources":["../../../src/botlit/hooks/useAgents.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport {\n ListBotmanorAgentsPageDocument,\n type ListBotmanorAgentsPageQuery,\n} from '../../generated/wspace-operations';\nimport type { UpdateBotmanorAgentInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { AgentFilter } from '../types';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst GET_AGENT_DOCUMENT = gql`\n query GetBotmanorAgent($id: ID!) {\n getBotmanorAgent(id: $id) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n bucketId\n currentVersionId\n draftVersionId\n executionCount\n lastExecutedAt\n specialization\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n knowledgeBaseIds\n mcpConnectionIds\n workflowIds\n tagIds\n tags\n metadata\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_AGENT_DOCUMENT = gql`\n mutation CreateBotmanorAgent($input: CreateBotmanorAgentInput!) {\n createBotmanorAgent(input: $input) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n tagIds\n tags\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_AGENT_DOCUMENT = gql`\n mutation UpdateBotmanorAgent($id: ID!, $input: UpdateBotmanorAgentInput!) {\n updateBotmanorAgent(id: $id, input: $input) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n knowledgeBaseIds\n mcpConnectionIds\n workflowIds\n tagIds\n tags\n metadata\n createdAt\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_AGENT_DOCUMENT = gql`\n mutation DeleteBotmanorAgent($id: ID!) {\n deleteBotmanorAgent(id: $id)\n }\n`;\n\n// BOFF-4381: agent version history, publish, and rollback.\nconst LIST_AGENT_VERSIONS_DOCUMENT = gql`\n query ListAgentVersions($agentId: ID!, $pagination: PaginationInput) {\n listAgentVersions(agentId: $agentId, pagination: $pagination) {\n id\n agentId\n version\n status\n changelog\n config\n createdById\n createdAt\n publishedById\n publishedAt\n }\n }\n`;\n\nconst PUBLISH_AGENT_VERSION_DOCUMENT = gql`\n mutation PublishAgentVersion($agentId: ID!, $versionId: ID!, $changelog: String) {\n publishAgentVersion(agentId: $agentId, versionId: $versionId, changelog: $changelog) {\n id\n agentId\n version\n status\n changelog\n publishedById\n publishedAt\n }\n }\n`;\n\nconst ROLLBACK_AGENT_VERSION_DOCUMENT = gql`\n mutation RollbackAgentVersion($agentId: ID!, $targetVersionId: ID!) {\n rollbackAgentVersion(agentId: $agentId, targetVersionId: $targetVersionId) {\n id\n agentId\n version\n status\n changelog\n publishedById\n publishedAt\n }\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface AgentRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n /** Emoji chosen for the agent; null means the default. */\n avatar?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n capabilities?: string[] | null;\n llmModelId?: string | null;\n /** BOFF-15360 — ordered fallback models. */\n fallbackModelIds?: string[] | null;\n bucketId?: string | null;\n currentVersionId?: string | null;\n draftVersionId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n specialization?: string | null;\n systemPrompt?: string | null;\n temperature?: number | null;\n maxTokens?: number | null;\n maxConcurrentExecutions?: number | null;\n knowledgeBaseIds?: string[] | null;\n mcpConnectionIds?: string[] | null;\n workflowIds?: string[] | null;\n tagIds?: string[] | null;\n /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\n metadata?: Record<string, unknown> | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_AGENTS: AgentRecord[] = [];\n\ninterface GetAgentData {\n getBotmanorAgent: AgentRecord | null;\n}\n\ninterface CreateAgentData {\n createBotmanorAgent: AgentRecord;\n}\n\ninterface UpdateAgentData {\n updateBotmanorAgent: AgentRecord;\n}\n\ninterface DeleteAgentData {\n deleteBotmanorAgent: boolean;\n}\n\nexport interface AgentVersionRecord {\n id: string;\n agentId: string;\n version: string;\n status: 'DRAFT' | 'PUBLISHED' | 'HISTORICAL';\n changelog?: string | null;\n config?: Record<string, unknown> | null;\n createdById?: string | null;\n createdAt?: string | null;\n publishedById?: string | null;\n publishedAt?: string | null;\n}\n\ninterface ListAgentVersionsData {\n listAgentVersions: AgentVersionRecord[];\n}\n\ninterface PublishAgentVersionData {\n publishAgentVersion: AgentVersionRecord;\n}\n\ninterface RollbackAgentVersionData {\n rollbackAgentVersion: AgentVersionRecord;\n}\n\ninterface AgentMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateAgentInput {\n workspaceId: string;\n name: string;\n slug?: string;\n description?: string;\n avatar?: string;\n type: string;\n systemPrompt: string;\n temperature?: number;\n maxTokens?: number;\n maxConcurrentExecutions?: number;\n capabilities?: string[];\n llmModelId?: string;\n fallbackModelIds?: string[];\n knowledgeBaseIds?: string[];\n mcpConnectionIds?: string[];\n visibility?: string;\n}\n\ninterface UpdateAgentInput {\n agentId: string;\n input: GraphQLInput<UpdateBotmanorAgentInput>;\n}\n\nconst UPDATE_AGENT_FIELDS = fieldsOf<UpdateBotmanorAgentInput>({\n avatar: true,\n bucketId: true,\n capabilities: true,\n context: true,\n description: true,\n knowledgeBaseIds: true,\n llmModelId: true,\n fallbackModelIds: true,\n maxConcurrentExecutions: true,\n maxTokens: true,\n mcpConnectionIds: true,\n metadata: true,\n name: true,\n slug: true,\n specialization: true,\n status: true,\n systemPrompt: true,\n tagIds: true,\n tags: true,\n temperature: true,\n type: true,\n visibility: true,\n workflowIds: true,\n});\n\n/**\n * Apollo v4 resolves a mutation with `result.error` set (and no data) when the\n * server answers with a GraphQL error, instead of rejecting. Throw it so the\n * caller sees the server's actionable message (\"An agent named ... already\n * exists\") and not the generic fallback.\n */\nfunction throwOperationError(result: unknown, fallback: string): void {\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw new Error(graphqlErrorMessage(operationError, fallback), { cause: operationError });\n }\n}\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildAgentFilter(\n workspaceId: string | undefined,\n filter?: AgentFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const agentKeys = {\n all: ['agents'] as const,\n lists: () => [...agentKeys.all, 'list'] as const,\n list: (filter?: AgentFilter) => [...agentKeys.lists(), filter] as const,\n details: () => [...agentKeys.all, 'detail'] as const,\n detail: (id: string) => [...agentKeys.details(), id] as const,\n};\n\nexport function useAgents(\n filter?: AgentFilter,\n options?: { enabled?: boolean }\n): PaginatedQueryResult<AgentRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildAgentFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotmanorAgentsPageQuery, AgentRecord, AgentRecord[]>({\n document: ListBotmanorAgentsPageDocument,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotmanorAgentsPage.items ?? [],\n extractNextOffset: (data) => data?.listBotmanorAgentsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_AGENTS,\n enabled: Boolean(workspaceId) && options?.enabled !== false,\n errorMessage: 'Failed to load agents',\n });\n}\n\n/**\n * Exact agent counts by status for the workspace (BOFF-12426). Unlike\n * `useAgents` this is not capped at one page, so it is the source for\n * dashboard totals. `total` counts every status.\n */\nexport interface AgentCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n training: number;\n archived: number;\n}\n\ninterface AgentCountsData {\n getBotmanorAgentCounts?: AgentCounts | null;\n}\n\nconst GET_AGENT_COUNTS_DOCUMENT = gql`\n query GetBotmanorAgentCounts {\n getBotmanorAgentCounts {\n total\n draft\n active\n paused\n training\n archived\n }\n }\n`;\n\nexport function useAgentCounts(enabled = true): QueryResult<AgentCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<AgentCountsData, AgentCounts | null>({\n document: GET_AGENT_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotmanorAgentCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load agent counts',\n });\n}\n\n/** What still uses an agent, shown in the delete confirmation (BOFF-12457). */\nexport interface AgentUsage {\n bots: Array<{ id: string; name: string; isDefault: boolean }>;\n a2aConnections: Array<{ id: string; name: string }>;\n workflowIds: string[];\n}\n\ninterface AgentUsageData {\n getBotmanorAgentUsage?: AgentUsage | null;\n}\n\nconst GET_AGENT_USAGE_DOCUMENT = gql`\n query GetBotmanorAgentUsage($id: ID!) {\n getBotmanorAgentUsage(id: $id) {\n bots {\n id\n name\n isDefault\n }\n a2aConnections {\n id\n name\n }\n workflowIds\n }\n }\n`;\n\n/** Returns a function that reads what uses an agent. Reads fresh every time, because a delete is about to rely on it. */\nexport function useLoadAgentUsage() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n\n return useCallback(\n async (agentId: string): Promise<AgentUsage> => {\n const result = await client.query<AgentUsageData>({\n query: GET_AGENT_USAGE_DOCUMENT,\n variables: { id: agentId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load agent usage');\n }\n return (\n result.data?.getBotmanorAgentUsage ?? { bots: [], a2aConnections: [], workflowIds: [] }\n );\n },\n [client]\n );\n}\n\nexport function useAgent(agentId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<AgentRecord | null>(null);\n // Loading from the first render when there is an id to read, so a page never\n // shows \"not found\" (or an empty form) for the frame before the read starts.\n const [loading, setLoading] = useState(Boolean(agentId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!agentId) {\n setData(null);\n setLoading(false);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetAgentData>({\n query: GET_AGENT_DOCUMENT,\n variables: { id: agentId },\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load agent');\n }\n setData(result.data?.getBotmanorAgent ?? null);\n } catch (queryError) {\n setData(null);\n setError(queryError instanceof Error ? queryError : new Error('Failed to load agent'));\n } finally {\n setLoading(false);\n }\n }, [agentId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createAgent = useCallback(\n async (input: CreateAgentInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateAgentData>({\n mutation: CREATE_AGENT_DOCUMENT,\n variables: { input },\n });\n throwOperationError(result, 'Failed to create agent');\n\n const createdAgent = result.data?.createBotmanorAgent;\n if (!createdAgent) {\n throw new Error('Failed to create agent');\n }\n\n setState({ data: createdAgent, loading: false, error: undefined });\n return createdAgent;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to create agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createAgent, state] as const;\n}\n\nexport function useUpdateAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateAgent = useCallback(\n async ({ agentId, input }: UpdateAgentInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateAgentData>({\n mutation: UPDATE_AGENT_DOCUMENT,\n variables: { id: agentId, input: buildMutationInput(input, UPDATE_AGENT_FIELDS) },\n });\n throwOperationError(result, 'Failed to update agent');\n\n const updatedAgent = result.data?.updateBotmanorAgent;\n if (!updatedAgent) {\n throw new Error('Failed to update agent');\n }\n\n setState({ data: updatedAgent, loading: false, error: undefined });\n return updatedAgent;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to update agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateAgent, state] as const;\n}\n\nexport function useDeleteAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteAgent = useCallback(\n async (agentId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteAgentData>({\n mutation: DELETE_AGENT_DOCUMENT,\n variables: { id: agentId },\n });\n throwOperationError(result, 'Failed to delete agent');\n\n const deleted = result.data?.deleteBotmanorAgent ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to delete agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteAgent, state] as const;\n}\n\n// ============================================================================\n// VERSIONING (BOFF-4381) — version history, publish, rollback\n// ============================================================================\n\nexport function useAgentVersions(agentId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<AgentVersionRecord[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!agentId) {\n setData([]);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<ListAgentVersionsData>({\n query: LIST_AGENT_VERSIONS_DOCUMENT,\n variables: { agentId, pagination: { limit: 50, offset: 0 } },\n fetchPolicy: 'network-only',\n });\n const versions = result.data?.listAgentVersions ?? [];\n // Newest first, regardless of what the server returned.\n setData(\n [...versions].sort((a, b) =>\n a.createdAt && b.createdAt ? b.createdAt.localeCompare(a.createdAt) : 0\n )\n );\n } catch (queryError) {\n setError(\n queryError instanceof Error ? queryError : new Error('Failed to load agent versions')\n );\n } finally {\n setLoading(false);\n }\n }, [agentId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function usePublishAgentVersion() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentVersionRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const publishAgentVersion = useCallback(\n async ({\n agentId,\n versionId,\n changelog,\n }: {\n agentId: string;\n versionId: string;\n changelog?: string;\n }) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<PublishAgentVersionData>({\n mutation: PUBLISH_AGENT_VERSION_DOCUMENT,\n variables: { agentId, versionId, changelog: changelog?.trim() || undefined },\n });\n\n const published = result.data?.publishAgentVersion;\n if (!published) {\n throw new Error('Failed to publish agent version');\n }\n\n setState({ data: published, loading: false, error: undefined });\n return published;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error\n ? mutationError\n : new Error('Failed to publish agent version');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [publishAgentVersion, state] as const;\n}\n\nexport function useRollbackAgentVersion() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentVersionRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const rollbackAgentVersion = useCallback(\n async ({ agentId, targetVersionId }: { agentId: string; targetVersionId: string }) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<RollbackAgentVersionData>({\n mutation: ROLLBACK_AGENT_VERSION_DOCUMENT,\n variables: { agentId, targetVersionId },\n });\n\n const rolledBack = result.data?.rollbackAgentVersion;\n if (!rolledBack) {\n throw new Error('Failed to roll back agent version');\n }\n\n setState({ data: rolledBack, loading: false, error: undefined });\n return rolledBack;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error\n ? mutationError\n : new Error('Failed to roll back agent version');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [rollbackAgentVersion, state] as const;\n}\n"],"mappings":";;;;;;;;;AAoBA,IAAMA,IAAqB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCxBC,IAAwB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;GA2B3BC,IAAwB,CAAG;;;;;;;;;;;;;;;;;;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EAC7D,IAAI;GAMF,IAAM+B,KAAa,MALEnD,EAAO,OAAiC;IAC3D,UAAUX;IACV,WAAW;KAAE;KAAS;IAAgB;GACxC,CAAC,EAAA,CAEyB,MAAM;GAChC,IAAI,CAAC8D,GACH,MAAU,MAAM,mCAAmC;GAIrD,OADAjB,EAAS;IAAE,MAAMiB;IAAY,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACxDA;EACT,SAASf,GAAe;GACtB,IAAMT,IACJS,aAAyB,QACrBA,IACA,gBAAI,MAAM,mCAAmC;GAEnD,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CP;EACR;CACF,GACA,CAAC3B,CAAM,CAGD,GAAsBiC,CAAK;AACrC"}
|
|
1
|
+
{"version":3,"file":"useAgents.js","names":["GET_AGENT_DOCUMENT","CREATE_AGENT_DOCUMENT","UPDATE_AGENT_DOCUMENT","DELETE_AGENT_DOCUMENT","PUBLISH_AGENT_VERSION_DOCUMENT","ROLLBACK_AGENT_VERSION_DOCUMENT","LIST_PAGE_SIZE","NO_AGENTS","UPDATE_AGENT_FIELDS","fieldsOf","throwOperationError","operationError","result","graphqlErrorMessage","fallback","getWorkspaceClient","client","buildAgentFilter","workspaceId","filter","useAgents","useBotlit","variables","useMemo","useWorkspacePaginatedQuery","ListBotmanorAgentsPageDocument","data","rows","options","GET_AGENT_COUNTS_DOCUMENT","useAgentCounts","useWorkspaceQuery","enabled","GET_AGENT_USAGE_DOCUMENT","useLoadAgentUsage","useGatewayClient","useCallback","agentId","useAgent","setData","useState","loading","setLoading","error","setError","refetch","queryError","useEffect","useCreateAgent","state","setState","createdAgent","mutationError","useUpdateAgent","buildMutationInput","input","updatedAgent","useDeleteAgent","deleted","NO_AGENT_VERSIONS","useAgentVersions","ListBotmanorAgentVersionsPageDocument","b","a","usePublishAgentVersion","published","changelog","useRollbackAgentVersion","rolledBack"],"sources":["../../../src/botlit/hooks/useAgents.ts"],"sourcesContent":["import { gql, type ApolloClient } from '@apollo/client';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport {\n ListBotmanorAgentsPageDocument,\n ListBotmanorAgentVersionsPageDocument,\n type ListBotmanorAgentVersionsPageQuery,\n type ListBotmanorAgentsPageQuery,\n} from '../../generated/wspace-operations';\nimport type { UpdateBotmanorAgentInput } from '../../generated/wspace-types';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport type { AgentFilter } from '../types';\nimport { graphqlErrorMessage } from '../utils/errors';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst GET_AGENT_DOCUMENT = gql`\n query GetBotmanorAgent($id: ID!) {\n getBotmanorAgent(id: $id) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n bucketId\n currentVersionId\n draftVersionId\n executionCount\n lastExecutedAt\n specialization\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n knowledgeBaseIds\n mcpConnectionIds\n workflowIds\n tagIds\n tags\n metadata\n createdAt\n updatedAt\n createdById\n updatedById\n workspaceId\n }\n }\n`;\n\nconst CREATE_AGENT_DOCUMENT = gql`\n mutation CreateBotmanorAgent($input: CreateBotmanorAgentInput!) {\n createBotmanorAgent(input: $input) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n tagIds\n tags\n createdAt\n updatedAt\n workspaceId\n }\n }\n`;\n\nconst UPDATE_AGENT_DOCUMENT = gql`\n mutation UpdateBotmanorAgent($id: ID!, $input: UpdateBotmanorAgentInput!) {\n updateBotmanorAgent(id: $id, input: $input) {\n id\n name\n slug\n description\n avatar\n type\n status\n visibility\n capabilities\n llmModelId\n fallbackModelIds\n systemPrompt\n temperature\n maxTokens\n maxConcurrentExecutions\n knowledgeBaseIds\n mcpConnectionIds\n workflowIds\n tagIds\n tags\n metadata\n createdAt\n updatedAt\n updatedById\n workspaceId\n }\n }\n`;\n\nconst DELETE_AGENT_DOCUMENT = gql`\n mutation DeleteBotmanorAgent($id: ID!) {\n deleteBotmanorAgent(id: $id)\n }\n`;\n\n// BOFF-4381: agent version history, publish, and rollback.\nconst PUBLISH_AGENT_VERSION_DOCUMENT = gql`\n mutation PublishAgentVersion($agentId: ID!, $versionId: ID!, $changelog: String) {\n publishAgentVersion(agentId: $agentId, versionId: $versionId, changelog: $changelog) {\n id\n agentId\n version\n status\n changelog\n publishedById\n publishedAt\n }\n }\n`;\n\nconst ROLLBACK_AGENT_VERSION_DOCUMENT = gql`\n mutation RollbackAgentVersion($agentId: ID!, $targetVersionId: ID!) {\n rollbackAgentVersion(agentId: $agentId, targetVersionId: $targetVersionId) {\n id\n agentId\n version\n status\n changelog\n publishedById\n publishedAt\n }\n }\n`;\n\ntype WorkspaceClient = ApolloClient;\n\nexport interface AgentRecord {\n id: string;\n name: string;\n slug: string;\n description?: string | null;\n /** Emoji chosen for the agent; null means the default. */\n avatar?: string | null;\n type: string;\n status: string;\n visibility?: string | null;\n capabilities?: string[] | null;\n llmModelId?: string | null;\n /** BOFF-15360 — ordered fallback models. */\n fallbackModelIds?: string[] | null;\n bucketId?: string | null;\n currentVersionId?: string | null;\n draftVersionId?: string | null;\n executionCount?: number | null;\n lastExecutedAt?: string | null;\n specialization?: string | null;\n systemPrompt?: string | null;\n temperature?: number | null;\n maxTokens?: number | null;\n maxConcurrentExecutions?: number | null;\n knowledgeBaseIds?: string[] | null;\n mcpConnectionIds?: string[] | null;\n workflowIds?: string[] | null;\n tagIds?: string[] | null;\n /** Entity-owned universal tag records (JSON). */\n tags?: unknown;\n metadata?: Record<string, unknown> | null;\n createdAt?: string | null;\n updatedAt?: string | null;\n createdById?: string | null;\n updatedById?: string | null;\n workspaceId?: string | null;\n}\n\nconst LIST_PAGE_SIZE = 100;\nconst NO_AGENTS: AgentRecord[] = [];\n\ninterface GetAgentData {\n getBotmanorAgent: AgentRecord | null;\n}\n\ninterface CreateAgentData {\n createBotmanorAgent: AgentRecord;\n}\n\ninterface UpdateAgentData {\n updateBotmanorAgent: AgentRecord;\n}\n\ninterface DeleteAgentData {\n deleteBotmanorAgent: boolean;\n}\n\nexport interface AgentVersionRecord {\n id: string;\n agentId: string;\n version: string;\n status: 'DRAFT' | 'PUBLISHED' | 'HISTORICAL';\n changelog?: string | null;\n config?: Record<string, unknown> | null;\n createdById?: string | null;\n createdAt?: string | null;\n publishedById?: string | null;\n publishedAt?: string | null;\n}\n\ninterface PublishAgentVersionData {\n publishAgentVersion: AgentVersionRecord;\n}\n\ninterface RollbackAgentVersionData {\n rollbackAgentVersion: AgentVersionRecord;\n}\n\ninterface AgentMutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\ninterface CreateAgentInput {\n workspaceId: string;\n name: string;\n slug?: string;\n description?: string;\n avatar?: string;\n type: string;\n systemPrompt: string;\n temperature?: number;\n maxTokens?: number;\n maxConcurrentExecutions?: number;\n capabilities?: string[];\n llmModelId?: string;\n fallbackModelIds?: string[];\n knowledgeBaseIds?: string[];\n mcpConnectionIds?: string[];\n visibility?: string;\n}\n\ninterface UpdateAgentInput {\n agentId: string;\n input: GraphQLInput<UpdateBotmanorAgentInput>;\n}\n\nconst UPDATE_AGENT_FIELDS = fieldsOf<UpdateBotmanorAgentInput>({\n avatar: true,\n bucketId: true,\n capabilities: true,\n context: true,\n description: true,\n knowledgeBaseIds: true,\n llmModelId: true,\n fallbackModelIds: true,\n maxConcurrentExecutions: true,\n maxTokens: true,\n mcpConnectionIds: true,\n metadata: true,\n name: true,\n slug: true,\n specialization: true,\n status: true,\n systemPrompt: true,\n tagIds: true,\n tags: true,\n temperature: true,\n type: true,\n visibility: true,\n workflowIds: true,\n});\n\n/**\n * Apollo v4 resolves a mutation with `result.error` set (and no data) when the\n * server answers with a GraphQL error, instead of rejecting. Throw it so the\n * caller sees the server's actionable message (\"An agent named ... already\n * exists\") and not the generic fallback.\n */\nfunction throwOperationError(result: unknown, fallback: string): void {\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw new Error(graphqlErrorMessage(operationError, fallback), { cause: operationError });\n }\n}\n\nfunction getWorkspaceClient(client: unknown): WorkspaceClient {\n return client as WorkspaceClient;\n}\n\nfunction buildAgentFilter(\n workspaceId: string | undefined,\n filter?: AgentFilter\n): Record<string, unknown> | undefined {\n if (!workspaceId && !filter) return undefined;\n\n return {\n workspaceId,\n search: filter?.search,\n status: filter?.status?.[0],\n visibility: filter?.visibility?.[0],\n bucketId: filter?.bucketId,\n };\n}\n\nexport const agentKeys = {\n all: ['agents'] as const,\n lists: () => [...agentKeys.all, 'list'] as const,\n list: (filter?: AgentFilter) => [...agentKeys.lists(), filter] as const,\n details: () => [...agentKeys.all, 'detail'] as const,\n detail: (id: string) => [...agentKeys.details(), id] as const,\n};\n\nexport function useAgents(\n filter?: AgentFilter,\n options?: { enabled?: boolean }\n): PaginatedQueryResult<AgentRecord[]> {\n const { workspaceId } = useBotlit();\n\n const variables = useMemo(\n () => ({ filters: buildAgentFilter(workspaceId, filter) }),\n [filter, workspaceId]\n );\n\n return useWorkspacePaginatedQuery<ListBotmanorAgentsPageQuery, AgentRecord, AgentRecord[]>({\n document: ListBotmanorAgentsPageDocument,\n variables,\n pageSize: LIST_PAGE_SIZE,\n extractRows: (data) => data?.listBotmanorAgentsPage.items ?? [],\n extractNextOffset: (data) => data?.listBotmanorAgentsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_AGENTS,\n enabled: Boolean(workspaceId) && options?.enabled !== false,\n errorMessage: 'Failed to load agents',\n });\n}\n\n/**\n * Exact agent counts by status for the workspace (BOFF-12426). Unlike\n * `useAgents` this is not capped at one page, so it is the source for\n * dashboard totals. `total` counts every status.\n */\nexport interface AgentCounts {\n total: number;\n draft: number;\n active: number;\n paused: number;\n training: number;\n archived: number;\n}\n\ninterface AgentCountsData {\n getBotmanorAgentCounts?: AgentCounts | null;\n}\n\nconst GET_AGENT_COUNTS_DOCUMENT = gql`\n query GetBotmanorAgentCounts {\n getBotmanorAgentCounts {\n total\n draft\n active\n paused\n training\n archived\n }\n }\n`;\n\nexport function useAgentCounts(enabled = true): QueryResult<AgentCounts | null> {\n const { workspaceId } = useBotlit();\n const variables = useMemo(() => ({}), []);\n\n return useWorkspaceQuery<AgentCountsData, AgentCounts | null>({\n document: GET_AGENT_COUNTS_DOCUMENT,\n variables,\n select: (data) => data?.getBotmanorAgentCounts ?? null,\n fallback: null,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load agent counts',\n });\n}\n\n/** What still uses an agent, shown in the delete confirmation (BOFF-12457). */\nexport interface AgentUsage {\n bots: Array<{ id: string; name: string; isDefault: boolean }>;\n a2aConnections: Array<{ id: string; name: string }>;\n workflowIds: string[];\n}\n\ninterface AgentUsageData {\n getBotmanorAgentUsage?: AgentUsage | null;\n}\n\nconst GET_AGENT_USAGE_DOCUMENT = gql`\n query GetBotmanorAgentUsage($id: ID!) {\n getBotmanorAgentUsage(id: $id) {\n bots {\n id\n name\n isDefault\n }\n a2aConnections {\n id\n name\n }\n workflowIds\n }\n }\n`;\n\n/** Returns a function that reads what uses an agent. Reads fresh every time, because a delete is about to rely on it. */\nexport function useLoadAgentUsage() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n\n return useCallback(\n async (agentId: string): Promise<AgentUsage> => {\n const result = await client.query<AgentUsageData>({\n query: GET_AGENT_USAGE_DOCUMENT,\n variables: { id: agentId },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error\n ? operationError\n : new Error('Failed to load agent usage');\n }\n return (\n result.data?.getBotmanorAgentUsage ?? { bots: [], a2aConnections: [], workflowIds: [] }\n );\n },\n [client]\n );\n}\n\nexport function useAgent(agentId: string | undefined) {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [data, setData] = useState<AgentRecord | null>(null);\n // Loading from the first render when there is an id to read, so a page never\n // shows \"not found\" (or an empty form) for the frame before the read starts.\n const [loading, setLoading] = useState(Boolean(agentId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!agentId) {\n setData(null);\n setLoading(false);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<GetAgentData>({\n query: GET_AGENT_DOCUMENT,\n variables: { id: agentId },\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL errors.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw operationError instanceof Error ? operationError : new Error('Failed to load agent');\n }\n setData(result.data?.getBotmanorAgent ?? null);\n } catch (queryError) {\n setData(null);\n setError(queryError instanceof Error ? queryError : new Error('Failed to load agent'));\n } finally {\n setLoading(false);\n }\n }, [agentId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\nexport function useCreateAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const createAgent = useCallback(\n async (input: CreateAgentInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<CreateAgentData>({\n mutation: CREATE_AGENT_DOCUMENT,\n variables: { input },\n });\n throwOperationError(result, 'Failed to create agent');\n\n const createdAgent = result.data?.createBotmanorAgent;\n if (!createdAgent) {\n throw new Error('Failed to create agent');\n }\n\n setState({ data: createdAgent, loading: false, error: undefined });\n return createdAgent;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to create agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [createAgent, state] as const;\n}\n\nexport function useUpdateAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const updateAgent = useCallback(\n async ({ agentId, input }: UpdateAgentInput) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<UpdateAgentData>({\n mutation: UPDATE_AGENT_DOCUMENT,\n variables: { id: agentId, input: buildMutationInput(input, UPDATE_AGENT_FIELDS) },\n });\n throwOperationError(result, 'Failed to update agent');\n\n const updatedAgent = result.data?.updateBotmanorAgent;\n if (!updatedAgent) {\n throw new Error('Failed to update agent');\n }\n\n setState({ data: updatedAgent, loading: false, error: undefined });\n return updatedAgent;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to update agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [updateAgent, state] as const;\n}\n\nexport function useDeleteAgent() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<boolean>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const deleteAgent = useCallback(\n async (agentId: string) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<DeleteAgentData>({\n mutation: DELETE_AGENT_DOCUMENT,\n variables: { id: agentId },\n });\n throwOperationError(result, 'Failed to delete agent');\n\n const deleted = result.data?.deleteBotmanorAgent ?? false;\n setState({ data: deleted, loading: false, error: undefined });\n return deleted;\n } catch (mutationError) {\n const error = new Error(graphqlErrorMessage(mutationError, 'Failed to delete agent'), {\n cause: mutationError,\n });\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [deleteAgent, state] as const;\n}\n\n// ============================================================================\n// VERSIONING (BOFF-4381) — version history, publish, rollback\n// ============================================================================\n\ntype AgentVersionListItem =\n ListBotmanorAgentVersionsPageQuery['listBotmanorAgentVersionsPage']['items'][number];\nconst NO_AGENT_VERSIONS: AgentVersionRecord[] = [];\n\nexport function useAgentVersions(\n agentId: string | undefined\n): PaginatedQueryResult<AgentVersionRecord[]> {\n const variables = useMemo(() => ({ agentId }), [agentId]);\n return useWorkspacePaginatedQuery<\n ListBotmanorAgentVersionsPageQuery,\n AgentVersionListItem,\n AgentVersionRecord[]\n >({\n document: ListBotmanorAgentVersionsPageDocument,\n variables,\n pageSize: 50,\n extractRows: (data) => data?.listBotmanorAgentVersionsPage.items,\n extractNextOffset: (data) => data?.listBotmanorAgentVersionsPage.nextOffset ?? null,\n select: (rows) => [...rows].sort((a, b) => b.createdAt.localeCompare(a.createdAt)),\n fallback: NO_AGENT_VERSIONS,\n enabled: Boolean(agentId),\n errorMessage: 'Failed to load agent versions',\n });\n}\n\nexport function usePublishAgentVersion() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentVersionRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const publishAgentVersion = useCallback(\n async ({\n agentId,\n versionId,\n changelog,\n }: {\n agentId: string;\n versionId: string;\n changelog?: string;\n }) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<PublishAgentVersionData>({\n mutation: PUBLISH_AGENT_VERSION_DOCUMENT,\n variables: { agentId, versionId, changelog: changelog?.trim() || undefined },\n });\n\n const published = result.data?.publishAgentVersion;\n if (!published) {\n throw new Error('Failed to publish agent version');\n }\n\n setState({ data: published, loading: false, error: undefined });\n return published;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error\n ? mutationError\n : new Error('Failed to publish agent version');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [publishAgentVersion, state] as const;\n}\n\nexport function useRollbackAgentVersion() {\n const client = getWorkspaceClient(useGatewayClient('workspace'));\n const [state, setState] = useState<AgentMutationState<AgentVersionRecord>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const rollbackAgentVersion = useCallback(\n async ({ agentId, targetVersionId }: { agentId: string; targetVersionId: string }) => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<RollbackAgentVersionData>({\n mutation: ROLLBACK_AGENT_VERSION_DOCUMENT,\n variables: { agentId, targetVersionId },\n });\n\n const rolledBack = result.data?.rollbackAgentVersion;\n if (!rolledBack) {\n throw new Error('Failed to roll back agent version');\n }\n\n setState({ data: rolledBack, loading: false, error: undefined });\n return rolledBack;\n } catch (mutationError) {\n const error =\n mutationError instanceof Error\n ? mutationError\n : new Error('Failed to roll back agent version');\n setState({ data: undefined, loading: false, error });\n throw error;\n }\n },\n [client]\n );\n\n return [rollbackAgentVersion, state] as const;\n}\n"],"mappings":";;;;;;;;;AAsBA,IAAMA,IAAqB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCxBC,IAAwB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;GA2B3BC,IAAwB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgC3BC,IAAwB,CAAG;;;;GAO3BC,IAAiC,CAAG;;;;;;;;;;;;GAcpCC,IAAkC,CAAG;;;;;;;;;;;;GAsDrCC,IAAiB,KACjBC,IAA2B,CAAC,GAqE5BC,IAAsBC,EAAmC;CAC7D,QAAQ;CACR,UAAU;CACV,cAAc;CACd,SAAS;CACT,aAAa;CACb,kBAAkB;CAClB,YAAY;CACZ,kBAAkB;CAClB,yBAAyB;CACzB,WAAW;CACX,kBAAkB;CAClB,UAAU;CACV,MAAM;CACN,MAAM;CACN,gBAAgB;CAChB,QAAQ;CACR,cAAc;CACd,QAAQ;CACR,MAAM;CACN,aAAa;CACb,MAAM;CACN,YAAY;CACZ,aAAa;AACf,CAAC;AAQD,SAASC,EAAoB,GAAiB,GAAwB;CACpE,IAAMC,IAAkBC,EAA+B;CACvD,IAAID,KAAkB,MACpB,MAAU,MAAME,EAAoBF,GAAgBG,CAAQ,GAAG,EAAE,OAAOH,EAAe,CA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yBAAoE;EACpF,EAAS;GAAE,MAAM,KAAA;GAAW,SAAS;GAAM,OAAO,KAAA;EAAU,CAAC;EAC7D,IAAI;GAMF,IAAMgC,KAAa,MALEpD,EAAO,OAAiC;IAC3D,UAAUX;IACV,WAAW;KAAE;KAAS;IAAgB;GACxC,CAAC,EAAA,CAEyB,MAAM;GAChC,IAAI,CAAC+D,GACH,MAAU,MAAM,mCAAmC;GAIrD,OADAlB,EAAS;IAAE,MAAMkB;IAAY,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACxDA;EACT,SAAShB,GAAe;GACtB,IAAMT,IACJS,aAAyB,QACrBA,IACA,gBAAI,MAAM,mCAAmC;GAEnD,MADAF,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO;GAAM,CAAC,GAC7CP;EACR;CACF,GACA,CAAC3B,CAAM,CAGD,GAAsBiC,CAAK;AACrC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PaginatedQueryResult } from './internal/workspaceGateway';
|
|
2
2
|
export type BotVersionStatus = 'DRAFT' | 'PUBLISHED' | 'HISTORICAL';
|
|
3
3
|
export interface BotVersionRecord {
|
|
4
4
|
id: string;
|
|
@@ -11,7 +11,7 @@ export interface BotVersionRecord {
|
|
|
11
11
|
}
|
|
12
12
|
/** Newest first, whatever order the server returned. */
|
|
13
13
|
export declare function sortVersionsNewestFirst(versions: readonly BotVersionRecord[]): BotVersionRecord[];
|
|
14
|
-
export declare function useBotVersions(botId: string | undefined):
|
|
14
|
+
export declare function useBotVersions(botId: string | undefined): PaginatedQueryResult<BotVersionRecord[]>;
|
|
15
15
|
export interface PublishBotVersionInput {
|
|
16
16
|
botId: string;
|
|
17
17
|
versionId: string;
|
|
@@ -1,48 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ListBotmanorAppVersionsPageDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useWorkspaceMutation as t, useWorkspacePaginatedQuery as n } from "./internal/workspaceGateway.js";
|
|
3
|
+
import { useMemo as r } from "react";
|
|
4
|
+
import { gql as i } from "@apollo/client";
|
|
4
5
|
// src/botlit/hooks/useBotVersions.ts
|
|
5
|
-
var
|
|
6
|
-
query ListBotAppVersions($botAppId: ID!, $pagination: PaginationInput) {
|
|
7
|
-
listBotAppVersions(botAppId: $botAppId, pagination: $pagination) {
|
|
8
|
-
${i}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`, o = r`
|
|
6
|
+
var a = "\n id\n botAppId\n version\n status\n changelog\n createdAt\n publishedAt\n", o = i`
|
|
12
7
|
mutation PublishBotAppVersion($botAppId: ID!, $versionId: ID!, $changelog: String) {
|
|
13
8
|
publishBotAppVersion(botAppId: $botAppId, versionId: $versionId, changelog: $changelog) {
|
|
14
|
-
${
|
|
9
|
+
${a}
|
|
15
10
|
}
|
|
16
11
|
}
|
|
17
|
-
`, s =
|
|
12
|
+
`, s = i`
|
|
18
13
|
mutation RollbackBotAppVersion($botAppId: ID!, $targetVersionId: ID!) {
|
|
19
14
|
rollbackBotAppVersion(botAppId: $botAppId, targetVersionId: $targetVersionId) {
|
|
20
|
-
${
|
|
15
|
+
${a}
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
`, c = [];
|
|
24
19
|
function l(e) {
|
|
25
20
|
return [...e].sort((e, t) => e.createdAt && t.createdAt ? t.createdAt.localeCompare(e.createdAt) : 0);
|
|
26
21
|
}
|
|
27
|
-
function u(
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
document: a,
|
|
37
|
-
variables: r,
|
|
38
|
-
select: (e) => l(e?.listBotAppVersions ?? c),
|
|
22
|
+
function u(t) {
|
|
23
|
+
let i = r(() => ({ botAppId: t }), [t]);
|
|
24
|
+
return n({
|
|
25
|
+
document: e,
|
|
26
|
+
variables: i,
|
|
27
|
+
pageSize: 50,
|
|
28
|
+
extractRows: (e) => e?.listBotmanorAppVersionsPage.items,
|
|
29
|
+
extractNextOffset: (e) => e?.listBotmanorAppVersionsPage.nextOffset ?? null,
|
|
30
|
+
select: l,
|
|
39
31
|
fallback: c,
|
|
40
|
-
enabled: !!
|
|
32
|
+
enabled: !!t,
|
|
41
33
|
errorMessage: "Failed to load bot versions"
|
|
42
34
|
});
|
|
43
35
|
}
|
|
44
36
|
function d() {
|
|
45
|
-
return
|
|
37
|
+
return t({
|
|
46
38
|
document: o,
|
|
47
39
|
variables: ({ botId: e, versionId: t, changelog: n }) => ({
|
|
48
40
|
botAppId: e,
|
|
@@ -54,7 +46,7 @@ function d() {
|
|
|
54
46
|
});
|
|
55
47
|
}
|
|
56
48
|
function f() {
|
|
57
|
-
return
|
|
49
|
+
return t({
|
|
58
50
|
document: s,
|
|
59
51
|
variables: ({ botId: e, targetVersionId: t }) => ({
|
|
60
52
|
botAppId: e,
|