@blocklet/pages-kit 0.2.316 → 0.2.318

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 (149) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +26 -2
  2. package/lib/cjs/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +22 -0
  3. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +1 -1
  4. package/lib/cjs/builtin/async/ai-runtime/constants.js +34 -4
  5. package/lib/cjs/builtin/async/ai-runtime/contexts/ActiveAgent.js +28 -0
  6. package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +27 -0
  7. package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentMessage.js +2 -2
  8. package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +10 -5
  9. package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +39 -0
  10. package/lib/cjs/builtin/async/ai-runtime/index.js +17 -3
  11. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +26 -0
  12. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +3 -2
  13. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +4 -6
  14. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +2 -2
  15. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +60 -0
  16. package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +50 -0
  17. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +30 -0
  18. package/lib/cjs/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +13 -0
  19. package/lib/cjs/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +46 -0
  20. package/lib/cjs/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +2 -0
  21. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +5 -5
  22. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +26 -0
  23. package/lib/cjs/builtin/async/ai-runtime/runtime-components/ShareView/index.js +16 -0
  24. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +25 -0
  25. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +73 -0
  26. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +58 -0
  27. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +33 -0
  28. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +23 -0
  29. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +20 -0
  30. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +26 -0
  31. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +28 -134
  32. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +35 -9
  33. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +5 -5
  34. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +54 -0
  35. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +66 -36
  36. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +190 -57
  37. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +238 -85
  38. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +101 -0
  39. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +60 -0
  40. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +152 -0
  41. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +80 -0
  42. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +32 -0
  43. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +54 -0
  44. package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/utils.js +13 -0
  45. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +1 -6
  46. package/lib/cjs/builtin/async/ai-runtime/state/session.js +52 -23
  47. package/lib/cjs/builtin/mui/material.js +4 -2
  48. package/lib/cjs/components/CustomComponentRenderer/state.js +23 -4
  49. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  50. package/lib/cjs/utils/inject-global-components-dump-json.js +1 -1
  51. package/lib/cjs/utils/inject-global-components.js +2 -0
  52. package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +3 -2
  53. package/lib/esm/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +19 -0
  54. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +2 -2
  55. package/lib/esm/builtin/async/ai-runtime/constants.js +32 -3
  56. package/lib/esm/builtin/async/ai-runtime/contexts/ActiveAgent.js +23 -0
  57. package/lib/esm/builtin/async/ai-runtime/contexts/ComponentPreferences.js +22 -0
  58. package/lib/esm/builtin/async/ai-runtime/contexts/CurrentMessage.js +2 -2
  59. package/lib/esm/builtin/async/ai-runtime/hooks/use-appearances.js +10 -5
  60. package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +32 -0
  61. package/lib/esm/builtin/async/ai-runtime/index.js +8 -1
  62. package/lib/esm/builtin/async/ai-runtime/locales/index.js +26 -0
  63. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +3 -2
  64. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +4 -6
  65. package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +2 -2
  66. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +54 -0
  67. package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +44 -0
  68. package/lib/esm/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +24 -0
  69. package/lib/esm/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +7 -0
  70. package/lib/esm/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +40 -0
  71. package/lib/esm/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.js +1 -0
  72. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +5 -5
  73. package/lib/esm/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +20 -0
  74. package/lib/esm/builtin/async/ai-runtime/runtime-components/ShareView/index.js +10 -0
  75. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +22 -0
  76. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +44 -0
  77. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +30 -0
  78. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +27 -0
  79. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +18 -0
  80. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.js +14 -0
  81. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +20 -0
  82. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +25 -108
  83. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +36 -10
  84. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +5 -5
  85. package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +48 -0
  86. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +60 -30
  87. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +191 -58
  88. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +238 -85
  89. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +92 -0
  90. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.js +55 -0
  91. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +144 -0
  92. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.js +75 -0
  93. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +26 -0
  94. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +49 -0
  95. package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/utils.js +9 -0
  96. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +1 -6
  97. package/lib/esm/builtin/async/ai-runtime/state/session.js +52 -23
  98. package/lib/esm/builtin/mui/material.js +1 -1
  99. package/lib/esm/components/CustomComponentRenderer/state.js +22 -4
  100. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  101. package/lib/esm/utils/inject-global-components-dump-json.js +1 -1
  102. package/lib/esm/utils/inject-global-components.js +2 -0
  103. package/lib/types/builtin/async/ai-runtime/api/session.d.ts +1 -0
  104. package/lib/types/builtin/async/ai-runtime/components/OutputFieldContainer/index.d.ts +5 -0
  105. package/lib/types/builtin/async/ai-runtime/constants.d.ts +14 -0
  106. package/lib/types/builtin/async/ai-runtime/contexts/ActiveAgent.d.ts +9 -0
  107. package/lib/types/builtin/async/ai-runtime/contexts/ComponentPreferences.d.ts +5 -0
  108. package/lib/types/builtin/async/ai-runtime/contexts/CurrentMessage.d.ts +6 -1
  109. package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +4 -1
  110. package/lib/types/builtin/async/ai-runtime/hooks/use-header-menu.d.ts +1 -0
  111. package/lib/types/builtin/async/ai-runtime/index.d.ts +8 -1
  112. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +26 -0
  113. package/lib/types/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.d.ts +2 -1
  114. package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.d.ts +4 -0
  115. package/lib/types/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.d.ts +2 -0
  116. package/lib/types/builtin/async/ai-runtime/runtime-components/ImagesView/index.d.ts +2 -0
  117. package/lib/types/builtin/async/ai-runtime/runtime-components/MarkdownView/index.d.ts +5 -0
  118. package/lib/types/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.d.ts +2 -0
  119. package/lib/types/builtin/async/ai-runtime/runtime-components/OutputFieldView/type.d.ts +5 -0
  120. package/lib/types/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.d.ts +2 -0
  121. package/lib/types/builtin/async/ai-runtime/runtime-components/ShareView/index.d.ts +2 -0
  122. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.d.ts +1 -0
  123. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.d.ts +2 -0
  124. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +6 -0
  125. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.d.ts +2 -0
  126. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +3 -0
  127. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningQuestionsView.d.ts +1 -0
  128. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.d.ts +1 -0
  129. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +13 -3
  130. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.d.ts +1 -1
  131. package/lib/types/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.d.ts +4 -0
  132. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/Input.d.ts +1 -1
  133. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +20 -0
  134. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.d.ts +6 -0
  135. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/Loading.d.ts +3 -0
  136. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.d.ts +6 -0
  137. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.d.ts +3 -0
  138. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.d.ts +16 -0
  139. package/lib/types/builtin/async/ai-runtime/runtime-components/V0/utils.d.ts +7 -0
  140. package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +0 -1
  141. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +11 -3
  142. package/lib/types/builtin/mui/material.d.ts +1 -1
  143. package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -0
  144. package/lib/types/tsconfig.tsbuildinfo +1 -1
  145. package/lib/types/types/core.d.ts +2 -1
  146. package/package.json +9 -8
  147. package/lib/cjs/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +0 -193
  148. package/lib/esm/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.js +0 -164
  149. package/lib/types/builtin/async/ai-runtime/runtime-components/MultiAgentsChat/index.d.ts +0 -11
