@burdenoff/microfe-botmanor 2026.1120.10 → 2026.1120.11

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.
@@ -0,0 +1,170 @@
1
+ import { useWorkspaceId as e, useWorkspaceMutation as t, useWorkspaceQuery as n } from "./internal/workspaceGateway.js";
2
+ import { useMemo as r } from "react";
3
+ import { gql as i } from "@apollo/client";
4
+ // src/botlit/hooks/useAgentTuning.ts
5
+ var a = "\n id\n agentId\n kind\n status\n title\n recommendation\n severity\n score\n confidence\n change {\n type\n before\n after\n fallbackBefore\n fallbackAfter\n knowledgeBaseId\n }\n topics\n evidence\n draftedBy\n modelVersion\n generatedAt\n appliedAt\n", o = i`
6
+ query BotmanorAgentSuggestions($agentId: ID!) {
7
+ agentSuggestions(agentId: $agentId) {
8
+ ${a}
9
+ }
10
+ }
11
+ `, s = i`
12
+ mutation BotmanorSuggestAgentImprovements($agentId: ID!) {
13
+ suggestAgentImprovements(agentId: $agentId) {
14
+ agentId
15
+ runsAnalyzed
16
+ windowDays
17
+ suppressed
18
+ modelDrafted
19
+ suggestions {
20
+ ${a}
21
+ }
22
+ }
23
+ }
24
+ `, c = i`
25
+ mutation BotmanorAcceptAgentSuggestion($id: ID!) {
26
+ acceptAgentSuggestion(id: $id) {
27
+ draftChanged
28
+ suggestion {
29
+ ${a}
30
+ }
31
+ }
32
+ }
33
+ `, l = i`
34
+ mutation BotmanorDismissAgentSuggestion($id: ID!) {
35
+ dismissAgentSuggestion(id: $id) {
36
+ ${a}
37
+ }
38
+ }
39
+ `, u = i`
40
+ mutation BotmanorRateExecution($id: ID!, $rating: ExecutionFeedbackRating!) {
41
+ rateExecution(id: $id, rating: $rating) {
42
+ id
43
+ feedbackRating
44
+ feedbackAt
45
+ }
46
+ }
47
+ `, d = i`
48
+ mutation BotmanorSetKnowledgeBaseRefreshInterval($id: ID!, $days: Int) {
49
+ setKnowledgeBaseRefreshInterval(id: $id, days: $days) {
50
+ id
51
+ refreshIntervalDays
52
+ lastReviewedAt
53
+ }
54
+ }
55
+ `, f = i`
56
+ mutation BotmanorMarkKnowledgeBaseReviewed($id: ID!) {
57
+ markKnowledgeBaseReviewed(id: $id) {
58
+ id
59
+ refreshIntervalDays
60
+ lastReviewedAt
61
+ }
62
+ }
63
+ `, p = i`
64
+ query BotmanorKnowledgeBaseReviewSchedule($id: ID!) {
65
+ getKnowledgeBase(id: $id) {
66
+ id
67
+ refreshIntervalDays
68
+ lastReviewedAt
69
+ }
70
+ }
71
+ `, m = [];
72
+ function h(t) {
73
+ let i = e(), a = r(() => t ? { agentId: t } : void 0, [t]);
74
+ return n({
75
+ document: o,
76
+ variables: a,
77
+ enabled: !!i && !!t,
78
+ errorMessage: "Failed to load suggestions.",
79
+ fallback: m,
80
+ select: (e) => e?.agentSuggestions ?? m
81
+ });
82
+ }
83
+ function g() {
84
+ return t({
85
+ document: s,
86
+ variables: (e) => ({ agentId: e }),
87
+ select: (e) => e?.suggestAgentImprovements,
88
+ errorMessage: "Failed to generate suggestions."
89
+ });
90
+ }
91
+ function _() {
92
+ return t({
93
+ document: c,
94
+ variables: (e) => ({ id: e }),
95
+ select: (e) => e?.acceptAgentSuggestion,
96
+ errorMessage: "Failed to accept the suggestion."
97
+ });
98
+ }
99
+ function v() {
100
+ return t({
101
+ document: l,
102
+ variables: (e) => ({ id: e }),
103
+ select: (e) => e?.dismissAgentSuggestion,
104
+ errorMessage: "Failed to dismiss the suggestion."
105
+ });
106
+ }
107
+ function y() {
108
+ return t({
109
+ document: u,
110
+ variables: (e) => ({
111
+ id: e.id,
112
+ rating: e.rating
113
+ }),
114
+ select: (e) => e?.rateExecution,
115
+ errorMessage: "Failed to save the rating."
116
+ });
117
+ }
118
+ function b(t) {
119
+ let i = e(), a = r(() => t ? { id: t } : void 0, [t]);
120
+ return n({
121
+ document: p,
122
+ variables: a,
123
+ enabled: !!i && !!t,
124
+ errorMessage: "Failed to load the review schedule.",
125
+ fallback: void 0,
126
+ select: (e) => e?.getKnowledgeBase ?? void 0
127
+ });
128
+ }
129
+ function x() {
130
+ return t({
131
+ document: d,
132
+ variables: (e) => ({
133
+ id: e.id,
134
+ days: e.days
135
+ }),
136
+ select: (e) => e?.setKnowledgeBaseRefreshInterval,
137
+ errorMessage: "Failed to save the review interval."
138
+ });
139
+ }
140
+ function S() {
141
+ return t({
142
+ document: f,
143
+ variables: (e) => ({ id: e }),
144
+ select: (e) => e?.markKnowledgeBaseReviewed,
145
+ errorMessage: "Failed to mark the knowledge base reviewed."
146
+ });
147
+ }
148
+ var C = i`
149
+ query BotmanorExecutionFeedback($id: ID!) {
150
+ getExecution(id: $id) {
151
+ id
152
+ feedbackRating
153
+ feedbackAt
154
+ }
155
+ }
156
+ `;
157
+ function w(t) {
158
+ let i = e(), a = r(() => t ? { id: t } : void 0, [t]);
159
+ return n({
160
+ document: C,
161
+ variables: a,
162
+ enabled: !!i && !!t,
163
+ errorMessage: "Failed to load the rating.",
164
+ fallback: void 0,
165
+ select: (e) => e?.getExecution ?? void 0
166
+ });
167
+ }
168
+ export { _ as useAcceptAgentSuggestion, h as useAgentSuggestions, v as useDismissAgentSuggestion, w as useExecutionFeedback, b as useKnowledgeReviewSchedule, S as useMarkKnowledgeReviewed, y as useRateExecution, x as useSetKnowledgeRefreshInterval, g as useSuggestAgentImprovements };
169
+
170
+ //# sourceMappingURL=useAgentTuning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAgentTuning.js","names":["SUGGESTION_FIELDS","LIST_DOCUMENT","SUGGEST_DOCUMENT","ACCEPT_DOCUMENT","DISMISS_DOCUMENT","RATE_DOCUMENT","REFRESH_INTERVAL_DOCUMENT","MARK_REVIEWED_DOCUMENT","REVIEW_SCHEDULE_DOCUMENT","NO_SUGGESTIONS","useAgentSuggestions","workspaceId","useWorkspaceId","variables","useMemo","agentId","useWorkspaceQuery","data","useSuggestAgentImprovements","useWorkspaceMutation","useAcceptAgentSuggestion","useDismissAgentSuggestion","useRateExecution","input","useKnowledgeReviewSchedule","knowledgeBaseId","useSetKnowledgeRefreshInterval","useMarkKnowledgeReviewed","EXECUTION_FEEDBACK_DOCUMENT","useExecutionFeedback","executionId"],"sources":["../../../src/botlit/hooks/useAgentTuning.ts"],"sourcesContent":["/**\n * Evidence-based agent tuning and knowledge review hooks (BOFF-15360).\n *\n * Wrap the `agent-tuning` fields of wspace-botmanor-svc:\n * - `agentSuggestions` / `suggestAgentImprovements` / `acceptAgentSuggestion`\n * / `dismissAgentSuggestion` — the accept-or-dismiss cards on an agent;\n * - `rateExecution` — a reviewer's good/poor rating of a run's answer;\n * - `setKnowledgeBaseRefreshInterval` / `markKnowledgeBaseReviewed` — a\n * knowledge base's review schedule.\n */\nimport { gql } from '@apollo/client';\nimport { useMemo } from 'react';\n\nimport {\n type MutationState,\n type QueryResult,\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n} from './internal/workspaceGateway';\n\nexport type AgentSuggestionKind =\n 'PROMPT_EDIT' | 'KNOWLEDGE_GAP' | 'MODEL_CHANGE' | 'KNOWLEDGE_OVERDUE' | 'KNOWLEDGE_CONFLICT';\n\nexport interface AgentSuggestionChange {\n type: 'SYSTEM_PROMPT' | 'MODEL' | 'KNOWLEDGE_REVIEW';\n before: string | null;\n after: string | null;\n fallbackBefore: string[] | null;\n fallbackAfter: string[] | null;\n knowledgeBaseId: string | null;\n}\n\nexport interface AgentSuggestion {\n id: string;\n agentId: string;\n kind: AgentSuggestionKind;\n status: string;\n title: string;\n recommendation: string;\n severity: string;\n score: number;\n confidence: number;\n change: AgentSuggestionChange | null;\n topics: string[];\n evidence: Record<string, unknown>;\n draftedBy: 'MODEL' | 'RULES';\n modelVersion: string;\n generatedAt: string;\n appliedAt: string | null;\n}\n\nexport interface AgentSuggestionRun {\n suggestions: AgentSuggestion[];\n runsAnalyzed: number;\n windowDays: number;\n suppressed: number;\n modelDrafted: boolean;\n}\n\nconst SUGGESTION_FIELDS = `\n id\n agentId\n kind\n status\n title\n recommendation\n severity\n score\n confidence\n change {\n type\n before\n after\n fallbackBefore\n fallbackAfter\n knowledgeBaseId\n }\n topics\n evidence\n draftedBy\n modelVersion\n generatedAt\n appliedAt\n`;\n\nconst LIST_DOCUMENT = gql`\n query BotmanorAgentSuggestions($agentId: ID!) {\n agentSuggestions(agentId: $agentId) {\n ${SUGGESTION_FIELDS}\n }\n }\n`;\n\nconst SUGGEST_DOCUMENT = gql`\n mutation BotmanorSuggestAgentImprovements($agentId: ID!) {\n suggestAgentImprovements(agentId: $agentId) {\n agentId\n runsAnalyzed\n windowDays\n suppressed\n modelDrafted\n suggestions {\n ${SUGGESTION_FIELDS}\n }\n }\n }\n`;\n\nconst ACCEPT_DOCUMENT = gql`\n mutation BotmanorAcceptAgentSuggestion($id: ID!) {\n acceptAgentSuggestion(id: $id) {\n draftChanged\n suggestion {\n ${SUGGESTION_FIELDS}\n }\n }\n }\n`;\n\nconst DISMISS_DOCUMENT = gql`\n mutation BotmanorDismissAgentSuggestion($id: ID!) {\n dismissAgentSuggestion(id: $id) {\n ${SUGGESTION_FIELDS}\n }\n }\n`;\n\nconst RATE_DOCUMENT = gql`\n mutation BotmanorRateExecution($id: ID!, $rating: ExecutionFeedbackRating!) {\n rateExecution(id: $id, rating: $rating) {\n id\n feedbackRating\n feedbackAt\n }\n }\n`;\n\nconst REFRESH_INTERVAL_DOCUMENT = gql`\n mutation BotmanorSetKnowledgeBaseRefreshInterval($id: ID!, $days: Int) {\n setKnowledgeBaseRefreshInterval(id: $id, days: $days) {\n id\n refreshIntervalDays\n lastReviewedAt\n }\n }\n`;\n\nconst MARK_REVIEWED_DOCUMENT = gql`\n mutation BotmanorMarkKnowledgeBaseReviewed($id: ID!) {\n markKnowledgeBaseReviewed(id: $id) {\n id\n refreshIntervalDays\n lastReviewedAt\n }\n }\n`;\n\nconst REVIEW_SCHEDULE_DOCUMENT = gql`\n query BotmanorKnowledgeBaseReviewSchedule($id: ID!) {\n getKnowledgeBase(id: $id) {\n id\n refreshIntervalDays\n lastReviewedAt\n }\n }\n`;\n\nconst NO_SUGGESTIONS: AgentSuggestion[] = [];\n\n/** The agent's open suggestions. */\nexport function useAgentSuggestions(agentId: string | undefined): QueryResult<AgentSuggestion[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => (agentId ? { agentId } : undefined), [agentId]);\n return useWorkspaceQuery<{ agentSuggestions?: AgentSuggestion[] }, AgentSuggestion[]>({\n document: LIST_DOCUMENT,\n variables,\n enabled: !!workspaceId && !!agentId,\n errorMessage: 'Failed to load suggestions.',\n fallback: NO_SUGGESTIONS,\n select: (data) => data?.agentSuggestions ?? NO_SUGGESTIONS,\n });\n}\n\nexport function useSuggestAgentImprovements(): readonly [\n (agentId: string) => Promise<AgentSuggestionRun>,\n MutationState<AgentSuggestionRun>,\n] {\n return useWorkspaceMutation<\n { suggestAgentImprovements?: AgentSuggestionRun },\n string,\n AgentSuggestionRun\n >({\n document: SUGGEST_DOCUMENT,\n variables: (agentId) => ({ agentId }),\n select: (data) => data?.suggestAgentImprovements,\n errorMessage: 'Failed to generate suggestions.',\n });\n}\n\nexport function useAcceptAgentSuggestion(): readonly [\n (id: string) => Promise<{ draftChanged: boolean; suggestion: AgentSuggestion }>,\n MutationState<{ draftChanged: boolean; suggestion: AgentSuggestion }>,\n] {\n return useWorkspaceMutation<\n { acceptAgentSuggestion?: { draftChanged: boolean; suggestion: AgentSuggestion } },\n string,\n { draftChanged: boolean; suggestion: AgentSuggestion }\n >({\n document: ACCEPT_DOCUMENT,\n variables: (id) => ({ id }),\n select: (data) => data?.acceptAgentSuggestion,\n errorMessage: 'Failed to accept the suggestion.',\n });\n}\n\nexport function useDismissAgentSuggestion(): readonly [\n (id: string) => Promise<AgentSuggestion>,\n MutationState<AgentSuggestion>,\n] {\n return useWorkspaceMutation<\n { dismissAgentSuggestion?: AgentSuggestion },\n string,\n AgentSuggestion\n >({\n document: DISMISS_DOCUMENT,\n variables: (id) => ({ id }),\n select: (data) => data?.dismissAgentSuggestion,\n errorMessage: 'Failed to dismiss the suggestion.',\n });\n}\n\nexport type ExecutionFeedbackRating = 'GOOD' | 'POOR' | 'CLEAR';\n\nexport interface ExecutionFeedback {\n id: string;\n feedbackRating: number | null;\n feedbackAt: string | null;\n}\n\nexport function useRateExecution(): readonly [\n (input: { id: string; rating: ExecutionFeedbackRating }) => Promise<ExecutionFeedback>,\n MutationState<ExecutionFeedback>,\n] {\n return useWorkspaceMutation<\n { rateExecution?: ExecutionFeedback },\n { id: string; rating: ExecutionFeedbackRating },\n ExecutionFeedback\n >({\n document: RATE_DOCUMENT,\n variables: (input) => ({ id: input.id, rating: input.rating }),\n select: (data) => data?.rateExecution,\n errorMessage: 'Failed to save the rating.',\n });\n}\n\nexport interface KnowledgeReviewSchedule {\n id: string;\n refreshIntervalDays: number | null;\n lastReviewedAt: string | null;\n}\n\nexport function useKnowledgeReviewSchedule(\n knowledgeBaseId: string | undefined\n): QueryResult<KnowledgeReviewSchedule | undefined> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(\n () => (knowledgeBaseId ? { id: knowledgeBaseId } : undefined),\n [knowledgeBaseId]\n );\n return useWorkspaceQuery<\n { getKnowledgeBase?: KnowledgeReviewSchedule | null },\n KnowledgeReviewSchedule | undefined\n >({\n document: REVIEW_SCHEDULE_DOCUMENT,\n variables,\n enabled: !!workspaceId && !!knowledgeBaseId,\n errorMessage: 'Failed to load the review schedule.',\n fallback: undefined,\n select: (data) => data?.getKnowledgeBase ?? undefined,\n });\n}\n\nexport function useSetKnowledgeRefreshInterval(): readonly [\n (input: { id: string; days: number | null }) => Promise<KnowledgeReviewSchedule>,\n MutationState<KnowledgeReviewSchedule>,\n] {\n return useWorkspaceMutation<\n { setKnowledgeBaseRefreshInterval?: KnowledgeReviewSchedule },\n { id: string; days: number | null },\n KnowledgeReviewSchedule\n >({\n document: REFRESH_INTERVAL_DOCUMENT,\n variables: (input) => ({ id: input.id, days: input.days }),\n select: (data) => data?.setKnowledgeBaseRefreshInterval,\n errorMessage: 'Failed to save the review interval.',\n });\n}\n\nexport function useMarkKnowledgeReviewed(): readonly [\n (id: string) => Promise<KnowledgeReviewSchedule>,\n MutationState<KnowledgeReviewSchedule>,\n] {\n return useWorkspaceMutation<\n { markKnowledgeBaseReviewed?: KnowledgeReviewSchedule },\n string,\n KnowledgeReviewSchedule\n >({\n document: MARK_REVIEWED_DOCUMENT,\n variables: (id) => ({ id }),\n select: (data) => data?.markKnowledgeBaseReviewed,\n errorMessage: 'Failed to mark the knowledge base reviewed.',\n });\n}\n\nconst EXECUTION_FEEDBACK_DOCUMENT = gql`\n query BotmanorExecutionFeedback($id: ID!) {\n getExecution(id: $id) {\n id\n feedbackRating\n feedbackAt\n }\n }\n`;\n\n/** The reviewer rating recorded on a run. */\nexport function useExecutionFeedback(\n executionId: string | undefined\n): QueryResult<ExecutionFeedback | undefined> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => (executionId ? { id: executionId } : undefined), [executionId]);\n return useWorkspaceQuery<\n { getExecution?: ExecutionFeedback | null },\n ExecutionFeedback | undefined\n >({\n document: EXECUTION_FEEDBACK_DOCUMENT,\n variables,\n enabled: !!workspaceId && !!executionId,\n errorMessage: 'Failed to load the rating.',\n fallback: undefined,\n select: (data) => data?.getExecution ?? undefined,\n });\n}\n"],"mappings":";;;;AA4DA,IAAMA,IAAoB,oSA0BpBC,IAAgB,CAAG;;;QAGjBD,EAAkB;;;GAKpBE,IAAmB,CAAG;;;;;;;;;UASlBF,EAAkB;;;;GAMtBG,IAAkB,CAAG;;;;;UAKjBH,EAAkB;;;;GAMtBI,IAAmB,CAAG;;;QAGpBJ,EAAkB;;;GAKpBK,IAAgB,CAAG;;;;;;;;GAUnBC,IAA4B,CAAG;;;;;;;;GAU/BC,IAAyB,CAAG;;;;;;;;GAU5BC,IAA2B,CAAG;;;;;;;;GAU9BC,IAAoC,CAAC;AAG3C,SAAgBC,EAAoB,GAA6D;CAC/F,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,QA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Ac;CAChB,CAAC;AACH;AAEA,SAAgBU,IAGd;CACA,OAAOR,EAIL;EACA,UAAUZ;EACV,YAAY,OAAQ,EAAE,MAAG;EACzB,SAAS,MAASU,GAAM;EACxB,cAAc;CAChB,CAAC;AACH;AAEA,IAAMW,IAA8B,CAAG;;;;;;;;;AAWvC,SAAgBC,EACd,GAC4C;CAC5C,IAAMlB,IAAcC,EAAe,GAC7BC,IAAYC,QAAegB,IAAc,EAAE,IAAIA,EAAY,IAAI,KAAA,GAAY,CAACA,CAAW,CAAC;CAC9F,OAAOd,EAGL;EACA,UAAUY;EACV;EACA,SAAS,CAAC,CAACjB,KAAe,CAAC,CAACmB;EAC5B,cAAc;EACd,UAAU,KAAA;EACV,SAAS,MAASb,GAAM,gBAAgB,KAAA;CAC1C,CAAC;AACH"}
@@ -24,7 +24,7 @@ function p(e) {
24
24
  enabled: !!t,
25
25
  errorMessage: "Failed to load AI operations findings.",
26
26
  fallback: d,
27
- select: (e) => (e?.aiPredictions.items ?? []).map((e) => ({
27
+ select: (e) => (e?.aiPredictions.items ?? []).filter((e) => !e.predictionType.startsWith("agent_tuning.")).map((e) => ({
28
28
  id: e.id,
29
29
  predictionType: e.predictionType,
30
30
  subjectType: e.subjectType ?? null,
@@ -1 +1 @@
1
- {"version":3,"file":"useAiOperations.js","names":["LIST_LIMIT","NO_PREDICTIONS","NO_RUNS","useAiPredictions","workspaceId","useWorkspaceId","filter","variables","useMemo","gqlFilter","subjectType","subjectId","status","useWorkspaceQuery","ListAiPredictionsDocument","data","item","useSetAiPredictionStatus","useWorkspaceMutation","SetAiPredictionStatusDocument","input","row","useSupervisorConfig","GetSupervisorConfigDocument","config","useConfigureSupervisor","ConfigureSupervisorDocument","useRunSupervisorNow","RunSupervisorNowDocument","result","run","useSupervisorRuns","ListSupervisorRunsDocument","predictionSeverity","severity","record","\"severity\"","predictionSubjectName","name","\"subjectName\""],"sources":["../../../src/botlit/hooks/useAiOperations.ts"],"sourcesContent":["/**\n * AI Operations hooks (BOFF-3839)\n * @module botlit/hooks\n *\n * Backed by the supervisor surface on wspace-botmanor-svc: the AiPrediction\n * feed (findings as decision cards), the supervisor configuration, run-now\n * and the run history. Read conventions come from `useExecutions`\n * (network-only, explicit error state, caller-driven refetch).\n */\n\nimport { useMemo } from 'react';\nimport {\n ConfigureSupervisorDocument,\n GetSupervisorConfigDocument,\n ListAiPredictionsDocument,\n ListSupervisorRunsDocument,\n RunSupervisorNowDocument,\n SetAiPredictionStatusDocument,\n type ConfigureSupervisorMutation,\n type ConfigureSupervisorMutationVariables,\n type GetSupervisorConfigQuery,\n type ListAiPredictionsQuery,\n type ListSupervisorRunsQuery,\n type RunSupervisorNowMutation,\n type SetAiPredictionStatusMutation,\n type SetAiPredictionStatusMutationVariables,\n} from '../../generated/wspace-operations';\nimport type {\n AiPredictionFilterInput,\n AiPredictionStatus,\n ConfigureSupervisorInput,\n} from '../../generated/wspace-types';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface AiPredictionRecord {\n id: string;\n predictionType: string;\n subjectType: string | null;\n subjectId: string | null;\n score: number;\n confidence: number;\n recommendation: string;\n status: string;\n features: Record<string, unknown> | null;\n /** Supervisor metadata: fingerprint, severity, subjectName, runId. */\n metadata: Record<string, unknown> | null;\n generatedAt: string;\n}\n\nexport interface AiPredictionsFilter {\n subjectType?: string;\n subjectId?: string;\n status?: string;\n}\n\nexport interface SupervisorConfigRecord {\n enabled: boolean;\n cron: string;\n timezone: string;\n lastRunAt: string | null;\n updatedAt: string;\n}\n\nexport interface SupervisorRunRecord {\n id: string;\n trigger: string;\n status: string;\n findings: number;\n notified: number;\n error: string | null;\n startedAt: string;\n completedAt: string | null;\n}\n\nconst NO_PREDICTIONS: AiPredictionRecord[] = [];\nconst NO_RUNS: SupervisorRunRecord[] = [];\n\nexport const aiOperationsKeys = {\n all: ['ai-operations'] as const,\n predictions: (filter?: AiPredictionsFilter) =>\n [...aiOperationsKeys.all, 'predictions', filter] as const,\n config: () => [...aiOperationsKeys.all, 'config'] as const,\n runs: () => [...aiOperationsKeys.all, 'runs'] as const,\n};\n\n/** Decision-card feed, optionally narrowed to one subject (agent/app/KB). */\nexport function useAiPredictions(filter?: AiPredictionsFilter): QueryResult<AiPredictionRecord[]> {\n const workspaceId = useWorkspaceId();\n const { subjectType, subjectId, status } = filter ?? {};\n\n const variables = useMemo(() => {\n const gqlFilter: AiPredictionFilterInput = { sourceProduct: 'botmanor' };\n if (subjectType) gqlFilter.subjectType = subjectType;\n if (subjectId) gqlFilter.subjectId = subjectId;\n if (status) gqlFilter.status = status as AiPredictionStatus;\n return { filter: gqlFilter, pagination: { limit: LIST_LIMIT, offset: 0 } };\n }, [subjectType, subjectId, status]);\n\n return useWorkspaceQuery<ListAiPredictionsQuery, AiPredictionRecord[]>({\n document: ListAiPredictionsDocument,\n variables,\n enabled: !!workspaceId,\n errorMessage: 'Failed to load AI operations findings.',\n fallback: NO_PREDICTIONS,\n select: (data) =>\n (data?.aiPredictions.items ?? []).map((item) => ({\n id: item.id,\n predictionType: item.predictionType,\n subjectType: item.subjectType ?? null,\n subjectId: item.subjectId ?? null,\n score: item.score,\n confidence: item.confidence,\n recommendation: item.recommendation,\n status: item.status,\n features: (item.features ?? null) as Record<string, unknown> | null,\n metadata: (item.metadata ?? null) as Record<string, unknown> | null,\n generatedAt: item.generatedAt,\n })),\n });\n}\n\n/** Accept / dismiss one finding. Callers refetch the feed afterwards. */\nexport function useSetAiPredictionStatus(): readonly [\n (input: { id: string; status: AiPredictionStatus }) => Promise<{ id: string; status: string }>,\n { data: { id: string; status: string } | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<\n SetAiPredictionStatusMutation,\n { id: string; status: AiPredictionStatus },\n { id: string; status: string }\n >({\n document: SetAiPredictionStatusDocument,\n variables: (input) =>\n ({ id: input.id, status: input.status }) as SetAiPredictionStatusMutationVariables,\n select: (data) => {\n const row = data?.setAiPredictionStatus;\n return row ? { id: row.id, status: row.status } : undefined;\n },\n errorMessage: 'Failed to update the finding.',\n });\n}\n\nexport function useSupervisorConfig(): QueryResult<SupervisorConfigRecord | undefined> {\n const workspaceId = useWorkspaceId();\n return useWorkspaceQuery<GetSupervisorConfigQuery, SupervisorConfigRecord | undefined>({\n document: GetSupervisorConfigDocument,\n variables: {},\n enabled: !!workspaceId,\n errorMessage: 'Failed to load the supervisor configuration.',\n fallback: undefined,\n select: (data) => {\n const config = data?.supervisorConfig;\n if (!config) return undefined;\n return {\n enabled: config.enabled,\n cron: config.cron,\n timezone: config.timezone,\n lastRunAt: config.lastRunAt ?? null,\n updatedAt: config.updatedAt,\n };\n },\n });\n}\n\nexport function useConfigureSupervisor(): readonly [\n (input: {\n enabled?: boolean;\n cron?: string;\n timezone?: string;\n }) => Promise<SupervisorConfigRecord>,\n { data: SupervisorConfigRecord | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<\n ConfigureSupervisorMutation,\n ConfigureSupervisorInput,\n SupervisorConfigRecord\n >({\n document: ConfigureSupervisorDocument,\n variables: (input) => ({ input }) as ConfigureSupervisorMutationVariables,\n select: (data) => {\n const config = data?.configureSupervisor;\n if (!config) return undefined;\n return {\n enabled: config.enabled,\n cron: config.cron,\n timezone: config.timezone,\n lastRunAt: config.lastRunAt ?? null,\n updatedAt: config.updatedAt,\n };\n },\n errorMessage: 'Failed to save the supervisor configuration.',\n });\n}\n\nexport interface RunSupervisorNowResult {\n run: SupervisorRunRecord | null;\n findings: number;\n}\n\n/** Manual fleet review (the scheduled path is the FluidGrids cron tick). */\nexport function useRunSupervisorNow(): readonly [\n () => Promise<RunSupervisorNowResult>,\n { data: RunSupervisorNowResult | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<RunSupervisorNowMutation, void, RunSupervisorNowResult>({\n document: RunSupervisorNowDocument,\n variables: () => ({}),\n select: (data) => {\n const result = data?.runSupervisorNow;\n if (!result) return undefined;\n const run = result.run;\n return {\n findings: result.findings,\n run: run\n ? {\n id: run.id,\n trigger: run.trigger,\n status: run.status,\n findings: run.findings,\n notified: run.notified,\n error: run.error ?? null,\n startedAt: run.startedAt,\n completedAt: run.completedAt ?? null,\n }\n : null,\n };\n },\n errorMessage: 'Failed to run the supervisor review.',\n });\n}\n\nexport function useSupervisorRuns(): QueryResult<SupervisorRunRecord[]> {\n const workspaceId = useWorkspaceId();\n return useWorkspaceQuery<ListSupervisorRunsQuery, SupervisorRunRecord[]>({\n document: ListSupervisorRunsDocument,\n variables: { pagination: { limit: 20, offset: 0 } },\n enabled: !!workspaceId,\n errorMessage: 'Failed to load the supervisor run history.',\n fallback: NO_RUNS,\n select: (data) =>\n (data?.supervisorRuns.items ?? []).map((run) => ({\n id: run.id,\n trigger: run.trigger,\n status: run.status,\n findings: run.findings,\n notified: run.notified,\n error: run.error ?? null,\n startedAt: run.startedAt,\n completedAt: run.completedAt ?? null,\n })),\n });\n}\n\n/** Severity from supervisor metadata (WARNING/CRITICAL/INFO), defaulting to INFO. */\nexport function predictionSeverity(record: AiPredictionRecord): string {\n const severity = record.metadata?.['severity'];\n return typeof severity === 'string' ? severity : 'INFO';\n}\n\n/** Human name the supervisor recorded for the subject, when present. */\nexport function predictionSubjectName(record: AiPredictionRecord): string {\n const name = record.metadata?.['subjectName'];\n if (typeof name === 'string' && name.length > 0) return name;\n return record.subjectId ?? record.predictionType;\n}\n"],"mappings":";;;;AAuCA,IAAMA,IAAa,IA0CbC,IAAuC,CAAC,GACxCC,IAAiC,CAAC;AAWxC,SAAgBC,EAAiB,GAAiE;CAChG,IAAMC,IAAcC,EAAe,GAC7B,EAAE,gBAAa,cAAW,cAAWC,KAAU,CAAC,GAEhDC,IAAYC,QAAc;EAC9B,IAAMC,IAAqC,EAAE,eAAe,WAAW;EAIvE,OAHIC,MAAa,EAAU,cAAcA,IACrCC,MAAW,EAAU,YAAYA,IACjCC,MAAQ,EAAU,SAASA,IACx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AAWI;CAE/B,OADI,OAAOD,KAAS,YAAYA,EAAK,SAAS,IAAUA,IACjDH,EAAO,aAAaA,EAAO;AACpC"}
1
+ {"version":3,"file":"useAiOperations.js","names":["LIST_LIMIT","NO_PREDICTIONS","NO_RUNS","useAiPredictions","workspaceId","useWorkspaceId","filter","variables","useMemo","gqlFilter","subjectType","subjectId","status","useWorkspaceQuery","ListAiPredictionsDocument","data","item","useSetAiPredictionStatus","useWorkspaceMutation","SetAiPredictionStatusDocument","input","row","useSupervisorConfig","GetSupervisorConfigDocument","config","useConfigureSupervisor","ConfigureSupervisorDocument","useRunSupervisorNow","RunSupervisorNowDocument","result","run","useSupervisorRuns","ListSupervisorRunsDocument","predictionSeverity","severity","record","\"severity\"","predictionSubjectName","name","\"subjectName\""],"sources":["../../../src/botlit/hooks/useAiOperations.ts"],"sourcesContent":["/**\n * AI Operations hooks (BOFF-3839)\n * @module botlit/hooks\n *\n * Backed by the supervisor surface on wspace-botmanor-svc: the AiPrediction\n * feed (findings as decision cards), the supervisor configuration, run-now\n * and the run history. Read conventions come from `useExecutions`\n * (network-only, explicit error state, caller-driven refetch).\n */\n\nimport { useMemo } from 'react';\nimport {\n ConfigureSupervisorDocument,\n GetSupervisorConfigDocument,\n ListAiPredictionsDocument,\n ListSupervisorRunsDocument,\n RunSupervisorNowDocument,\n SetAiPredictionStatusDocument,\n type ConfigureSupervisorMutation,\n type ConfigureSupervisorMutationVariables,\n type GetSupervisorConfigQuery,\n type ListAiPredictionsQuery,\n type ListSupervisorRunsQuery,\n type RunSupervisorNowMutation,\n type SetAiPredictionStatusMutation,\n type SetAiPredictionStatusMutationVariables,\n} from '../../generated/wspace-operations';\nimport type {\n AiPredictionFilterInput,\n AiPredictionStatus,\n ConfigureSupervisorInput,\n} from '../../generated/wspace-types';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface AiPredictionRecord {\n id: string;\n predictionType: string;\n subjectType: string | null;\n subjectId: string | null;\n score: number;\n confidence: number;\n recommendation: string;\n status: string;\n features: Record<string, unknown> | null;\n /** Supervisor metadata: fingerprint, severity, subjectName, runId. */\n metadata: Record<string, unknown> | null;\n generatedAt: string;\n}\n\nexport interface AiPredictionsFilter {\n subjectType?: string;\n subjectId?: string;\n status?: string;\n}\n\nexport interface SupervisorConfigRecord {\n enabled: boolean;\n cron: string;\n timezone: string;\n lastRunAt: string | null;\n updatedAt: string;\n}\n\nexport interface SupervisorRunRecord {\n id: string;\n trigger: string;\n status: string;\n findings: number;\n notified: number;\n error: string | null;\n startedAt: string;\n completedAt: string | null;\n}\n\nconst NO_PREDICTIONS: AiPredictionRecord[] = [];\nconst NO_RUNS: SupervisorRunRecord[] = [];\n\nexport const aiOperationsKeys = {\n all: ['ai-operations'] as const,\n predictions: (filter?: AiPredictionsFilter) =>\n [...aiOperationsKeys.all, 'predictions', filter] as const,\n config: () => [...aiOperationsKeys.all, 'config'] as const,\n runs: () => [...aiOperationsKeys.all, 'runs'] as const,\n};\n\n/** Decision-card feed, optionally narrowed to one subject (agent/app/KB). */\nexport function useAiPredictions(filter?: AiPredictionsFilter): QueryResult<AiPredictionRecord[]> {\n const workspaceId = useWorkspaceId();\n const { subjectType, subjectId, status } = filter ?? {};\n\n const variables = useMemo(() => {\n const gqlFilter: AiPredictionFilterInput = { sourceProduct: 'botmanor' };\n if (subjectType) gqlFilter.subjectType = subjectType;\n if (subjectId) gqlFilter.subjectId = subjectId;\n if (status) gqlFilter.status = status as AiPredictionStatus;\n return { filter: gqlFilter, pagination: { limit: LIST_LIMIT, offset: 0 } };\n }, [subjectType, subjectId, status]);\n\n return useWorkspaceQuery<ListAiPredictionsQuery, AiPredictionRecord[]>({\n document: ListAiPredictionsDocument,\n variables,\n enabled: !!workspaceId,\n errorMessage: 'Failed to load AI operations findings.',\n fallback: NO_PREDICTIONS,\n select: (data) =>\n (data?.aiPredictions.items ?? [])\n // BOFF-15360: agent tuning suggestions have their own panel and accept\n // path (acceptAgentSuggestion); they are not supervisor findings.\n .filter((item) => !item.predictionType.startsWith('agent_tuning.'))\n .map((item) => ({\n id: item.id,\n predictionType: item.predictionType,\n subjectType: item.subjectType ?? null,\n subjectId: item.subjectId ?? null,\n score: item.score,\n confidence: item.confidence,\n recommendation: item.recommendation,\n status: item.status,\n features: (item.features ?? null) as Record<string, unknown> | null,\n metadata: (item.metadata ?? null) as Record<string, unknown> | null,\n generatedAt: item.generatedAt,\n })),\n });\n}\n\n/** Accept / dismiss one finding. Callers refetch the feed afterwards. */\nexport function useSetAiPredictionStatus(): readonly [\n (input: { id: string; status: AiPredictionStatus }) => Promise<{ id: string; status: string }>,\n { data: { id: string; status: string } | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<\n SetAiPredictionStatusMutation,\n { id: string; status: AiPredictionStatus },\n { id: string; status: string }\n >({\n document: SetAiPredictionStatusDocument,\n variables: (input) =>\n ({ id: input.id, status: input.status }) as SetAiPredictionStatusMutationVariables,\n select: (data) => {\n const row = data?.setAiPredictionStatus;\n return row ? { id: row.id, status: row.status } : undefined;\n },\n errorMessage: 'Failed to update the finding.',\n });\n}\n\nexport function useSupervisorConfig(): QueryResult<SupervisorConfigRecord | undefined> {\n const workspaceId = useWorkspaceId();\n return useWorkspaceQuery<GetSupervisorConfigQuery, SupervisorConfigRecord | undefined>({\n document: GetSupervisorConfigDocument,\n variables: {},\n enabled: !!workspaceId,\n errorMessage: 'Failed to load the supervisor configuration.',\n fallback: undefined,\n select: (data) => {\n const config = data?.supervisorConfig;\n if (!config) return undefined;\n return {\n enabled: config.enabled,\n cron: config.cron,\n timezone: config.timezone,\n lastRunAt: config.lastRunAt ?? null,\n updatedAt: config.updatedAt,\n };\n },\n });\n}\n\nexport function useConfigureSupervisor(): readonly [\n (input: {\n enabled?: boolean;\n cron?: string;\n timezone?: string;\n }) => Promise<SupervisorConfigRecord>,\n { data: SupervisorConfigRecord | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<\n ConfigureSupervisorMutation,\n ConfigureSupervisorInput,\n SupervisorConfigRecord\n >({\n document: ConfigureSupervisorDocument,\n variables: (input) => ({ input }) as ConfigureSupervisorMutationVariables,\n select: (data) => {\n const config = data?.configureSupervisor;\n if (!config) return undefined;\n return {\n enabled: config.enabled,\n cron: config.cron,\n timezone: config.timezone,\n lastRunAt: config.lastRunAt ?? null,\n updatedAt: config.updatedAt,\n };\n },\n errorMessage: 'Failed to save the supervisor configuration.',\n });\n}\n\nexport interface RunSupervisorNowResult {\n run: SupervisorRunRecord | null;\n findings: number;\n}\n\n/** Manual fleet review (the scheduled path is the FluidGrids cron tick). */\nexport function useRunSupervisorNow(): readonly [\n () => Promise<RunSupervisorNowResult>,\n { data: RunSupervisorNowResult | undefined; loading: boolean; error: Error | undefined },\n] {\n return useWorkspaceMutation<RunSupervisorNowMutation, void, RunSupervisorNowResult>({\n document: RunSupervisorNowDocument,\n variables: () => ({}),\n select: (data) => {\n const result = data?.runSupervisorNow;\n if (!result) return undefined;\n const run = result.run;\n return {\n findings: result.findings,\n run: run\n ? {\n id: run.id,\n trigger: run.trigger,\n status: run.status,\n findings: run.findings,\n notified: run.notified,\n error: run.error ?? null,\n startedAt: run.startedAt,\n completedAt: run.completedAt ?? null,\n }\n : null,\n };\n },\n errorMessage: 'Failed to run the supervisor review.',\n });\n}\n\nexport function useSupervisorRuns(): QueryResult<SupervisorRunRecord[]> {\n const workspaceId = useWorkspaceId();\n return useWorkspaceQuery<ListSupervisorRunsQuery, SupervisorRunRecord[]>({\n document: ListSupervisorRunsDocument,\n variables: { pagination: { limit: 20, offset: 0 } },\n enabled: !!workspaceId,\n errorMessage: 'Failed to load the supervisor run history.',\n fallback: NO_RUNS,\n select: (data) =>\n (data?.supervisorRuns.items ?? []).map((run) => ({\n id: run.id,\n trigger: run.trigger,\n status: run.status,\n findings: run.findings,\n notified: run.notified,\n error: run.error ?? null,\n startedAt: run.startedAt,\n completedAt: run.completedAt ?? null,\n })),\n });\n}\n\n/** Severity from supervisor metadata (WARNING/CRITICAL/INFO), defaulting to INFO. */\nexport function predictionSeverity(record: AiPredictionRecord): string {\n const severity = record.metadata?.['severity'];\n return typeof severity === 'string' ? severity : 'INFO';\n}\n\n/** Human name the supervisor recorded for the subject, when present. */\nexport function predictionSubjectName(record: AiPredictionRecord): string {\n const name = record.metadata?.['subjectName'];\n if (typeof name === 'string' && name.length > 0) return name;\n return record.subjectId ?? record.predictionType;\n}\n"],"mappings":";;;;AAuCA,IAAMA,IAAa,IA0CbC,IAAuC,CAAC,GACxCC,IAAiC,CAAC;AAWxC,SAAgBC,EAAiB,GAAiE;CAChG,IAAMC,IAAcC,EAAe,GAC7B,EAAE,gBAAa,cAAW,cAAWC,KAAU,CAAC,GAEhDC,IAAYC,QAAc;EAC9B,IAAMC,IAAqC,EAAE,eAAe,WAAW;EAIvE,OAHIC,MAAa,EAAU,cAAcA,IACrCC,MAAW,EAAU,YAAYA,IACjCC,MAAQ,EAAU,SAASA,IACxB;GAAE,QAAQH;GAAW,YAAY;IAAE,OAAOT;IAAY,QAAQ;GAAE;EAAE;CAC3E,GAAG;EAACU;EAAaC;EAAWC;CAAM,CAAC;CAEnC,OAAOC,EAAgE;EACrE,UAAUC;EACV;EACA,SAAS,CAAC,CAACV;EACX,cAAc;EACd,UAAUH;EACV,SAAS,OACNc,GAAM,cAAc,SAAS,CAAC,EAAA,CAG5B,QAAQ,MAAS,CAACC,EAAK,eAAe,WAAW,eAAe,CAAC,CAAC,CAClE,KAAK,OAAU;GACd,IAAIA,EAAK;GACT,gBAAgBA,EAAK;GACrB,aAAaA,EAAK,eAAe;GACjC,WAAWA,EAAK,aAAa;GAC7B,OAAOA,EAAK;GACZ,YAAYA,EAAK;GACjB,gBAAgBA,EAAK;GACrB,QAAQA,EAAK;GACb,UAAWA,EAAK,YAAY;GAC5B,UAAWA,EAAK,YAAY;GAC5B,aAAaA,EAAK;EACpB,EAAE;CACR,C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