@blocklet/pages-kit 0.2.344 → 0.2.346

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.
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useIsAgentAdmin = void 0;
4
4
  const session_1 = require("../../../session");
5
+ const ADMIN_ROLES = ['admin', 'owner'];
5
6
  function useIsAgentAdmin(agent) {
6
7
  const { session } = (0, session_1.useSessionContext)();
7
8
  if (!session.user)
8
9
  return false;
10
+ if (ADMIN_ROLES.includes(session.user.role))
11
+ return true;
9
12
  return session.user.did === agent.createdBy;
10
13
  }
11
14
  exports.useIsAgentAdmin = useIsAgentAdmin;
@@ -142,7 +142,7 @@ function AgentMessage({ message, hideAvatar }) {
142
142
  p: 0.25,
143
143
  } })), children: (0, jsx_runtime_1.jsx)(material_1.Stack, { gap: 1, className: "message-response", children: ((_d = message.outputs) === null || _d === void 0 ? void 0 : _d.content) && ((0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { className: isMessageLoading ? 'writing' : '', children: message.outputs.content })) }) })) : (isMessageLoading && ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", height: 24 + 8 + 8,
144
144
  // only response with loading
145
- className: "message-response" }))), (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.map((object) => ((0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: object.data }, object.taskId))), message.error && (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: message.error })] })] })] }));
145
+ className: "message-response" }))), (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.map((object, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: object }, index)), message.error && (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: message.error })] })] })] }));
146
146
  }
147
147
  function MessageItemWrapper(_a) {
148
148
  var _b;
@@ -42,7 +42,7 @@ function PhotoGalleryItem() {
42
42
  const { message } = (0, CurrentMessage_1.useCurrentMessage)();
43
43
  const [openDialog, setOpenDialog] = (0, react_2.useState)(false);
44
44
  const objects = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) !== null && _b !== void 0 ? _b : [];
45
- const images = objects.flatMap((i) => { var _a; return (_a = i.data[types_1.RuntimeOutputVariable.images]) !== null && _a !== void 0 ? _a : []; });
45
+ const images = objects.flatMap((i) => { var _a, _b; return (_b = (_a = i.data) === null || _a === void 0 ? void 0 : _a[types_1.RuntimeOutputVariable.images]) !== null && _b !== void 0 ? _b : []; });
46
46
  if (!images.length && message.error) {
47
47
  return ((0, jsx_runtime_1.jsx)(material_1.Stack, { alignItems: "center", justifyContent: "center", sx: {
48
48
  aspectRatio: 1,
@@ -19,6 +19,7 @@ const material_1 = require("@mui/material");
19
19
  const react_1 = require("react");
20
20
  const react_wrap_balancer_1 = __importDefault(require("react-wrap-balancer"));
21
21
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
22
+ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
22
23
  const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
23
24
  const SimpleLayout_1 = __importDefault(require("../../components/Layout/SimpleLayout"));
24
25
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
@@ -48,5 +49,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
48
49
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
49
50
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
50
51
  return null;
51
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }));
52
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }) }) }) }));
52
53
  });