@@ -426,7 +426,7 @@ export default function FormDemo() {
426
426
  import { Icon } from '@blocklet/pages-kit/builtin/iconify/react';
427
427
 
428
428
  export default function TablerSuccessIcon() {
429
- return <Icon icon="tabler:check" />;
429
+ return <Icon icon="tabler:check" fontSize={24} color="rgba(75, 85, 99, 1)"/>;
430
430
  }
431
431
  `,
432
432
  },
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importDefault(require("react"));
29
30
  const arcblockUx = __importStar(require("../builtin/arcblock/ux"));
30
31
  const aiRuntime = __importStar(require("../builtin/async/ai-runtime"));
31
32
  const imagePreview = __importStar(require("../builtin/async/image-preview"));
@@ -87,5 +88,6 @@ function injectGlobalComponents() {
87
88
  return win[builtin_1.BuiltinModulesGlobalVariableName].modules[module];
88
89
  },
89
90
  };
91
+ win.React = react_1.default;
90
92
  }
91
93
  injectGlobalComponents();
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { Icon } from '@iconify/react';
14
14
  import { Box, Stack, styled } from '@mui/material';
15
- import React from 'react';
15
+ import React, { Suspense } from 'react';
16
16
  import Markdown from 'react-markdown';
17
17
  import remarkGfm from 'remark-gfm';
18
18
  import { useLocaleContext } from '../../../locale';
@@ -26,7 +26,7 @@ const MarkdownRenderer = styled((props) => (_jsx(Markdown, Object.assign({}, pro
26
26
  if (!children)
27
27
  return null;
28
28
  const match = /language-(\w+)/.exec(className || '');
29
- return !inline ? (_jsx(Box, Object.assign({ component: ReactSyntaxHighlighter, language: match === null || match === void 0 ? void 0 : match[1] }, props, { sx: { borderRadius: 1 }, children: String(children).replace(/\n$/, '') }))) : (_jsx(Box, Object.assign({ component: "code", className: className }, props, { children: children })));
29
+ return !inline ? (_jsx(Suspense, { children: _jsx(Box, Object.assign({ component: ReactSyntaxHighlighter, language: match === null || match === void 0 ? void 0 : match[1] }, props, { sx: { borderRadius: 1 }, children: String(children).replace(/\n$/, '') })) })) : (_jsx(Box, Object.assign({ component: "code", className: className }, props, { children: children })));
30
30
  },
31
31
  table: ({ className, children }) => {
32
32
  return (_jsx(Box, { sx: { overflow: 'auto', my: 1 }, children: _jsx("table", { className: className, children: children }) }));
@@ -80,6 +80,7 @@ const MarkdownRenderer = styled((props) => (_jsx(Markdown, Object.assign({}, pro
80
80
  }
81
81
  }
82
82
 
83
+ &.writing:empty,
83
84
  &.writing > *:last-child {
84
85
  &:after {
85
86
  content: '';
@@ -0,0 +1,19 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Icon } from '@iconify/react';
14
+ import { Box, Stack, Typography } from '@mui/material';
15
+ export default function OutputFieldContainer(_a) {
16
+ var _b;
17
+ var { output } = _a, props = __rest(_a, ["output"]);
18
+ return (_jsxs(Stack, Object.assign({ gap: 1 }, props, { children: [((_b = output.appearance) === null || _b === void 0 ? void 0 : _b.title) && (_jsxs(Typography, { component: "h6", noWrap: true, sx: { display: 'flex', alignItems: 'center', gap: 1, fontSize: 18, fontWeight: 500 }, children: [output.appearance.icon && _jsx(Box, { component: Icon, icon: output.appearance.icon }), _jsx(Box, { component: "span", sx: { flex: 1, textOverflow: 'hidden' }, children: output.appearance.title })] })), props.children] })));
19
+ }
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
23
23
  import { Icon } from '@iconify/react';
24
- import { Stack, styled } from '@mui/material';
24
+ import { Box, Stack, styled } from '@mui/material';
25
25
  import { saveAs } from 'file-saver';
26
26
  import { useMemo } from 'react';
27
27
  import { withQuery } from 'ufo';
@@ -44,7 +44,7 @@ export default function ShareActions(_a) {
44
44
  const C = ShareActionsMap[item.to];
45
45
  if (!C)
46
46
  return null;
47
- return _jsx(C, {});
47
+ return (_jsx(Box, { children: _jsx(C, {}) }));
48
48
  }).filter((i) => !!i);
49
49
  if (!(items === null || items === void 0 ? void 0 : items.length))
50
50
  return null;
@@ -1,5 +1,34 @@
1
+ import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
1
2
  export const AI_STUDIO_DID = 'z8iZpog7mcgcgBZzTiXJCWESvmnRrQmnd3XBB';
2
3
  export const PAYMENT_KIT_DID = 'z2qaCNvKMv5GjouKdcDWexv6WqtHbpNPQDnAk';
3
- export const DEFAULT_PAGE_COMPONENT_ID = 'ctnxha29uu8cx4xv';
4
- export const DEFAULT_INPUT_COMPONENT_ID = '1wwtemqcdio6nqf0';
5
- export const DEFAULT_OUTPUT_COMPONENT_ID = 'q0ckknkxph4hfwas';
4
+ export const DEFAULT_PAGE_COMPONENT_ID = 'ctnxha29uu8cx4xv'; // Simple Layout
5
+ export const DEFAULT_INPUT_COMPONENT_ID = '1wwtemqcdio6nqf0'; // Auto Form
6
+ export const DEFAULT_OUTPUT_COMPONENT_ID = 'q0ckknkxph4hfwas'; // Simple Output
7
+ export const MARKDOWN_VIEW_ID = 'a4oldpoxv7bikvpj';
8
+ export const SUGGESTED_QUESTIONS_VIEW_ID = '6u8m11ss7fvu8t7i';
9
+ export const REFERENCED_LINKS_VIEW_ID = 'baqmaoccdntqwayc';
10
+ export const SHARE_VIEW_ID = 'jfq3df9z8lkk9not';
11
+ export const IMAGES_VIEW_ID = 'txirtdgx8h2bmo7s';
12
+ export const DEFAULT_OUTPUT_COMPONENTS = {
13
+ [RuntimeOutputVariable.text]: {
14
+ componentId: MARKDOWN_VIEW_ID,
15
+ },
16
+ [RuntimeOutputVariable.images]: {
17
+ componentId: IMAGES_VIEW_ID,
18
+ },
19
+ [RuntimeOutputVariable.openingMessage]: {
20
+ componentId: MARKDOWN_VIEW_ID,
21
+ },
22
+ [RuntimeOutputVariable.suggestedQuestions]: {
23
+ componentId: SUGGESTED_QUESTIONS_VIEW_ID,
24
+ },
25
+ [RuntimeOutputVariable.referenceLinks]: {
26
+ componentId: REFERENCED_LINKS_VIEW_ID,
27
+ },
28
+ [RuntimeOutputVariable.share]: {
29
+ componentId: SHARE_VIEW_ID,
30
+ },
31
+ };
32
+ export function getDefaultOutputComponent(output) {
33
+ return DEFAULT_OUTPUT_COMPONENTS[output.name];
34
+ }
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
3
+ import { createContext, useContext, useMemo, useState } from 'react';
4
+ import { useRuntimeState } from '../state/runtime';
5
+ import { getOutputVariableInitialValue } from '../utils/runtime-output-schema';
6
+ const activeAgentContext = createContext(undefined);
7
+ export function useActiveAgent() {
8
+ const context = useContext(activeAgentContext);
9
+ if (!context) {
10
+ throw new Error('No such activeAgentContext. You should use `useActiveAgent` within the `ActiveAgentProvider`');
11
+ }
12
+ return context;
13
+ }
14
+ export default function ActiveAgentProvider({ children }) {
15
+ const { agent } = useRuntimeState();
16
+ const childAgentId = useMemo(() => {
17
+ var _a, _b, _c, _d;
18
+ return (_d = (_c = (_b = (_a = getOutputVariableInitialValue(agent, RuntimeOutputVariable.children)) === null || _a === void 0 ? void 0 : _a.agents) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : agent.id;
19
+ }, [agent]);
20
+ const [activeAgentId, setActiveAgentId] = useState(childAgentId);
21
+ const activeAgent = useMemo(() => ({ activeAgentId, setActiveAgentId }), [activeAgentId, setActiveAgentId]);
22
+ return _jsx(activeAgentContext.Provider, { value: activeAgent, children: children });
23
+ }
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { createContext, useContext, useMemo } from 'react';
14
+ const componentPreferencesContext = createContext(undefined);
15
+ export function ComponentPreferencesProvider(_a) {
16
+ var { children } = _a, preferences = __rest(_a, ["children"]);
17
+ const value = useMemo(() => (Object.assign({}, preferences)), Object.values(preferences));
18
+ return _jsx(componentPreferencesContext.Provider, { value: value, children: children });
19
+ }
20
+ export function useComponentPreferences() {
21
+ return useContext(componentPreferencesContext);
22
+ }
@@ -5,9 +5,9 @@ export default function CurrentMessageProvider({ message, children }) {
5
5
  const state = useMemo(() => ({ message }), [message]);
6
6
  return _jsx(context.Provider, { value: state, children: children });
7
7
  }
8
- export function useCurrentMessage() {
8
+ export function useCurrentMessage({ optional } = {}) {
9
9
  const current = useContext(context);
10
- if (!current) {
10
+ if (!optional && !current) {
11
11
  throw new Error('No such message state. You should use `useCurrentMessage` within the `CurrentMessageProvider`');
12
12
  }
13
13
  return current;
@@ -10,14 +10,16 @@ export default function useAppearances(args) {
10
10
  const { agent: runtimeAgent } = useRuntimeState();
11
11
  const { agent } = useCurrentAgent(args);
12
12
  const appearancePage = useMemo(() => {
13
- const appearance = getOutputVariableInitialValue(agent, RuntimeOutputVariable.appearancePage);
13
+ var _a, _b;
14
+ const appearance = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearancePage)) === null || _b === void 0 ? void 0 : _b.appearance;
14
15
  return Object.assign(Object.assign({}, appearance), { componentId: (appearance === null || appearance === void 0 ? void 0 : appearance.componentId) || DEFAULT_PAGE_COMPONENT_ID });
15
16
  }, [agent]);
16
17
  const appearanceInput = useMemo(() => {
17
- const appearance = getOutputVariableInitialValue(agent, RuntimeOutputVariable.appearanceInput);
18
+ var _a, _b, _c, _d;
19
+ const appearance = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearanceInput)) === null || _b === void 0 ? void 0 : _b.appearance;
18
20
  if (appearance)
19
21
  return appearance;
20
- const runtimeAppearance = getOutputVariableInitialValue(runtimeAgent, RuntimeOutputVariable.appearanceInput);
22
+ const runtimeAppearance = (_d = (_c = runtimeAgent.outputVariables) === null || _c === void 0 ? void 0 : _c.find((i) => i.name === RuntimeOutputVariable.appearanceInput)) === null || _d === void 0 ? void 0 : _d.appearance;
21
23
  if (runtimeAppearance)
22
24
  return runtimeAppearance;
23
25
  return {
@@ -25,10 +27,11 @@ export default function useAppearances(args) {
25
27
  };
26
28
  }, [agent, runtimeAgent]);
27
29
  const appearanceOutput = useMemo(() => {
28
- const appearance = getOutputVariableInitialValue(agent, RuntimeOutputVariable.appearanceOutput);
30
+ var _a, _b, _c, _d;
31
+ const appearance = (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === RuntimeOutputVariable.appearanceOutput)) === null || _b === void 0 ? void 0 : _b.appearance;
29
32
  if (appearance === null || appearance === void 0 ? void 0 : appearance.componentId)
30
33
  return appearance;
31
- const runtimeAppearance = getOutputVariableInitialValue(runtimeAgent, RuntimeOutputVariable.appearanceOutput);
34
+ const runtimeAppearance = (_d = (_c = runtimeAgent.outputVariables) === null || _c === void 0 ? void 0 : _c.find((i) => i.name === RuntimeOutputVariable.appearanceOutput)) === null || _d === void 0 ? void 0 : _d.appearance;
32
35
  if (runtimeAppearance)
33
36
  return runtimeAppearance;
34
37
  return {
@@ -61,6 +64,7 @@ export function useOpeningMessage(args) {
61
64
  const agentOpening = getOutputVariableInitialValue(agent, RuntimeOutputVariable.openingMessage);
62
65
  if (agentOpening === null || agentOpening === void 0 ? void 0 : agentOpening.message) {
63
66
  return {
67
+ agent,
64
68
  message: agentOpening.message,
65
69
  profile,
66
70
  };
@@ -68,6 +72,7 @@ export function useOpeningMessage(args) {
68
72
  const runtimeOpening = getOutputVariableInitialValue(runtimeAgent, RuntimeOutputVariable.openingMessage);
69
73
  if (runtimeOpening === null || runtimeOpening === void 0 ? void 0 : runtimeOpening.message) {
70
74
  return {
75
+ agent: runtimeAgent,
71
76
  message: runtimeOpening.message,
72
77
  profile: runtimeProfile,
73
78
  };
@@ -0,0 +1,32 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { Icon } from '@iconify/react';
12
+ import { IconButton, ListItemIcon } from '@mui/material';
13
+ import { useLocaleContext } from '../../../locale';
14
+ import { useHeader } from '../../../page/header';
15
+ import PopperMenuButton from '../components/PopperMenuButton';
16
+ import LoadingMenuItem from '../components/PopperMenuButton/LoadingMenuItem';
17
+ import { useComponentPreferences } from '../contexts/ComponentPreferences';
18
+ import { useSessionState } from '../state/session';
19
+ export function useHeaderMenu() {
20
+ var _a;
21
+ const { t, locale } = useLocaleContext();
22
+ const { hideHeaderMenuButton } = (_a = useComponentPreferences()) !== null && _a !== void 0 ? _a : {};
23
+ const clearSession = useSessionState((s) => s.clearSession);
24
+ useHeader(() => hideHeaderMenuButton
25
+ ? {}
26
+ : {
27
+ addons: (...exists) => [
28
+ _jsx(PopperMenuButton, { component: IconButton, PopperProps: { placement: 'bottom-end', sx: { zIndex: 'appBar' } }, menus: _jsxs(LoadingMenuItem, { onClick: () => __awaiter(this, void 0, void 0, function* () { return clearSession(); }), children: [_jsx(ListItemIcon, { children: _jsx(Icon, { icon: "mingcute:broom-line" }) }), t('clearSession')] }), children: _jsx(Icon, { icon: "tabler:dots" }) }),
29
+ ...exists,
30
+ ],
31
+ }, [locale, hideHeaderMenuButton]);
32
+ }
@@ -8,11 +8,18 @@ export { default as Runtime } from './runtime/Runtime';
8
8
  export { default as ChatBotButton } from './runtime/ChatBotButton';
9
9
  export { default as SimplePage } from './runtime-components/SimplePage';
10
10
  export { default as SimpleChat } from './runtime-components/SimpleChat';
11
- export { default as MultiAgentsChat } from './runtime-components/MultiAgentsChat';
12
11
  export { default as PhotoGallery } from './runtime-components/PhotoGallery';
13
12
  export { default as AutoForm } from './runtime-components/AutoForm';
14
13
  export { default as SimpleOutput } from './runtime-components/SimpleOutput';
15
14
  export { default as ChatOutput } from './runtime-components/ChatOutput';
16
15
  export { default as PhotoGalleryItem } from './runtime-components/PhotoGalleryItem';
16
+ export { default as SuggestedQuestionsView } from './runtime-components/SuggestedQuestionsView';
17
+ export { default as ReferencedLinksView } from './runtime-components/ReferencedLinksView';
18
+ export { default as ShareView } from './runtime-components/ShareView';
19
+ export { default as OpeningQuestionsView } from './runtime-components/OpeningQuestionsView';
20
+ export { default as ImagesView } from './runtime-components/ImagesView';
21
+ export { default as GoogleSearchRelatedQuestionsView } from './runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView';
22
+ export { default as GoogleSearchSourcesView } from './runtime-components/GoogleSearch/GoogleSearchSourcesView';
23
+ export { default as MarkdownView } from './runtime-components/MarkdownView';
17
24
  // only use to debug, should be removed when PR
18
25
  export * from './runtime-components/V0';
@@ -34,6 +34,7 @@ export const translations = {
34
34
  rename: 'Rename',
35
35
  delete: 'Delete',
36
36
  confirmDelete: 'Confirm Delete?',
37
+ confirm: 'Confirm',
37
38
  noData: 'No {data} yet',
38
39
  createObject: 'Create {object}',
39
40
  title: 'Title',
@@ -92,6 +93,18 @@ export const translations = {
92
93
  send: 'Send',
93
94
  session: 'Session',
94
95
  loadMore: 'Load More',
96
+ v0: {
97
+ title: 'AIGNE v0',
98
+ description: 'AIGNE v0 is an AI-based code tool that can help you generate code quickly.',
99
+ noData: 'No conversation information yet, click the button below to start generating!',
100
+ deleteSessionTitle: 'Delete Conversation Information',
101
+ deleteSessionTip: 'Are you sure you want to delete this Conversation Information?',
102
+ propertiesSetting: 'Properties Setting',
103
+ propertiesSettingTip: 'This function is used for debugging components and does not affect the final code',
104
+ cannotSetPropertiesTip: 'Failed to parse PROPERTIES_SCHEMA, this code cannot be set properties',
105
+ codePreview: 'Code Preview',
106
+ codePreviewTip: 'Here is the code preview, you can view the generated code, and editing is not supported yet.',
107
+ },
95
108
  },
96
109
  zh: {
97
110
  by: '作者',
@@ -128,6 +141,7 @@ export const translations = {
128
141
  rename: '重命名',
129
142
  delete: '删除',
130
143
  confirmDelete: '确定删除?',
144
+ confirm: '确定',
131
145
  noData: '暂无{data}',
132
146
  createObject: '创建{object}',
133
147
  title: '标题',
@@ -186,5 +200,17 @@ export const translations = {
186
200
  send: '发送',
187
201
  session: '会话',
188
202
  loadMore: '加载更多',
203
+ v0: {
204
+ title: 'AIGNE v0',
205
+ description: 'AIGNE v0 是一个基于人工智能的代码工具,可以帮助您快速生成代码。',
206
+ noData: '暂无生成记录,点击下方按钮开始生成吧!',
207
+ deleteSessionTitle: '删除生成记录',
208
+ deleteSessionTip: '确定要删除此生成记录吗?',
209
+ propertiesSetting: '属性设置',
210
+ propertiesSettingTip: '此功能用于调试组件,不影响最终代码',
211
+ cannotSetPropertiesTip: '解析 PROPERTIES_SCHEMA 失败,此代码无法进行属性设置',
212
+ codePreview: '代码预览',
213
+ codePreviewTip: '以下是代码预览,您可以查看生成的代码,目前还不支持编辑。',
214
+ },
189
215
  },
190
216
  };
@@ -20,12 +20,13 @@ import LoadingMenuItem from '../../components/PopperMenuButton/LoadingMenuItem';
20
20
  import RuntimeCommonProvider from '../../components/RuntimeCommonProvider';
21
21
  import ScrollView from '../../components/ScrollView';
22
22
  import { DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
23
+ import ActiveAgentProvider from '../../contexts/ActiveAgent';
23
24
  import RuntimeProvider from '../../contexts/Runtime';
24
25
  import useAppearances, { useProfile } from '../../hooks/use-appearances';
25
26
  import { useRuntimeState } from '../../state/runtime';
26
27
  import { useAutoLoadSessionState, useSessionState } from '../../state/session';
27
28
  export default function ChatBotButton({ aid, working }) {
28
- return (_jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(RuntimeCommonProvider, { children: _jsx(ChatBotContent, {}) }) }));
29
+ return (_jsx(RuntimeCommonProvider, { children: _jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(ActiveAgentProvider, { children: _jsx(ChatBotContent, {}) }) }) }));
29
30
  }
30
31
  function ChatBotContent() {
31
32
  var _a, _b;
@@ -44,7 +45,7 @@ function ChatBotContent() {
44
45
  '.aigne-layout': {
45
46
  px: 2,
46
47
  },
47
- }, children: _jsx(Suspense, { fallback: _jsx(Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: _jsx(CircularProgress, { size: 24 }) }), children: _jsx(CustomComponentRenderer, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProps, props: { scrollViewProps: { disabled: true }, hideHeaderMenuButton: true } }) }) }) }))] }));
48
+ }, children: _jsx(Suspense, { fallback: _jsx(Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: _jsx(CircularProgress, { size: 24 }) }), children: _jsx(CustomComponentRenderer, { componentId: componentId, properties: appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentProperties, props: { scrollViewProps: { disabled: true }, hideHeaderMenuButton: true } }) }) }) }))] }));
48
49
  }
49
50
  function ResponsiveChatBotContainer({ open, anchorEl, children, onClose, }) {
50
51
  const theme = useTheme();
@@ -10,6 +10,7 @@ import { getComponentMountPoint } from '../../../../utils';
10
10
  import RuntimeCommonProvider, { RuntimeLocaleProvider } from '../../components/RuntimeCommonProvider';
11
11
  import SocialShare from '../../components/SocialShare';
12
12
  import { AI_STUDIO_DID, DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
13
+ import ActiveAgentProvider from '../../contexts/ActiveAgent';
13
14
  import RuntimeProvider, { RuntimeProviderFromUrl } from '../../contexts/Runtime';
14
15
  import useAppearances from '../../hooks/use-appearances';
15
16
  import { useRuntimeState } from '../../state/runtime';
@@ -19,11 +20,8 @@ function AgentCreatedBy({ did }) {
19
20
  return (_jsxs(_Fragment, { children: [t('by'), " ", _jsx(Box, { component: DID, did: did, copyable: false, responsive: true })] }));
20
21
  }
21
22
  export default function Runtime({ aid, working }) {
22
- const children = (_jsx(RuntimeCommonProvider, { children: _jsx(RuntimeView, {}) }));
23
- if (aid) {
24
- return (_jsx(RuntimeProvider, { aid: aid, working: working, children: children }));
25
- }
26
- return _jsx(RuntimeProviderFromUrl, { children: children });
23
+ const children = (_jsx(ActiveAgentProvider, { children: _jsx(RuntimeView, {}) }));
24
+ return (_jsx(RuntimeCommonProvider, { children: aid ? (_jsx(RuntimeProvider, { aid: aid, working: working, children: children })) : (_jsx(RuntimeProviderFromUrl, { children: children })) }));
27
25
  }
28
26
  function RuntimeView() {
29
27
  var _a;
@@ -59,5 +57,5 @@ ${agent === null || agent === void 0 ? void 0 : agent.description}
59
57
  };
60
58
  }, [locale, isMobile, agent]);
61
59
  const componentId = (_a = appearancePage === null || appearancePage === void 0 ? void 0 : appearancePage.componentId) !== null && _a !== void 0 ? _a : DEFAULT_PAGE_COMPONENT_ID;
62
- 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.componentProps })] }));
60
+ 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 })] }));
63
61
  }
@@ -2,12 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Alert, Box } from '@mui/material';
3
3
  import { useLocaleContext } from '../../../../locale';
4
4
  import MarkdownRenderer from '../../components/MarkdownRenderer';
5
- export default function MessageErrorView({ error }) {
5
+ export default function MessageErrorView({ error, sx }) {
6
6
  const { t } = useLocaleContext();
7
7
  if (!error)
8
8
  return null;
9
9
  if (error.status === 401) {
10
10
  return (_jsx(Box, { className: "ai-chat-message-error", children: _jsx(Box, { className: "message-response", children: _jsx(MarkdownRenderer, { children: t('requireLogin') }) }) }));
11
11
  }
12
- return (_jsx(Alert, { className: "ai-chat-message-error", severity: "error", sx: { mr: 5 }, children: error.message }));
12
+ return (_jsx(Alert, { className: "ai-chat-message-error", severity: "error", sx: Object.assign({ mr: 5 }, sx), children: error.message }));
13
13
  }
@@ -0,0 +1,54 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { Divider, List, ListItemButton } from '@mui/material';
12
+ import Joi from 'joi';
13
+ import { useMemo, useState } from 'react';
14
+ import OutputFieldContainer from '../../components/OutputFieldContainer';
15
+ import { useCurrentAgent } from '../../contexts/CurrentAgent';
16
+ import { useCurrentMessage } from '../../contexts/CurrentMessage';
17
+ import { useRuntimeState } from '../../state/runtime';
18
+ import { useCurrentSessionState } from '../../state/session';
19
+ const searchResultSchema = Joi.object({
20
+ related_questions: Joi.array().items(Joi.object({
21
+ question: Joi.string().required(),
22
+ link: Joi.string().required(),
23
+ snippet: Joi.string().empty([null, '']),
24
+ title: Joi.string().required(),
25
+ })),
26
+ });
27
+ export default function GoogleSearchRelatedView({ output, outputValue, onlyLastMessage, }) {
28
+ var _a, _b;
29
+ const { aid } = useCurrentAgent();
30
+ const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
31
+ const lastMessage = useCurrentSessionState((s) => { var _a; return (_a = s === null || s === void 0 ? void 0 : s.messages) === null || _a === void 0 ? void 0 : _a.at(-1); });
32
+ const isLastMessage = !!message && (message === null || message === void 0 ? void 0 : message.taskId) === (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.taskId);
33
+ const [submitting, setSubmitting] = useState(false);
34
+ const { execute } = useRuntimeState();
35
+ const result = useMemo(() => {
36
+ const result = searchResultSchema.validate(outputValue, { allowUnknown: true });
37
+ if (result.error)
38
+ return undefined;
39
+ return result.value;
40
+ }, [outputValue]);
41
+ if ((!isLastMessage && onlyLastMessage) || !((_b = result === null || result === void 0 ? void 0 : result.related_questions) === null || _b === void 0 ? void 0 : _b.length))
42
+ return null;
43
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { dense: true, disablePadding: true, children: result.related_questions.map((item) => (_jsxs(_Fragment, { children: [_jsx(ListItemButton, { onClick: () => __awaiter(this, void 0, void 0, function* () {
44
+ if (submitting)
45
+ return;
46
+ setSubmitting(true);
47
+ try {
48
+ yield execute({ aid, parameters: { question: item.question } });
49
+ }
50
+ finally {
51
+ setSubmitting(false);
52
+ }
53
+ }), children: item.question }, item.title), _jsx(Divider, {})] }))) }) }));
54
+ }
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Avatar, Box, Card, CardActionArea, Grid, Skeleton, Stack, Typography } from '@mui/material';
3
+ import Joi from 'joi';
4
+ import { useMemo } from 'react';
5
+ import OutputFieldContainer from '../../components/OutputFieldContainer';
6
+ import { useCurrentMessage } from '../../contexts/CurrentMessage';
7
+ const searchResultSchema = Joi.object({
8
+ organic_results: Joi.array().items(Joi.object({
9
+ title: Joi.string().required(),
10
+ link: Joi.string().required(),
11
+ snippet: Joi.string().required(),
12
+ favicon: Joi.string().empty([null, '']),
13
+ source: Joi.string().empty([null, '']),
14
+ })),
15
+ });
16
+ export default function GoogleSearchSourcesView({ output, outputValue }) {
17
+ var _a;
18
+ const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
19
+ const searchResult = useMemo(() => {
20
+ const result = searchResultSchema.validate(outputValue, { allowUnknown: true });
21
+ if (result.error)
22
+ return undefined;
23
+ return result.value;
24
+ }, [outputValue]);
25
+ if (!message || (!(searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results.length) && !message.loading))
26
+ return null;
27
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsxs(Grid, { container: true, spacing: 1.5, children: [message.loading && (_jsxs(_Fragment, { children: [_jsx(Grid, { item: true, xs: 4, sm: 3, md: 2, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 3, md: 2, children: _jsx(ItemSkeleton, {}) }), _jsx(Grid, { item: true, xs: 4, sm: 3, md: 2, children: _jsx(ItemSkeleton, {}) })] })), searchResult === null || searchResult === void 0 ? void 0 : searchResult.organic_results.map((item) => (_jsx(Grid, { item: true, xs: 4, sm: 3, md: 2, children: _jsx(ItemView, { item: item }) }, item.link)))] }) }));
28
+ }
29
+ function ItemView({ item }) {
30
+ var _a;
31
+ return (_jsx(ItemContainer, { title: `${item.title} - ${item.source}`, favicon: _jsx(Avatar, { src: item.favicon, sx: { width: 18, height: 18 }, children: (_a = item.source) === null || _a === void 0 ? void 0 : _a.slice(0, 1) }), link: item.link }));
32
+ }
33
+ function ItemSkeleton() {
34
+ return (_jsx(ItemContainer, { title: _jsxs(_Fragment, { children: [_jsx(Skeleton, { width: "100%" }), _jsx(Skeleton, { width: "40%" })] }), favicon: _jsx(Skeleton, { width: 18, height: 18, variant: "circular" }), link: _jsx(Skeleton, { width: "70%" }) }));
35
+ }
36
+ function ItemContainer({ title, favicon, link }) {
37
+ return (_jsx(Card, { sx: { height: '100%' }, children: _jsx(CardActionArea, { component: "a", href: typeof link === 'string' ? link : undefined, target: "_blank", sx: { height: '100%' }, children: _jsxs(Stack, { sx: { p: 1, gap: 1, height: '100%' }, children: [_jsx(Box, { flexGrow: 1, children: _jsx(Typography, { variant: "body2", sx: {
38
+ display: '-webkit-box',
39
+ WebkitBoxOrient: 'vertical',
40
+ WebkitLineClamp: 2,
41
+ overflow: 'hidden',
42
+ fontWeight: 500,
43
+ }, children: title }) }), _jsxs(Stack, { flexDirection: "row", alignItems: "center", gap: 1, overflow: "hidden", children: [_jsx(Box, { width: 18, height: 18, children: favicon }), _jsx(Typography, { variant: "caption", noWrap: true, sx: { flex: 1, width: 1 }, children: link })] })] }) }) }));
44
+ }
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import ImagePreview from '@blocklet/ai-kit/components/image-preview';
3
+ import { Skeleton } from '@mui/material';
4
+ import Joi from 'joi';
5
+ import { useMemo } from 'react';
6
+ import OutputFieldContainer from '../../components/OutputFieldContainer';
7
+ import { useCurrentMessage } from '../../contexts/CurrentMessage';
8
+ const imagesSchema = Joi.array().items(Joi.object({
9
+ url: Joi.string().required(),
10
+ }));
11
+ export default function ImagesView({ output, outputValue }) {
12
+ var _a;
13
+ const { message } = (_a = useCurrentMessage({ optional: true })) !== null && _a !== void 0 ? _a : {};
14
+ const images = useMemo(() => {
15
+ var _a;
16
+ const result = imagesSchema.validate(outputValue, { allowUnknown: true });
17
+ if (result.error)
18
+ return undefined;
19
+ return (_a = result.value) === null || _a === void 0 ? void 0 : _a.map((i) => ({ src: i.url }));
20
+ }, [outputValue]);
21
+ if (!(images === null || images === void 0 ? void 0 : images.length) && !(message === null || message === void 0 ? void 0 : message.loading))
22
+ return null;
23
+ return (_jsx(OutputFieldContainer, { output: output, sx: { '.lazy-image-wrapper': { borderRadius: 1, img: { borderRadius: 1 } } }, children: (images === null || images === void 0 ? void 0 : images.length) ? (_jsx(ImagePreview, { dataSource: images, itemWidth: 200, spacing: 1 })) : (message === null || message === void 0 ? void 0 : message.loading) ? (_jsx(Skeleton, { width: 200, height: 200, variant: "rounded" })) : null }));
24
+ }
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '@emotion/css';
3
+ import MarkdownRenderer from '../../components/MarkdownRenderer';
4
+ import OutputFieldContainer from '../../components/OutputFieldContainer';
5
+ export default function MarkdownView({ output, outputValue, fontSize, writing, }) {
6
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsx(MarkdownRenderer, { className: cx(writing && 'writing'), sx: { fontSize: typeof fontSize === 'string' && /^\d+$/.test(fontSize) ? Number(fontSize) : fontSize }, children: outputValue }) }));
7
+ }
@@ -0,0 +1,40 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { List, ListItemButton, listItemButtonClasses } from '@mui/material';
12
+ import { useState } from 'react';
13
+ import OutputFieldContainer from '../../components/OutputFieldContainer';
14
+ import { useCurrentAgent } from '../../contexts/CurrentAgent';
15
+ import { useOpeningQuestions } from '../../hooks/use-appearances';
16
+ import { useRuntimeState } from '../../state/runtime';
17
+ export default function OpeningQuestionsView({ output }) {
18
+ const { aid } = useCurrentAgent();
19
+ const { execute } = useRuntimeState();
20
+ const opening = useOpeningQuestions();
21
+ const [submitting, setSubmitting] = useState(false);
22
+ if (!(opening === null || opening === void 0 ? void 0 : opening.questions.length))
23
+ return null;
24
+ return (_jsx(OutputFieldContainer, { output: output, children: _jsx(List, { disablePadding: true, sx: { [`.${listItemButtonClasses.root}`]: { border: 1, borderColor: 'grey.200', borderRadius: 1, my: 1 } }, children: opening.questions.map((item) => {
25
+ return (_jsx(ListItemButton, { onClick: () => __awaiter(this, void 0, void 0, function* () {
26
+ if (submitting)
27
+ return;
28
+ try {
29
+ setSubmitting(true);
30
+ yield execute({
31
+ aid,
32
+ parameters: Object.assign(Object.assign({}, item.parameters), { question: item.parameters.question || item.title }),
33
+ });
34
+ }
35
+ finally {
36
+ setSubmitting(false);
37
+ }
38
+ }), children: item.title }, item.id));
39
+ }) }) }));
40
+ }