@blocklet/pages-kit 0.2.340 → 0.2.342
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/builtin/async/ai-runtime/api/agent.js +3 -5
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +2 -4
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +5 -1
- package/lib/cjs/builtin/async/ai-runtime/api/{subscription.js → secret.js} +7 -15
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +9 -10
- package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +27 -0
- package/lib/cjs/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +80 -0
- package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +10 -10
- package/lib/cjs/builtin/async/ai-runtime/constants.js +2 -1
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +4 -3
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-agent-admin.js +11 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +10 -2
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +4 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +5 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +26 -57
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +10 -19
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +5 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +5 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +7 -7
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +8 -8
- package/lib/cjs/builtin/async/ai-runtime/state/agent.js +7 -8
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +5 -5
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +15 -17
- package/lib/cjs/builtin/page/header.js +3 -3
- package/lib/cjs/components/CustomComponentRenderer/index.js +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/api/agent.js +4 -6
- package/lib/esm/builtin/async/ai-runtime/api/message.js +3 -5
- package/lib/esm/builtin/async/ai-runtime/api/request.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/api/{subscription.js → secret.js} +7 -14
- package/lib/esm/builtin/async/ai-runtime/api/session.js +10 -11
- package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +76 -0
- package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ShareActions/index.js +10 -10
- package/lib/esm/builtin/async/ai-runtime/constants.js +1 -0
- package/lib/esm/builtin/async/ai-runtime/contexts/CurrentAgent.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/contexts/Runtime.js +4 -3
- package/lib/esm/builtin/async/ai-runtime/hooks/use-agent-admin.js +7 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/use-header-menu.js +11 -3
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +4 -0
- package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +5 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +27 -58
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +10 -19
- package/lib/esm/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +3 -3
- package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +5 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +5 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +7 -7
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +8 -8
- package/lib/esm/builtin/async/ai-runtime/state/agent.js +6 -6
- package/lib/esm/builtin/async/ai-runtime/state/runtime.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/state/session.js +15 -17
- package/lib/esm/builtin/page/header.js +3 -3
- package/lib/esm/components/CustomComponentRenderer/BlockletReactComponentRenderer.js +1 -1
- package/lib/esm/components/CustomComponentRenderer/index.js +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +10 -1
- package/lib/types/builtin/async/ai-runtime/api/message.d.ts +4 -15
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/api/secret.d.ts +12 -0
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +5 -8
- package/lib/types/builtin/async/ai-runtime/components/AgentErrorBoundary.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.d.ts +10 -0
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/contexts/Runtime.d.ts +3 -1
- package/lib/types/builtin/async/ai-runtime/hooks/use-agent-admin.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/runtime/Runtime/index.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/state/agent.d.ts +2 -6
- package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +1 -0
- package/lib/types/builtin/page/header.d.ts +2 -2
- package/lib/types/components/CustomComponentRenderer/index.d.ts +3 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +0 -15
|
@@ -16,8 +16,8 @@ const Runtime_1 = require("../contexts/Runtime");
|
|
|
16
16
|
const agent_1 = require("./agent");
|
|
17
17
|
const session_2 = require("./session");
|
|
18
18
|
function useRuntimeState() {
|
|
19
|
-
const { aid, working } = (0, Runtime_1.useRuntimeContext)();
|
|
20
|
-
const [agent] = (0, agent_1.useAgentState)({ aid, working });
|
|
19
|
+
const { blockletDid, aid, working } = (0, Runtime_1.useRuntimeContext)();
|
|
20
|
+
const [agent] = (0, agent_1.useAgentState)({ blockletDid, aid, working });
|
|
21
21
|
const { session: authSession, events } = (0, session_1.useSessionContext)();
|
|
22
22
|
const sessionState = (0, react_1.useMemo)(() => (0, session_2.createSessionState)({ aid }), [aid]);
|
|
23
23
|
const exec = sessionState((s) => s.execute);
|
|
@@ -41,8 +41,8 @@ function useRuntimeState() {
|
|
|
41
41
|
if (!authSession.user) {
|
|
42
42
|
yield login();
|
|
43
43
|
}
|
|
44
|
-
return exec(Object.assign(Object.assign({}, args), { working }));
|
|
45
|
-
}), [authSession.user, exec, working, login]);
|
|
46
|
-
return { aid, working, agent, execute };
|
|
44
|
+
return exec(Object.assign(Object.assign({}, args), { blockletDid, working }));
|
|
45
|
+
}), [authSession.user, exec, blockletDid, working, login]);
|
|
46
|
+
return { blockletDid, aid, working, agent, execute };
|
|
47
47
|
}
|
|
48
48
|
exports.useRuntimeState = useRuntimeState;
|
|
@@ -246,7 +246,7 @@ const createSessionState = ({ aid }) => {
|
|
|
246
246
|
}),
|
|
247
247
|
execute: (_g) => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
248
|
var _h, e_1, _j, _k;
|
|
249
|
-
var { aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["aid", "working", "parameters", "onResponseStart"]);
|
|
249
|
+
var { blockletDid, aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["blockletDid", "aid", "working", "parameters", "onResponseStart"]);
|
|
250
250
|
const sessionId = args.sessionId ||
|
|
251
251
|
get().currentSessionId ||
|
|
252
252
|
(yield get().createSession({
|
|
@@ -264,6 +264,7 @@ const createSessionState = ({ aid }) => {
|
|
|
264
264
|
});
|
|
265
265
|
try {
|
|
266
266
|
const stream = (0, session_1.runAgent)({
|
|
267
|
+
blockletDid,
|
|
267
268
|
aid,
|
|
268
269
|
sessionId,
|
|
269
270
|
working,
|
|
@@ -282,10 +283,10 @@ const createSessionState = ({ aid }) => {
|
|
|
282
283
|
if ((value === null || value === void 0 ? void 0 : value.type) === 'CHUNK') {
|
|
283
284
|
if (!message) {
|
|
284
285
|
message = {
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
id: value.taskId,
|
|
287
|
+
agentId: identity.assistantId,
|
|
287
288
|
sessionId,
|
|
288
|
-
parameters,
|
|
289
|
+
inputs: parameters,
|
|
289
290
|
createdAt: new Date().toISOString(),
|
|
290
291
|
updatedAt: new Date().toISOString(),
|
|
291
292
|
loading: true,
|
|
@@ -299,25 +300,22 @@ const createSessionState = ({ aid }) => {
|
|
|
299
300
|
s.messages.push(message);
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
|
-
if (message.
|
|
303
|
+
if (message.id === value.taskId) {
|
|
303
304
|
requestAnimationFrame(() => {
|
|
304
305
|
set((state) => {
|
|
305
|
-
var _a, _b, _c, _d
|
|
306
|
-
var
|
|
306
|
+
var _a, _b, _c, _d;
|
|
307
|
+
var _e;
|
|
307
308
|
const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
|
|
308
309
|
if (!s)
|
|
309
310
|
return;
|
|
310
|
-
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.
|
|
311
|
+
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
|
|
311
312
|
if (!msg)
|
|
312
313
|
return;
|
|
313
|
-
(_c = msg.
|
|
314
|
-
msg.
|
|
315
|
-
if ((_e = (_d = value.delta) === null || _d === void 0 ? void 0 : _d.images) === null || _e === void 0 ? void 0 : _e.length) {
|
|
316
|
-
msg.result.images = ((_f = msg.result.images) !== null && _f !== void 0 ? _f : []).concat(value.delta.images);
|
|
317
|
-
}
|
|
314
|
+
(_c = msg.outputs) !== null && _c !== void 0 ? _c : (msg.outputs = {});
|
|
315
|
+
msg.outputs.content = (msg.outputs.content || '') + (value.delta.content || '');
|
|
318
316
|
if (value.delta.object) {
|
|
319
|
-
(
|
|
320
|
-
msg.
|
|
317
|
+
(_d = (_e = msg.outputs).objects) !== null && _d !== void 0 ? _d : (_e.objects = []);
|
|
318
|
+
msg.outputs.objects.push(value.delta.object);
|
|
321
319
|
}
|
|
322
320
|
});
|
|
323
321
|
});
|
|
@@ -329,7 +327,7 @@ const createSessionState = ({ aid }) => {
|
|
|
329
327
|
const s = (_a = state.sessionMap) === null || _a === void 0 ? void 0 : _a[sessionId];
|
|
330
328
|
if (!s)
|
|
331
329
|
return;
|
|
332
|
-
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.
|
|
330
|
+
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
|
|
333
331
|
if (msg)
|
|
334
332
|
msg.error = value.error;
|
|
335
333
|
else
|
|
@@ -363,7 +361,7 @@ const createSessionState = ({ aid }) => {
|
|
|
363
361
|
return;
|
|
364
362
|
s.running = false;
|
|
365
363
|
if (message) {
|
|
366
|
-
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.
|
|
364
|
+
const msg = (_b = s.messages) === null || _b === void 0 ? void 0 : _b.findLast((i) => i.id === message.id);
|
|
367
365
|
if (msg)
|
|
368
366
|
msg.loading = false;
|
|
369
367
|
}
|
|
@@ -25,10 +25,10 @@ exports.useHeaderState = (0, zustand_1.create)()((0, immer_2.immer)((set, get) =
|
|
|
25
25
|
for (const i of get().stack) {
|
|
26
26
|
widgets.push(i());
|
|
27
27
|
}
|
|
28
|
-
const r = widgets.reduce((res, i) => (Object.assign(Object.assign(Object.assign({}, res), i), { addons: (
|
|
28
|
+
const r = widgets.reduce((res, i) => (Object.assign(Object.assign(Object.assign({}, res), i), { addons: (exists) => {
|
|
29
29
|
var _a, _b, _c, _d;
|
|
30
|
-
const a = (_b = (_a = res.addons) === null || _a === void 0 ? void 0 : _a.call(res,
|
|
31
|
-
const b = (_d = (_c = i.addons) === null || _c === void 0 ? void 0 : _c.call(i,
|
|
30
|
+
const a = (_b = (_a = res.addons) === null || _a === void 0 ? void 0 : _a.call(res, exists)) !== null && _b !== void 0 ? _b : exists;
|
|
31
|
+
const b = (_d = (_c = i.addons) === null || _c === void 0 ? void 0 : _c.call(i, a)) !== null && _d !== void 0 ? _d : a;
|
|
32
32
|
return b;
|
|
33
33
|
} })), {});
|
|
34
34
|
set((state) => {
|
|
@@ -42,7 +42,7 @@ function CustomComponentRenderer(_a) {
|
|
|
42
42
|
var { dev } = _a, props = __rest(_a, ["dev"]);
|
|
43
43
|
const inheritedDev = (0, DevProvider_1.useDev)();
|
|
44
44
|
const BuiltinComponent = BuiltinComponents[props.componentId];
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, {
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
|
|
46
46
|
}
|
|
47
47
|
exports.default = CustomComponentRenderer;
|
|
48
48
|
const BuiltinComponents = {
|