@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.
- package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +5 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +2 -1
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +0 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +2 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/tsconfig.json +2 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SubscriptionErrorType } from '@blocklet/ai-kit/api';
|
|
3
|
+
import { SubscribeErrorAlert } from '@blocklet/ai-kit/components';
|
|
2
4
|
import { Alert, Button, Stack, alertClasses } from '@mui/material';
|
|
3
5
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
6
|
import { useLocaleContext } from '../../../locale';
|
|
@@ -12,6 +14,9 @@ export function AgentErrorView({ error }) {
|
|
|
12
14
|
if (error.type === 'MissingSecretError') {
|
|
13
15
|
return _jsx(MissingSecretErrorView, {});
|
|
14
16
|
}
|
|
17
|
+
if (error.type === SubscriptionErrorType.UNSUBSCRIBED) {
|
|
18
|
+
return _jsx(SubscribeErrorAlert, { error: error });
|
|
19
|
+
}
|
|
15
20
|
return _jsx(Alert, { severity: "error", children: String(error === null || error === void 0 ? void 0 : error.message) });
|
|
16
21
|
}
|
|
17
22
|
function MissingSecretErrorView() {
|
|
@@ -26,12 +26,13 @@ export function useHeaderMenu() {
|
|
|
26
26
|
const clearSession = useSessionState((s) => s.clearSession);
|
|
27
27
|
const { agent } = useRuntimeState();
|
|
28
28
|
const isAdmin = useIsAgentAdmin(agent);
|
|
29
|
+
const hasSettings = agent.config.secrets.length > 0;
|
|
29
30
|
useHeader(() => hideHeaderMenuButton
|
|
30
31
|
? {}
|
|
31
32
|
: {
|
|
32
33
|
addons: (exists) => [
|
|
33
34
|
_jsx(PopperMenuButton, { component: IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: [
|
|
34
|
-
isAdmin && (_jsxs(MenuItem, { onClick: () => settingsDialogState.getState().open(), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "tabler:settings" }) }), t('settings')] }, "settings")),
|
|
35
|
+
hasSettings && isAdmin && (_jsxs(MenuItem, { onClick: () => settingsDialogState.getState().open(), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "tabler:settings" }) }), t('settings')] }, "settings")),
|
|
35
36
|
_jsxs(LoadingMenuItem, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }, "clearSession"),
|
|
36
37
|
], children: _jsx(Icon, { icon: "tabler:dots" }) }),
|
|
37
38
|
...exists,
|
|
@@ -15,6 +15,7 @@ import { AI_STUDIO_DID, DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
|
|
|
15
15
|
import ActiveAgentProvider from '../../contexts/ActiveAgent';
|
|
16
16
|
import RuntimeProvider, { RuntimeProviderFromUrl } from '../../contexts/Runtime';
|
|
17
17
|
import useAppearances from '../../hooks/use-appearances';
|
|
18
|
+
import { useHeaderMenu } from '../../hooks/use-header-menu';
|
|
18
19
|
import { useRuntimeState } from '../../state/runtime';
|
|
19
20
|
const logoSize = 44;
|
|
20
21
|
function AgentCreatedBy({ did }) {
|
|
@@ -58,6 +59,7 @@ ${agent === null || agent === void 0 ? void 0 : agent.description}
|
|
|
58
59
|
addons: (exists) => [_jsx(SocialShare, { content: shareContent }), ...exists].filter(Boolean),
|
|
59
60
|
};
|
|
60
61
|
}, [locale, isMobile, agent]);
|
|
62
|
+
useHeaderMenu();
|
|
61
63
|
const componentId = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentId) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_COMPONENT_ID;
|
|
62
64
|
return (_jsxs(_Fragment, { children: [_jsxs(Helmet, { children: [agent.project.name && _jsx("title", { children: agent.project.name }), agent.project.description && _jsx("meta", { name: "description", content: agent.project.description })] }), _jsx(CustomComponentRenderer, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProperties }), _jsx(AgentSettingsDialog, {})] }));
|
|
63
65
|
}
|
|
@@ -16,6 +16,7 @@ import { Suspense, memo, useRef } from 'react';
|
|
|
16
16
|
import Balancer from 'react-wrap-balancer';
|
|
17
17
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
18
18
|
import { useLocaleContext } from '../../../../locale';
|
|
19
|
+
import { AgentErrorView } from '../../components/AgentErrorBoundary';
|
|
19
20
|
import SimpleHeader from '../../components/Header/SimpleHeader';
|
|
20
21
|
import LoadingButton from '../../components/LoadingButton';
|
|
21
22
|
import { useActiveAgent } from '../../contexts/ActiveAgent';
|
|
@@ -55,5 +56,5 @@ const OutputItemView = memo(({ message }) => {
|
|
|
55
56
|
const { appearanceOutput } = useAppearances({ agentId: message.agentId });
|
|
56
57
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
57
58
|
return null;
|
|
58
|
-
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }, message.id));
|
|
59
|
+
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }, message.id) }) }) }, message.id));
|
|
59
60
|
});
|
|
@@ -31,7 +31,7 @@ const MessageView = memo(({ message }) => {
|
|
|
31
31
|
const { hideAgentAvatar, hideUserInputs } = (_b = useComponentPreferences()) !== null && _b !== void 0 ? _b : {};
|
|
32
32
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
33
33
|
return null;
|
|
34
|
-
const agentMessage = (_jsx(MessageBodyContainer, { messageRole: "assistant", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }) }));
|
|
34
|
+
const agentMessage = (_jsx(MessageBodyContainer, { messageRole: "assistant", children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }, message.id) }));
|
|
35
35
|
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsxs(Stack, { gap: 2, children: [!hideUserInputs && (_jsx(Box, { children: _jsx(UserInfo, { 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: _jsx(Stack, { sx: { alignItems: 'flex-end' }, children: _jsx(MessageBodyContainer, { messageRole: "user", children: _jsx(UserMessageView, {}) }) }) }) })), _jsx(Box, { children: !hideAgentAvatar ? (_jsx(UserInfo, { 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) })] }) }) }));
|
|
36
36
|
});
|
|
37
37
|
export default MessageView;
|
|
@@ -19,7 +19,6 @@ import ScrollView from '../../components/ScrollView';
|
|
|
19
19
|
import { useActiveAgent } from '../../contexts/ActiveAgent';
|
|
20
20
|
import { ComponentPreferencesProvider, useComponentPreferences } from '../../contexts/ComponentPreferences';
|
|
21
21
|
import CurrentAgentProvider from '../../contexts/CurrentAgent';
|
|
22
|
-
import { useHeaderMenu } from '../../hooks/use-header-menu';
|
|
23
22
|
import { useAutoLoadSessionState, useCurrentSessionState, useSessionState } from '../../state/session';
|
|
24
23
|
import BackgroundImage from './BackgroundImage';
|
|
25
24
|
import InputsView from './InputsView';
|
|
@@ -43,7 +42,6 @@ function SimpleChatView() {
|
|
|
43
42
|
}, [scrollToBottom, running]);
|
|
44
43
|
const sessionLoading = useCurrentSessionState((s) => s === null || s === void 0 ? void 0 : s.loading);
|
|
45
44
|
const loading = useSessionState((s) => s === null || s === void 0 ? void 0 : s.loading) || sessionLoading;
|
|
46
|
-
useHeaderMenu();
|
|
47
45
|
return (_jsxs(SimpleLayout, { px: 0, children: [_jsx(SimpleHeader, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? (_jsx(Box, { textAlign: "center", my: 10, children: _jsx(CircularProgress, { size: 24 }) })) : (_jsxs(_Fragment, { children: [_jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(MessagesView, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: 1, pb: 10, px: { xs: 2, sm: 3 } }) }), _jsx(CurrentAgentProvider, { agentId: activeAgentId, children: _jsx(InputsView, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
48
46
|
position: 'sticky',
|
|
49
47
|
bottom: 0,
|
|
@@ -43,5 +43,5 @@ const OutputItemView = memo(({ message }) => {
|
|
|
43
43
|
const { appearanceOutput } = useAppearances({ agentId: message.agentId });
|
|
44
44
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
45
45
|
return null;
|
|
46
|
-
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }) }) }) }));
|
|
46
|
+
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }, message.id) }) }) }));
|
|
47
47
|
});
|
|
@@ -16,6 +16,7 @@ import { Box, Button, Chip, Container, IconButton, Stack, ThemeProvider, Tooltip
|
|
|
16
16
|
import { Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
17
|
import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
|
|
18
18
|
import { useLocaleContext } from '../../../../locale';
|
|
19
|
+
import { AgentErrorView } from '../../components/AgentErrorBoundary';
|
|
19
20
|
import { useActiveAgent } from '../../contexts/ActiveAgent';
|
|
20
21
|
import CurrentAgentProvider from '../../contexts/CurrentAgent';
|
|
21
22
|
import CurrentMessageProvider from '../../contexts/CurrentMessage';
|
|
@@ -292,5 +293,5 @@ function AgentOutputRender({ message }) {
|
|
|
292
293
|
const { appearanceOutput } = useAppearances();
|
|
293
294
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
|
|
294
295
|
return null;
|
|
295
|
-
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }) }) }));
|
|
296
|
+
return (_jsx(CurrentAgentProvider, { agentId: message.agentId, children: _jsx(CurrentMessageProvider, { message: message, children: _jsx(Suspense, { children: _jsx(CustomComponentRenderer, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties, fallbackRender: AgentErrorView }, message.id) }) }) }));
|
|
296
297
|
}
|