@blocklet/pages-kit 0.2.366 → 0.2.367

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 (32) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/Community.js +6 -0
  2. package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +37 -10
  3. package/lib/cjs/builtin/async/ai-runtime/contexts/Identity.js +36 -0
  4. package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +45 -25
  5. package/lib/cjs/builtin/async/ai-runtime/index.js +6 -3
  6. package/lib/cjs/builtin/async/ai-runtime/locales/index.js +2 -0
  7. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +1 -3
  8. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -4
  9. package/lib/cjs/builtin/async/ai-runtime/state/agent.js +3 -3
  10. package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +2 -2
  11. package/lib/cjs/builtin/async/ai-runtime/state/session.js +3 -3
  12. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  13. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/Community.js +4 -0
  14. package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +38 -11
  15. package/lib/esm/builtin/async/ai-runtime/contexts/Identity.js +28 -0
  16. package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +19 -24
  17. package/lib/esm/builtin/async/ai-runtime/index.js +2 -0
  18. package/lib/esm/builtin/async/ai-runtime/locales/index.js +2 -0
  19. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +1 -3
  20. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -4
  21. package/lib/esm/builtin/async/ai-runtime/state/agent.js +3 -3
  22. package/lib/esm/builtin/async/ai-runtime/state/runtime.js +2 -2
  23. package/lib/esm/builtin/async/ai-runtime/state/session.js +3 -3
  24. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  25. package/lib/types/builtin/async/ai-runtime/components/ShareActions/Community.d.ts +4 -0
  26. package/lib/types/builtin/async/ai-runtime/contexts/Identity.d.ts +16 -0
  27. package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +4 -16
  28. package/lib/types/builtin/async/ai-runtime/index.d.ts +2 -0
  29. package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +2 -0
  30. package/lib/types/builtin/async/ai-runtime/state/session.d.ts +1 -2
  31. package/lib/types/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +3 -3
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createSvgIcon } from '@mui/material';
3
+ const CommunityIcon = createSvgIcon(_jsxs("svg", { style: { width: '15px', height: '15px' }, viewBox: "0 0 60 60", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { opacity: "0.6", fillRule: "evenodd", clipRule: "evenodd", d: "M29.2518 28.4159V29.282L28.5018 29.715L6.89191 42.1915L7.64197 43.4906L30.0019 30.5811L52.3618 43.4906L53.1119 42.1915L31.502 29.715L30.752 29.282V28.4159V3.46293H29.2518V28.4159Z", stroke: "currentColor", fill: "white", strokeWidth: "2" }), _jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M30.0019 2L54.0038 15.8575V43.5725L30.0019 57.43L6 43.5725V15.8575L30.0019 2ZM8.25018 16.2905L23.1764 24.9082L30.0019 13.086L36.8274 24.9082L51.7536 16.2905L30.0019 3.73219L8.25018 16.2905ZM52.5037 17.5897L37.5775 26.2073L44.403 38.0295L30.752 45.911V55.2648L52.5037 42.7064V17.5897ZM29.2518 55.2648V45.911L15.6008 38.0295L22.4263 26.2073L7.50012 17.5897V42.7064L29.2518 55.2648ZM23.7254 26.9574L17.65 37.4804L29.2518 44.1788V31.0141V30.148L28.5018 29.715L23.7254 26.9574ZM30.752 44.1788L42.3538 37.4804L36.2784 26.9574L31.502 29.715L30.752 30.148V31.0141V44.1788ZM35.5283 25.6582L30.0019 16.0862L24.4755 25.6582L30.0019 28.8489L35.5283 25.6582Z", stroke: "currentColor", fill: "white", strokeWidth: "2" })] }), 'AIGNE');
4
+ export default CommunityIcon;
@@ -23,9 +23,9 @@ import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
23
23
  import { Icon } from '@iconify/react';
24
24
  import { Box, Stack, styled } from '@mui/material';
25
25
  import { saveAs } from 'file-saver';
26
- import _ from 'lodash';
26
+ import { fromPairs, identity, pickBy } from 'lodash';
27
27
  import { useMemo } from 'react';
28
- import { withQuery } from 'ufo';
28
+ import { joinURL, withQuery } from 'ufo';
29
29
  import { useLocaleContext } from '../../../../locale';
30
30
  import { useCurrentAgent } from '../../contexts/CurrentAgent';
31
31
  import { useCurrentMessage } from '../../contexts/CurrentMessage';
@@ -34,6 +34,7 @@ import { useRuntimeState } from '../../state/runtime';
34
34
  import { isValidInput } from '../../utils/agent-inputs';
35
35
  import { convertImageToBlob, downloadImage } from '../../utils/download-image';
36
36
  import ActionButton from '../ActionButton';
37
+ import CommunityIcon from './Community';
37
38
  export default function ShareActions(_a) {
38
39
  var _b;
39
40
  var props = __rest(_a, []);
@@ -52,7 +53,7 @@ export default function ShareActions(_a) {
52
53
  const C = ShareActionsMap[item.to];
53
54
  if (!C)
54
55
  return null;
55
- return (_jsx(Box, { children: _jsx(C, { inputs: JSON.stringify(_.fromPairs(params), null, 2), shareAttach: {
56
+ return (_jsx(Box, { children: _jsx(C, { inputs: JSON.stringify(fromPairs(params), null, 2), shareAttach: {
56
57
  shareAttachInputs: (_a = sharing === null || sharing === void 0 ? void 0 : sharing.shareAttachInputs) !== null && _a !== void 0 ? _a : false,
57
58
  shareAttachUrl: (_b = sharing === null || sharing === void 0 ? void 0 : sharing.shareAttachUrl) !== null && _b !== void 0 ? _b : false,
58
59
  } }) }));
@@ -66,11 +67,13 @@ const ShareActionsMap = {
66
67
  copy: ShareCopy,
67
68
  saveAs: ShareSave,
68
69
  community: ShareCommunity,
70
+ link: ShareLink,
69
71
  };
70
72
  function ShareTwitter({ inputs, shareAttach, }) {
71
73
  var _a, _b, _c, _d, _e, _f, _g, _h;
72
74
  const { t } = useLocaleContext();
73
75
  const { message } = useCurrentMessage();
76
+ const { link } = useCurrentLink();
74
77
  let content = ((_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[RuntimeOutputVariable.text]) ||
75
78
  ((_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url);
76
79
  if (!content)
@@ -78,15 +81,29 @@ function ShareTwitter({ inputs, shareAttach, }) {
78
81
  if (shareAttach.shareAttachInputs) {
79
82
  content += `\nInputs: ${inputs}`;
80
83
  }
84
+ // 如果 content 长度超过 100,截断
85
+ if (content.length > 100) {
86
+ content = `${content.slice(0, 100)}...`;
87
+ }
81
88
  return (_jsx(StyledActionButton, { tip: t('socialShare.shareToX'), title: _jsx(Icon, { icon: "tabler:brand-x" }), target: "_blank", href: withQuery('https://twitter.com/intent/tweet', {
82
89
  text: content,
83
- url: shareAttach.shareAttachUrl ? window.location.href : undefined,
90
+ url: link,
91
+ }) }));
92
+ }
93
+ function ShareLink() {
94
+ const { t } = useLocaleContext();
95
+ const { link } = useCurrentLink();
96
+ return (_jsx(StyledActionButton, { autoReset: true, tip: t('socialShare.copyLink'), tipSucceed: t('copied'), title: _jsx(Icon, { icon: "tabler:link" }), titleSucceed: _jsx(Icon, { icon: "tabler:link-plus" }), onClick: () => __awaiter(this, void 0, void 0, function* () {
97
+ if (link) {
98
+ window.navigator.clipboard.writeText(link);
99
+ }
84
100
  }) }));
85
101
  }
86
102
  function ShareCopy({ inputs, shareAttach, }) {
87
103
  var _a, _b, _c, _d, _e, _f, _g, _h;
88
104
  const { t } = useLocaleContext();
89
105
  const { message } = useCurrentMessage();
106
+ const { link } = useCurrentLink();
90
107
  let content = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[RuntimeOutputVariable.text];
91
108
  const image = (_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url;
92
109
  if (!content && !image)
@@ -97,7 +114,7 @@ function ShareCopy({ inputs, shareAttach, }) {
97
114
  content += `\nInputs: ${inputs}`;
98
115
  }
99
116
  if (shareAttach.shareAttachUrl) {
100
- content += `\nURL: ${window.location.href}`;
117
+ content += `\nURL: ${link}`;
101
118
  }
102
119
  window.navigator.clipboard.writeText(content);
103
120
  }
@@ -113,6 +130,7 @@ function ShareSave({ inputs, shareAttach, }) {
113
130
  const { message } = useCurrentMessage();
114
131
  const { aid, agent } = useRuntimeState();
115
132
  const profile = useProfile({ aid });
133
+ const { link } = useCurrentLink();
116
134
  const content = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[RuntimeOutputVariable.text];
117
135
  const image = (_h = (_g = (_f = (_e = (_d = message.outputs) === null || _d === void 0 ? void 0 : _d.objects) === null || _e === void 0 ? void 0 : _e.find((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _f === void 0 ? void 0 : _f[RuntimeOutputVariable.images]) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.url;
118
136
  if (!content && !image)
@@ -127,7 +145,7 @@ function ShareSave({ inputs, shareAttach, }) {
127
145
  element.innerHTML += `<br/>Inputs: ${inputs}`;
128
146
  }
129
147
  if (shareAttach.shareAttachUrl) {
130
- element.innerHTML += `<br/>URL: ${window.location.href}`;
148
+ element.innerHTML += `<br/>URL: ${link}`;
131
149
  }
132
150
  yield html2pdf()
133
151
  .set({
@@ -146,25 +164,28 @@ function ShareSave({ inputs, shareAttach, }) {
146
164
  }) }));
147
165
  }
148
166
  function ShareCommunity({ inputs, shareAttach, }) {
149
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
167
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
150
168
  const { t } = useLocaleContext();
151
169
  const { message } = useCurrentMessage();
170
+ const { link } = useCurrentLink();
171
+ const { agent } = useCurrentAgent();
152
172
  let content = (_d = (_c = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.find((i) => i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.text])) === null || _c === void 0 ? void 0 : _c[RuntimeOutputVariable.text]) !== null && _d !== void 0 ? _d : '';
153
173
  const image = ((_k = (_j = (_h = (_g = (_f = (_e = message.outputs) === null || _e === void 0 ? void 0 : _e.objects) === null || _f === void 0 ? void 0 : _f.find) === null || _g === void 0 ? void 0 : _g.call(_f, (i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[RuntimeOutputVariable.images]) === null || _a === void 0 ? void 0 : _a.length; })) === null || _h === void 0 ? void 0 : _h[RuntimeOutputVariable.images]) === null || _j === void 0 ? void 0 : _j.map((i) => i.url)) !== null && _k !== void 0 ? _k : []).join(',');
174
+ content = `[Sharing from ${(_l = agent === null || agent === void 0 ? void 0 : agent.project) === null || _l === void 0 ? void 0 : _l.name}]: ${window.location.href}\n ${content}`;
154
175
  if (!content && !image)
155
176
  return null;
156
177
  if (shareAttach.shareAttachInputs) {
157
178
  content += `\nInputs: ${inputs}`;
158
179
  }
159
180
  if (shareAttach.shareAttachUrl) {
160
- content += `\nURL: ${window.location.href}`;
181
+ content += `\nURL: ${link}`;
161
182
  }
162
- return (_jsx(StyledActionButton, { tip: t('share to community'), title: _jsx(Icon, { icon: "tabler:share-2" }), target: "_blank", href: withQuery('https://community.arcblock.io/discussions/add?', {
183
+ return (_jsx(StyledActionButton, { tip: t('socialShare.shareToCommunity'), title: _jsx(CommunityIcon, {}), target: "_blank", href: withQuery('https://community.arcblock.io/discussions/add?', pickBy({
163
184
  boardId: 'aigne',
164
- title: '[Share the generation from Aigne](Give your post a title...)',
185
+ title: `${((_m = message.inputs) === null || _m === void 0 ? void 0 : _m.question) || ''}`,
165
186
  content,
166
187
  images: image,
167
- }) }));
188
+ }, identity)) }));
168
189
  }
169
190
  const StyledActionButton = styled(ActionButton)(({ theme }) => theme.unstable_sx({
170
191
  fontSize: 'inherit',
@@ -172,3 +193,9 @@ const StyledActionButton = styled(ActionButton)(({ theme }) => theme.unstable_sx
172
193
  minWidth: '0 !important',
173
194
  minHeight: '0 !important',
174
195
  }));
196
+ const useCurrentLink = () => {
197
+ var _a;
198
+ const { message } = useCurrentMessage();
199
+ const link = joinURL(window.origin, ((_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.prefix) || '/', '/messages', message.id);
200
+ return { link };
201
+ };
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ import { useSearchParams } from 'react-router-dom';
4
+ import RuntimeCommonProvider from '../components/RuntimeCommonProvider';
5
+ import { CustomError } from '../error';
6
+ const identityContext = createContext(undefined);
7
+ export function useIdentityContext() {
8
+ const context = useContext(identityContext);
9
+ if (!context) {
10
+ throw new Error('No such runtime context. You should use `useRuntimeContext` within the `RuntimeProvider`');
11
+ }
12
+ return context;
13
+ }
14
+ export default function IdentityProvider({ blockletDid, aid, working, children, }) {
15
+ if (!aid)
16
+ throw new Error('Missing required props `aid`');
17
+ const value = useMemo(() => ({ blockletDid, aid, working }), [blockletDid, aid, working]);
18
+ return (_jsx(RuntimeCommonProvider, { children: _jsx(identityContext.Provider, { value: value, children: children }) }));
19
+ }
20
+ export function IdentityProviderFromUrl({ children }) {
21
+ const [query] = useSearchParams();
22
+ const aid = query.get('aid');
23
+ const blockletDid = query.get('blockletDid') || undefined;
24
+ const working = query.get('working') === 'true';
25
+ if (!aid)
26
+ throw new CustomError(404, 'Missing required query parameters `aid`');
27
+ return (_jsx(IdentityProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children }));
28
+ }
@@ -1,27 +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
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, useMemo } from 'react';
3
- import { useSearchParams } from 'react-router-dom';
4
- import { CustomError } from '../error';
5
- const runtimeContext = createContext(undefined);
6
- export function useRuntimeContext() {
7
- const context = useContext(runtimeContext);
8
- if (!context) {
9
- throw new Error('No such runtime context. You should use `useRuntimeContext` within the `RuntimeProvider`');
10
- }
11
- return context;
13
+ import ThemeProvider from '../components/ThemeProvider';
14
+ import IdentityProvider, { IdentityProviderFromUrl } from './Identity';
15
+ export default function RuntimeProvider(_a) {
16
+ var props = __rest(_a, []);
17
+ return (_jsx(IdentityProvider, Object.assign({}, props, { children: _jsx(ThemeProvider, { children: props.children }) })));
12
18
  }
13
- export default function RuntimeProvider({ blockletDid, aid, working, children, }) {
14
- if (!aid)
15
- throw new Error('Missing required props `aid`');
16
- const value = useMemo(() => ({ blockletDid, aid, working }), [blockletDid, aid, working]);
17
- return _jsx(runtimeContext.Provider, { value: value, children: children });
18
- }
19
- export function RuntimeProviderFromUrl({ children }) {
20
- const [query] = useSearchParams();
21
- const aid = query.get('aid');
22
- const blockletDid = query.get('blockletDid') || undefined;
23
- const working = query.get('working') === 'true';
24
- if (!aid)
25
- throw new CustomError(404, 'Missing required query parameters `aid`');
26
- return (_jsx(RuntimeProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children }));
19
+ export function RuntimeProviderFromUrl(_a) {
20
+ var props = __rest(_a, []);
21
+ return (_jsx(IdentityProviderFromUrl, Object.assign({}, props, { children: _jsx(ThemeProvider, { children: props.children }) })));
27
22
  }
@@ -1,3 +1,5 @@
1
+ export * from './contexts/Runtime';
2
+ export { default as RuntimeProvider } from './contexts/Runtime';
1
3
  export * from './contexts/ComponentPreferences';
2
4
  export { default as ComponentPreferencesProvider } from './contexts/ComponentPreferences';
3
5
  export * from './contexts/CurrentAgent';
@@ -10,6 +10,7 @@ export const translations = {
10
10
  shareToFacebook: 'Share to Facebook',
11
11
  shareToLinkedin: 'Share to Linkedin',
12
12
  copyLink: 'Copy Link',
13
+ shareToCommunity: 'Share to Community',
13
14
  },
14
15
  photoWall: {
15
16
  dialog: {
@@ -124,6 +125,7 @@ export const translations = {
124
125
  shareToFacebook: '分享到 Facebook',
125
126
  shareToLinkedin: '分享到 Linkedin',
126
127
  copyLink: '复制链接',
128
+ shareToCommunity: '分享到社区',
127
129
  },
128
130
  photoWall: {
129
131
  dialog: {
@@ -17,9 +17,7 @@ import { Avatar } from '../../../../arcblock/ux';
17
17
  import { useLocaleContext } from '../../../../locale';
18
18
  import PopperMenuButton from '../../components/PopperMenuButton';
19
19
  import LoadingMenuItem from '../../components/PopperMenuButton/LoadingMenuItem';
20
- import RuntimeCommonProvider from '../../components/RuntimeCommonProvider';
21
20
  import ScrollView from '../../components/ScrollView';
22
- import ThemeProvider from '../../components/ThemeProvider';
23
21
  import { DEFAULT_PAGE_COMPONENT_ID } from '../../constants';
24
22
  import ActiveAgentProvider from '../../contexts/ActiveAgent';
25
23
  import RuntimeProvider from '../../contexts/Runtime';
@@ -27,7 +25,7 @@ import useAppearances, { useProfile } from '../../hooks/use-appearances';
27
25
  import { useRuntimeState } from '../../state/runtime';
28
26
  import { useAutoLoadSessionState, useSessionState } from '../../state/session';
29
27
  export default function ChatBotButton({ aid, working }) {
30
- return (_jsx(RuntimeCommonProvider, { children: _jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(ThemeProvider, { children: _jsx(ActiveAgentProvider, { children: _jsx(ChatBotContent, {}) }) }) }) }));
28
+ return (_jsx(RuntimeProvider, { aid: aid, working: working, children: _jsx(ActiveAgentProvider, { children: _jsx(ChatBotContent, {}) }) }));
31
29
  }
32
30
  function ChatBotContent() {
33
31
  var _a, _b;
@@ -2,16 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Helmet } from 'react-helmet';
3
3
  import CustomComponentRenderer from '../../../../../components/CustomComponentRenderer';
4
4
  import AgentSettingsDialog from '../../components/AgentSettings/AgentSettingsDialog';
5
- import RuntimeCommonProvider from '../../components/RuntimeCommonProvider';
6
- import ThemeProvider from '../../components/ThemeProvider';
7
5
  import ActiveAgentProvider from '../../contexts/ActiveAgent';
8
6
  import RuntimeProvider, { RuntimeProviderFromUrl } from '../../contexts/Runtime';
9
7
  import useAppearances from '../../hooks/use-appearances';
10
8
  import { useHeaderMenu } from '../../hooks/use-header-menu';
11
9
  import { useRuntimeState } from '../../state/runtime';
12
10
  export default function Runtime({ blockletDid, aid, working, }) {
13
- const children = (_jsx(ThemeProvider, { children: _jsx(ActiveAgentProvider, { children: _jsx(RuntimeView, {}) }) }));
14
- return (_jsx(RuntimeCommonProvider, { children: aid ? (_jsx(RuntimeProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children })) : (_jsx(RuntimeProviderFromUrl, { children: children })) }));
11
+ const children = (_jsx(ActiveAgentProvider, { children: _jsx(RuntimeView, {}) }));
12
+ return aid ? (_jsx(RuntimeProvider, { blockletDid: blockletDid, aid: aid, working: working, children: children })) : (_jsx(RuntimeProviderFromUrl, { children: children }));
15
13
  }
16
14
  function RuntimeView() {
17
15
  const { aid, agent } = useRuntimeState();
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { create } from 'zustand';
11
11
  import { immer } from 'zustand/middleware/immer';
12
12
  import { getAgent } from '../api/agent';
13
- import { useRuntimeContext } from '../contexts/Runtime';
13
+ import { useIdentityContext } from '../contexts/Identity';
14
14
  import { createCachedStore } from '../utils/zustand';
15
15
  const createAgentState = ({ blockletDid, aid, working, agent, }) => {
16
16
  return createCachedStore(`agent-state-${blockletDid}-${aid}-${working}`, () => create()(immer((set) => ({
@@ -42,8 +42,8 @@ const createAgentState = ({ blockletDid, aid, working, agent, }) => {
42
42
  const LOADING_TASKS = {};
43
43
  export function useAgentState({ blockletDid, aid, working, }) {
44
44
  var _a;
45
- const runtimeState = useRuntimeContext();
46
- const state = createAgentState({ blockletDid, aid, working: working !== null && working !== void 0 ? working : runtimeState.working })();
45
+ const identity = useIdentityContext();
46
+ const state = createAgentState({ blockletDid, aid, working: working !== null && working !== void 0 ? working : identity.working })();
47
47
  if (!state.agent) {
48
48
  if (state.error)
49
49
  throw state.error;
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { useCallback, useEffect, useMemo } from 'react';
11
11
  import { useSessionContext } from '../../../session';
12
- import { useRuntimeContext } from '../contexts/Runtime';
12
+ import { useIdentityContext } from '../contexts/Identity';
13
13
  import { useAgentState } from './agent';
14
14
  import { createSessionState } from './session';
15
15
  export function useRuntimeState() {
16
- const { blockletDid, aid, working } = useRuntimeContext();
16
+ const { blockletDid, aid, working } = useIdentityContext();
17
17
  const [agent] = useAgentState({ blockletDid, aid, working });
18
18
  const { session: authSession, events } = useSessionContext();
19
19
  const sessionState = useMemo(() => createSessionState({ aid }), [aid]);
@@ -31,7 +31,7 @@ import { create } from 'zustand';
31
31
  import { immer } from 'zustand/middleware/immer';
32
32
  import { getMessages } from '../api/message';
33
33
  import { clearSession, createSession, deleteSession, getSessions, runAgent } from '../api/session';
34
- import { useRuntimeContext } from '../contexts/Runtime';
34
+ import { useIdentityContext } from '../contexts/Identity';
35
35
  import { createCachedStore } from '../utils/zustand';
36
36
  const GET_MESSAGES_LIMIT = 100;
37
37
  const GET_MESSAGES_ORDER_DIRECTION = 'desc';
@@ -370,7 +370,7 @@ export const createSessionState = ({ aid }) => {
370
370
  }))));
371
371
  };
372
372
  export function useAutoLoadSessionState(...args) {
373
- const { aid } = useRuntimeContext();
373
+ const { aid } = useIdentityContext();
374
374
  const state = useMemo(() => createSessionState({ aid }), [aid]);
375
375
  const currentSessionId = state((s) => s.currentSessionId);
376
376
  useEffect(() => {
@@ -378,7 +378,7 @@ export function useAutoLoadSessionState(...args) {
378
378
  }, [state, currentSessionId]);
379
379
  }
380
380
  export function useSessionState(selector) {
381
- const { aid } = useRuntimeContext();
381
+ const { aid } = useIdentityContext();
382
382
  return useMemo(() => createSessionState({ aid }), [aid])(selector);
383
383
  }
384
384
  export function useCurrentSessionState(selector) {