@blocklet/pages-kit 0.2.309 → 0.2.311

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 (60) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +3 -3
  2. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +5 -3
  3. package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +6 -14
  4. package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +94 -0
  5. package/lib/cjs/builtin/async/ai-runtime/index.js +5 -1
  6. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +33 -7
  7. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +12 -9
  8. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +13 -10
  9. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +8 -5
  10. package/lib/cjs/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +192 -0
  11. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +4 -26
  12. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +18 -24
  13. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -26
  14. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +152 -0
  15. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +79 -0
  16. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +147 -0
  17. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/index.js +12 -0
  18. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +1 -5
  19. package/lib/cjs/builtin/async/ai-runtime/utils/runtime-output-schema.js +8 -0
  20. package/lib/cjs/builtin/mui/material.js +3 -2
  21. package/lib/cjs/tsconfig.tsbuildinfo +1 -0
  22. package/lib/cjs/utils/inject-global-components-dump-json.js +1167 -0
  23. package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +3 -3
  24. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +5 -3
  25. package/lib/esm/builtin/async/ai-runtime/contexts/CurrentAgent.js +6 -14
  26. package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +87 -0
  27. package/lib/esm/builtin/async/ai-runtime/index.js +3 -0
  28. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +10 -7
  29. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +13 -10
  30. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +13 -10
  31. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +8 -5
  32. package/lib/esm/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +163 -0
  33. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +4 -3
  34. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +19 -25
  35. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -3
  36. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +146 -0
  37. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +73 -0
  38. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +142 -0
  39. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/index.js +3 -0
  40. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +1 -5
  41. package/lib/esm/builtin/async/ai-runtime/utils/runtime-output-schema.js +4 -0
  42. package/lib/esm/builtin/mui/material.js +1 -1
  43. package/lib/esm/tsconfig.tsbuildinfo +1 -0
  44. package/lib/esm/utils/inject-global-components-dump-json.js +1165 -0
  45. package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +8 -0
  46. package/lib/types/builtin/async/ai-runtime/contexts/CurrentAgent.d.ts +4 -5
  47. package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +45 -0
  48. package/lib/types/builtin/async/ai-runtime/index.d.ts +2 -0
  49. package/lib/types/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.d.ts +11 -0
  50. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Input.d.ts +7 -0
  51. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Output.d.ts +1 -0
  52. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Page.d.ts +5 -0
  53. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/index.d.ts +3 -0
  54. package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +1 -1
  55. package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +1 -3
  56. package/lib/types/builtin/async/ai-runtime/utils/runtime-output-schema.d.ts +3 -0
  57. package/lib/types/builtin/mui/material.d.ts +1 -1
  58. package/lib/types/tsconfig.tsbuildinfo +1 -0
  59. package/lib/types/utils/inject-global-components-dump-json.d.ts +1 -0
  60. package/package.json +13 -9
