@burdenoff/microfe-botmanor 2026.1120.27 → 2026.1123.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/dist/botlit/components/HandoffConfigPanel.js +133 -132
- package/dist/botlit/components/HandoffConfigPanel.js.map +1 -1
- package/dist/botlit/components/HandoffTargetPickers.d.ts +28 -0
- package/dist/botlit/components/HandoffTargetPickers.js +180 -0
- package/dist/botlit/components/HandoffTargetPickers.js.map +1 -0
- package/dist/botlit/hooks/index.js +2 -2
- package/dist/botlit/hooks/useHandoffInbox.d.ts +26 -0
- package/dist/botlit/hooks/useHandoffInbox.js +126 -0
- package/dist/botlit/hooks/useHandoffInbox.js.map +1 -0
- package/dist/botlit/hooks/useHandoffs.js +36 -63
- package/dist/botlit/hooks/useHandoffs.js.map +1 -1
- package/dist/botlit/hooks/useMyIntegrationConnections.d.ts +4 -0
- package/dist/botlit/hooks/useMyIntegrationConnections.js +26 -0
- package/dist/botlit/hooks/useMyIntegrationConnections.js.map +1 -0
- package/dist/botlit/hooks/useWorkspaceMemberDirectory.d.ts +26 -0
- package/dist/botlit/hooks/useWorkspaceMemberDirectory.js +84 -0
- package/dist/botlit/hooks/useWorkspaceMemberDirectory.js.map +1 -0
- package/dist/botlit/pages/AiOperationsPage.js +100 -95
- package/dist/botlit/pages/AiOperationsPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +288 -250
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/HandoffsPage.js +216 -171
- package/dist/botlit/pages/HandoffsPage.js.map +1 -1
- package/dist/botlit/permissions/botmanorPermissions.d.ts +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js +1 -0
- package/dist/botlit/permissions/botmanorPermissions.js.map +1 -1
- package/dist/botlit/utils/handoffInbox.d.ts +64 -0
- package/dist/botlit/utils/handoffInbox.js +62 -0
- package/dist/botlit/utils/handoffInbox.js.map +1 -0
- package/dist/generated/wspace-operations.d.ts +160 -0
- package/dist/generated/wspace-operations.js +128 -87
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.js +8 -6
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BotmanorMyIntegrationConnectionsDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { ConnectionAccessFilter as t } from "../../generated/wspace-types.js";
|
|
3
|
+
import { useWorkspaceId as n, useWorkspaceQuery as r } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useMemo as i } from "react";
|
|
5
|
+
// src/botlit/hooks/useMyIntegrationConnections.ts
|
|
6
|
+
var a = [];
|
|
7
|
+
function o(o) {
|
|
8
|
+
let s = n(), c = i(() => ({
|
|
9
|
+
filter: { access: t.OwnedByMe },
|
|
10
|
+
pagination: {
|
|
11
|
+
limit: 100,
|
|
12
|
+
offset: 0
|
|
13
|
+
}
|
|
14
|
+
}), []);
|
|
15
|
+
return r({
|
|
16
|
+
document: e,
|
|
17
|
+
variables: c,
|
|
18
|
+
select: (e) => e?.getConnections.items ?? a,
|
|
19
|
+
fallback: a,
|
|
20
|
+
enabled: o && !!s,
|
|
21
|
+
errorMessage: "Failed to load your integration connections"
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export { o as useMyIntegrationConnections };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=useMyIntegrationConnections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMyIntegrationConnections.js","names":["NO_CONNECTIONS","useMyIntegrationConnections","workspaceId","useWorkspaceId","variables","useMemo","ConnectionAccessFilter","useWorkspaceQuery","BotmanorMyIntegrationConnectionsDocument","data","enabled"],"sources":["../../../src/botlit/hooks/useMyIntegrationConnections.ts"],"sourcesContent":["/**\n * The caller's own integration connections (BOFF-15472)\n * @module botlit/hooks\n *\n * Feeds the channel \"link your account\" picker, which used to ask people to\n * paste a raw connection id copied from the Integrations page.\n */\n\nimport { useMemo } from 'react';\n\nimport {\n BotmanorMyIntegrationConnectionsDocument,\n type BotmanorMyIntegrationConnectionsQuery,\n} from '../../generated/wspace-operations';\nimport { ConnectionAccessFilter } from '../../generated/wspace-types';\nimport { useWorkspaceId, useWorkspaceQuery, type QueryResult } from './internal/workspaceGateway';\n\nexport type MyIntegrationConnection = NonNullable<\n BotmanorMyIntegrationConnectionsQuery['getConnections']\n>['items'][number];\n\nconst NO_CONNECTIONS: MyIntegrationConnection[] = [];\n\nexport function useMyIntegrationConnections(\n enabled: boolean\n): QueryResult<MyIntegrationConnection[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(\n () => ({\n filter: { access: ConnectionAccessFilter.OwnedByMe },\n pagination: { limit: 100, offset: 0 },\n }),\n []\n );\n return useWorkspaceQuery<BotmanorMyIntegrationConnectionsQuery, MyIntegrationConnection[]>({\n document: BotmanorMyIntegrationConnectionsDocument,\n variables,\n select: (data) => data?.getConnections.items ?? NO_CONNECTIONS,\n fallback: NO_CONNECTIONS,\n enabled: enabled && Boolean(workspaceId),\n errorMessage: 'Failed to load your integration connections',\n });\n}\n"],"mappings":";;;;;AAqBA,IAAMA,IAA4C,CAAC;AAEnD,SAAgBC,EACd,GACwC;CACxC,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SACT;EACL,QAAQ,EAAE,QAAQC,EAAuB,UAAU;EACnD,YAAY;GAAE,OAAO;GAAK,QAAQ;EAAE;CACtC,IACA,CAAC,CACH;CACA,OAAOC,EAAoF;EACzF,UAAUC;EACV;EACA,SAAS,MAASC,GAAM,eAAe,SAAST;EAChD,UAAUA;EACV,SAASU,KAAW,EAAQR;EAC5B,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace member directory for pickers (BOFF-15472)
|
|
3
|
+
* @module botlit/hooks
|
|
4
|
+
*
|
|
5
|
+
* Lists the active workspace's members with their membership role and a
|
|
6
|
+
* human identity (name, email), so handoff routing picks teammates by name
|
|
7
|
+
* instead of asking for raw auth user ids. Identity lookup is best effort: a
|
|
8
|
+
* member whose identity cannot be resolved still appears, under a short id.
|
|
9
|
+
*/
|
|
10
|
+
export interface DirectoryMember {
|
|
11
|
+
/** Auth user id — what handoff routing stores. */
|
|
12
|
+
userId: string;
|
|
13
|
+
/** Membership role, e.g. owner, admin, member. */
|
|
14
|
+
role: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
email: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkspaceMemberDirectory {
|
|
19
|
+
members: DirectoryMember[];
|
|
20
|
+
loading: boolean;
|
|
21
|
+
error: Error | undefined;
|
|
22
|
+
refetch: () => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/** Short label for a member whose identity is unknown. */
|
|
25
|
+
export declare function shortUserLabel(userId: string): string;
|
|
26
|
+
export declare function useWorkspaceMemberDirectory(enabled?: boolean): WorkspaceMemberDirectory;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { BotmanorWorkspaceMemberIdentitiesDocument as e, BotmanorWorkspaceMembersDocument as t } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { extractGraphqlFailureMessage as n } from "../utils/errors.js";
|
|
3
|
+
import { useWorkspaceClient as r, useWorkspaceId as i } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as a, useEffect as o, useState as s } from "react";
|
|
5
|
+
// src/botlit/hooks/useWorkspaceMemberDirectory.ts
|
|
6
|
+
var c = 100, l = 1e3, u = 100;
|
|
7
|
+
function d(e) {
|
|
8
|
+
return e.length > 12 ? `${e.slice(0, 8)}…` : e;
|
|
9
|
+
}
|
|
10
|
+
function f(f = !0) {
|
|
11
|
+
let p = r(), m = i(), [h, g] = s([]), [_, v] = s(f && !!m), [y, b] = s(), x = a(async () => {
|
|
12
|
+
if (f && m) {
|
|
13
|
+
v(!0), b(void 0);
|
|
14
|
+
try {
|
|
15
|
+
let n = [];
|
|
16
|
+
for (let e = 0; e < l; e += c) {
|
|
17
|
+
let r = await p.query({
|
|
18
|
+
query: t,
|
|
19
|
+
variables: {
|
|
20
|
+
workspaceId: m,
|
|
21
|
+
pagination: {
|
|
22
|
+
limit: c,
|
|
23
|
+
offset: e
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
fetchPolicy: "network-only"
|
|
27
|
+
}), i = r.error;
|
|
28
|
+
if (i != null) throw i;
|
|
29
|
+
let a = r.data?.workspaceMembers;
|
|
30
|
+
if (n.push(...a?.items ?? []), !a?.hasMore) break;
|
|
31
|
+
}
|
|
32
|
+
let r = n.filter((e) => e.status.toLowerCase() !== "suspended"), i = [...new Set(r.map((e) => e.userId))], a = /* @__PURE__ */ new Map();
|
|
33
|
+
for (let t = 0; t < i.length; t += u) try {
|
|
34
|
+
let n = await p.query({
|
|
35
|
+
query: e,
|
|
36
|
+
variables: {
|
|
37
|
+
workspaceId: m,
|
|
38
|
+
userIds: i.slice(t, t + u)
|
|
39
|
+
},
|
|
40
|
+
fetchPolicy: "network-only"
|
|
41
|
+
});
|
|
42
|
+
for (let e of n.data?.workspaceMemberIdentities ?? []) a.set(e.userId, {
|
|
43
|
+
displayName: e.displayName,
|
|
44
|
+
email: e.email ?? null
|
|
45
|
+
});
|
|
46
|
+
} catch {}
|
|
47
|
+
let o = /* @__PURE__ */ new Set(), s = [];
|
|
48
|
+
for (let e of r) {
|
|
49
|
+
if (o.has(e.userId)) continue;
|
|
50
|
+
o.add(e.userId);
|
|
51
|
+
let t = a.get(e.userId);
|
|
52
|
+
s.push({
|
|
53
|
+
userId: e.userId,
|
|
54
|
+
role: e.role,
|
|
55
|
+
displayName: t?.displayName || t?.email || d(e.userId),
|
|
56
|
+
email: t?.email ?? null
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
s.sort((e, t) => e.displayName.localeCompare(t.displayName)), g(s);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
g([]);
|
|
62
|
+
let t = n(e) ?? (e instanceof Error && e.message ? e.message : "Failed to load workspace members");
|
|
63
|
+
b(Error(t, { cause: e }));
|
|
64
|
+
} finally {
|
|
65
|
+
v(!1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [
|
|
69
|
+
p,
|
|
70
|
+
f,
|
|
71
|
+
m
|
|
72
|
+
]);
|
|
73
|
+
return o(() => {
|
|
74
|
+
x();
|
|
75
|
+
}, [x]), {
|
|
76
|
+
members: h,
|
|
77
|
+
loading: _,
|
|
78
|
+
error: y,
|
|
79
|
+
refetch: x
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export { d as shortUserLabel, f as useWorkspaceMemberDirectory };
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=useWorkspaceMemberDirectory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWorkspaceMemberDirectory.js","names":["PAGE_SIZE","MAX_MEMBERS","IDENTITY_BATCH","shortUserLabel","userId","useWorkspaceMemberDirectory","client","useWorkspaceClient","workspaceId","useWorkspaceId","members","setMembers","useState","loading","setLoading","enabled","error","setError","refetch","useCallback","rows","offset","result","BotmanorWorkspaceMembersDocument","operationError","page","active","row","userIds","identities","start","BotmanorWorkspaceMemberIdentitiesDocument","identity","seen","resolved","a","b","cause","message","extractGraphqlFailureMessage","useEffect"],"sources":["../../../src/botlit/hooks/useWorkspaceMemberDirectory.ts"],"sourcesContent":["/**\n * Workspace member directory for pickers (BOFF-15472)\n * @module botlit/hooks\n *\n * Lists the active workspace's members with their membership role and a\n * human identity (name, email), so handoff routing picks teammates by name\n * instead of asking for raw auth user ids. Identity lookup is best effort: a\n * member whose identity cannot be resolved still appears, under a short id.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\n\nimport {\n BotmanorWorkspaceMemberIdentitiesDocument,\n BotmanorWorkspaceMembersDocument,\n type BotmanorWorkspaceMemberIdentitiesQuery,\n type BotmanorWorkspaceMembersQuery,\n} from '../../generated/wspace-operations';\nimport { extractGraphqlFailureMessage } from '../utils/errors';\nimport { useWorkspaceClient, useWorkspaceId } from './internal/workspaceGateway';\n\nexport interface DirectoryMember {\n /** Auth user id — what handoff routing stores. */\n userId: string;\n /** Membership role, e.g. owner, admin, member. */\n role: string;\n displayName: string;\n email: string | null;\n}\n\nexport interface WorkspaceMemberDirectory {\n members: DirectoryMember[];\n loading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nconst PAGE_SIZE = 100;\n/** Upper bound on members listed in a picker (10 pages). */\nconst MAX_MEMBERS = 1000;\n/** User ids per identity lookup. */\nconst IDENTITY_BATCH = 100;\n\n/** Short label for a member whose identity is unknown. */\nexport function shortUserLabel(userId: string): string {\n return userId.length > 12 ? `${userId.slice(0, 8)}…` : userId;\n}\n\nexport function useWorkspaceMemberDirectory(enabled = true): WorkspaceMemberDirectory {\n const client = useWorkspaceClient();\n const workspaceId = useWorkspaceId();\n const [members, setMembers] = useState<DirectoryMember[]>([]);\n // Loading from the first frame when a read will start, so pickers don't\n // flash \"every teammate is already chosen\" before it does.\n const [loading, setLoading] = useState(enabled && Boolean(workspaceId));\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled || !workspaceId) return;\n setLoading(true);\n setError(undefined);\n try {\n const rows: Array<{ userId: string; role: string; status: string }> = [];\n for (let offset = 0; offset < MAX_MEMBERS; offset += PAGE_SIZE) {\n const result = await client.query<BotmanorWorkspaceMembersQuery>({\n query: BotmanorWorkspaceMembersDocument,\n variables: { workspaceId, pagination: { limit: PAGE_SIZE, offset } },\n fetchPolicy: 'network-only',\n });\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) throw operationError;\n const page = result.data?.workspaceMembers;\n rows.push(...(page?.items ?? []));\n if (!page?.hasMore) break;\n }\n const active = rows.filter((row) => row.status.toLowerCase() !== 'suspended');\n const userIds = [...new Set(active.map((row) => row.userId))];\n\n const identities = new Map<string, { displayName: string; email: string | null }>();\n // In batches, so a large workspace never sends one huge id list.\n for (let start = 0; start < userIds.length; start += IDENTITY_BATCH) {\n try {\n const result = await client.query<BotmanorWorkspaceMemberIdentitiesQuery>({\n query: BotmanorWorkspaceMemberIdentitiesDocument,\n variables: { workspaceId, userIds: userIds.slice(start, start + IDENTITY_BATCH) },\n fetchPolicy: 'network-only',\n });\n for (const identity of result.data?.workspaceMemberIdentities ?? []) {\n identities.set(identity.userId, {\n displayName: identity.displayName,\n email: identity.email ?? null,\n });\n }\n } catch {\n // Best effort: members of this batch stay selectable under their short id.\n }\n }\n\n const seen = new Set<string>();\n const resolved: DirectoryMember[] = [];\n for (const row of active) {\n if (seen.has(row.userId)) continue;\n seen.add(row.userId);\n const identity = identities.get(row.userId);\n resolved.push({\n userId: row.userId,\n role: row.role,\n displayName: identity?.displayName || identity?.email || shortUserLabel(row.userId),\n email: identity?.email ?? null,\n });\n }\n resolved.sort((a, b) => a.displayName.localeCompare(b.displayName));\n setMembers(resolved);\n } catch (cause) {\n setMembers([]);\n const message =\n extractGraphqlFailureMessage(cause) ??\n (cause instanceof Error && cause.message\n ? cause.message\n : 'Failed to load workspace members');\n setError(new Error(message, { cause }));\n } finally {\n setLoading(false);\n }\n }, [client, enabled, workspaceId]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { members, loading, error, refetch };\n}\n"],"mappings":";;;;;AAqCA,IAAMA,IAAY,KAEZC,IAAc,KAEdC,IAAiB;AAGvB,SAAgBC,EAAe,GAAwB;CACrD,OAAOC,EAAO,SAAS,KAAK,GAAGA,EAAO,MAAM,GAAG,CAAC,EAAE,KAAKA;AACzD;AAEA,SAAgBC,EAA4B,IAAU,IAAgC;CACpF,IAAMC,IAASC,EAAmB,GAC5BC,IAAcC,EAAe,GAC7B,CAACC,GAASC,KAAcC,EAA4B,CAAC,CAAC,GAGtD,CAACC,GAASC,KAAcF,EAASG,KAAW,EAAQP,CAAY,GAChE,CAACQ,GAAOC,KAAYL,EAA4B,GAEhDM,IAAUC,EAAY,YAAY;EACtC,IAA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EAAW,IAAIF,EAAI,MAAM;KAC1C,EAAS,KAAK;MACZ,QAAQA,EAAI;MACZ,MAAMA,EAAI;MACV,aAAaK,GAAU,eAAeA,GAAU,SAAS7B,EAAewB,EAAI,MAAM;MAClF,OAAOK,GAAU,SAAS;KAC5B,CAAC;IACH;IAEA,AADAE,EAAS,MAAM,GAAG,MAAMC,EAAE,YAAY,cAAcC,EAAE,WAAW,CAAC,GAClEzB,EAAWuB,CAAQ;GACrB,SAASG,GAAO;IACd,EAAW,CAAC,CAAC;IACb,IAAMC,IACJC,EAA6BF,CAAK,MACjCA,aAAiB,SAASA,EAAM,UAC7BA,EAAM,UACN;IACN,EAAa,MAAMC,GAAS,EAAE,SAAM,CAAC,CAAC;GACxC,UAAU;IACR,EAAW,EAAK;GAClB;EAhEe;CAiEjB,GAAG;EAAChC;EAAQS;EAASP;CAAW,CAAC;CAMjC,OAJAgC,QAAgB;EACd,EAAa;CACf,GAAG,CAACtB,CAAO,CAAC,GAEL;EAAE;EAAS;EAAS;EAAO;CAAQ;AAC5C"}
|
|
@@ -1,115 +1,120 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
2
|
import { PageLayout as t } from "../components/PageLayout.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
3
|
+
import { BOTMANOR_PERMISSIONS as n } from "../permissions/botmanorPermissions.js";
|
|
4
|
+
import { useBotmanorPermission as r } from "../permissions/useBotmanorPermissions.js";
|
|
5
|
+
import { AiOperationsPanel as i } from "../components/AiOperationsPanel.js";
|
|
6
|
+
import { Badge as a } from "../components/Badge.js";
|
|
7
|
+
import { Button as o } from "../components/Button.js";
|
|
8
|
+
import { Card as s, CardContent as c, CardHeader as l, CardTitle as u } from "../components/Card.js";
|
|
9
|
+
import { ErrorState as d } from "../components/ErrorState.js";
|
|
10
|
+
import { Input as f, Label as p } from "../components/Input.js";
|
|
10
11
|
import "../hooks/index.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
12
|
+
import { useConfigureSupervisor as m, useRunSupervisorNow as h, useSupervisorConfig as g, useSupervisorRuns as _ } from "../hooks/useAiOperations.js";
|
|
13
|
+
import { formatRelativeTime as v } from "../utils/formatters.js";
|
|
14
|
+
import "../permissions/index.js";
|
|
15
|
+
import { useState as y } from "react";
|
|
16
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
17
|
+
import { Play as S, ShieldCheck as C } from "lucide-react";
|
|
15
18
|
// src/botlit/pages/AiOperationsPage.tsx
|
|
16
|
-
var
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
var w = "0 9 * * *", T = "UTC", E = ({ canUpdate: t }) => {
|
|
20
|
+
let n = e(), { data: r, loading: i, error: a, refetch: o } = g(), [h, _] = m(), [S, E] = y(null), [D, O] = y(null), [k, A] = y(null), j = r?.enabled ?? !1, M = S ?? r?.cron ?? w, N = D ?? r?.timezone ?? T, P = _.loading || i || !t, F = async (e) => {
|
|
21
|
+
if (t) {
|
|
22
|
+
A(null);
|
|
23
|
+
try {
|
|
24
|
+
await h(e), await o();
|
|
25
|
+
} catch (e) {
|
|
26
|
+
A(e instanceof Error ? e.message : String(e));
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
};
|
|
25
|
-
return
|
|
26
|
-
resource:
|
|
27
|
-
error:
|
|
28
|
-
onRetry: () => void
|
|
29
|
-
}) : /* @__PURE__ */
|
|
30
|
+
return a ? /* @__PURE__ */ b(d, {
|
|
31
|
+
resource: n("botlit.aiOperations.configErrorTitle", "Supervisor configuration"),
|
|
32
|
+
error: a,
|
|
33
|
+
onRetry: () => void o()
|
|
34
|
+
}) : /* @__PURE__ */ x(s, { children: [/* @__PURE__ */ b(l, { children: /* @__PURE__ */ x(u, {
|
|
30
35
|
className: "flex items-center gap-2 text-base",
|
|
31
|
-
children: [/* @__PURE__ */
|
|
32
|
-
}) }), /* @__PURE__ */
|
|
36
|
+
children: [/* @__PURE__ */ b(C, { className: "h-4 w-4" }), n("botlit.aiOperations.configTitle", "Scheduled fleet review")]
|
|
37
|
+
}) }), /* @__PURE__ */ x(c, {
|
|
33
38
|
className: "space-y-4",
|
|
34
39
|
children: [
|
|
35
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ x("label", {
|
|
36
41
|
className: "flex items-center gap-2 text-sm text-text-primary",
|
|
37
|
-
children: [/* @__PURE__ */
|
|
42
|
+
children: [/* @__PURE__ */ b("input", {
|
|
38
43
|
type: "checkbox",
|
|
39
44
|
className: "h-4 w-4",
|
|
40
|
-
checked:
|
|
41
|
-
disabled:
|
|
42
|
-
onChange: (e) => void
|
|
45
|
+
checked: j,
|
|
46
|
+
disabled: P,
|
|
47
|
+
onChange: (e) => void F({
|
|
43
48
|
enabled: e.target.checked,
|
|
44
|
-
cron:
|
|
45
|
-
timezone:
|
|
49
|
+
cron: M,
|
|
50
|
+
timezone: N
|
|
46
51
|
})
|
|
47
|
-
}),
|
|
52
|
+
}), n("botlit.aiOperations.configEnable", "Run the supervisor automatically every day")]
|
|
48
53
|
}),
|
|
49
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ x("div", {
|
|
50
55
|
className: "grid gap-4 sm:grid-cols-2",
|
|
51
|
-
children: [/* @__PURE__ */
|
|
56
|
+
children: [/* @__PURE__ */ x("div", {
|
|
52
57
|
className: "space-y-1.5",
|
|
53
|
-
children: [/* @__PURE__ */
|
|
58
|
+
children: [/* @__PURE__ */ b(p, {
|
|
54
59
|
htmlFor: "supervisor-cron",
|
|
55
|
-
children:
|
|
56
|
-
}), /* @__PURE__ */
|
|
60
|
+
children: n("botlit.aiOperations.cronLabel", "Cron (FluidGrids schedule)")
|
|
61
|
+
}), /* @__PURE__ */ b(f, {
|
|
57
62
|
id: "supervisor-cron",
|
|
58
|
-
value:
|
|
59
|
-
disabled:
|
|
60
|
-
onChange: (e) =>
|
|
61
|
-
onBlur: () => void
|
|
62
|
-
enabled:
|
|
63
|
-
cron:
|
|
64
|
-
timezone:
|
|
63
|
+
value: M,
|
|
64
|
+
disabled: P,
|
|
65
|
+
onChange: (e) => E(e.target.value),
|
|
66
|
+
onBlur: () => void F({
|
|
67
|
+
enabled: j,
|
|
68
|
+
cron: M,
|
|
69
|
+
timezone: N
|
|
65
70
|
}),
|
|
66
|
-
placeholder:
|
|
71
|
+
placeholder: w
|
|
67
72
|
})]
|
|
68
|
-
}), /* @__PURE__ */
|
|
73
|
+
}), /* @__PURE__ */ x("div", {
|
|
69
74
|
className: "space-y-1.5",
|
|
70
|
-
children: [/* @__PURE__ */
|
|
75
|
+
children: [/* @__PURE__ */ b(p, {
|
|
71
76
|
htmlFor: "supervisor-timezone",
|
|
72
|
-
children:
|
|
73
|
-
}), /* @__PURE__ */
|
|
77
|
+
children: n("botlit.aiOperations.timezoneLabel", "Timezone")
|
|
78
|
+
}), /* @__PURE__ */ b(f, {
|
|
74
79
|
id: "supervisor-timezone",
|
|
75
|
-
value:
|
|
76
|
-
disabled:
|
|
77
|
-
onChange: (e) =>
|
|
78
|
-
onBlur: () => void
|
|
79
|
-
enabled:
|
|
80
|
-
cron:
|
|
81
|
-
timezone:
|
|
80
|
+
value: N,
|
|
81
|
+
disabled: P,
|
|
82
|
+
onChange: (e) => O(e.target.value),
|
|
83
|
+
onBlur: () => void F({
|
|
84
|
+
enabled: j,
|
|
85
|
+
cron: M,
|
|
86
|
+
timezone: N
|
|
82
87
|
}),
|
|
83
|
-
placeholder:
|
|
88
|
+
placeholder: T
|
|
84
89
|
})]
|
|
85
90
|
})]
|
|
86
91
|
}),
|
|
87
|
-
|
|
92
|
+
r?.lastRunAt && /* @__PURE__ */ b("p", {
|
|
88
93
|
className: "text-xs text-text-tertiary",
|
|
89
|
-
children:
|
|
94
|
+
children: n("botlit.aiOperations.lastRun", "Last review: {{time}}", { time: v(r.lastRunAt) })
|
|
90
95
|
}),
|
|
91
|
-
|
|
96
|
+
k && /* @__PURE__ */ b("p", {
|
|
92
97
|
className: "text-sm text-status-error-text",
|
|
93
98
|
role: "alert",
|
|
94
|
-
children:
|
|
99
|
+
children: k
|
|
95
100
|
})
|
|
96
101
|
]
|
|
97
102
|
})] });
|
|
98
|
-
},
|
|
99
|
-
let t = e(), { data: n, loading:
|
|
100
|
-
return
|
|
103
|
+
}, D = () => {
|
|
104
|
+
let t = e(), { data: n, loading: r, error: i } = _();
|
|
105
|
+
return i || !r && n.length === 0 ? null : /* @__PURE__ */ x(s, { children: [/* @__PURE__ */ b(l, { children: /* @__PURE__ */ b(u, {
|
|
101
106
|
className: "text-base",
|
|
102
107
|
children: t("botlit.aiOperations.runHistoryTitle", "Review history")
|
|
103
|
-
}) }), /* @__PURE__ */
|
|
108
|
+
}) }), /* @__PURE__ */ b(c, { children: /* @__PURE__ */ b("ul", {
|
|
104
109
|
className: "divide-y divide-border-subtle",
|
|
105
|
-
children: n.map((e) => /* @__PURE__ */
|
|
110
|
+
children: n.map((e) => /* @__PURE__ */ x("li", {
|
|
106
111
|
className: "flex items-center justify-between gap-3 py-2 text-sm",
|
|
107
|
-
children: [/* @__PURE__ */
|
|
112
|
+
children: [/* @__PURE__ */ x("div", {
|
|
108
113
|
className: "flex items-center gap-2",
|
|
109
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ b(a, {
|
|
110
115
|
variant: e.status === "COMPLETED" ? "success" : e.status === "FAILED" ? "destructive" : "secondary",
|
|
111
116
|
children: e.status
|
|
112
|
-
}), /* @__PURE__ */
|
|
117
|
+
}), /* @__PURE__ */ b("span", {
|
|
113
118
|
className: "text-text-secondary",
|
|
114
119
|
children: t("botlit.aiOperations.runMeta", "{{trigger}} · {{findings}} findings · {{notified}} notified", {
|
|
115
120
|
trigger: e.trigger,
|
|
@@ -117,49 +122,49 @@ var S = "0 9 * * *", C = "UTC", w = () => {
|
|
|
117
122
|
notified: e.notified
|
|
118
123
|
})
|
|
119
124
|
})]
|
|
120
|
-
}), /* @__PURE__ */
|
|
125
|
+
}), /* @__PURE__ */ b("span", {
|
|
121
126
|
className: "text-xs text-text-tertiary whitespace-nowrap",
|
|
122
|
-
children:
|
|
127
|
+
children: v(e.startedAt)
|
|
123
128
|
})]
|
|
124
129
|
}, e.id))
|
|
125
130
|
}) })] });
|
|
126
|
-
},
|
|
127
|
-
let
|
|
128
|
-
|
|
131
|
+
}, O = () => {
|
|
132
|
+
let a = e(), s = r(n.AI_PREDICTION_UPDATE), [c, l] = h(), [u, d] = y(null), [f, p] = y(null), m = l.loading, g = async () => {
|
|
133
|
+
d(null), p(null);
|
|
129
134
|
try {
|
|
130
|
-
let e = await
|
|
131
|
-
|
|
135
|
+
let e = await c();
|
|
136
|
+
p(e.run ? a("botlit.aiOperations.runNowSummary", "Review finished: {{status}}, {{findings}} new findings.", {
|
|
132
137
|
status: e.run.status,
|
|
133
138
|
findings: e.findings
|
|
134
|
-
}) :
|
|
139
|
+
}) : a("botlit.aiOperations.runNowSkipped", "Nothing to run — enable the scheduled review first."));
|
|
135
140
|
} catch (e) {
|
|
136
|
-
|
|
141
|
+
d(e instanceof Error ? e.message : String(e));
|
|
137
142
|
}
|
|
138
143
|
};
|
|
139
|
-
return /* @__PURE__ */
|
|
140
|
-
title:
|
|
141
|
-
description:
|
|
142
|
-
actions: /* @__PURE__ */
|
|
144
|
+
return /* @__PURE__ */ b(t, {
|
|
145
|
+
title: a("botlit.aiOperations.title", "AI Operations"),
|
|
146
|
+
description: a("botlit.aiOperations.description", "Supervisor findings across your agent fleet — what drifted, the evidence, and the recommended action."),
|
|
147
|
+
actions: s ? /* @__PURE__ */ x(o, {
|
|
143
148
|
variant: "outline",
|
|
144
|
-
onClick: () => void
|
|
145
|
-
disabled:
|
|
146
|
-
children: [/* @__PURE__ */
|
|
147
|
-
}),
|
|
148
|
-
children: /* @__PURE__ */
|
|
149
|
+
onClick: () => void g(),
|
|
150
|
+
disabled: m,
|
|
151
|
+
children: [/* @__PURE__ */ b(S, { className: "h-4 w-4" }), a("botlit.aiOperations.runNow", "Run review now")]
|
|
152
|
+
}) : null,
|
|
153
|
+
children: /* @__PURE__ */ x("div", {
|
|
149
154
|
className: "space-y-6",
|
|
150
155
|
children: [
|
|
151
|
-
(
|
|
152
|
-
className:
|
|
156
|
+
(u || f) && /* @__PURE__ */ b("p", {
|
|
157
|
+
className: u ? "text-sm text-status-error-text" : "text-sm text-status-success-text",
|
|
153
158
|
role: "status",
|
|
154
|
-
children:
|
|
159
|
+
children: u ?? f
|
|
155
160
|
}),
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ b(i, {}),
|
|
162
|
+
/* @__PURE__ */ b(E, { canUpdate: s }),
|
|
163
|
+
/* @__PURE__ */ b(D, {})
|
|
159
164
|
]
|
|
160
165
|
})
|
|
161
166
|
});
|
|
162
167
|
};
|
|
163
|
-
export {
|
|
168
|
+
export { O as AiOperationsPage };
|
|
164
169
|
|
|
165
170
|
//# sourceMappingURL=AiOperationsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiOperationsPage.js","names":["DEFAULT_CRON","DEFAULT_TIMEZONE","SupervisorConfigSection","useTr","config","useSupervisorConfig","configure","configureState","useConfigureSupervisor","cron","setCron","useState","timezone","setTimezone","saveError","setSaveError","enabled","effectiveCron","effectiveTimezone","busy","loading","save","next","refetch","configureError","error","ErrorState","Card","CardHeader","CardTitle","ShieldCheck","CardContent","event","Label","Input","formatRelativeTime","RunHistorySection","runs","useSupervisorRuns","Badge","run","AiOperationsPage","t","runNow","runNowState","useRunSupervisorNow","runError","setRunError","runSummary","setRunSummary","onRunNow","result","PageLayout","Button","Play","AiOperationsPanel"],"sources":["../../../src/botlit/pages/AiOperationsPage.tsx"],"sourcesContent":["/**\n * AI Operations Page (BOFF-3839)\n * @module botlit/pages\n *\n * The workspace-wide supervisor feed at /botmanor/ai: decision cards, the\n * supervisor schedule configuration (FluidGrids owns the cron — enabling\n * provisions it, disabling removes it), a run-now action and the run\n * history. The same decision-card panel renders narrowed on the agent and\n * bot detail pages.\n */\n\nimport type { FC } from 'react';\nimport { useState } from 'react';\nimport { Play, ShieldCheck } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { AiOperationsPanel } from '../components/AiOperationsPanel';\nimport { Badge } from '../components/Badge';\nimport { Button } from '../components/Button';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/Card';\nimport { ErrorState } from '../components/ErrorState';\nimport { Input, Label } from '../components/Input';\nimport {\n useConfigureSupervisor,\n useRunSupervisorNow,\n useSupervisorConfig,\n useSupervisorRuns,\n} from '../hooks';\nimport { formatRelativeTime } from '../utils/formatters';\n\nconst DEFAULT_CRON = '0 9 * * *';\nconst DEFAULT_TIMEZONE = 'UTC';\n\n/** Schedule configuration: enable switch + cadence, provisioned in FluidGrids. */\nconst SupervisorConfigSection: FC = () => {\n const t = useTr();\n const { data: config, loading, error, refetch } = useSupervisorConfig();\n const [configure, configureState] = useConfigureSupervisor();\n const [cron, setCron] = useState<string | null>(null);\n const [timezone, setTimezone] = useState<string | null>(null);\n const [saveError, setSaveError] = useState<string | null>(null);\n\n const enabled = config?.enabled ?? false;\n const effectiveCron = cron ?? config?.cron ?? DEFAULT_CRON;\n const effectiveTimezone = timezone ?? config?.timezone ?? DEFAULT_TIMEZONE;\n const busy = configureState.loading || loading;\n\n const save = async (next: { enabled: boolean; cron: string; timezone: string }) => {\n setSaveError(null);\n try {\n await configure(next);\n await refetch();\n } catch (configureError) {\n setSaveError(\n configureError instanceof Error ? configureError.message : String(configureError)\n );\n }\n };\n\n if (error) {\n return (\n <ErrorState\n resource={t('botlit.aiOperations.configErrorTitle', 'Supervisor configuration')}\n error={error}\n onRetry={() => void refetch()}\n />\n );\n }\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <ShieldCheck className=\"h-4 w-4\" />\n {t('botlit.aiOperations.configTitle', 'Scheduled fleet review')}\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={enabled}\n disabled={busy}\n onChange={(event) =>\n void save({\n enabled: event.target.checked,\n cron: effectiveCron,\n timezone: effectiveTimezone,\n })\n }\n />\n {t('botlit.aiOperations.configEnable', 'Run the supervisor automatically every day')}\n </label>\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"space-y-1.5\">\n <Label htmlFor=\"supervisor-cron\">\n {t('botlit.aiOperations.cronLabel', 'Cron (FluidGrids schedule)')}\n </Label>\n <Input\n id=\"supervisor-cron\"\n value={effectiveCron}\n disabled={busy}\n onChange={(event) => setCron(event.target.value)}\n onBlur={() =>\n void save({ enabled, cron: effectiveCron, timezone: effectiveTimezone })\n }\n placeholder={DEFAULT_CRON}\n />\n </div>\n <div className=\"space-y-1.5\">\n <Label htmlFor=\"supervisor-timezone\">\n {t('botlit.aiOperations.timezoneLabel', 'Timezone')}\n </Label>\n <Input\n id=\"supervisor-timezone\"\n value={effectiveTimezone}\n disabled={busy}\n onChange={(event) => setTimezone(event.target.value)}\n onBlur={() =>\n void save({ enabled, cron: effectiveCron, timezone: effectiveTimezone })\n }\n placeholder={DEFAULT_TIMEZONE}\n />\n </div>\n </div>\n {config?.lastRunAt && (\n <p className=\"text-xs text-text-tertiary\">\n {t('botlit.aiOperations.lastRun', 'Last review: {{time}}', {\n time: formatRelativeTime(config.lastRunAt),\n })}\n </p>\n )}\n {saveError && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {saveError}\n </p>\n )}\n </CardContent>\n </Card>\n );\n};\n\n/** Recent supervisor runs (both triggers), newest first. */\nconst RunHistorySection: FC = () => {\n const t = useTr();\n const { data: runs, loading, error } = useSupervisorRuns();\n\n if (error || (!loading && runs.length === 0)) return null;\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base\">\n {t('botlit.aiOperations.runHistoryTitle', 'Review history')}\n </CardTitle>\n </CardHeader>\n <CardContent>\n <ul className=\"divide-y divide-border-subtle\">\n {runs.map((run) => (\n <li key={run.id} className=\"flex items-center justify-between gap-3 py-2 text-sm\">\n <div className=\"flex items-center gap-2\">\n <Badge\n variant={\n run.status === 'COMPLETED'\n ? 'success'\n : run.status === 'FAILED'\n ? 'destructive'\n : 'secondary'\n }\n >\n {run.status}\n </Badge>\n <span className=\"text-text-secondary\">\n {t(\n 'botlit.aiOperations.runMeta',\n '{{trigger}} · {{findings}} findings · {{notified}} notified',\n {\n trigger: run.trigger,\n findings: run.findings,\n notified: run.notified,\n }\n )}\n </span>\n </div>\n <span className=\"text-xs text-text-tertiary whitespace-nowrap\">\n {formatRelativeTime(run.startedAt)}\n </span>\n </li>\n ))}\n </ul>\n </CardContent>\n </Card>\n );\n};\n\nexport const AiOperationsPage: FC = () => {\n const t = useTr();\n const [runNow, runNowState] = useRunSupervisorNow();\n const [runError, setRunError] = useState<string | null>(null);\n const [runSummary, setRunSummary] = useState<string | null>(null);\n const busy = runNowState.loading;\n\n const onRunNow = async () => {\n setRunError(null);\n setRunSummary(null);\n try {\n const result = await runNow();\n setRunSummary(\n result.run\n ? t(\n 'botlit.aiOperations.runNowSummary',\n 'Review finished: {{status}}, {{findings}} new findings.',\n {\n status: result.run.status,\n findings: result.findings,\n }\n )\n : t(\n 'botlit.aiOperations.runNowSkipped',\n 'Nothing to run — enable the scheduled review first.'\n )\n );\n } catch (error) {\n setRunError(error instanceof Error ? error.message : String(error));\n }\n };\n\n return (\n <PageLayout\n title={t('botlit.aiOperations.title', 'AI Operations')}\n description={t(\n 'botlit.aiOperations.description',\n 'Supervisor findings across your agent fleet — what drifted, the evidence, and the recommended action.'\n )}\n actions={\n <Button variant=\"outline\" onClick={() => void onRunNow()} disabled={busy}>\n <Play className=\"h-4 w-4\" />\n {t('botlit.aiOperations.runNow', 'Run review now')}\n </Button>\n }\n >\n <div className=\"space-y-6\">\n {(runError || runSummary) && (\n <p\n className={\n runError ? 'text-sm text-status-error-text' : 'text-sm text-status-success-text'\n }\n role=\"status\"\n >\n {runError ?? runSummary}\n </p>\n )}\n <AiOperationsPanel />\n <SupervisorConfigSection />\n <RunHistorySection />\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA8BA,IAAMA,IAAe,aACfC,IAAmB,OAGnBC,UAAoC;CACxC,IAAM,IAAIC,EAAM,GACV,EAAE,MAAMC,GAAQ,YAAS,UAAO,eAAYC,EAAoB,GAChE,CAACC,GAAWC,KAAkBC,EAAuB,GACrD,CAACC,GAAMC,KAAWC,EAAwB,IAAI,GAC9C,CAACC,GAAUC,KAAeF,EAAwB,IAAI,GACtD,CAACG,GAAWC,KAAgBJ,EAAwB,IAAI,GAExDK,IAAUZ,GAAQ,WAAW,IAC7Ba,IAAgBR,KAAQL,GAAQ,QAAQJ,GACxCkB,IAAoBN,KAAYR,GAAQ,YAAYH,GACpDkB,IAAOZ,EAAe,WAAWa,GAEjCC,IAAO,OAAO,MAA+D;EACjF,EAAa,IAAI;EACjB,IAAI;GAEF,AADA,MAAMf,EAAUgB,CAAI,GACpB,MAAMC,EAAQ;EAChB,SAASC,GAAgB;GACvB,EACEA,aAA0B,QAAQA,EAAe,UAAU,OAAOA,CAAc,CAClF;EACF;CACF;CAYA,OAVIC,IAEA,kBAACC,GAAD;EACE,UAAU,EAAE,wCAAwC,0BAA0B;EACvE;EACP,eAAe,KAAKH,EAAQ;CAC7B,CAAA,IAKH,kBAACI,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;EAAW,WAAU;EAArB,UAAA,CACE,kBAACC,GAAD,EAAa,WAAU,UAAW,CAAA,GACjC,EAAE,mCAAmC,wB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O,MACHT,EACE,qCACA,2DACA;IACE,QAAQS,EAAO,IAAI;IACnB,UAAUA,EAAO;GACnB,CACF,IACAT,EACE,qCACA,qDACF,CACN;EACF,SAASjB,GAAO;GACd,EAAYA,aAAiB,QAAQA,EAAM,UAAU,OAAOA,CAAK,CAAC;EACpE;CACF;CAEA,OACE,kBAAC2B,GAAD;EACE,OAAOV,EAAE,6BAA6B,eAAe;EACrD,aAAaA,EACX,mCACA,uGACF;EACA,SACE,kBAACW,GAAD;GAAQ,SAAQ;GAAU,eAAe,KAAKH,EAAS;GAAG,UAAU/B;GAApE,UAAA,CACE,kBAACmC,GAAD,EAAM,WAAU,UAAW,CAAA,GAC1BZ,EAAE,8BAA8B,gBAAgB,CAC3C;;EAGV,UAAA,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA;KACII,KAAYE,MACZ,kBAAC,KAAD;KACE,WACEF,IAAW,mCAAmC;KAEhD,MAAK;KAEJ,UAAAA,KAAYE;IACZ,CAAA;IAEL,kBAACO,GAAD,CAAoB,CAAA;IACpB,kBAACrD,GAAD,CAA0B,CAAA;IAC1B,kBAACkC,GAAD,CAAoB,CAAA;GACjB;;CACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"AiOperationsPage.js","names":["DEFAULT_CRON","DEFAULT_TIMEZONE","SupervisorConfigSection","t","useTr","config","useSupervisorConfig","configure","configureState","useConfigureSupervisor","cron","setCron","useState","timezone","setTimezone","saveError","setSaveError","enabled","effectiveCron","effectiveTimezone","busy","loading","canUpdate","save","next","refetch","configureError","error","ErrorState","Card","CardHeader","CardTitle","ShieldCheck","CardContent","event","Label","Input","formatRelativeTime","RunHistorySection","runs","useSupervisorRuns","Badge","run","AiOperationsPage","useBotmanorPermission","BOTMANOR_PERMISSIONS","runNow","runNowState","useRunSupervisorNow","runError","setRunError","runSummary","setRunSummary","onRunNow","result","PageLayout","Button","Play","AiOperationsPanel"],"sources":["../../../src/botlit/pages/AiOperationsPage.tsx"],"sourcesContent":["/**\n * AI Operations Page (BOFF-3839)\n * @module botlit/pages\n *\n * The workspace-wide supervisor feed at /botmanor/ai: decision cards, the\n * supervisor schedule configuration (FluidGrids owns the cron — enabling\n * provisions it, disabling removes it), a run-now action and the run\n * history. The same decision-card panel renders narrowed on the agent and\n * bot detail pages.\n */\n\nimport type { FC } from 'react';\nimport { useState } from 'react';\nimport { Play, ShieldCheck } from 'lucide-react';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { AiOperationsPanel } from '../components/AiOperationsPanel';\nimport { Badge } from '../components/Badge';\nimport { Button } from '../components/Button';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/Card';\nimport { ErrorState } from '../components/ErrorState';\nimport { Input, Label } from '../components/Input';\nimport {\n useConfigureSupervisor,\n useRunSupervisorNow,\n useSupervisorConfig,\n useSupervisorRuns,\n} from '../hooks';\nimport { formatRelativeTime } from '../utils/formatters';\nimport { BOTMANOR_PERMISSIONS, useBotmanorPermission } from '../permissions';\n\nconst DEFAULT_CRON = '0 9 * * *';\nconst DEFAULT_TIMEZONE = 'UTC';\n\n/** Schedule configuration: enable switch + cadence, provisioned in FluidGrids. */\nconst SupervisorConfigSection: FC<{ canUpdate: boolean }> = ({ canUpdate }) => {\n const t = useTr();\n const { data: config, loading, error, refetch } = useSupervisorConfig();\n const [configure, configureState] = useConfigureSupervisor();\n const [cron, setCron] = useState<string | null>(null);\n const [timezone, setTimezone] = useState<string | null>(null);\n const [saveError, setSaveError] = useState<string | null>(null);\n\n const enabled = config?.enabled ?? false;\n const effectiveCron = cron ?? config?.cron ?? DEFAULT_CRON;\n const effectiveTimezone = timezone ?? config?.timezone ?? DEFAULT_TIMEZONE;\n const busy = configureState.loading || loading || !canUpdate;\n\n const save = async (next: { enabled: boolean; cron: string; timezone: string }) => {\n if (!canUpdate) return;\n setSaveError(null);\n try {\n await configure(next);\n await refetch();\n } catch (configureError) {\n setSaveError(\n configureError instanceof Error ? configureError.message : String(configureError)\n );\n }\n };\n\n if (error) {\n return (\n <ErrorState\n resource={t('botlit.aiOperations.configErrorTitle', 'Supervisor configuration')}\n error={error}\n onRetry={() => void refetch()}\n />\n );\n }\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2 text-base\">\n <ShieldCheck className=\"h-4 w-4\" />\n {t('botlit.aiOperations.configTitle', 'Scheduled fleet review')}\n </CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <label className=\"flex items-center gap-2 text-sm text-text-primary\">\n <input\n type=\"checkbox\"\n className=\"h-4 w-4\"\n checked={enabled}\n disabled={busy}\n onChange={(event) =>\n void save({\n enabled: event.target.checked,\n cron: effectiveCron,\n timezone: effectiveTimezone,\n })\n }\n />\n {t('botlit.aiOperations.configEnable', 'Run the supervisor automatically every day')}\n </label>\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"space-y-1.5\">\n <Label htmlFor=\"supervisor-cron\">\n {t('botlit.aiOperations.cronLabel', 'Cron (FluidGrids schedule)')}\n </Label>\n <Input\n id=\"supervisor-cron\"\n value={effectiveCron}\n disabled={busy}\n onChange={(event) => setCron(event.target.value)}\n onBlur={() =>\n void save({ enabled, cron: effectiveCron, timezone: effectiveTimezone })\n }\n placeholder={DEFAULT_CRON}\n />\n </div>\n <div className=\"space-y-1.5\">\n <Label htmlFor=\"supervisor-timezone\">\n {t('botlit.aiOperations.timezoneLabel', 'Timezone')}\n </Label>\n <Input\n id=\"supervisor-timezone\"\n value={effectiveTimezone}\n disabled={busy}\n onChange={(event) => setTimezone(event.target.value)}\n onBlur={() =>\n void save({ enabled, cron: effectiveCron, timezone: effectiveTimezone })\n }\n placeholder={DEFAULT_TIMEZONE}\n />\n </div>\n </div>\n {config?.lastRunAt && (\n <p className=\"text-xs text-text-tertiary\">\n {t('botlit.aiOperations.lastRun', 'Last review: {{time}}', {\n time: formatRelativeTime(config.lastRunAt),\n })}\n </p>\n )}\n {saveError && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {saveError}\n </p>\n )}\n </CardContent>\n </Card>\n );\n};\n\n/** Recent supervisor runs (both triggers), newest first. */\nconst RunHistorySection: FC = () => {\n const t = useTr();\n const { data: runs, loading, error } = useSupervisorRuns();\n\n if (error || (!loading && runs.length === 0)) return null;\n\n return (\n <Card>\n <CardHeader>\n <CardTitle className=\"text-base\">\n {t('botlit.aiOperations.runHistoryTitle', 'Review history')}\n </CardTitle>\n </CardHeader>\n <CardContent>\n <ul className=\"divide-y divide-border-subtle\">\n {runs.map((run) => (\n <li key={run.id} className=\"flex items-center justify-between gap-3 py-2 text-sm\">\n <div className=\"flex items-center gap-2\">\n <Badge\n variant={\n run.status === 'COMPLETED'\n ? 'success'\n : run.status === 'FAILED'\n ? 'destructive'\n : 'secondary'\n }\n >\n {run.status}\n </Badge>\n <span className=\"text-text-secondary\">\n {t(\n 'botlit.aiOperations.runMeta',\n '{{trigger}} · {{findings}} findings · {{notified}} notified',\n {\n trigger: run.trigger,\n findings: run.findings,\n notified: run.notified,\n }\n )}\n </span>\n </div>\n <span className=\"text-xs text-text-tertiary whitespace-nowrap\">\n {formatRelativeTime(run.startedAt)}\n </span>\n </li>\n ))}\n </ul>\n </CardContent>\n </Card>\n );\n};\n\nexport const AiOperationsPage: FC = () => {\n const t = useTr();\n const canUpdate = useBotmanorPermission(BOTMANOR_PERMISSIONS.AI_PREDICTION_UPDATE);\n const [runNow, runNowState] = useRunSupervisorNow();\n const [runError, setRunError] = useState<string | null>(null);\n const [runSummary, setRunSummary] = useState<string | null>(null);\n const busy = runNowState.loading;\n\n const onRunNow = async () => {\n setRunError(null);\n setRunSummary(null);\n try {\n const result = await runNow();\n setRunSummary(\n result.run\n ? t(\n 'botlit.aiOperations.runNowSummary',\n 'Review finished: {{status}}, {{findings}} new findings.',\n {\n status: result.run.status,\n findings: result.findings,\n }\n )\n : t(\n 'botlit.aiOperations.runNowSkipped',\n 'Nothing to run — enable the scheduled review first.'\n )\n );\n } catch (error) {\n setRunError(error instanceof Error ? error.message : String(error));\n }\n };\n\n return (\n <PageLayout\n title={t('botlit.aiOperations.title', 'AI Operations')}\n description={t(\n 'botlit.aiOperations.description',\n 'Supervisor findings across your agent fleet — what drifted, the evidence, and the recommended action.'\n )}\n actions={\n canUpdate ? (\n <Button variant=\"outline\" onClick={() => void onRunNow()} disabled={busy}>\n <Play className=\"h-4 w-4\" />\n {t('botlit.aiOperations.runNow', 'Run review now')}\n </Button>\n ) : null\n }\n >\n <div className=\"space-y-6\">\n {(runError || runSummary) && (\n <p\n className={\n runError ? 'text-sm text-status-error-text' : 'text-sm text-status-success-text'\n }\n role=\"status\"\n >\n {runError ?? runSummary}\n </p>\n )}\n <AiOperationsPanel />\n <SupervisorConfigSection canUpdate={canUpdate} />\n <RunHistorySection />\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,IAAMA,IAAe,aACfC,IAAmB,OAGnBC,KAAuD,EAAE,mBAAgB;CAC7E,IAAMC,IAAIC,EAAM,GACV,EAAE,MAAMC,GAAQ,YAAS,UAAO,eAAYC,EAAoB,GAChE,CAACC,GAAWC,KAAkBC,EAAuB,GACrD,CAACC,GAAMC,KAAWC,EAAwB,IAAI,GAC9C,CAACC,GAAUC,KAAeF,EAAwB,IAAI,GACtD,CAACG,GAAWC,KAAgBJ,EAAwB,IAAI,GAExDK,IAAUZ,GAAQ,WAAW,IAC7Ba,IAAgBR,KAAQL,GAAQ,QAAQL,GACxCmB,IAAoBN,KAAYR,GAAQ,YAAYJ,GACpDmB,IAAOZ,EAAe,WAAWa,KAAW,CAACC,GAE7CC,IAAO,OAAO,MAA+D;EACjF,IAAKD,GACL;KAAa,IAAI;GACjB,IAAI;IAEF,AADA,MAAMf,EAAUiB,CAAI,GACpB,MAAMC,EAAQ;GAChB,SAASC,GAAgB;IACvB,EACEA,aAA0B,QAAQA,EAAe,UAAU,OAAOA,CAAc,CAClF;GACF;EARiB;CASnB;CAYA,OAVIC,IAEA,kBAACC,GAA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