@blocklet/pages-kit 0.2.361 → 0.2.363

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.
@@ -64,7 +64,7 @@ function ThemeProvider({ children }) {
64
64
  props: {},
65
65
  style: ({ theme }) => theme.unstable_sx({
66
66
  '.MuiInputBase-root': {
67
- fieldset: { borderColor: 'rgba(229, 231, 235, 1)' },
67
+ fieldset: { borderColor: 'grey.400' },
68
68
  [`&.Mui-focused, :not(.${material_1.inputBaseClasses.disabled}):hover`]: {
69
69
  fieldset: {
70
70
  border: 'none',
@@ -53,17 +53,17 @@ function useAppearances(args) {
53
53
  }, [agent, runtimeAgent]);
54
54
  return { appearancePage, appearanceInput, appearanceOutput };
55
55
  }
56
- function getProjectIconUrl(projectId) {
57
- return (0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.AI_STUDIO_DID), '/api/projects', projectId, '/logo.png');
56
+ function getProjectIconUrl({ blockletDid, aid }) {
57
+ return (0, ufo_1.withQuery)((0, ufo_1.joinURL)(window.location.origin, (0, utils_1.getComponentMountPoint)(constants_1.AI_RUNTIME_DID), '/api/agents', aid, '/logo'), { blockletDid });
58
58
  }
59
59
  function useProfile(args) {
60
- const { agent: runtimeAgent } = (0, runtime_1.useRuntimeState)();
60
+ const { blockletDid, aid, agent: runtimeAgent } = (0, runtime_1.useRuntimeState)();
61
61
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)(args);
62
62
  return (0, react_1.useMemo)(() => {
63
63
  const profile = (0, runtime_output_schema_1.getOutputVariableInitialValue)(agent, types_1.RuntimeOutputVariable.profile);
64
64
  const runtimeProfile = (0, runtime_output_schema_1.getOutputVariableInitialValue)(runtimeAgent, types_1.RuntimeOutputVariable.profile);
65
65
  return {
66
- avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl(agent.project.id),
66
+ avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl({ blockletDid, aid }),
67
67
  name: (profile === null || profile === void 0 ? void 0 : profile.name) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.name) || agent.name,
68
68
  };
69
69
  }, [agent, runtimeAgent]);
@@ -28,6 +28,7 @@ const runtime_1 = require("../../state/runtime");
28
28
  const session_1 = require("../../state/session");
29
29
  const agent_inputs_1 = require("../../utils/agent-inputs");
30
30
  function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQuestionField, chatMode, }) {
31
+ const submitRef = (0, react_1.useRef)(null);
31
32
  const { t } = (0, locale_1.useLocaleContext)();
32
33
  const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
33
34
  const { execute } = (0, runtime_1.useRuntimeState)();
@@ -47,6 +48,8 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
47
48
  }
48
49
  }, [defaultForm, autoFillLastForm, form, chatMode]);
49
50
  const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
51
+ var _a;
52
+ (_a = submitRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'center' });
50
53
  yield execute({
51
54
  aid,
52
55
  parameters,
@@ -76,11 +79,11 @@ function AutoForm({ submitText, inlineLabel, autoFillLastForm = true, submitInQu
76
79
  var _a;
77
80
  return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "form-item", children: [parameter.label && (0, jsx_runtime_1.jsx)(material_1.FormLabel, { children: parameter.label }), (0, jsx_runtime_1.jsx)(AgentInputField_1.default, { inputRef: field.ref, autoFocus: index === 0, size: "small", hiddenLabel: true, fullWidth: true, label: undefined, parameter: parameter, maxRows: !(parameter === null || parameter === void 0 ? void 0 : parameter.type) || (parameter === null || parameter === void 0 ? void 0 : parameter.type) === 'string' ? 5 : undefined, value: field.value || '', onChange: (value) => field.onChange({ target: { value } }), error: Boolean(fieldState.error), helperText: ((_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message) || (parameter === null || parameter === void 0 ? void 0 : parameter.helper), InputProps: parameter.key === 'question' && submitInQuestionField
78
81
  ? {
79
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
82
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: { py: 3, mr: -0.75, alignSelf: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { borderRadius: 1.5 }, children: submitText }) })),
80
83
  }
81
84
  : undefined })] }));
82
85
  } }) }, parameter.id));
83
- }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }));
86
+ }), !(submitInQuestionField && (parameters === null || parameters === void 0 ? void 0 : parameters.some((i) => i.key === 'question'))) && ((0, jsx_runtime_1.jsx)(LoadingButton_1.default, { ref: submitRef, type: "submit", variant: "contained", loading: running, sx: { height: 40 }, children: submitText || t('generate') }))] }));
84
87
  }