@@ -0,0 +1,147 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const jsx_runtime_1 = require("react/jsx-runtime");
18
+ const material_1 = require("@mui/material");
19
+ const dayjs_1 = __importDefault(require("dayjs"));
20
+ // import { useRuntimeState } from '@blocklet/pages-kit/builtin/async/ai-runtime';
21
+ // import { Icon } from 'iconify/react';
22
+ const react_1 = require("react");
23
+ const CustomComponentRenderer_1 = __importDefault(require("../../../../../components/CustomComponentRenderer"));
24
+ const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
25
+ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
26
+ const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
27
+ const runtime_1 = require("../../state/runtime");
28
+ const session_1 = require("../../state/session");
29
+ const getLineClamp = (count) => {
30
+ return {
31
+ display: '-webkit-box',
32
+ WebkitLineClamp: count,
33
+ WebkitBoxOrient: 'vertical',
34
+ overflow: 'hidden',
35
+ textOverflow: 'ellipsis',
36
+ };
37
+ };
38
+ function V0Page({ textColor = '#333', primaryColor }) {
39
+ var _a;
40
+ const inheritedTheme = (0, material_1.useTheme)();
41
+ const theme = (0, react_1.useMemo)(() => {
42
+ let { primary } = inheritedTheme.palette;
43
+ try {
44
+ if (primaryColor) {
45
+ primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
46
+ }
47
+ }
48
+ catch (error) {
49
+ console.error('augment primary color error', { error });
50
+ }
51
+ return (0, material_1.createTheme)(inheritedTheme, {
52
+ palette: { primary, textColor },
53
+ shape: {
54
+ borderRadius: 8,
55
+ },
56
+ });
57
+ }, [inheritedTheme, primaryColor, textColor]);
58
+ const [sessionId] = (0, react_1.useState)('1');
59
+ const [message, setMessage] = (0, react_1.useState)();
60
+ const { childAgentId } = (0, runtime_1.useRuntimeState)();
61
+ const messagesList = (0, session_1.useSessionState)({
62
+ autoLoad: true,
63
+ })((s) => s.messages);
64
+ (0, react_1.useEffect)(() => {
65
+ if (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length) {
66
+ const lastMessage = messagesList[messagesList.length - 1];
67
+ // @ts-ignore
68
+ setMessage(lastMessage);
69
+ }
70
+ }, [messagesList]);
71
+ const SliderRender = (0, react_1.useCallback)(({ message }) => {
72
+ // if is detail, return output
73
+ if (sessionId && (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length)) {
74
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
75
+ width: 200,
76
+ p: 2,
77
+ position: 'sticky',
78
+ top: 64,
79
+ height: 'calc(100vh - 65px)',
80
+ overflowY: 'auto',
81
+ }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { spacing: 2, justifyContent: "center", children: messagesList === null || messagesList === void 0 ? void 0 : messagesList.map((_, i) => {
82
+ var _a;
83
+ const isCurrent = _.taskId === (message === null || message === void 0 ? void 0 : message.taskId);
84
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => {
85
+ // @ts-ignore
86
+ setMessage(_);
87
+ }, sx: {
88
+ cursor: 'pointer',
89
+ backgroundColor: isCurrent ? 'primary.main' : 'rgba(0, 0, 0, 0.5)',
90
+ color: '#fff',
91
+ borderRadius: 1,
92
+ p: 1,
93
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", display: "block", sx: Object.assign({ color: 'rgba(255, 255, 255, 0.9)' }, getLineClamp(2)), children: (_a = _.parameters) === null || _a === void 0 ? void 0 : _a.question }), (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: {
94
+ textAlign: 'right',
95
+ fontWeight: 600,
96
+ fontSize: 12,
97
+ mt: 0.5,
98
+ display: 'flex',
99
+ justifyContent: 'space-between',
100
+ }, children: [(0, jsx_runtime_1.jsx)("span", { style: {
101
+ color: 'rgba(255, 255, 255, 0.7)',
102
+ fontWeight: 400,
103
+ }, children: (0, dayjs_1.default)(_.updatedAt).format('MM-DD HH:mm') }), (0, jsx_runtime_1.jsx)("span", { children: `V${i}` })] }) })] }, _.assistantId));
104
+ }) }) }, "slider"));
105
+ }
106
+ return null;
107
+ }, [JSON.stringify(messagesList)]);
108
+ const ContentRender = (0, react_1.useCallback)(() => {
109
+ // if is detail, return output
110
+ if (sessionId) {
111
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: (0, jsx_runtime_1.jsx)(AgentOutputRender, { message: message }) }));
112
+ }
113
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: (0, jsx_runtime_1.jsx)(material_1.Grid, { container: true, spacing: 2, justifyContent: "center", children: [...Array(3)].map((_, i) => ((0, jsx_runtime_1.jsx)(material_1.Grid, { item: true, xs: 12, sm: 6, md: 4, children: (0, jsx_runtime_1.jsx)(material_1.Card, { sx: { backgroundColor: 'rgba(0, 0, 0, 0.5)', color: '#fff' }, children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", sx: { mb: 1 }, children: `Code Snippet ${i + 1}` }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", display: "block", sx: { color: 'rgba(255, 255, 255, 0.7)' }, children: `This is history requirement ${i + 1}` })] }) }) }, i))) }) }));
114
+ }, [JSON.stringify(message)]);
115
+ return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: childAgentId, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
116
+ display: 'flex',
117
+ // background: 'linear-gradient(135deg, #1a237e 0%, #3c3f41 100%)',
118
+ }, children: [(0, jsx_runtime_1.jsx)(SliderRender, { message: message }), (0, jsx_runtime_1.jsxs)(material_1.Container, { sx: {
119
+ minHeight: 'calc(100vh - 64px - 1px)',
120
+ textAlign: 'center',
121
+ py: 2,
122
+ pt: 10,
123
+ gap: 2,
124
+ display: 'flex',
125
+ flexDirection: 'column',
126
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold' }, children: "AIGNE V0" }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign({}, getLineClamp(5)), children: ((_a = message === null || message === void 0 ? void 0 : message.parameters) === null || _a === void 0 ? void 0 : _a.question) || 'A v0 release to help you build code quickly' }), (0, jsx_runtime_1.jsx)(ContentRender, {}), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
127
+ position: 'sticky',
128
+ bottom: 0,
129
+ backgroundColor: 'white',
130
+ pt: 4,
131
+ }, children: (0, jsx_runtime_1.jsx)(AgentInputRender, {}) })] })] }) }) }));
132
+ }
133
+ exports.default = V0Page;
134
+ function AgentInputRender(_a) {
135
+ var props = __rest(_a, []);
136
+ const { appearanceInput } = (0, use_appearances_1.default)();
137
+ if (!(appearanceInput === null || appearanceInput === void 0 ? void 0 : appearanceInput.componentId))
138
+ return null;
139
+ return ((0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, Object.assign({ componentId: appearanceInput.componentId, properties: appearanceInput.componentProps }, props)) }));
140
+ }
141
+ function AgentOutputRender(_a) {
142
+ var { message } = _a, props = __rest(_a, ["message"]);
143
+ const { appearanceOutput } = (0, use_appearances_1.default)();
144
+ if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId) || !message)
145
+ return null;
146
+ 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_1.Suspense, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, Object.assign({ componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProps }, props)) }) }) }));
147
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.V0Input = exports.V0Output = exports.V0Page = void 0;
7
+ var Page_1 = require("./Page");
8
+ Object.defineProperty(exports, "V0Page", { enumerable: true, get: function () { return __importDefault(Page_1).default; } });
9
+ var Output_1 = require("./Output");
10
+ Object.defineProperty(exports, "V0Output", { enumerable: true, get: function () { return __importDefault(Output_1).default; } });
11
+ var Input_1 = require("./Input");
12
+ Object.defineProperty(exports, "V0Input", { enumerable: true, get: function () { return __importDefault(Input_1).default; } });
@@ -42,14 +42,10 @@ function useRuntimeState() {
42
42
  }
