@iblai/iblai-js 2.64.0 → 2.65.0
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/web-containers/source/components/modals/create-agent-modal/create-agent-form.js +18 -10
- package/dist/web-containers/source/components/modals/create-agent-modal/create-agent-form.js.map +1 -1
- package/dist/web-containers/source/components/modals/create-agent-modal/use-create-agent-field-permissions.js +20 -0
- package/dist/web-containers/source/components/modals/create-agent-modal/use-create-agent-field-permissions.js.map +1 -0
- package/dist/web-containers/source/components/modals/create-agent-modal/use-create-agent-form.js +20 -22
- package/dist/web-containers/source/components/modals/create-agent-modal/use-create-agent-form.js.map +1 -1
- package/dist/web-containers/source/create-agent-form.js +18 -10
- package/dist/web-containers/source/create-agent-form.js.map +1 -1
- package/dist/web-containers/source/create-agent-modal/create-agent-form.js +18 -10
- package/dist/web-containers/source/create-agent-modal/create-agent-form.js.map +1 -1
- package/dist/web-containers/source/create-agent-modal/use-create-agent-field-permissions.js +20 -0
- package/dist/web-containers/source/create-agent-modal/use-create-agent-field-permissions.js.map +1 -0
- package/dist/web-containers/source/create-agent-modal/use-create-agent-form.js +20 -22
- package/dist/web-containers/source/create-agent-modal/use-create-agent-form.js.map +1 -1
- package/dist/web-containers/source/modals/create-agent-modal/create-agent-form.js +18 -10
- package/dist/web-containers/source/modals/create-agent-modal/create-agent-form.js.map +1 -1
- package/dist/web-containers/source/modals/create-agent-modal/use-create-agent-field-permissions.js +20 -0
- package/dist/web-containers/source/modals/create-agent-modal/use-create-agent-field-permissions.js.map +1 -0
- package/dist/web-containers/source/modals/create-agent-modal/use-create-agent-form.js +20 -22
- package/dist/web-containers/source/modals/create-agent-modal/use-create-agent-form.js.map +1 -1
- package/dist/web-containers/source/tsconfig.build.tsbuildinfo +1 -1
- package/dist/web-containers/source/use-create-agent-field-permissions.js +20 -0
- package/dist/web-containers/source/use-create-agent-field-permissions.js.map +1 -0
- package/dist/web-containers/source/use-create-agent-form.js +20 -22
- package/dist/web-containers/source/use-create-agent-form.js.map +1 -1
- package/dist/web-containers/source/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
import { useGetAgentSettingsFieldPermissionsQuery } from '@iblai/data-layer';
|
|
3
|
+
import { getCreateAgentFieldVisibility, canWriteAgentField } from '@iblai/web-utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Which Create Agent fields this person may set (iblai-platform#2766). An
|
|
7
|
+
* answer the backend cannot give — a 403, an older backend's 404, a network
|
|
8
|
+
* failure — leaves every field writable, today's behaviour; only an explicit
|
|
9
|
+
* `{ write: false }` hides one.
|
|
10
|
+
*/
|
|
11
|
+
function useCreateAgentFieldPermissions({ org, skip = false, }) {
|
|
12
|
+
const { data, isLoading, isError } = useGetAgentSettingsFieldPermissionsQuery({ org }, { skip: skip || !org });
|
|
13
|
+
const permissions = isError ? undefined : data;
|
|
14
|
+
const visibility = useMemo(() => getCreateAgentFieldVisibility(permissions), [permissions]);
|
|
15
|
+
const canWrite = useCallback((field) => canWriteAgentField(permissions, field), [permissions]);
|
|
16
|
+
return { permissions, visibility, isLoading, canWrite };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { useCreateAgentFieldPermissions };
|
|
20
|
+
//# sourceMappingURL=use-create-agent-field-permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-create-agent-field-permissions.js","sources":["../../../../../../../../src/components/modals/create-agent-modal/use-create-agent-field-permissions.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA2BA;;;;;AAKG;AACG,SAAU,8BAA8B,CAAC,EAC7C,GAAG,EACH,IAAI,GAAG,KAAK,GACuB,EAAA;IACnC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,wCAAwC,CAC3E,EAAE,GAAG,EAAE,EACP,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CACvB;IACD,MAAM,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI;AAE9C,IAAA,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,6BAA6B,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC3F,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAAa,KAAK,kBAAkB,CAAC,WAAW,EAAE,KAAK,CAAC,EACzD,CAAC,WAAW,CAAC,CACd;IAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE;AACzD;;;;"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useStore } from '../../../node_modules/.pnpm/@tanstack_react-store@0.7.7_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/@tanstack/react-store/dist/esm/index.js';
|
|
2
2
|
import { useForm } from '../../../node_modules/.pnpm/@tanstack_react-form@1.11.2_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/@tanstack/react-form/dist/esm/useForm.js';
|
|
3
3
|
import { useGetMentorCategoriesQuery, useCreateMentorMutation } from '@iblai/data-layer';
|
|
4
|
+
import { buildCreateAgentPayload } from '@iblai/web-utils';
|
|
4
5
|
import { DEFAULT_VISIBILITY_OPTIONS, DEFAULT_VISIBILITY_INDEX, DEFAULT_MODEL_OPTIONS, DEFAULT_AGENT_TEMPLATE, DEFAULT_AGENT_PROMPTS } from './defaults.js';
|
|
6
|
+
import { useCreateAgentFieldPermissions } from './use-create-agent-field-permissions.js';
|
|
5
7
|
|
|
6
8
|
/** Strip `undefined` values so a partial override only overrides set keys. */
|
|
7
9
|
function pickDefined(obj) {
|
|
@@ -15,9 +17,10 @@ function pickDefined(obj) {
|
|
|
15
17
|
return out;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
|
-
* Owns the Create Agent form state (TanStack form), the categories query,
|
|
19
|
-
* the create mutation. Identity/config come in as
|
|
20
|
-
* side effects are callbacks (no toast/navigation),
|
|
20
|
+
* Owns the Create Agent form state (TanStack form), the categories query, the
|
|
21
|
+
* field-permissions query and the create mutation. Identity/config come in as
|
|
22
|
+
* args (no app context), and side effects are callbacks (no toast/navigation),
|
|
23
|
+
* so it works for any host.
|
|
21
24
|
*/
|
|
22
25
|
function useCreateAgentForm({ org, username, initialValues, defaultPrompts, modelOptions, visibilityOptions, onCreated, onError, onBeforeCreate, }) {
|
|
23
26
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -26,6 +29,7 @@ function useCreateAgentForm({ org, username, initialValues, defaultPrompts, mode
|
|
|
26
29
|
{ org, userId: username }, {
|
|
27
30
|
skip: !org || !username,
|
|
28
31
|
});
|
|
32
|
+
const { permissions: fieldPermissions, visibility, isLoading: isLoadingFieldPermissions, } = useCreateAgentFieldPermissions({ org });
|
|
29
33
|
const [createMentor, { isLoading: isCreating }] = useCreateMentorMutation();
|
|
30
34
|
const models = modelOptions !== null && modelOptions !== void 0 ? modelOptions : DEFAULT_MODEL_OPTIONS;
|
|
31
35
|
const visibilities = visibilityOptions !== null && visibilityOptions !== void 0 ? visibilityOptions : DEFAULT_VISIBILITY_OPTIONS;
|
|
@@ -49,28 +53,14 @@ function useCreateAgentForm({ org, username, initialValues, defaultPrompts, mode
|
|
|
49
53
|
const form = useForm({
|
|
50
54
|
defaultValues,
|
|
51
55
|
onSubmit: async ({ value }) => {
|
|
52
|
-
|
|
56
|
+
const formData = buildCreateAgentPayload(value, fieldPermissions);
|
|
53
57
|
try {
|
|
54
58
|
const mentor = await createMentor({
|
|
55
59
|
org,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
new_mentor_name: value.name,
|
|
61
|
-
display_name: value.name,
|
|
62
|
-
template_name: value.base,
|
|
63
|
-
metadata: {
|
|
64
|
-
category: value.category,
|
|
65
|
-
},
|
|
66
|
-
guided_prompt_instructions: value.guidedPrompt,
|
|
67
|
-
proactive_prompt: value.proactivePrompt,
|
|
68
|
-
moderation_system_prompt: value.moderationPrompt,
|
|
69
|
-
system_prompt: value.systemPrompt,
|
|
70
|
-
description: value.description,
|
|
71
|
-
mentor_visibility: value.mentorVisibility,
|
|
72
|
-
...(value.category && { categories: [value.category] }),
|
|
73
|
-
},
|
|
60
|
+
// @ts-expect-error - uploaded_profile_image is a File upload, which the
|
|
61
|
+
// generated form-data type declares as a string, and template_name is left
|
|
62
|
+
// out when the person may not set it, which that type requires.
|
|
63
|
+
formData,
|
|
74
64
|
userId: username,
|
|
75
65
|
}).unwrap();
|
|
76
66
|
onCreated === null || onCreated === void 0 ? void 0 : onCreated(mentor);
|
|
@@ -87,6 +77,10 @@ function useCreateAgentForm({ org, username, initialValues, defaultPrompts, mode
|
|
|
87
77
|
const systemPrompt = useStore(form.store, (state) => state.values.systemPrompt);
|
|
88
78
|
const proactivePrompt = useStore(form.store, (state) => state.values.proactivePrompt);
|
|
89
79
|
const guidedPrompt = useStore(form.store, (state) => state.values.guidedPrompt);
|
|
80
|
+
// A field the person may not write is not shown, so it cannot be required.
|
|
81
|
+
const isSettingsComplete = name !== '' &&
|
|
82
|
+
(!visibility.description || description !== '') &&
|
|
83
|
+
(!visibility.category || category !== null);
|
|
90
84
|
const editPrompt = (prompt, type) => {
|
|
91
85
|
form.setFieldValue(type, prompt);
|
|
92
86
|
};
|
|
@@ -106,6 +100,10 @@ function useCreateAgentForm({ org, username, initialValues, defaultPrompts, mode
|
|
|
106
100
|
isCreating,
|
|
107
101
|
models,
|
|
108
102
|
visibilities,
|
|
103
|
+
visibility,
|
|
104
|
+
isLoadingFieldPermissions,
|
|
105
|
+
isSettingsComplete,
|
|
106
|
+
hasPromptsStep: visibility.anyPrompt,
|
|
109
107
|
name,
|
|
110
108
|
description,
|
|
111
109
|
category,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-create-agent-form.js","sources":["../../../../../../../../src/components/modals/create-agent-modal/use-create-agent-form.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-create-agent-form.js","sources":["../../../../../../../../src/components/modals/create-agent-modal/use-create-agent-form.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAuBA;AACA,SAAS,WAAW,CAAoC,GAAgB,EAAA;AACtE,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,EAAE;IACnB,MAAM,GAAG,GAAe,EAAE;IAC1B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAgB,EAAE;AACjD,QAAA,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAe;IAC/D;AACA,IAAA,OAAO,GAAG;AACZ;AAcA;;;;;AAKG;AACG,SAAU,kBAAkB,CAAC,EACjC,GAAG,EACH,QAAQ,EACR,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,cAAc,GACS,EAAA;;IACvB,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,GAAG,2BAA2B;;AAEtF,IAAA,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,EACzB;AACE,QAAA,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ;AACxB,KAAA,CACF;AAED,IAAA,MAAM,EACJ,WAAW,EAAE,gBAAgB,EAC7B,UAAU,EACV,SAAS,EAAE,yBAAyB,GACrC,GAAG,8BAA8B,CAAC,EAAE,GAAG,EAAE,CAAC;AAE3C,IAAA,MAAM,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,uBAAuB,EAAE;IAE3E,MAAM,MAAM,GAAG,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAZ,YAAY,GAAI,qBAAqB;IACpD,MAAM,YAAY,GAAG,iBAAiB,KAAA,IAA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