@@ -230,7 +230,7 @@ function V0Output() {
230
230
  overflowY: 'auto',
231
231
  scrollbarWidth: 'thin',
232
232
  scrollbarColor: 'grey transparent',
233
- }, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: item.data }, index)), !isMessageLoading && ((_b = message.outputs) === null || _b === void 0 ? void 0 : _b.content) && ((0, jsx_runtime_1.jsx)(ShareActions_1.default, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), (0, jsx_runtime_1.jsxs)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Loading_1.default, {}), children: [(0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: isMobile ? 'bottom' : 'right', open: !!code, onClose: onCloseCode, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ p: 2, pt: 0 }, (isMobile ? { maxHeight: '70vh' } : { maxWidth: '70vw' })), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
233
+ }, propertiesValueMap: propertiesValueMap }) }), objects === null || objects === void 0 ? void 0 : objects.map((item, index) => (0, jsx_runtime_1.jsx)(MessageMetadataRenderer_1.default, { object: item }, index)), !isMessageLoading && ((_b = message.outputs) === null || _b === void 0 ? void 0 : _b.content) && ((0, jsx_runtime_1.jsx)(ShareActions_1.default, { direction: "row", justifyContent: "flex-end", sx: { mt: 2 } })), (0, jsx_runtime_1.jsxs)(react_2.Suspense, { fallback: (0, jsx_runtime_1.jsx)(Loading_1.default, {}), children: [(0, jsx_runtime_1.jsx)(material_1.Drawer, { anchor: isMobile ? 'bottom' : 'right', open: !!code, onClose: onCloseCode, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: Object.assign({ p: 2, pt: 0 }, (isMobile ? { maxHeight: '70vh' } : { maxWidth: '70vw' })), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
234
234
  py: 2,
235
235
  position: 'sticky',
236
236
  top: 0,
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
13
  };
@@ -297,19 +286,17 @@ function V0DetailRender() {
297
286
  backgroundColor: 'background.block',
298
287
  flex: 1,
299
288
  maxWidth: isMobile ? '100%' : `calc(100% - ${sliderWidth}px - 16px)`,
300
- }, children: (0, jsx_runtime_1.jsx)(AgentOutputRender, { message: currentMessage }) })] }));
289
+ }, children: currentMessage && (0, jsx_runtime_1.jsx)(AgentOutputRender, { message: currentMessage }) })] }));
301
290
  }
302
- function AgentInputRender(_a) {
303
- var props = __rest(_a, []);
291
+ function AgentInputRender() {
304
292
  const { appearanceInput } = (0, use_appearances_1.default)();
305
293
  if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
306
294
  return null;
307
- return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties, props: props }) }));
295
+ return ((0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceInput.componentId, properties: appearanceInput.componentProperties }) }));
308
296
  }
309
- function AgentOutputRender(_a) {
310
- var { message } = _a, props = __rest(_a, ["message"]);
297
+ function AgentOutputRender({ message }) {
311
298
  const { appearanceOutput } = (0, use_appearances_1.default)();
312
299
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
313
300
  return null;
314
- return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, props: props }) }) }) }));
301
+ return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.agentId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsx)(react_2.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }));
315
302
  }
@@ -134,11 +134,11 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
134
134
  return (0, jsx_runtime_1.jsx)(RetryComponent, { message: message });
135
135
  }
136
136
  return (_d = (_c = message === null || message === void 0 ? void 0 : message.outputs) === null || _c === void 0 ? void 0 : _c.objects) === null || _d === void 0 ? void 0 : _d.map((item) => {
137
- var _a, _b, _c;
137
+ var _a, _b;
138
138
  const { taskId } = item;
139
139
  // @ts-ignore
140
- const code = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a[codeField];
141
- return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {}, message: message }, item.taskId));
140
+ const code = item === null || item === void 0 ? void 0 : item[codeField];
141
+ return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_a = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _a === void 0 ? void 0 : _a[locale]) || ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b.en) || {}, message: message }, item.taskId));
142
142
  });
143
143
  // eslint-disable-next-line react-hooks/exhaustive-deps
144
144
  }, [isMessageLoading, (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects, propertiesValueMap, locale]);
@@ -149,8 +149,8 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
149
149
  exports.CodeRenderByMessage = CodeRenderByMessage;
150
150
  exports.CodeRenderByMessageMemo = (0, react_2.memo)(CodeRenderByMessage);
151
151
  function getCurrentCodeByTaskId(message, taskId) {
152
- var _a, _b, _c, _d;
152
+ var _a, _b, _c;
153
153
  // @ts-ignore
154
- return (_d = (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((item) => item.taskId === taskId)) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[codeField];
154
+ return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((item) => item.taskId === taskId)) === null || _c === void 0 ? void 0 : _c[codeField];
155
155
  }
156
156
  exports.getCurrentCodeByTaskId = getCurrentCodeByTaskId;