85
88
  function useInitialFormValues() {
86
89
  const { agent } = (0, CurrentAgent_1.useCurrentAgent)();
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.default = DrawerOpenCloseIcon;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const css_1 = require("@emotion/css");
17
+ const material_1 = require("@mui/material");
18
+ function DrawerOpenCloseIcon(_a) {
19
+ var { arrowDirection } = _a, props = __rest(_a, ["arrowDirection"]);
20
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", position: "relative" }, props, { className: (0, css_1.cx)(props.className, `drawer-open-close-icon-${arrowDirection || 'up'}`), sx: Object.assign({ p: 1, cursor: 'pointer', ':hover': {
21
+ opacity: 0.7,
22
+ }, ':before,:after': {
23
+ content: '""',
24
+ display: 'block',
25
+ bgcolor: 'currentColor',
26
+ width: 22,
27
+ height: 6,
28
+ borderRadius: 100,
29
+ position: 'relative',
30
+ }, ':before': {
31
+ transform: 'translateX(2px) rotateZ(-8deg)',
32
+ }, ':after': {
33
+ transform: 'translateX(-2px) rotateZ(8deg)',
34
+ }, '&.drawer-open-close-icon-down': {
35
+ ':before': {
36
+ transform: 'translateX(2px) rotateZ(8deg)',
37
+ },
38
+ ':after': {
39
+ transform: 'translateX(-2px) rotateZ(-8deg)',
40
+ },
41
+ } }, props.sx) })));
42
+ }
@@ -48,14 +48,33 @@ const ActiveAgent_1 = require("../../contexts/ActiveAgent");
48
48
  const CurrentAgent_1 = __importStar(require("../../contexts/CurrentAgent"));
49
49
  const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
50
50
  const runtime_1 = require("../../state/runtime");
51
+ const agent_inputs_1 = require("../../utils/agent-inputs");
51
52
  const runtime_output_schema_1 = require("../../utils/runtime-output-schema");
53
+ const DrawerOpenCloseIcon_1 = __importDefault(require("./DrawerOpenCloseIcon"));
54
+ const COLLAPSED_SIZE = 80;
52
55
  function InputsView(_a) {
53
56
  var props = __rest(_a, []);
54
- const { activeAgentId, setActiveAgentId } = (0, ActiveAgent_1.useActiveAgent)();
55
- const { agent } = (0, runtime_1.useRuntimeState)();
56
- const children = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = (0, runtime_output_schema_1.getOutputVariableInitialValue)(agent, types_1.RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b.filter((i) => !!i.id); }, [agent]);
57
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 2 }, props, { children: [children && children.length > 1 && ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", gap: 2, children: children === null || children === void 0 ? void 0 : children.map((child) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: child.id, children: (0, jsx_runtime_1.jsx)(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }))) })), (0, jsx_runtime_1.jsx)(material_1.Stack, { children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInput, {}) }) })] })));
57
+ const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
58
+ const { agent } = (0, CurrentAgent_1.useCurrentAgent)({ agentId: activeAgentId });
59
+ const inputs = (0, react_1.useMemo)(() => { var _a; return (_a = agent.parameters) === null || _a === void 0 ? void 0 : _a.filter(agent_inputs_1.isValidInput); }, [agent]);
60
+ const enableCollapse = !!inputs && inputs.length > 1;
61
+ const [open, setOpen] = (0, react_1.useState)(true);
62
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ gap: 1, py: 1 }, props, { children: [enableCollapse && ((0, jsx_runtime_1.jsx)(material_1.Stack, { direction: "row", justifyContent: "center", onClick: () => setOpen(!open), mb: -1, children: (0, jsx_runtime_1.jsx)(DrawerOpenCloseIcon_1.default, { color: "grey.500", arrowDirection: open ? 'down' : 'up' }) })), (0, jsx_runtime_1.jsx)(AgentList, { sx: { px: { xs: 2, sm: 3 } } }), (0, jsx_runtime_1.jsx)(material_1.Collapse, { in: !enableCollapse || open, orientation: "vertical", collapsedSize: enableCollapse ? COLLAPSED_SIZE : 0, sx: {
63
+ py: 1,
64
+ maxHeight: '40vh',
65
+ px: { xs: 2, sm: 3 },
66
+ overflow: 'auto',
67
+ }, children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInput, {}) }) }, inputs === null || inputs === void 0 ? void 0 : inputs.length)] })));
58
68
  }
69
+ const AgentList = (0, react_1.memo)((_a) => {
70
+ var props = __rest(_a, []);
71
+ const { activeAgentId, setActiveAgentId } = (0, ActiveAgent_1.useActiveAgent)();
72
+ const { agent: runtimeAgent } = (0, runtime_1.useRuntimeState)();
73
+ const children = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = (0, runtime_output_schema_1.getOutputVariableInitialValue)(runtimeAgent, types_1.RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b.filter((i) => !!i.id); }, [runtimeAgent]);
74
+ if (!(children === null || children === void 0 ? void 0 : children.length) || children.length <= 1)
75
+ return null;
76
+ return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ direction: "row", gap: 2, py: 1, overflow: "auto" }, props, { children: children === null || children === void 0 ? void 0 : children.map((child) => ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: child.id, children: (0, jsx_runtime_1.jsx)(AgentAvatar, { selected: activeAgentId === child.id, onClick: () => setActiveAgentId(child.id) }) }))) })));
77
+ });
59
78
  function AgentAvatar(_a) {
60
79
  var _b;
61
80
  var { selected } = _a, props = __rest(_a, ["selected"]);
@@ -51,11 +51,9 @@ function SimpleChatView() {
51
51
  return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
52
52
  position: 'sticky',
53
53
  bottom: 0,
54
- py: 2,
55
- px: { xs: 2, sm: 3 },
56
54
  zIndex: 10,
57
55
  borderRadius: 1,
58
- bgcolor: (theme) => (0, material_1.alpha)(theme.palette.background.paper, 0.7),
59
- backdropFilter: 'blur(10px)',
56
+ bgcolor: (theme) => (0, material_1.alpha)(theme.palette.background.paper, 0.8),
57
+ backdropFilter: 'blur(16px)',
60
58
  } }) })] }))] }));
61
59
  }