@blocklet/pages-kit 0.2.350 → 0.2.352

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.
Files changed (21) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
  2. package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -1
  3. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -0
  4. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -2
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
  8. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
  9. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  10. package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
  11. package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -1
  12. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -0
  13. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
  14. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
  15. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -2
  16. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
  17. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
  18. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  19. package/lib/types/tsconfig.tsbuildinfo +1 -1
  20. package/package.json +4 -4
  21. package/tsconfig.json +2 -1
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AgentErrorView = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const api_1 = require("@blocklet/ai-kit/api");
6
+ const components_1 = require("@blocklet/ai-kit/components");
5
7
  const material_1 = require("@mui/material");
6
8
  const react_error_boundary_1 = require("react-error-boundary");
7
9
  const locale_1 = require("../../../locale");
@@ -16,6 +18,9 @@ function AgentErrorView({ error }) {
16
18
  if (error.type === 'MissingSecretError') {
17
19
  return (0, jsx_runtime_1.jsx)(MissingSecretErrorView, {});
18
20
  }
21
+ if (error.type === api_1.SubscriptionErrorType.UNSUBSCRIBED) {
22
+ return (0, jsx_runtime_1.jsx)(components_1.SubscribeErrorAlert, { error: error });
23
+ }
19
24
  return (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", children: String(error === null || error === void 0 ? void 0 : error.message) });
20
25
  }
21
26
  exports.AgentErrorView = AgentErrorView;
@@ -32,12 +32,13 @@ function useHeaderMenu() {
32
32
  const clearSession = (0, session_1.useSessionState)((s) => s.clearSession);
33
33
  const { agent } = (0, runtime_1.useRuntimeState)();
34
34
  const isAdmin = (0, use_agent_admin_1.useIsAgentAdmin)(agent);
35
+ const hasSettings = agent.config.secrets.length > 0;
35
36
  (0, header_1.useHeader)(() => hideHeaderMenuButton
36
37
  ? {}
37
38
  : {
38
39
  addons: (exists) => [
39
40
  (0, jsx_runtime_1.jsx)(PopperMenuButton_1.default, { component: material_1.IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: [
40
- isAdmin && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => AgentSettingsDialog_1.settingsDialogState.getState().open(), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:settings" }) }), t('settings')] }, "settings")),
41
+ hasSettings && isAdmin && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, { onClick: () => AgentSettingsDialog_1.settingsDialogState.getState().open(), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:settings" }) }), t('settings')] }, "settings")),
41
42
  (0, jsx_runtime_1.jsxs)(LoadingMenuItem_1.default, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }, "clearSession"),
42
43
  ], children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:dots" }) }),
43
44
  ...exists,
@@ -43,6 +43,7 @@ const constants_1 = require("../../constants");
43
43
  const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
44
44
  const Runtime_1 = __importStar(require("../../contexts/Runtime"));
45
45
  const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
46
+ const use_header_menu_1 = require("../../hooks/use-header-menu");
46
47
  const runtime_1 = require("../../state/runtime");
47
48
  const logoSize = 44;
48
49
  function AgentCreatedBy({ did }) {
@@ -87,6 +88,7 @@ ${agent === null || agent === void 0 ? void 0 : agent.description}
87
88
  addons: (exists) => [(0, jsx_runtime_1.jsx)(SocialShare_1.default, { content: shareContent }), ...exists].filter(Boolean),
88
89
  };
89
90
  }, [locale, isMobile, agent]);
91
+ (0, use_header_menu_1.useHeaderMenu)();
90
92
  const componentId = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentId) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_PAGE_COMPONENT_ID;
91
93
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(react_helmet_1.Helmet, { children: [agent.project.name && (0, jsx_runtime_1.jsx)("title", { children: agent.project.name }), agent.project.description && (0, jsx_runtime_1.jsx)("meta", { name: "description", content: agent.project.description })] }), (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProperties }), (0, jsx_runtime_1.jsx)(AgentSettingsDialog_1.default, {})] }));
92
94
  }
@@ -21,6 +21,7 @@ const react_1 = require("react");
21
21
  const react_wrap_balancer_1 = __importDefault(require("react-wrap-balancer"));
22
22
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
23
23
  const locale_1 = require("../../../../locale");
24
+ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
24
25
  const SimpleHeader_1 = __importDefault(require("../../components/Header/SimpleHeader"));
25
26
  const LoadingButton_1 = __importDefault(require("../../components/LoadingButton"));
26
27
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
@@ -61,5 +62,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
61
62
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
62
63
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
63
64
  return null;
64
- 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 }) }) }) }, message.id));
65
+ 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 }, message.id) }) }) }, message.id));
65
66
  });
@@ -60,7 +60,7 @@ const MessageView = (0, react_1.memo)(({ message }) => {
60
60
  const { hideAgentAvatar, hideUserInputs } = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _b !== void 0 ? _b : {};
61
61
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
62
62
  return null;
63
- const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }) }));
63
+ const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }));
64
64
  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.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
65
65
  });
66
66
  exports.default = MessageView;
@@ -24,7 +24,6 @@ const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
24
24
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
25
25
  const ComponentPreferences_1 = require("../../contexts/ComponentPreferences");
26
26
  const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
27
- const use_header_menu_1 = require("../../hooks/use-header-menu");
28
27
  const session_1 = require("../../state/session");
29
28
  const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
30
29
  const InputsView_1 = __importDefault(require("./InputsView"));
@@ -49,7 +48,6 @@ function SimpleChatView() {
49
48
  }, [scrollToBottom, running]);
50
49
  const sessionLoading = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading);
51
50
  const loading = (0, session_1.useSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading) || sessionLoading;
52
- (0, use_header_menu_1.useHeaderMenu)();
53
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: {
54
52
  position: 'sticky',
55
53
  bottom: 0,
@@ -49,5 +49,5 @@ const OutputItemView = (0, react_1.memo)(({ message }) => {
49
49
  const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.agentId });
50
50
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
51
51
  return null;
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
+ 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 }, message.id) }) }) }));
53
53
  });
@@ -21,6 +21,7 @@ const material_1 = require("@mui/material");
21
21
  const react_2 = require("react");
22
22
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
23
23
  const locale_1 = require("../../../../locale");
24
+ const AgentErrorBoundary_1 = require("../../components/AgentErrorBoundary");
24
25
  const ActiveAgent_1 = require("../../contexts/ActiveAgent");
25
26
  const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
26
27
  const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
@@ -298,5 +299,5 @@ function AgentOutputRender({ message }) {
298
299
  const { appearanceOutput } = (0, use_appearances_1.default)();
299
300
  if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
300
301
  return null;
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 }) }) }) }));
302
+ 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, fallbackRender: AgentErrorBoundary_1.AgentErrorView }, message.id) }) }) }));
302
303
  }