@burdenoff/microfe-botmanor 2026.1127.3 → 2026.1127.5
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/hooks/useSkills.d.ts +5 -1
- package/dist/botlit/hooks/useSkills.js +55 -37
- package/dist/botlit/hooks/useSkills.js.map +1 -1
- package/dist/botlit/pages/AgentTestChatPage.js +95 -94
- package/dist/botlit/pages/AgentTestChatPage.js.map +1 -1
- package/dist/botlit/pages/BotChannelsTab.js +327 -328
- package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
- package/dist/botlit/pages/MCPServerDetailPage.js +285 -289
- package/dist/botlit/pages/MCPServerDetailPage.js.map +1 -1
- package/dist/botlit/pages/PolicyDetailPage.js +457 -453
- package/dist/botlit/pages/PolicyDetailPage.js.map +1 -1
- package/dist/botlit/pages/RetrievalProfileDetailPage.js +229 -228
- package/dist/botlit/pages/RetrievalProfileDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillDetailPage.js +324 -323
- package/dist/botlit/pages/SkillDetailPage.js.map +1 -1
- package/dist/botlit/pages/SkillsPage.js +171 -150
- package/dist/botlit/pages/SkillsPage.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +45 -0
- package/dist/generated/wspace-operations.js +44 -28
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/shared/hooks/useTr.js +1 -1
- package/dist/shared/hooks/useTr.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { ListBotmanorSkillsPageQuery } from '../../generated/wspace-operations';
|
|
1
2
|
import { CreateSkillInput, UpdateSkillInput } from '../../generated/wspace-types';
|
|
2
3
|
import { GraphQLInput } from './internal/mutationInput';
|
|
3
|
-
import { QueryResult } from './internal/workspaceGateway';
|
|
4
|
+
import { PaginatedQueryResult, QueryResult } from './internal/workspaceGateway';
|
|
4
5
|
export interface SkillRecord {
|
|
5
6
|
id: string;
|
|
6
7
|
name: string;
|
|
@@ -46,6 +47,8 @@ export declare const skillKeys: {
|
|
|
46
47
|
detail: (id: string) => readonly ["skills", "detail", string];
|
|
47
48
|
};
|
|
48
49
|
export declare function useSkills(filter?: SkillFilterVariables): QueryResult<SkillRecord[]>;
|
|
50
|
+
type SkillListItem = ListBotmanorSkillsPageQuery['listBotmanorSkillsPage']['items'][number];
|
|
51
|
+
export declare function useSkillsPage(search: string): PaginatedQueryResult<SkillListItem[]>;
|
|
49
52
|
export declare function useSkill(skillId: string | undefined): QueryResult<SkillRecord | null>;
|
|
50
53
|
export declare function useCreateSkill(): {
|
|
51
54
|
create: (input: CreateSkillVariables) => Promise<SkillRecord>;
|
|
@@ -62,3 +65,4 @@ export declare function useDeleteSkill(): {
|
|
|
62
65
|
loading: boolean;
|
|
63
66
|
error: Error | undefined;
|
|
64
67
|
};
|
|
68
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CreateSkillDocument as e, DeleteSkillDocument as t, GetSkillDocument as n,
|
|
2
|
-
import { buildMutationInput as
|
|
3
|
-
import { useWorkspaceId as
|
|
4
|
-
import { useCallback as
|
|
1
|
+
import { CreateSkillDocument as e, DeleteSkillDocument as t, GetSkillDocument as n, ListBotmanorSkillsPageDocument as r, ListSkillsDocument as i, UpdateSkillDocument as a } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { buildMutationInput as o, fieldsOf as s } from "./internal/mutationInput.js";
|
|
3
|
+
import { useWorkspaceId as c, useWorkspaceMutation as l, useWorkspacePaginatedQuery as u, useWorkspaceQuery as d } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useCallback as f, useMemo as p } from "react";
|
|
5
5
|
// src/botlit/hooks/useSkills.ts
|
|
6
|
-
var
|
|
6
|
+
var m = 100, h = 50, g = s({
|
|
7
7
|
bucketId: !0,
|
|
8
8
|
capabilityFlags: !0,
|
|
9
9
|
description: !0,
|
|
@@ -18,7 +18,7 @@ var f = 100, p = o({
|
|
|
18
18
|
toolPolicyId: !0,
|
|
19
19
|
visibility: !0,
|
|
20
20
|
workspaceId: !0
|
|
21
|
-
}),
|
|
21
|
+
}), _ = s({
|
|
22
22
|
bucketId: !0,
|
|
23
23
|
capabilityFlags: !0,
|
|
24
24
|
description: !0,
|
|
@@ -32,48 +32,66 @@ var f = 100, p = o({
|
|
|
32
32
|
toolPackDeps: !0,
|
|
33
33
|
toolPolicyId: !0,
|
|
34
34
|
visibility: !0
|
|
35
|
-
}),
|
|
36
|
-
function
|
|
37
|
-
return e?.listSkills ??
|
|
35
|
+
}), v = [];
|
|
36
|
+
function y(e) {
|
|
37
|
+
return e?.listSkills ?? v;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
let t =
|
|
39
|
+
function b(e) {
|
|
40
|
+
let t = c(), { search: n, status: r, visibility: a, bucketId: o, promptTemplateId: s, retrievalProfileId: l, toolPolicyId: u } = e ?? {}, f = p(() => ({
|
|
41
41
|
filters: {
|
|
42
42
|
workspaceId: t,
|
|
43
43
|
search: n || void 0,
|
|
44
|
-
status:
|
|
44
|
+
status: r,
|
|
45
45
|
visibility: a,
|
|
46
46
|
bucketId: o,
|
|
47
|
-
promptTemplateId:
|
|
48
|
-
retrievalProfileId:
|
|
49
|
-
toolPolicyId:
|
|
47
|
+
promptTemplateId: s,
|
|
48
|
+
retrievalProfileId: l,
|
|
49
|
+
toolPolicyId: u
|
|
50
50
|
},
|
|
51
51
|
pagination: {
|
|
52
|
-
limit:
|
|
52
|
+
limit: m,
|
|
53
53
|
offset: 0
|
|
54
54
|
}
|
|
55
55
|
}), [
|
|
56
56
|
t,
|
|
57
57
|
n,
|
|
58
|
-
|
|
58
|
+
r,
|
|
59
59
|
a,
|
|
60
60
|
o,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
s,
|
|
62
|
+
l,
|
|
63
|
+
u
|
|
64
64
|
]);
|
|
65
|
-
return
|
|
65
|
+
return d({
|
|
66
|
+
document: i,
|
|
67
|
+
variables: f,
|
|
68
|
+
select: y,
|
|
69
|
+
fallback: v,
|
|
70
|
+
enabled: !!t,
|
|
71
|
+
errorMessage: "Failed to load skills"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
var x = [];
|
|
75
|
+
function S(e) {
|
|
76
|
+
let t = c(), n = p(() => ({ filters: {
|
|
77
|
+
workspaceId: t,
|
|
78
|
+
search: e || void 0
|
|
79
|
+
} }), [t, e]);
|
|
80
|
+
return u({
|
|
66
81
|
document: r,
|
|
67
|
-
variables:
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
variables: n,
|
|
83
|
+
pageSize: h,
|
|
84
|
+
extractRows: (e) => e?.listBotmanorSkillsPage.items,
|
|
85
|
+
extractNextOffset: (e) => e?.listBotmanorSkillsPage.nextOffset ?? null,
|
|
86
|
+
select: (e) => e,
|
|
87
|
+
fallback: x,
|
|
70
88
|
enabled: !!t,
|
|
71
89
|
errorMessage: "Failed to load skills"
|
|
72
90
|
});
|
|
73
91
|
}
|
|
74
|
-
function
|
|
75
|
-
let t =
|
|
76
|
-
return
|
|
92
|
+
function C(e) {
|
|
93
|
+
let t = p(() => ({ id: e ?? "" }), [e]);
|
|
94
|
+
return d({
|
|
77
95
|
document: n,
|
|
78
96
|
variables: t,
|
|
79
97
|
select: (e) => e?.getSkill ?? null,
|
|
@@ -82,11 +100,11 @@ function v(e) {
|
|
|
82
100
|
errorMessage: "Failed to load skill"
|
|
83
101
|
});
|
|
84
102
|
}
|
|
85
|
-
function
|
|
86
|
-
let t =
|
|
103
|
+
function w() {
|
|
104
|
+
let t = c(), n = f((e) => ({ input: o({
|
|
87
105
|
...e,
|
|
88
106
|
workspaceId: t
|
|
89
|
-
},
|
|
107
|
+
}, g) }), [t]), [r, i] = l({
|
|
90
108
|
document: e,
|
|
91
109
|
variables: n,
|
|
92
110
|
select: (e) => e?.createSkill,
|
|
@@ -98,12 +116,12 @@ function y() {
|
|
|
98
116
|
error: i.error
|
|
99
117
|
};
|
|
100
118
|
}
|
|
101
|
-
function
|
|
102
|
-
let [e, t] =
|
|
103
|
-
document:
|
|
119
|
+
function T() {
|
|
120
|
+
let [e, t] = l({
|
|
121
|
+
document: a,
|
|
104
122
|
variables: ({ skillId: e, input: t }) => ({
|
|
105
123
|
id: e,
|
|
106
|
-
input:
|
|
124
|
+
input: o(t, _)
|
|
107
125
|
}),
|
|
108
126
|
select: (e) => e?.updateSkill,
|
|
109
127
|
errorMessage: "Failed to update skill"
|
|
@@ -114,8 +132,8 @@ function b() {
|
|
|
114
132
|
error: t.error
|
|
115
133
|
};
|
|
116
134
|
}
|
|
117
|
-
function
|
|
118
|
-
let [e, n] =
|
|
135
|
+
function E() {
|
|
136
|
+
let [e, n] = l({
|
|
119
137
|
document: t,
|
|
120
138
|
variables: (e) => ({ id: e }),
|
|
121
139
|
select: (e) => e?.deleteSkill,
|
|
@@ -127,6 +145,6 @@ function x() {
|
|
|
127
145
|
error: n.error
|
|
128
146
|
};
|
|
129
147
|
}
|
|
130
|
-
export {
|
|
148
|
+
export { w as useCreateSkill, E as useDeleteSkill, C as useSkill, b as useSkills, S as useSkillsPage, T as useUpdateSkill };
|
|
131
149
|
|
|
132
150
|
//# sourceMappingURL=useSkills.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSkills.js","names":["LIST_LIMIT","CREATE_SKILL_FIELDS","fieldsOf","UPDATE_SKILL_FIELDS","NO_SKILLS","selectSkills","data","useSkills","workspaceId","useWorkspaceId","filter","variables","useMemo","search","status","visibility","bucketId","promptTemplateId","retrievalProfileId","toolPolicyId","useWorkspaceQuery","ListSkillsDocument","useSkill","skillId","GetSkillDocument","useCreateSkill","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreateSkillDocument","useUpdateSkill","update","UpdateSkillDocument","useDeleteSkill","remove","DeleteSkillDocument"],"sources":["../../../src/botlit/hooks/useSkills.ts"],"sourcesContent":["/**\n * Skills Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listSkills` / `getSkill` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateSkillDocument,\n DeleteSkillDocument,\n GetSkillDocument,\n ListSkillsDocument,\n UpdateSkillDocument,\n type CreateSkillMutation,\n type DeleteSkillMutation,\n type GetSkillQuery,\n type ListSkillsQuery,\n type UpdateSkillMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateSkillInput, UpdateSkillInput } from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\n\nexport interface SkillRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n promptTemplateId?: string | null;\n retrievalProfileId?: string | null;\n toolPolicyId?: string | null;\n toolPackDeps: string[];\n recommendedPolicies: string[];\n capabilityFlags?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface SkillFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n promptTemplateId?: string;\n retrievalProfileId?: string;\n toolPolicyId?: string;\n}\n\n/** `CreateSkillInput` minus the `workspaceId` the hook supplies. */\nexport type CreateSkillVariables = Omit<GraphQLInput<CreateSkillInput>, 'workspaceId'>;\n\nexport interface UpdateSkillVariables {\n skillId: string;\n input: GraphQLInput<UpdateSkillInput>;\n}\n\nconst CREATE_SKILL_FIELDS = fieldsOf<CreateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_SKILL_FIELDS = fieldsOf<UpdateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n});\n\nconst NO_SKILLS: SkillRecord[] = [];\n\nfunction selectSkills(data: ListSkillsQuery | undefined): SkillRecord[] {\n return data?.listSkills ?? NO_SKILLS;\n}\n\nexport const skillKeys = {\n all: ['skills'] as const,\n lists: () => [...skillKeys.all, 'list'] as const,\n list: (filter?: SkillFilterVariables) => [...skillKeys.lists(), filter] as const,\n details: () => [...skillKeys.all, 'detail'] as const,\n detail: (id: string) => [...skillKeys.details(), id] as const,\n};\n\nexport function useSkills(filter?: SkillFilterVariables): QueryResult<SkillRecord[]> {\n const workspaceId = useWorkspaceId();\n const {\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [\n workspaceId,\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n ]\n );\n\n return useWorkspaceQuery<ListSkillsQuery, SkillRecord[]>({\n document: ListSkillsDocument,\n variables,\n select: selectSkills,\n fallback: NO_SKILLS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load skills',\n });\n}\n\nexport function useSkill(skillId: string | undefined): QueryResult<SkillRecord | null> {\n const variables = useMemo(() => ({ id: skillId ?? '' }), [skillId]);\n\n return useWorkspaceQuery<GetSkillQuery, SkillRecord | null>({\n document: GetSkillDocument,\n variables,\n select: (data) => data?.getSkill ?? null,\n fallback: null,\n enabled: Boolean(skillId),\n errorMessage: 'Failed to load skill',\n });\n}\n\nexport function useCreateSkill() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateSkillVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_SKILL_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateSkillMutation,\n CreateSkillVariables,\n SkillRecord\n >({\n document: CreateSkillDocument,\n variables,\n select: (data) => data?.createSkill,\n errorMessage: 'Failed to create skill',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateSkill() {\n const [update, state] = useWorkspaceMutation<\n UpdateSkillMutation,\n UpdateSkillVariables,\n SkillRecord\n >({\n document: UpdateSkillDocument,\n variables: ({ skillId, input }) => ({\n id: skillId,\n input: buildMutationInput(input, UPDATE_SKILL_FIELDS),\n }),\n select: (data) => data?.updateSkill,\n errorMessage: 'Failed to update skill',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteSkill() {\n const [remove, state] = useWorkspaceMutation<DeleteSkillMutation, string, boolean>({\n document: DeleteSkillDocument,\n variables: (skillId) => ({ id: skillId }),\n select: (data) => data?.deleteSkill,\n errorMessage: 'Failed to delete skill',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AA8BA,IAAMA,IAAa,KA2CbC,IAAsBC,EAA2B;CACrD,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,UAAU;CACV,MAAM;CACN,kBAAkB;CAClB,qBAAqB;CACrB,oBAAoB;CACpB,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,YAAY;CACZ,aAAa;AACf,CAAC,GAEKC,IAAsBD,EAA2B;CACrD,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,UAAU;CACV,MAAM;CACN,kBAAkB;CAClB,qBAAqB;CACrB,oBAAoB;CACpB,QAAQ;CACR,MAAM;CACN,cAAc;CACd,cAAc;CACd,YAAY;AACd,CAAC,GAEKE,IAA2B,CAAC;AAElC,SAASC,EAAa,GAAkD;CACtE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AChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASwB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D;AAEA,SAAgBM,IAAiB;CAC/B,IAAM,CAACC,GAAQP,KAASC,EAA2D;EACjF,UAAUO;EACV,YAAY,OAAa,EAAE,IAAIf,EAAQ;EACvC,SAAS,MAASjB,GAAM;EACxB,cAAc;CAChB,CAAC;CAED,OAAO;EAAE;EAAQ,SAASwB,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC9D"}
|
|
1
|
+
{"version":3,"file":"useSkills.js","names":["LIST_LIMIT","SKILLS_PAGE_SIZE","CREATE_SKILL_FIELDS","fieldsOf","UPDATE_SKILL_FIELDS","NO_SKILLS","selectSkills","data","useSkills","workspaceId","useWorkspaceId","filter","variables","useMemo","search","status","visibility","bucketId","promptTemplateId","retrievalProfileId","toolPolicyId","useWorkspaceQuery","ListSkillsDocument","NO_SKILL_LIST_ITEMS","useSkillsPage","useWorkspacePaginatedQuery","ListBotmanorSkillsPageDocument","rows","useSkill","skillId","GetSkillDocument","useCreateSkill","useCallback","buildMutationInput","input","create","state","useWorkspaceMutation","CreateSkillDocument","useUpdateSkill","update","UpdateSkillDocument","useDeleteSkill","remove","DeleteSkillDocument"],"sources":["../../../src/botlit/hooks/useSkills.ts"],"sourcesContent":["/**\n * Skills Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listSkills` / `getSkill` operations and the\n * create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateSkillDocument,\n DeleteSkillDocument,\n GetSkillDocument,\n ListBotmanorSkillsPageDocument,\n ListSkillsDocument,\n UpdateSkillDocument,\n type CreateSkillMutation,\n type DeleteSkillMutation,\n type GetSkillQuery,\n type ListBotmanorSkillsPageQuery,\n type ListBotmanorSkillsPageQueryVariables,\n type ListSkillsQuery,\n type UpdateSkillMutation,\n} from '../../generated/wspace-operations';\nimport type { CreateSkillInput, UpdateSkillInput } from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 100;\nconst SKILLS_PAGE_SIZE = 50;\n\nexport interface SkillRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n description?: string | null;\n bucketId?: string | null;\n promptTemplateId?: string | null;\n retrievalProfileId?: string | null;\n toolPolicyId?: string | null;\n toolPackDeps: string[];\n recommendedPolicies: string[];\n capabilityFlags?: Record<string, unknown> | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\nexport interface SkillFilterVariables {\n search?: string;\n status?: string;\n visibility?: string;\n bucketId?: string;\n promptTemplateId?: string;\n retrievalProfileId?: string;\n toolPolicyId?: string;\n}\n\n/** `CreateSkillInput` minus the `workspaceId` the hook supplies. */\nexport type CreateSkillVariables = Omit<GraphQLInput<CreateSkillInput>, 'workspaceId'>;\n\nexport interface UpdateSkillVariables {\n skillId: string;\n input: GraphQLInput<UpdateSkillInput>;\n}\n\nconst CREATE_SKILL_FIELDS = fieldsOf<CreateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n workspaceId: true,\n});\n\nconst UPDATE_SKILL_FIELDS = fieldsOf<UpdateSkillInput>({\n bucketId: true,\n capabilityFlags: true,\n description: true,\n metadata: true,\n name: true,\n promptTemplateId: true,\n recommendedPolicies: true,\n retrievalProfileId: true,\n status: true,\n tags: true,\n toolPackDeps: true,\n toolPolicyId: true,\n visibility: true,\n});\n\nconst NO_SKILLS: SkillRecord[] = [];\n\nfunction selectSkills(data: ListSkillsQuery | undefined): SkillRecord[] {\n return data?.listSkills ?? NO_SKILLS;\n}\n\nexport const skillKeys = {\n all: ['skills'] as const,\n lists: () => [...skillKeys.all, 'list'] as const,\n list: (filter?: SkillFilterVariables) => [...skillKeys.lists(), filter] as const,\n details: () => [...skillKeys.all, 'detail'] as const,\n detail: (id: string) => [...skillKeys.details(), id] as const,\n};\n\nexport function useSkills(filter?: SkillFilterVariables): QueryResult<SkillRecord[]> {\n const workspaceId = useWorkspaceId();\n const {\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n } = filter ?? {};\n\n const variables = useMemo(\n () => ({\n filters: {\n workspaceId,\n search: search || undefined,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n },\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [\n workspaceId,\n search,\n status,\n visibility,\n bucketId,\n promptTemplateId,\n retrievalProfileId,\n toolPolicyId,\n ]\n );\n\n return useWorkspaceQuery<ListSkillsQuery, SkillRecord[]>({\n document: ListSkillsDocument,\n variables,\n select: selectSkills,\n fallback: NO_SKILLS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load skills',\n });\n}\n\ntype SkillListItem = ListBotmanorSkillsPageQuery['listBotmanorSkillsPage']['items'][number];\nconst NO_SKILL_LIST_ITEMS: SkillListItem[] = [];\n\nexport function useSkillsPage(search: string): PaginatedQueryResult<SkillListItem[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo<ListBotmanorSkillsPageQueryVariables>(\n () => ({ filters: { workspaceId, search: search || undefined } }),\n [workspaceId, search]\n );\n\n return useWorkspacePaginatedQuery<ListBotmanorSkillsPageQuery, SkillListItem, SkillListItem[]>({\n document: ListBotmanorSkillsPageDocument,\n variables,\n pageSize: SKILLS_PAGE_SIZE,\n extractRows: (data) => data?.listBotmanorSkillsPage.items,\n extractNextOffset: (data) => data?.listBotmanorSkillsPage.nextOffset ?? null,\n select: (rows) => rows,\n fallback: NO_SKILL_LIST_ITEMS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load skills',\n });\n}\n\nexport function useSkill(skillId: string | undefined): QueryResult<SkillRecord | null> {\n const variables = useMemo(() => ({ id: skillId ?? '' }), [skillId]);\n\n return useWorkspaceQuery<GetSkillQuery, SkillRecord | null>({\n document: GetSkillDocument,\n variables,\n select: (data) => data?.getSkill ?? null,\n fallback: null,\n enabled: Boolean(skillId),\n errorMessage: 'Failed to load skill',\n });\n}\n\nexport function useCreateSkill() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: CreateSkillVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_SKILL_FIELDS),\n }),\n [workspaceId]\n );\n\n const [create, state] = useWorkspaceMutation<\n CreateSkillMutation,\n CreateSkillVariables,\n SkillRecord\n >({\n document: CreateSkillDocument,\n variables,\n select: (data) => data?.createSkill,\n errorMessage: 'Failed to create skill',\n });\n\n return { create, loading: state.loading, error: state.error };\n}\n\nexport function useUpdateSkill() {\n const [update, state] = useWorkspaceMutation<\n UpdateSkillMutation,\n UpdateSkillVariables,\n SkillRecord\n >({\n document: UpdateSkillDocument,\n variables: ({ skillId, input }) => ({\n id: skillId,\n input: buildMutationInput(input, UPDATE_SKILL_FIELDS),\n }),\n select: (data) => data?.updateSkill,\n errorMessage: 'Failed to update skill',\n });\n\n return { update, loading: state.loading, error: state.error };\n}\n\nexport function useDeleteSkill() {\n const [remove, state] = useWorkspaceMutation<DeleteSkillMutation, string, boolean>({\n document: DeleteSkillDocument,\n variables: (skillId) => ({ id: skillId }),\n select: (data) => data?.deleteSkill,\n errorMessage: 'Failed to delete skill',\n });\n\n return { remove, loading: state.loading, error: state.error };\n}\n"],"mappings":";;;;;AAmCA,IAAMA,IAAa,KACbC,IAAmB,IA2CnBC,IAAsBC,EAA2B;CACrD,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,UAAU;CACV,MAAM;CACN,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9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
1
|
+
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
|
+
import { PageLayout as t } from "../components/PageLayout.js";
|
|
3
|
+
import { Button as n } from "../components/Button.js";
|
|
4
|
+
import { Badge as r, StatusBadge as i } from "../components/Badge.js";
|
|
5
|
+
import { Textarea as a } from "../components/Input.js";
|
|
6
|
+
import { ErrorState as o } from "../components/ErrorState.js";
|
|
7
|
+
import { useAgent as s } from "../hooks/useAgents.js";
|
|
8
|
+
import { useAgentTestChat as c } from "../hooks/useAgentTestChat.js";
|
|
9
|
+
import { useBotlit as l } from "../providers/BotlitProvider.js";
|
|
10
|
+
import { useRef as u, useState as d } from "react";
|
|
11
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
12
|
+
import { Link as m, useParams as h } from "react-router";
|
|
13
|
+
import { ArrowLeft as g, Send as _ } from "lucide-react";
|
|
13
14
|
// src/botlit/pages/AgentTestChatPage.tsx
|
|
14
|
-
var
|
|
15
|
-
let { agentId:
|
|
16
|
-
if (
|
|
17
|
-
title: "Test Agent",
|
|
18
|
-
children: /* @__PURE__ */
|
|
15
|
+
var v = /* @__PURE__ */ new Set(["DRAFT", "ACTIVE"]), y = 8192, b = () => {
|
|
16
|
+
let b = e(), { agentId: x } = h(), { navigateTo: S, getPath: C } = l(), { data: w, loading: T, error: E, refetch: D } = s(x), [O, k] = c(), [A, j] = d(""), [M, N] = d([]), [P, F] = d(null), I = u(0);
|
|
17
|
+
if (T && !w) return /* @__PURE__ */ f(t, {
|
|
18
|
+
title: b("botlit.agentTest.title", "Test Agent"),
|
|
19
|
+
children: /* @__PURE__ */ f("div", {
|
|
19
20
|
role: "status",
|
|
20
|
-
"aria-label": "Loading",
|
|
21
|
+
"aria-label": b("botlit.common.loading", "Loading"),
|
|
21
22
|
className: "h-64 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer"
|
|
22
23
|
})
|
|
23
24
|
});
|
|
24
|
-
if (
|
|
25
|
-
title: "Test Agent",
|
|
26
|
-
children: /* @__PURE__ */
|
|
27
|
-
resource: "this agent",
|
|
28
|
-
error:
|
|
29
|
-
onRetry: () => void
|
|
25
|
+
if (E || !w || !x) return /* @__PURE__ */ f(t, {
|
|
26
|
+
title: b("botlit.agentTest.title", "Test Agent"),
|
|
27
|
+
children: /* @__PURE__ */ f(o, {
|
|
28
|
+
resource: b("botlit.agentTest.resource", "this agent"),
|
|
29
|
+
error: E ?? Error(b("botlit.agentTest.notFound", "Agent not found")),
|
|
30
|
+
onRetry: () => void D()
|
|
30
31
|
})
|
|
31
32
|
});
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let L = v.has(w.status), R = L && !!w.llmModelId, z = /* @__PURE__ */ new Map([
|
|
34
|
+
["PAUSED", b("botlit.agentTest.statusPaused", "paused")],
|
|
35
|
+
["TRAINING", b("botlit.agentTest.statusTraining", "training")],
|
|
36
|
+
["ARCHIVED", b("botlit.agentTest.statusArchived", "archived")]
|
|
37
|
+
]), B = A.trim(), V = async (e) => {
|
|
38
|
+
if (e.preventDefault(), !B || B.length > y || k.loading) return;
|
|
39
|
+
let t = Date.now(), n = I.current;
|
|
40
|
+
N((e) => [...e, {
|
|
36
41
|
id: t,
|
|
37
|
-
prompt:
|
|
38
|
-
}]),
|
|
42
|
+
prompt: B
|
|
43
|
+
}]), j("");
|
|
39
44
|
try {
|
|
40
|
-
let e = await
|
|
41
|
-
agentId:
|
|
42
|
-
message:
|
|
43
|
-
conversationId:
|
|
45
|
+
let e = await O({
|
|
46
|
+
agentId: x,
|
|
47
|
+
message: B,
|
|
48
|
+
conversationId: P
|
|
44
49
|
});
|
|
45
|
-
if (n !==
|
|
46
|
-
e.conversationId &&
|
|
50
|
+
if (n !== I.current) return;
|
|
51
|
+
e.conversationId && F(e.conversationId), N((n) => n.map((n) => n.id === t ? {
|
|
47
52
|
...n,
|
|
48
53
|
reply: e
|
|
49
54
|
} : n));
|
|
50
55
|
} catch (e) {
|
|
51
|
-
let n = e instanceof Error ? e.message : "The agent could not answer";
|
|
52
|
-
|
|
56
|
+
let n = e instanceof Error ? e.message : b("botlit.agentTest.replyFailed", "The agent could not answer");
|
|
57
|
+
N((e) => e.map((e) => e.id === t ? {
|
|
53
58
|
...e,
|
|
54
59
|
error: n
|
|
55
60
|
} : e));
|
|
56
61
|
}
|
|
57
62
|
};
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
leading: /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ f(t, {
|
|
64
|
+
leading: /* @__PURE__ */ f(n, {
|
|
60
65
|
variant: "ghost",
|
|
61
66
|
size: "icon",
|
|
62
67
|
type: "button",
|
|
63
|
-
"aria-label": "Back to agent",
|
|
64
|
-
onClick: () =>
|
|
65
|
-
children: /* @__PURE__ */
|
|
68
|
+
"aria-label": b("botlit.agentTest.backToAgent", "Back to agent"),
|
|
69
|
+
onClick: () => S(`agents/${x}`),
|
|
70
|
+
children: /* @__PURE__ */ f(g, {
|
|
66
71
|
size: 20,
|
|
67
72
|
"aria-hidden": "true"
|
|
68
73
|
})
|
|
69
74
|
}),
|
|
70
|
-
title:
|
|
71
|
-
meta: /* @__PURE__ */
|
|
72
|
-
description: "Each message is a real run of this agent's current configuration and is recorded in Executions.",
|
|
73
|
-
actions:
|
|
75
|
+
title: b("botlit.agentTest.namedTitle", "Test {{name}}", { name: w.name }),
|
|
76
|
+
meta: /* @__PURE__ */ f(i, { status: w.status }),
|
|
77
|
+
description: b("botlit.agentTest.description", "Each message is a real run of this agent's current configuration and is recorded in Executions."),
|
|
78
|
+
actions: M.length > 0 ? /* @__PURE__ */ f(n, {
|
|
74
79
|
variant: "outline",
|
|
75
80
|
onClick: () => {
|
|
76
|
-
|
|
81
|
+
I.current += 1, N([]), F(null);
|
|
77
82
|
},
|
|
78
|
-
children: "New conversation"
|
|
83
|
+
children: b("botlit.agentTest.newConversation", "New conversation")
|
|
79
84
|
}) : void 0,
|
|
80
|
-
children: /* @__PURE__ */
|
|
85
|
+
children: /* @__PURE__ */ p("div", {
|
|
81
86
|
className: "mx-auto flex w-full max-w-4xl flex-col gap-4",
|
|
82
87
|
children: [
|
|
83
|
-
!
|
|
88
|
+
!L && /* @__PURE__ */ f("p", {
|
|
84
89
|
role: "alert",
|
|
85
90
|
className: "text-sm",
|
|
86
|
-
children:
|
|
87
|
-
"A ",
|
|
88
|
-
S.status.toLowerCase(),
|
|
89
|
-
" agent does not run. Activate it or move it back to draft to test it."
|
|
90
|
-
]
|
|
91
|
+
children: b("botlit.agentTest.statusUnavailable", "A {{status}} agent does not run. Activate it or move it back to draft to test it.", { status: z.get(w.status) ?? w.status.toLowerCase() })
|
|
91
92
|
}),
|
|
92
|
-
!
|
|
93
|
+
!w.llmModelId && /* @__PURE__ */ f("p", {
|
|
93
94
|
role: "status",
|
|
94
95
|
className: "text-sm text-text-secondary",
|
|
95
|
-
children: "This agent has no model yet. Choose one in Edit Agent before testing."
|
|
96
|
+
children: b("botlit.agentTest.modelRequired", "This agent has no model yet. Choose one in Edit Agent before testing.")
|
|
96
97
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
"aria-label": "Conversation",
|
|
98
|
+
/* @__PURE__ */ p("ol", {
|
|
99
|
+
"aria-label": b("botlit.agentTest.conversation", "Conversation"),
|
|
99
100
|
className: "space-y-4",
|
|
100
|
-
children: [
|
|
101
|
+
children: [M.length === 0 && /* @__PURE__ */ f("li", {
|
|
101
102
|
className: "text-sm text-text-secondary",
|
|
102
|
-
children: "Send a message to start testing."
|
|
103
|
-
}),
|
|
103
|
+
children: b("botlit.agentTest.emptyConversation", "Send a message to start testing.")
|
|
104
|
+
}), M.map((e) => /* @__PURE__ */ p("li", {
|
|
104
105
|
className: "space-y-2",
|
|
105
|
-
children: [/* @__PURE__ */
|
|
106
|
+
children: [/* @__PURE__ */ p("div", {
|
|
106
107
|
className: "ml-auto max-w-[80%] rounded-lg bg-bg-sunken p-3 text-sm",
|
|
107
|
-
children: [/* @__PURE__ */
|
|
108
|
+
children: [/* @__PURE__ */ p("span", {
|
|
108
109
|
className: "sr-only",
|
|
109
|
-
children: "You: "
|
|
110
|
+
children: [b("botlit.agentTest.you", "You:"), " "]
|
|
110
111
|
}), e.prompt]
|
|
111
|
-
}), e.reply ? /* @__PURE__ */
|
|
112
|
+
}), e.reply ? /* @__PURE__ */ p("div", {
|
|
112
113
|
className: "max-w-[80%] space-y-2 rounded-lg border border-border-subtle p-3",
|
|
113
|
-
children: [/* @__PURE__ */
|
|
114
|
+
children: [/* @__PURE__ */ p("p", {
|
|
114
115
|
className: "whitespace-pre-wrap text-sm",
|
|
115
|
-
children: [/* @__PURE__ */
|
|
116
|
+
children: [/* @__PURE__ */ p("span", {
|
|
116
117
|
className: "sr-only",
|
|
117
|
-
children: [
|
|
118
|
+
children: [w.name, ": "]
|
|
118
119
|
}), e.reply.message]
|
|
119
|
-
}), /* @__PURE__ */
|
|
120
|
+
}), /* @__PURE__ */ p("div", {
|
|
120
121
|
className: "flex flex-wrap items-center gap-2 text-xs text-text-secondary",
|
|
121
122
|
children: [
|
|
122
|
-
e.reply.model && /* @__PURE__ */
|
|
123
|
+
e.reply.model && /* @__PURE__ */ f(r, {
|
|
123
124
|
variant: "outline",
|
|
124
125
|
children: e.reply.model
|
|
125
126
|
}),
|
|
126
|
-
typeof e.reply.tokensUsed == "number" && /* @__PURE__ */ f("span", { children:
|
|
127
|
-
e.reply.sources.length > 0 && /* @__PURE__ */ f("span", { children:
|
|
128
|
-
e.reply.executionId && /* @__PURE__ */
|
|
129
|
-
to:
|
|
127
|
+
typeof e.reply.tokensUsed == "number" && /* @__PURE__ */ f("span", { children: e.reply.tokensUsed === 1 ? b("botlit.agentTest.tokenOne", "{{count}} token", { count: 1 }) : b("botlit.agentTest.tokenOther", "{{count}} tokens", { count: e.reply.tokensUsed }) }),
|
|
128
|
+
e.reply.sources.length > 0 && /* @__PURE__ */ f("span", { children: e.reply.sources.length === 1 ? b("botlit.agentTest.sourceOne", "{{count}} cited source", { count: 1 }) : b("botlit.agentTest.sourceOther", "{{count}} cited sources", { count: e.reply.sources.length }) }),
|
|
129
|
+
e.reply.executionId && /* @__PURE__ */ f(m, {
|
|
130
|
+
to: C(`executions/${e.reply.executionId}`),
|
|
130
131
|
className: "underline",
|
|
131
|
-
children: "View execution"
|
|
132
|
+
children: b("botlit.agentTest.viewExecution", "View execution")
|
|
132
133
|
})
|
|
133
134
|
]
|
|
134
135
|
})]
|
|
135
|
-
}) : e.error ? /* @__PURE__ */
|
|
136
|
+
}) : e.error ? /* @__PURE__ */ f("p", {
|
|
136
137
|
role: "alert",
|
|
137
138
|
className: "max-w-[80%] text-sm text-status-error-text",
|
|
138
139
|
children: e.error
|
|
139
140
|
}) : /* @__PURE__ */ f("p", {
|
|
140
141
|
role: "status",
|
|
141
142
|
className: "text-sm text-text-secondary",
|
|
142
|
-
children:
|
|
143
|
+
children: b("botlit.agentTest.answering", "{{name}} is answering…", { name: w.name })
|
|
143
144
|
})]
|
|
144
145
|
}, e.id))]
|
|
145
146
|
}),
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
+
/* @__PURE__ */ p("form", {
|
|
147
148
|
noValidate: !0,
|
|
148
|
-
onSubmit: (e) => void
|
|
149
|
+
onSubmit: (e) => void V(e),
|
|
149
150
|
className: "flex items-end gap-2",
|
|
150
|
-
children: [/* @__PURE__ */
|
|
151
|
-
"aria-label": "Message",
|
|
152
|
-
value:
|
|
151
|
+
children: [/* @__PURE__ */ f(a, {
|
|
152
|
+
"aria-label": b("botlit.agentTest.message", "Message"),
|
|
153
|
+
value: A,
|
|
153
154
|
rows: 3,
|
|
154
|
-
maxLength:
|
|
155
|
-
disabled: !
|
|
156
|
-
placeholder: "Ask the agent something…",
|
|
157
|
-
onChange: (e) =>
|
|
155
|
+
maxLength: y,
|
|
156
|
+
disabled: !R || k.loading,
|
|
157
|
+
placeholder: b("botlit.agentTest.messagePlaceholder", "Ask the agent something…"),
|
|
158
|
+
onChange: (e) => j(e.target.value),
|
|
158
159
|
onKeyDown: (e) => {
|
|
159
160
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), e.currentTarget.form?.requestSubmit());
|
|
160
161
|
},
|
|
161
162
|
className: "flex-1"
|
|
162
|
-
}), /* @__PURE__ */
|
|
163
|
+
}), /* @__PURE__ */ f(n, {
|
|
163
164
|
type: "submit",
|
|
164
|
-
leftIcon: /* @__PURE__ */
|
|
165
|
-
isLoading:
|
|
166
|
-
disabled: !
|
|
167
|
-
children: "Send"
|
|
165
|
+
leftIcon: /* @__PURE__ */ f(_, { size: 16 }),
|
|
166
|
+
isLoading: k.loading,
|
|
167
|
+
disabled: !R || !B,
|
|
168
|
+
children: b("botlit.agentTest.send", "Send")
|
|
168
169
|
})]
|
|
169
170
|
})
|
|
170
171
|
]
|
|
171
172
|
})
|
|
172
173
|
});
|
|
173
174
|
};
|
|
174
|
-
export {
|
|
175
|
+
export { b as AgentTestChatPage };
|
|
175
176
|
|
|
176
177
|
//# sourceMappingURL=AgentTestChatPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTestChatPage.js","names":["TESTABLE","MAX_MESSAGE_LENGTH","AgentTestChatPage","useParams","useBotlit","agent","useAgent","agentId","send","sendState","useAgentTestChat","message","setMessage","useState","turns","setTurns","conversationId","setConversationId","conversationEpoch","useRef","loading","PageLayout","error","ErrorState","refetch","testable","trimmed","submit","event","id","epoch","current","reply","turn","sendError","text","Button","navigateTo","ArrowLeft","StatusBadge","Badge","Link","getPath","Textarea","Send"],"sources":["../../../src/botlit/pages/AgentTestChatPage.tsx"],"sourcesContent":["/**\n * Agent test chat (BOFF-15360)\n * @module botlit/pages\n *\n * \"Test Agent\" from the builder: talk to any agent — including a draft that is\n * not live yet — before publishing it. Every message is one real run\n * (`chatWithAgent`) with a row in the execution ledger, so each reply shows the\n * model, the tokens it used and a link to its execution.\n */\n\nimport { useRef, useState, type FC, type FormEvent } from 'react';\nimport { Link, useParams } from 'react-router';\nimport { ArrowLeft, Send } from 'lucide-react';\n\nimport { PageLayout } from '../components/PageLayout';\nimport { Button } from '../components/Button';\nimport { Badge, StatusBadge } from '../components/Badge';\nimport { Textarea } from '../components/Input';\nimport { ErrorState } from '../components/ErrorState';\nimport { useAgent } from '../hooks/useAgents';\nimport { useAgentTestChat, type AgentTestReply } from '../hooks/useAgentTestChat';\nimport { useBotlit } from '../providers/BotlitProvider';\n\n/** Statuses the server lets a test turn run on. */\nconst TESTABLE = new Set(['DRAFT', 'ACTIVE']);\nconst MAX_MESSAGE_LENGTH = 8192;\n\ninterface Turn {\n id: number;\n prompt: string;\n reply?: AgentTestReply;\n error?: string;\n}\n\nexport const AgentTestChatPage: FC = () => {\n const { agentId } = useParams();\n const { navigateTo, getPath } = useBotlit();\n const { data: agent, loading, error, refetch } = useAgent(agentId);\n const [send, sendState] = useAgentTestChat();\n const [message, setMessage] = useState('');\n const [turns, setTurns] = useState<Turn[]>([]);\n const [conversationId, setConversationId] = useState<string | null>(null);\n // Bumped by \"New conversation\": a reply to an earlier conversation that\n // arrives afterwards must not re-thread the new one.\n const conversationEpoch = useRef(0);\n\n if (loading && !agent) {\n return (\n <PageLayout title=\"Test Agent\">\n <div\n role=\"status\"\n aria-label=\"Loading\"\n className=\"h-64 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\"\n />\n </PageLayout>\n );\n }\n if (error || !agent || !agentId) {\n return (\n <PageLayout title=\"Test Agent\">\n <ErrorState\n resource=\"this agent\"\n error={error ?? new Error('Agent not found')}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n const testable = TESTABLE.has(agent.status) && Boolean(agent.llmModelId);\n const trimmed = message.trim();\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (!trimmed || trimmed.length > MAX_MESSAGE_LENGTH || sendState.loading) return;\n const id = Date.now();\n const epoch = conversationEpoch.current;\n setTurns((current) => [...current, { id, prompt: trimmed }]);\n setMessage('');\n try {\n const reply = await send({ agentId, message: trimmed, conversationId });\n if (epoch !== conversationEpoch.current) return;\n if (reply.conversationId) setConversationId(reply.conversationId);\n setTurns((current) => current.map((turn) => (turn.id === id ? { ...turn, reply } : turn)));\n } catch (sendError: unknown) {\n const text = sendError instanceof Error ? sendError.message : 'The agent could not answer';\n setTurns((current) =>\n current.map((turn) => (turn.id === id ? { ...turn, error: text } : turn))\n );\n }\n };\n\n return (\n <PageLayout\n leading={\n <Button\n variant=\"ghost\"\n size=\"icon\"\n type=\"button\"\n aria-label=\"Back to agent\"\n onClick={() => navigateTo(`agents/${agentId}`)}\n >\n <ArrowLeft size={20} aria-hidden=\"true\" />\n </Button>\n }\n title={`Test ${agent.name}`}\n meta={<StatusBadge status={agent.status} />}\n description=\"Each message is a real run of this agent's current configuration and is recorded in Executions.\"\n actions={\n turns.length > 0 ? (\n <Button\n variant=\"outline\"\n onClick={() => {\n conversationEpoch.current += 1;\n setTurns([]);\n setConversationId(null);\n }}\n >\n New conversation\n </Button>\n ) : undefined\n }\n >\n <div className=\"mx-auto flex w-full max-w-4xl flex-col gap-4\">\n {!TESTABLE.has(agent.status) && (\n <p role=\"alert\" className=\"text-sm\">\n A {agent.status.toLowerCase()} agent does not run. Activate it or move it back to draft\n to test it.\n </p>\n )}\n {!agent.llmModelId && (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n This agent has no model yet. Choose one in Edit Agent before testing.\n </p>\n )}\n <ol aria-label=\"Conversation\" className=\"space-y-4\">\n {turns.length === 0 && (\n <li className=\"text-sm text-text-secondary\">Send a message to start testing.</li>\n )}\n {turns.map((turn) => (\n <li key={turn.id} className=\"space-y-2\">\n <div className=\"ml-auto max-w-[80%] rounded-lg bg-bg-sunken p-3 text-sm\">\n <span className=\"sr-only\">You: </span>\n {turn.prompt}\n </div>\n {turn.reply ? (\n <div className=\"max-w-[80%] space-y-2 rounded-lg border border-border-subtle p-3\">\n <p className=\"whitespace-pre-wrap text-sm\">\n <span className=\"sr-only\">{agent.name}: </span>\n {turn.reply.message}\n </p>\n <div className=\"flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n {turn.reply.model && <Badge variant=\"outline\">{turn.reply.model}</Badge>}\n {typeof turn.reply.tokensUsed === 'number' && (\n <span>{turn.reply.tokensUsed} tokens</span>\n )}\n {turn.reply.sources.length > 0 && (\n <span>{turn.reply.sources.length} cited sources</span>\n )}\n {turn.reply.executionId && (\n <Link\n to={getPath(`executions/${turn.reply.executionId}`)}\n className=\"underline\"\n >\n View execution\n </Link>\n )}\n </div>\n </div>\n ) : turn.error ? (\n <p role=\"alert\" className=\"max-w-[80%] text-sm text-status-error-text\">\n {turn.error}\n </p>\n ) : (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n {agent.name} is answering…\n </p>\n )}\n </li>\n ))}\n </ol>\n <form noValidate onSubmit={(event) => void submit(event)} className=\"flex items-end gap-2\">\n <Textarea\n aria-label=\"Message\"\n value={message}\n rows={3}\n maxLength={MAX_MESSAGE_LENGTH}\n disabled={!testable || sendState.loading}\n placeholder=\"Ask the agent something…\"\n onChange={(event) => setMessage(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }}\n className=\"flex-1\"\n />\n <Button\n type=\"submit\"\n leftIcon={<Send size={16} />}\n isLoading={sendState.loading}\n disabled={!testable || !trimmed}\n >\n Send\n </Button>\n </form>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAMA,oBAAW,IAAI,IAAI,CAAC,SAAS,QAAQ,CAAC,GACtCC,IAAqB,MASdC,UAA8B;CACzC,IAAM,EAAE,eAAYC,EAAU,GACxB,EAAE,eAAY,eAAYC,EAAU,GACpC,EAAE,MAAMC,GAAO,YAAS,UAAO,eAAYC,EAASC,CAAO,GAC3D,CAACC,GAAMC,KAAaC,EAAiB,GACrC,CAACC,GAASC,KAAcC,EAAS,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cAAc;MAE5C;MACA,WAAU;KACX,CAAA,GACD,kBAACQ,GAAD;MACE,MAAK;MACL,UAAU,kBAACQ,GAAD,EAAM,MAAM,GAAK,CAAA;MAC3B,WAAWnC,EAAU;MACrB,UAAU,CAACgB,KAAY,CAACC;MACzB,UAAA;KAEO,CAAA,CACJ;;GACH;;CACK,CAAA;AAEhB"}
|
|
1
|
+
{"version":3,"file":"AgentTestChatPage.js","names":["TESTABLE","MAX_MESSAGE_LENGTH","AgentTestChatPage","t","useTr","useParams","useBotlit","agent","useAgent","agentId","send","sendState","useAgentTestChat","message","setMessage","useState","turns","setTurns","conversationId","setConversationId","conversationEpoch","useRef","loading","PageLayout","error","ErrorState","refetch","statusAllowsTest","testable","unavailableStatusLabels","trimmed","submit","event","id","epoch","current","reply","turn","sendError","text","Button","navigateTo","ArrowLeft","StatusBadge","Badge","Link","getPath","Textarea","Send"],"sources":["../../../src/botlit/pages/AgentTestChatPage.tsx"],"sourcesContent":["/**\n * Agent test chat (BOFF-15360)\n * @module botlit/pages\n *\n * \"Test Agent\" from the builder: talk to any agent — including a draft that is\n * not live yet — before publishing it. Every message is one real run\n * (`chatWithAgent`) with a row in the execution ledger, so each reply shows the\n * model, the tokens it used and a link to its execution.\n */\n\nimport { useRef, useState, type FC, type FormEvent } from 'react';\nimport { Link, useParams } from 'react-router';\nimport { ArrowLeft, Send } from 'lucide-react';\n\nimport { useTr } from '../../shared/hooks/useTr';\nimport { PageLayout } from '../components/PageLayout';\nimport { Button } from '../components/Button';\nimport { Badge, StatusBadge } from '../components/Badge';\nimport { Textarea } from '../components/Input';\nimport { ErrorState } from '../components/ErrorState';\nimport { useAgent } from '../hooks/useAgents';\nimport { useAgentTestChat, type AgentTestReply } from '../hooks/useAgentTestChat';\nimport { useBotlit } from '../providers/BotlitProvider';\n\n/** Statuses the server lets a test turn run on. */\nconst TESTABLE = new Set(['DRAFT', 'ACTIVE']);\nconst MAX_MESSAGE_LENGTH = 8192;\n\ninterface Turn {\n id: number;\n prompt: string;\n reply?: AgentTestReply;\n error?: string;\n}\n\nexport const AgentTestChatPage: FC = () => {\n const t = useTr();\n const { agentId } = useParams();\n const { navigateTo, getPath } = useBotlit();\n const { data: agent, loading, error, refetch } = useAgent(agentId);\n const [send, sendState] = useAgentTestChat();\n const [message, setMessage] = useState('');\n const [turns, setTurns] = useState<Turn[]>([]);\n const [conversationId, setConversationId] = useState<string | null>(null);\n // Bumped by \"New conversation\": a reply to an earlier conversation that\n // arrives afterwards must not re-thread the new one.\n const conversationEpoch = useRef(0);\n\n if (loading && !agent) {\n return (\n <PageLayout title={t('botlit.agentTest.title', 'Test Agent')}>\n <div\n role=\"status\"\n aria-label={t('botlit.common.loading', 'Loading')}\n className=\"h-64 rounded-lg bg-bg-sunken motion-safe:animate-vc-shimmer\"\n />\n </PageLayout>\n );\n }\n if (error || !agent || !agentId) {\n return (\n <PageLayout title={t('botlit.agentTest.title', 'Test Agent')}>\n <ErrorState\n resource={t('botlit.agentTest.resource', 'this agent')}\n error={error ?? new Error(t('botlit.agentTest.notFound', 'Agent not found'))}\n onRetry={() => void refetch()}\n />\n </PageLayout>\n );\n }\n\n const statusAllowsTest = TESTABLE.has(agent.status);\n const testable = statusAllowsTest && Boolean(agent.llmModelId);\n const unavailableStatusLabels = new Map([\n ['PAUSED', t('botlit.agentTest.statusPaused', 'paused')],\n ['TRAINING', t('botlit.agentTest.statusTraining', 'training')],\n ['ARCHIVED', t('botlit.agentTest.statusArchived', 'archived')],\n ]);\n const trimmed = message.trim();\n\n const submit = async (event: FormEvent) => {\n event.preventDefault();\n if (!trimmed || trimmed.length > MAX_MESSAGE_LENGTH || sendState.loading) return;\n const id = Date.now();\n const epoch = conversationEpoch.current;\n setTurns((current) => [...current, { id, prompt: trimmed }]);\n setMessage('');\n try {\n const reply = await send({ agentId, message: trimmed, conversationId });\n if (epoch !== conversationEpoch.current) return;\n if (reply.conversationId) setConversationId(reply.conversationId);\n setTurns((current) => current.map((turn) => (turn.id === id ? { ...turn, reply } : turn)));\n } catch (sendError: unknown) {\n const text =\n sendError instanceof Error\n ? sendError.message\n : t('botlit.agentTest.replyFailed', 'The agent could not answer');\n setTurns((current) =>\n current.map((turn) => (turn.id === id ? { ...turn, error: text } : turn))\n );\n }\n };\n\n return (\n <PageLayout\n leading={\n <Button\n variant=\"ghost\"\n size=\"icon\"\n type=\"button\"\n aria-label={t('botlit.agentTest.backToAgent', 'Back to agent')}\n onClick={() => navigateTo(`agents/${agentId}`)}\n >\n <ArrowLeft size={20} aria-hidden=\"true\" />\n </Button>\n }\n title={t('botlit.agentTest.namedTitle', 'Test {{name}}', { name: agent.name })}\n meta={<StatusBadge status={agent.status} />}\n description={t(\n 'botlit.agentTest.description',\n \"Each message is a real run of this agent's current configuration and is recorded in Executions.\"\n )}\n actions={\n turns.length > 0 ? (\n <Button\n variant=\"outline\"\n onClick={() => {\n conversationEpoch.current += 1;\n setTurns([]);\n setConversationId(null);\n }}\n >\n {t('botlit.agentTest.newConversation', 'New conversation')}\n </Button>\n ) : undefined\n }\n >\n <div className=\"mx-auto flex w-full max-w-4xl flex-col gap-4\">\n {!statusAllowsTest && (\n <p role=\"alert\" className=\"text-sm\">\n {t(\n 'botlit.agentTest.statusUnavailable',\n 'A {{status}} agent does not run. Activate it or move it back to draft to test it.',\n { status: unavailableStatusLabels.get(agent.status) ?? agent.status.toLowerCase() }\n )}\n </p>\n )}\n {!agent.llmModelId && (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n {t(\n 'botlit.agentTest.modelRequired',\n 'This agent has no model yet. Choose one in Edit Agent before testing.'\n )}\n </p>\n )}\n <ol aria-label={t('botlit.agentTest.conversation', 'Conversation')} className=\"space-y-4\">\n {turns.length === 0 && (\n <li className=\"text-sm text-text-secondary\">\n {t('botlit.agentTest.emptyConversation', 'Send a message to start testing.')}\n </li>\n )}\n {turns.map((turn) => (\n <li key={turn.id} className=\"space-y-2\">\n <div className=\"ml-auto max-w-[80%] rounded-lg bg-bg-sunken p-3 text-sm\">\n <span className=\"sr-only\">{t('botlit.agentTest.you', 'You:')} </span>\n {turn.prompt}\n </div>\n {turn.reply ? (\n <div className=\"max-w-[80%] space-y-2 rounded-lg border border-border-subtle p-3\">\n <p className=\"whitespace-pre-wrap text-sm\">\n <span className=\"sr-only\">{agent.name}: </span>\n {turn.reply.message}\n </p>\n <div className=\"flex flex-wrap items-center gap-2 text-xs text-text-secondary\">\n {turn.reply.model && <Badge variant=\"outline\">{turn.reply.model}</Badge>}\n {typeof turn.reply.tokensUsed === 'number' && (\n <span>\n {turn.reply.tokensUsed === 1\n ? t('botlit.agentTest.tokenOne', '{{count}} token', { count: 1 })\n : t('botlit.agentTest.tokenOther', '{{count}} tokens', {\n count: turn.reply.tokensUsed,\n })}\n </span>\n )}\n {turn.reply.sources.length > 0 && (\n <span>\n {turn.reply.sources.length === 1\n ? t('botlit.agentTest.sourceOne', '{{count}} cited source', { count: 1 })\n : t('botlit.agentTest.sourceOther', '{{count}} cited sources', {\n count: turn.reply.sources.length,\n })}\n </span>\n )}\n {turn.reply.executionId && (\n <Link\n to={getPath(`executions/${turn.reply.executionId}`)}\n className=\"underline\"\n >\n {t('botlit.agentTest.viewExecution', 'View execution')}\n </Link>\n )}\n </div>\n </div>\n ) : turn.error ? (\n <p role=\"alert\" className=\"max-w-[80%] text-sm text-status-error-text\">\n {turn.error}\n </p>\n ) : (\n <p role=\"status\" className=\"text-sm text-text-secondary\">\n {t('botlit.agentTest.answering', '{{name}} is answering…', { name: agent.name })}\n </p>\n )}\n </li>\n ))}\n </ol>\n <form noValidate onSubmit={(event) => void submit(event)} className=\"flex items-end gap-2\">\n <Textarea\n aria-label={t('botlit.agentTest.message', 'Message')}\n value={message}\n rows={3}\n maxLength={MAX_MESSAGE_LENGTH}\n disabled={!testable || sendState.loading}\n placeholder={t('botlit.agentTest.messagePlaceholder', 'Ask the agent something…')}\n onChange={(event) => setMessage(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n event.currentTarget.form?.requestSubmit();\n }\n }}\n className=\"flex-1\"\n />\n <Button\n type=\"submit\"\n leftIcon={<Send size={16} />}\n isLoading={sendState.loading}\n disabled={!testable || !trimmed}\n >\n {t('botlit.agentTest.send', 'Send')}\n </Button>\n </form>\n </div>\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAMA,oBAAW,IAAI,IAAI,CAAC,SAAS,QAAQ,CAAC,GACtCC,IAAqB,MASdC,UAA8B;CACzC,IAAMC,IAAIC,EAAM,GACV,EAAE,eAAYC,EAAU,GACxB,EAAE,eAAY,eAAYC,EAAU,GACpC,EAAE,MAAMC,GAAO,YAAS,UAAO,eAAYC,EAASC,CAAO,GAC3D,CAACC,GAAMC,KAAaC,EAAiB,GACrC,CAACC,GAASC,KAAcC,EAAS,EAAE,GACnC,CAACC,GAAOC,KAAYF,EAAiB,CAAC,CAAC,GACvC,CAACG,GAAgBC,KAAqBJ,EAAwB,IAAI,GAGlEK,IAAoBC,EAAO,CAAC;CAElC,IAAIC,KAAW,CAACf,GACd,OACE,kBAACgB,GAAD;EAAY,OAAOpB,EAAE,0BAA0B,YAAY;EACzD,UAAA,kBAAC,OAAD;GACE,MAAK;GACL,cAAYA,EAAE,yBAAyB,SAAS;GAChD,WAAU;EACX,CAAA;CACS,CAAA;CAGhB,IAAIqB,KAAS,CAACjB,KAAS,CAACE,GACtB,OACE,kBAACc,GAAD;EAAY,OAAOpB,EAAE,0BAA0B,YAAY;EACzD,UAAA,kBAACsB,GAAD;GACE,UAAUtB,EAAE,6BAA6B,YAAY;GACrD,OAAOqB,KAAa,MAAMrB,EAAE,6BAA6B,iBAAiB,CAAC;GAC3E,eAAe,KAAKuB,EAAQ;EAC7B,CAAA;CACS,CAAA;CAIhB,IAAMC,IAAmB3B,EAAS,IAAIO,EAAM,MAAM,GAC5CqB,IAAWD,KAAoB,EAAQpB,EAAM,YAC7CsB,oBAA0B,IAAI,IAAI;EACtC,CAAC,UAAU1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