43
43
  return exec(Object.assign(Object.assign({}, args), { working }));
44
44
  }), [authSession.user, exec, working, login]);
45
- const appearancePage = (0, react_1.useMemo)(() => {
46
- var _a, _b;
47
- return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.appearancePage)) === null || _b === void 0 ? void 0 : _b.initialValue;
48
- }, [agent]);
49
45
  const childAgentId = (0, react_1.useMemo)(() => {
50
46
  var _a, _b, _c, _d, _e, _f;
51
47
  return ((_f = (_e = (_d = (_c = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.children)) === null || _b === void 0 ? void 0 : _b.initialValue) === null || _c === void 0 ? void 0 : _c.agents) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : agent.id);
52
48
  }, [agent]);
53
- return { aid, working, agent, appearancePage, childAgentId, execute };
49
+ return { aid, working, agent, childAgentId, execute };
54
50
  }
55
51
  exports.useRuntimeState = useRuntimeState;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOutputVariableInitialValue = void 0;
4
+ function getOutputVariableInitialValue(agent, output) {
5
+ var _a, _b;
6
+ return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === output)) === null || _b === void 0 ? void 0 : _b.initialValue;
7
+ }
8
+ exports.getOutputVariableInitialValue = getOutputVariableInitialValue;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTheme = exports.alpha = exports.Zoom = exports.Typography = exports.Tooltip = exports.ThemeProvider = exports.TextField = exports.Switch = exports.Stack = exports.Slide = exports.Popper = exports.Paper = exports.MenuList = exports.MenuItem = exports.Menu = exports.ListSubheader = exports.ListItemSecondaryAction = exports.ListItemIcon = exports.ListItemButton = exports.ListItemAvatar = exports.ListItem = exports.List = exports.Link = exports.LinearProgress = exports.Grow = exports.Grid = exports.GlobalStyles = exports.Fade = exports.Divider = exports.DialogTitle = exports.DialogContent = exports.DialogActions = exports.Dialog = exports.Container = exports.Collapse = exports.ClickAwayListener = exports.CircularProgress = exports.CardMedia = exports.CardHeader = exports.CardContent = exports.CardActions = exports.CardActionArea = exports.Card = exports.ButtonGroup = exports.Button = exports.Box = exports.Avatar = exports.Autocomplete = exports.AlertTitle = exports.Alert = void 0;
4
- exports.useTheme = exports.useMediaQuery = exports.styled = void 0;
3
+ exports.alpha = exports.Zoom = exports.Typography = exports.Tooltip = exports.ThemeProvider = exports.TextField = exports.Switch = exports.Stack = exports.Slide = exports.Popper = exports.Paper = exports.MenuList = exports.MenuItem = exports.Menu = exports.ListSubheader = exports.ListItemSecondaryAction = exports.ListItemIcon = exports.ListItemButton = exports.ListItemAvatar = exports.ListItem = exports.List = exports.Link = exports.LinearProgress = exports.Grow = exports.Grid = exports.GlobalStyles = exports.Fade = exports.Divider = exports.DialogTitle = exports.DialogContent = exports.DialogActions = exports.Dialog = exports.Container = exports.Collapse = exports.ClickAwayListener = exports.CircularProgress = exports.CardMedia = exports.CardHeader = exports.CardContent = exports.CardActions = exports.CardActionArea = exports.Card = exports.ButtonGroup = exports.IconButton = exports.Button = exports.Box = exports.Avatar = exports.Autocomplete = exports.AlertTitle = exports.Alert = void 0;
4
+ exports.useTheme = exports.useMediaQuery = exports.styled = exports.createTheme = void 0;
5
5
  var material_1 = require("@mui/material");
6
6
  Object.defineProperty(exports, "Alert", { enumerable: true, get: function () { return material_1.Alert; } });
7
7
  Object.defineProperty(exports, "AlertTitle", { enumerable: true, get: function () { return material_1.AlertTitle; } });
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "Autocomplete", { enumerable: true, get: function
9
9
  Object.defineProperty(exports, "Avatar", { enumerable: true, get: function () { return material_1.Avatar; } });
10
10
  Object.defineProperty(exports, "Box", { enumerable: true, get: function () { return material_1.Box; } });
11
11
  Object.defineProperty(exports, "Button", { enumerable: true, get: function () { return material_1.Button; } });
12
+ Object.defineProperty(exports, "IconButton", { enumerable: true, get: function () { return material_1.IconButton; } });
12
13
  Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return material_1.ButtonGroup; } });
13
14
  Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return material_1.Card; } });
14
15
  Object.defineProperty(exports, "CardActionArea", { enumerable: true, get: function () { return material_1.CardActionArea; } });