@arbidocs/blocks 0.4.27 → 0.4.29
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/README.md +17 -0
- package/dist/agents/index.cjs +224 -212
- package/dist/agents/index.js +6 -6
- package/dist/agents/tasks/TaskRowMenu.d.ts +4 -1
- package/dist/agents/tasks/TaskRunsDialog.d.ts +3 -1
- package/dist/agents/tasks/taskRows.d.ts +2 -0
- package/dist/agents/workflows/WorkflowDocumentsField.d.ts +12 -0
- package/dist/agents/workflows/index.d.ts +2 -0
- package/dist/agents/workflows/workspaceScope.d.ts +18 -0
- package/dist/chat/ChatPage.d.ts +1 -1
- package/dist/chat/chat-page-types.d.ts +12 -1
- package/dist/chat/index.cjs +129 -129
- package/dist/chat/index.js +2 -2
- package/dist/chunk-4XJZ6AAY.js +407 -0
- package/dist/chunk-4XJZ6AAY.js.map +1 -0
- package/dist/{chunk-UOLMFC5K.js → chunk-6YVI74BC.js} +498 -108
- package/dist/chunk-6YVI74BC.js.map +1 -0
- package/dist/{chunk-CQ6CYPV4.js → chunk-7FF473XB.js} +7 -119
- package/dist/chunk-7FF473XB.js.map +1 -0
- package/dist/{chunk-ZEIOREJY.js → chunk-EHXSBH6U.js} +37 -6
- package/dist/chunk-EHXSBH6U.js.map +1 -0
- package/dist/chunk-EYPPB5CY.cjs +85 -0
- package/dist/chunk-EYPPB5CY.cjs.map +1 -0
- package/dist/{chunk-ENY6XXKR.js → chunk-I7FJS7WG.js} +155 -39
- package/dist/chunk-I7FJS7WG.js.map +1 -0
- package/dist/{chunk-557EU3G4.js → chunk-JLOYWXRB.js} +3 -3
- package/dist/{chunk-557EU3G4.js.map → chunk-JLOYWXRB.js.map} +1 -1
- package/dist/chunk-KF4EC5XU.js +68 -0
- package/dist/chunk-KF4EC5XU.js.map +1 -0
- package/dist/{chunk-3ZXXHROK.cjs → chunk-L6YRTT5M.cjs} +158 -39
- package/dist/chunk-L6YRTT5M.cjs.map +1 -0
- package/dist/chunk-S5HZBXZA.cjs +430 -0
- package/dist/chunk-S5HZBXZA.cjs.map +1 -0
- package/dist/{chunk-JCVZKCXC.cjs → chunk-TLQQV7WW.cjs} +37 -6
- package/dist/chunk-TLQQV7WW.cjs.map +1 -0
- package/dist/{chunk-NNH7N62N.cjs → chunk-VMCOH3AY.cjs} +497 -105
- package/dist/chunk-VMCOH3AY.cjs.map +1 -0
- package/dist/{chunk-JLPYOPCX.js → chunk-WSJVHSGN.js} +225 -36
- package/dist/chunk-WSJVHSGN.js.map +1 -0
- package/dist/{chunk-DCEI37AX.cjs → chunk-YVIOCITQ.cjs} +3 -3
- package/dist/{chunk-DCEI37AX.cjs.map → chunk-YVIOCITQ.cjs.map} +1 -1
- package/dist/{chunk-J22DXUJY.cjs → chunk-ZHLMDJCO.cjs} +226 -34
- package/dist/chunk-ZHLMDJCO.cjs.map +1 -0
- package/dist/{chunk-TL2DHSC5.cjs → chunk-ZXGBUHES.cjs} +5 -120
- package/dist/chunk-ZXGBUHES.cjs.map +1 -0
- package/dist/connect/docx.cjs +26 -8
- package/dist/connect/docx.cjs.map +1 -1
- package/dist/connect/docx.d.ts +1 -0
- package/dist/connect/docx.js +24 -7
- package/dist/connect/docx.js.map +1 -1
- package/dist/connect/index.cjs +303 -61
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +4 -0
- package/dist/connect/index.js +263 -25
- package/dist/connect/index.js.map +1 -1
- package/dist/connection/ConnectedAgentChatPanel.d.ts +7 -0
- package/dist/connection/ConnectedNativeDocxEditor.d.ts +2 -1
- package/dist/connection/ConnectedSkillUpload.d.ts +2 -0
- package/dist/connection/ConnectedStreamedWordArtifact.d.ts +4 -0
- package/dist/connection/ConnectedTaskAccessRequest.d.ts +4 -0
- package/dist/connection/ai.d.ts +4 -1
- package/dist/connection/useConnectedWorkNotifications.d.ts +21 -0
- package/dist/docx/DocxMentions.d.ts +9 -2
- package/dist/docx/NativeDocxEditor.d.ts +11 -3
- package/dist/docx/StreamedWordArtifact.d.ts +15 -0
- package/dist/docx/index.cjs +16 -8
- package/dist/docx/index.d.ts +3 -2
- package/dist/docx/index.js +2 -2
- package/dist/docx/streamWordDocument.d.ts +12 -0
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +3 -3
- package/dist/files/index.js +3 -3
- package/dist/index.cjs +778 -766
- package/dist/index.js +15 -15
- package/dist/settings/index.cjs +42 -232
- package/dist/settings/index.cjs.map +1 -1
- package/dist/settings/index.js +7 -203
- package/dist/settings/index.js.map +1 -1
- package/dist/site/index.cjs +5 -5
- package/dist/site/index.js +1 -1
- package/dist/studio/index.cjs +7 -6
- package/dist/studio/index.cjs.map +1 -1
- package/dist/studio/index.js +5 -4
- package/dist/studio/index.js.map +1 -1
- package/dist/workspaces/index.cjs +2 -2
- package/dist/workspaces/index.js +2 -2
- package/package.json +3 -3
- package/src/docx/styles.css +13 -0
- package/dist/chunk-3ZXXHROK.cjs.map +0 -1
- package/dist/chunk-5TRALRWN.js +0 -42
- package/dist/chunk-5TRALRWN.js.map +0 -1
- package/dist/chunk-CQ6CYPV4.js.map +0 -1
- package/dist/chunk-CQCC7LE7.js +0 -210
- package/dist/chunk-CQCC7LE7.js.map +0 -1
- package/dist/chunk-ENY6XXKR.js.map +0 -1
- package/dist/chunk-EUOGPUMJ.cjs +0 -59
- package/dist/chunk-EUOGPUMJ.cjs.map +0 -1
- package/dist/chunk-J22DXUJY.cjs.map +0 -1
- package/dist/chunk-JCVZKCXC.cjs.map +0 -1
- package/dist/chunk-JLPYOPCX.js.map +0 -1
- package/dist/chunk-NNH7N62N.cjs.map +0 -1
- package/dist/chunk-RFIBUWLF.cjs +0 -232
- package/dist/chunk-RFIBUWLF.cjs.map +0 -1
- package/dist/chunk-TL2DHSC5.cjs.map +0 -1
- package/dist/chunk-UOLMFC5K.js.map +0 -1
- package/dist/chunk-ZEIOREJY.js.map +0 -1
package/dist/connect/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-
|
|
3
|
-
import { SettingsSection, ProfileCard, AvatarPicker, SettingsCard, SettingsActionRow, PasswordChangeDialog, EMAIL_NOTIFICATION_KEYS, EMAIL_NOTIFICATION_CATEGORIES, NotificationCategoryList, toNotificationCategories, toActiveSessionViews, SettingsRow, ActiveSessionsDialog, LogoutDialog, toLogoutSessionViews, SettingsDangerZone, DeleteAccountDialog, toDeleteBlockerViews } from '../chunk-
|
|
2
|
+
export { ConnectedAssistantDock, redlineStats, textToArtifact, toRedlineMarkdown, useConnectedAiTask, useConnectedChat, useSemanticSearch, useWorkspaceDocs } from '../chunk-KF4EC5XU.js';
|
|
3
|
+
import { SettingsSection, ProfileCard, AvatarPicker, SettingsCard, SettingsActionRow, PasswordChangeDialog, EMAIL_NOTIFICATION_KEYS, EMAIL_NOTIFICATION_CATEGORIES, NotificationCategoryList, toNotificationCategories, toActiveSessionViews, SettingsRow, ActiveSessionsDialog, LogoutDialog, toLogoutSessionViews, SettingsDangerZone, DeleteAccountDialog, toDeleteBlockerViews } from '../chunk-JLOYWXRB.js';
|
|
4
4
|
import { StreamedArtifactFrame } from '../chunk-LOJVUGBJ.js';
|
|
5
5
|
import '../chunk-VILAPTCB.js';
|
|
6
|
-
import '../chunk-
|
|
6
|
+
import { ChatPage } from '../chunk-WSJVHSGN.js';
|
|
7
7
|
import '../chunk-KZJAG7T3.js';
|
|
8
8
|
import '../chunk-NPLYHR2E.js';
|
|
9
|
-
import '../chunk-TJMKFY5P.js';
|
|
10
9
|
import { initials } from '../chunk-OXF2IFXG.js';
|
|
11
|
-
import
|
|
12
|
-
|
|
10
|
+
import '../chunk-TJMKFY5P.js';
|
|
11
|
+
import { ConnectionProvider, useConnection } from '../chunk-EHXSBH6U.js';
|
|
12
|
+
export { ConnectionProvider, SESSION_EXPIRED_MESSAGE, isAuthenticated, useConnection } from '../chunk-EHXSBH6U.js';
|
|
13
|
+
import '../chunk-AA3PT6KR.js';
|
|
13
14
|
import '../chunk-7F6CBP3Z.js';
|
|
14
15
|
import { lazy, useState, Suspense, useMemo, useEffect } from 'react';
|
|
15
16
|
import { QueryClient, QueryClientProvider, useQueryClient, useQuery } from '@tanstack/react-query';
|
|
16
|
-
import { ArbiProvider, ArtifactCanvas, useWorkspaces, useShellWorkspaces, useProfile, useUpdateProfile, useRequestEmailChange, useConfirmEmailChange, useNameEditor, useAvatarCrop, useEmailChange, ImageCropModal, usePasswordChange, usePasswordChangeForm, useNotificationPreferences, useSessions, useCurrentSessionId, useTerminateSession, useLogoutAllSessions, useDeleteAccount, useDeleteAccountFlow, useArbi, useArbiWebSocket, notify, ArbiWebSocketProvider } from '@arbidocs/react';
|
|
17
|
+
import { ArbiProvider, useConversations, useRunConversation, useUploadSkillFiles, ArtifactCanvas, useWorkspaces, useShellWorkspaces, useProfile, useUpdateProfile, useRequestEmailChange, useConfirmEmailChange, useNameEditor, useAvatarCrop, useEmailChange, ImageCropModal, usePasswordChange, usePasswordChangeForm, useNotificationPreferences, useSessions, useCurrentSessionId, useTerminateSession, useLogoutAllSessions, useDeleteAccount, useDeleteAccountFlow, useArbi, useArbiWebSocket, notify, useWorkNotifications, useAgentSession, useStartAgentSession, useCloseAgentSession, ArbiWebSocketProvider, useArbiChat } from '@arbidocs/react';
|
|
17
18
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
+
import { Button, Label, Input } from '@arbidocs/react/ui';
|
|
18
20
|
import { useStreamedArtifact } from '@arbidocs/react/artifacts';
|
|
19
21
|
import { UserCircle, KeyRound, Radio } from 'lucide-react';
|
|
20
|
-
import { Button } from '@arbidocs/react/ui';
|
|
21
22
|
import { useNotify } from '@arbidocs/react/shell';
|
|
22
23
|
|
|
23
24
|
function ConnectionBoundWebSocket({ children }) {
|
|
@@ -36,6 +37,75 @@ function ArbiAppProvider({
|
|
|
36
37
|
const providerUrl = config.apiUrl || config.demoApiUrl || "https://demo.arbi.local";
|
|
37
38
|
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(ArbiProvider, { url: providerUrl, children: /* @__PURE__ */ jsx(ConnectionProvider, { config, children: /* @__PURE__ */ jsx(ConnectionBoundWebSocket, { children }) }) }) });
|
|
38
39
|
}
|
|
40
|
+
function ConnectedTaskAccessRequest({ conversationId }) {
|
|
41
|
+
const { workspaceId } = useConnection();
|
|
42
|
+
const tasks = useConversations(workspaceId ?? void 0, { live: true });
|
|
43
|
+
const run = useRunConversation();
|
|
44
|
+
const task = tasks.data?.find((item) => item.external_id === conversationId);
|
|
45
|
+
if (!task?.pending_auth_request_id || !task.is_owner) return null;
|
|
46
|
+
return /* @__PURE__ */ jsxs(
|
|
47
|
+
"section",
|
|
48
|
+
{
|
|
49
|
+
className: "flex flex-wrap items-center gap-3 rounded-lg border bg-card p-3",
|
|
50
|
+
"data-testid": "task-chat-access-request",
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx("p", { className: "flex-1 text-sm", children: "This task is waiting for temporary workspace access." }),
|
|
53
|
+
/* @__PURE__ */ jsx(
|
|
54
|
+
Button,
|
|
55
|
+
{
|
|
56
|
+
disabled: run.isPending,
|
|
57
|
+
onClick: () => run.mutate(task.external_id),
|
|
58
|
+
"data-testid": "task-chat-allow-access",
|
|
59
|
+
children: run.isPending ? "Allowing access\u2026" : "Allow access and run"
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
run.error && /* @__PURE__ */ jsx("p", { role: "alert", className: "w-full text-sm text-destructive", children: run.error.message })
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function ConnectedSkillUpload() {
|
|
68
|
+
const [name, setName] = useState("");
|
|
69
|
+
const [file, setFile] = useState(null);
|
|
70
|
+
const upload = useUploadSkillFiles();
|
|
71
|
+
const slug = name.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
72
|
+
return /* @__PURE__ */ jsxs("section", { className: "space-y-3 rounded-lg border p-4", "data-testid": "skill-upload", children: [
|
|
73
|
+
/* @__PURE__ */ jsx("h2", { className: "text-sm font-semibold", children: "Add a skill" }),
|
|
74
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Upload a SKILL.md file containing the instructions your assistant should follow." }),
|
|
75
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "skill-upload-name", children: "Skill name" }),
|
|
76
|
+
/* @__PURE__ */ jsx(
|
|
77
|
+
Input,
|
|
78
|
+
{
|
|
79
|
+
id: "skill-upload-name",
|
|
80
|
+
value: name,
|
|
81
|
+
onChange: (event) => setName(event.target.value),
|
|
82
|
+
placeholder: "disclosure-review",
|
|
83
|
+
"data-testid": "skill-upload-name"
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
Input,
|
|
88
|
+
{
|
|
89
|
+
type: "file",
|
|
90
|
+
accept: ".md",
|
|
91
|
+
"aria-label": "Skill instructions file",
|
|
92
|
+
onChange: (event) => setFile(event.target.files?.[0] ?? null),
|
|
93
|
+
"data-testid": "skill-upload-file"
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Button,
|
|
98
|
+
{
|
|
99
|
+
disabled: !slug || !file || upload.isPending,
|
|
100
|
+
onClick: () => file && upload.mutate([{ folder: `skills/${slug}`, fileName: "SKILL.md", content: file }]),
|
|
101
|
+
"data-testid": "skill-upload-submit",
|
|
102
|
+
children: upload.isPending ? "Uploading\u2026" : "Upload skill"
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
upload.isSuccess && /* @__PURE__ */ jsx("p", { role: "status", className: "text-sm", children: "Uploaded. The skill will appear once processing finishes." }),
|
|
106
|
+
upload.error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: upload.error.message })
|
|
107
|
+
] });
|
|
108
|
+
}
|
|
39
109
|
var StreamedArtifactEditor = lazy(() => import('../StreamedArtifactEditor-7JHF4JIY.js'));
|
|
40
110
|
function StreamedArtifact({
|
|
41
111
|
artifacts,
|
|
@@ -128,7 +198,7 @@ var AVATAR_PROBLEMS = {
|
|
|
128
198
|
"too-large": "Image must be 5 MB or smaller",
|
|
129
199
|
unreadable: "Couldn't read that image \u2014 try a different file"
|
|
130
200
|
};
|
|
131
|
-
function ConnectedProfileCard({ notify:
|
|
201
|
+
function ConnectedProfileCard({ notify: notify3, title = "Profile" }) {
|
|
132
202
|
const { data: profile } = useProfile();
|
|
133
203
|
const updateProfile = useUpdateProfile();
|
|
134
204
|
const requestEmailChange = useRequestEmailChange();
|
|
@@ -140,9 +210,9 @@ function ConnectedProfileCard({ notify: notify2, title = "Profile" }) {
|
|
|
140
210
|
save: async (next) => {
|
|
141
211
|
try {
|
|
142
212
|
await updateProfile.mutateAsync(next);
|
|
143
|
-
|
|
213
|
+
notify3?.("Name updated", "success");
|
|
144
214
|
} catch (e) {
|
|
145
|
-
|
|
215
|
+
notify3?.("Failed to update name", "error");
|
|
146
216
|
throw e;
|
|
147
217
|
}
|
|
148
218
|
}
|
|
@@ -151,30 +221,30 @@ function ConnectedProfileCard({ notify: notify2, title = "Profile" }) {
|
|
|
151
221
|
upload: async (picture) => {
|
|
152
222
|
try {
|
|
153
223
|
await updateProfile.mutateAsync({ picture });
|
|
154
|
-
|
|
224
|
+
notify3?.("Profile picture updated", "success");
|
|
155
225
|
} catch (e) {
|
|
156
|
-
|
|
226
|
+
notify3?.("Failed to update picture", "error");
|
|
157
227
|
throw e;
|
|
158
228
|
}
|
|
159
229
|
},
|
|
160
|
-
onProblem: (problem) =>
|
|
230
|
+
onProblem: (problem) => notify3?.(AVATAR_PROBLEMS[problem], "error")
|
|
161
231
|
});
|
|
162
232
|
const email = useEmailChange({
|
|
163
233
|
requestCode: async (address) => {
|
|
164
234
|
try {
|
|
165
235
|
await requestEmailChange.mutateAsync(address);
|
|
166
|
-
|
|
236
|
+
notify3?.("Verification code sent to your new email", "success");
|
|
167
237
|
} catch (e) {
|
|
168
|
-
|
|
238
|
+
notify3?.(errorText(e, "Failed to send verification code"), "error");
|
|
169
239
|
throw e;
|
|
170
240
|
}
|
|
171
241
|
},
|
|
172
242
|
confirm: async (args) => {
|
|
173
243
|
try {
|
|
174
244
|
await confirmEmailChange.mutateAsync(args);
|
|
175
|
-
|
|
245
|
+
notify3?.("Email address updated", "success");
|
|
176
246
|
} catch (e) {
|
|
177
|
-
|
|
247
|
+
notify3?.(errorText(e, "Invalid or expired verification code"), "error");
|
|
178
248
|
throw e;
|
|
179
249
|
}
|
|
180
250
|
}
|
|
@@ -225,7 +295,7 @@ function defaultUnmetPasswordRequirement(password) {
|
|
|
225
295
|
return null;
|
|
226
296
|
}
|
|
227
297
|
function ConnectedSecuritySection({
|
|
228
|
-
notify:
|
|
298
|
+
notify: notify3,
|
|
229
299
|
getUnmetRequirement = defaultUnmetPasswordRequirement,
|
|
230
300
|
renderRecoveryKey,
|
|
231
301
|
children
|
|
@@ -238,7 +308,7 @@ function ConnectedSecuritySection({
|
|
|
238
308
|
getUnmetRequirement,
|
|
239
309
|
submit: async (vars) => {
|
|
240
310
|
const result = await change.mutateAsync(vars);
|
|
241
|
-
|
|
311
|
+
notify3?.("Password changed successfully", "success");
|
|
242
312
|
return result;
|
|
243
313
|
},
|
|
244
314
|
onClose: () => setOpen(false)
|
|
@@ -303,7 +373,7 @@ function ConnectedNotificationPreferences({
|
|
|
303
373
|
) }) });
|
|
304
374
|
}
|
|
305
375
|
function ConnectedSessionsRow({
|
|
306
|
-
notify:
|
|
376
|
+
notify: notify3,
|
|
307
377
|
confirm,
|
|
308
378
|
renderSessionIcon
|
|
309
379
|
}) {
|
|
@@ -357,7 +427,7 @@ function ConnectedSessionsRow({
|
|
|
357
427
|
try {
|
|
358
428
|
await terminate.mutateAsync(id);
|
|
359
429
|
} catch {
|
|
360
|
-
|
|
430
|
+
notify3?.("Failed to end session. Please try again.", "error");
|
|
361
431
|
}
|
|
362
432
|
})();
|
|
363
433
|
}
|
|
@@ -394,7 +464,7 @@ function ConnectedLogoutDialog({
|
|
|
394
464
|
}
|
|
395
465
|
);
|
|
396
466
|
}
|
|
397
|
-
function ConnectedDangerZone({ notify:
|
|
467
|
+
function ConnectedDangerZone({ notify: notify3, renderSubscriptionLink }) {
|
|
398
468
|
const [zoneOpen, setZoneOpen] = useState(false);
|
|
399
469
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
400
470
|
const { user, logout } = useConnection();
|
|
@@ -404,7 +474,7 @@ function ConnectedDangerZone({ notify: notify2, renderSubscriptionLink }) {
|
|
|
404
474
|
remove: () => remove.mutateAsync(),
|
|
405
475
|
onClose: () => setDialogOpen(false),
|
|
406
476
|
onDeleted: logout,
|
|
407
|
-
onError: () =>
|
|
477
|
+
onError: () => notify3?.("Failed to delete account. Please try again.", "error")
|
|
408
478
|
});
|
|
409
479
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
410
480
|
/* @__PURE__ */ jsx(
|
|
@@ -510,7 +580,175 @@ function useConnectedDocxNotifications(onOpen) {
|
|
|
510
580
|
}
|
|
511
581
|
};
|
|
512
582
|
}
|
|
583
|
+
function useConnectedWorkNotifications(onOpen) {
|
|
584
|
+
const { status, user, apiUrl } = useConnection();
|
|
585
|
+
const source = `work-notifications:${apiUrl}:${user?.externalId || ""}`;
|
|
586
|
+
const { data = [], markRead: persistRead } = useWorkNotifications({
|
|
587
|
+
apiUrl,
|
|
588
|
+
userId: user?.externalId,
|
|
589
|
+
enabled: status === "authenticated"
|
|
590
|
+
});
|
|
591
|
+
useEffect(() => {
|
|
592
|
+
const items = [];
|
|
593
|
+
if (status === "authenticated")
|
|
594
|
+
for (const note of data) {
|
|
595
|
+
if (note.recipient.external_id !== user?.externalId) continue;
|
|
596
|
+
const mapped = mapWorkNotification(note);
|
|
597
|
+
if (!mapped) continue;
|
|
598
|
+
items.push({
|
|
599
|
+
id: `work:${note.external_id}`,
|
|
600
|
+
title: mapped.title,
|
|
601
|
+
variant: note.type === "workflow_failed" ? "error" : note.type === "conversation_done" ? "success" : "info",
|
|
602
|
+
ts: Date.parse(note.created_at),
|
|
603
|
+
read: note.read,
|
|
604
|
+
source,
|
|
605
|
+
onSelect: () => {
|
|
606
|
+
void Promise.resolve().then(() => onOpen(mapped.target)).catch(
|
|
607
|
+
(error) => notify.error(
|
|
608
|
+
error instanceof Error ? error.message : "Could not open this notification."
|
|
609
|
+
)
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
useNotify.getState().syncSource(source, items);
|
|
615
|
+
return () => useNotify.getState().syncSource(source, []);
|
|
616
|
+
}, [data, status, user?.externalId, source, onOpen]);
|
|
617
|
+
const markRead = async (ids) => {
|
|
618
|
+
if (!ids.length) return;
|
|
619
|
+
try {
|
|
620
|
+
await persistRead(ids);
|
|
621
|
+
} catch {
|
|
622
|
+
notify.error("Could not mark work notifications read.");
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
return {
|
|
626
|
+
onMarkRead: (id) => {
|
|
627
|
+
if (data.some(
|
|
628
|
+
(note) => `work:${note.external_id}` === id && note.recipient.external_id === user?.externalId && mapWorkNotification(note)
|
|
629
|
+
))
|
|
630
|
+
void markRead([id.slice(5)]);
|
|
631
|
+
},
|
|
632
|
+
onMarkAllRead: () => {
|
|
633
|
+
void markRead(
|
|
634
|
+
data.filter(
|
|
635
|
+
(note) => !note.read && note.recipient.external_id === user?.externalId && mapWorkNotification(note)
|
|
636
|
+
).map((note) => note.external_id)
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function mapWorkNotification(note) {
|
|
642
|
+
const sender = [note.sender.given_name, note.sender.family_name].filter(Boolean).join(" ") || note.sender.email;
|
|
643
|
+
if (note.type === "workflow_failed") {
|
|
644
|
+
try {
|
|
645
|
+
const payload = JSON.parse(note.content || "{}");
|
|
646
|
+
if (!payload.workflow_ext_id?.match(/^wfl-[a-zA-Z0-9]+$/)) return null;
|
|
647
|
+
if (note.workspace_ext_id?.match(/^wrk-[a-zA-Z0-9]+$/) && note.conversation_ext_id?.match(/^con-[a-zA-Z0-9]+$/)) {
|
|
648
|
+
return {
|
|
649
|
+
title: "A workflow failed to run",
|
|
650
|
+
target: {
|
|
651
|
+
kind: "conversation",
|
|
652
|
+
workspaceId: note.workspace_ext_id,
|
|
653
|
+
conversationId: note.conversation_ext_id
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
return {
|
|
658
|
+
title: "A workflow failed to run",
|
|
659
|
+
target: {
|
|
660
|
+
kind: "workflow",
|
|
661
|
+
workflowId: payload.workflow_ext_id,
|
|
662
|
+
workspaceId: note.workspace_ext_id || void 0
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
} catch {
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const titles = {
|
|
670
|
+
mention: `${sender} mentioned you in a conversation`,
|
|
671
|
+
workspace_access_request: `${sender} needs workspace access to run a task`,
|
|
672
|
+
conversation_ready_for_review: `${sender} has a task ready for your review`,
|
|
673
|
+
conversation_approval_request: `${sender} asked you to approve a task`,
|
|
674
|
+
conversation_done: `${sender} marked a task done`
|
|
675
|
+
};
|
|
676
|
+
const title = titles[note.type];
|
|
677
|
+
if (!title || !note.workspace_ext_id || !note.conversation_ext_id?.match(/^con-[a-zA-Z0-9]+$/))
|
|
678
|
+
return null;
|
|
679
|
+
return {
|
|
680
|
+
title,
|
|
681
|
+
target: {
|
|
682
|
+
kind: "conversation",
|
|
683
|
+
workspaceId: note.workspace_ext_id,
|
|
684
|
+
conversationId: note.conversation_ext_id,
|
|
685
|
+
...note.message_ext_id ? { messageId: note.message_ext_id } : {}
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
function ActiveChat({ agentId, workspaceId }) {
|
|
690
|
+
const chat = useArbiChat({ agentId, workspaceId });
|
|
691
|
+
return /* @__PURE__ */ jsx(
|
|
692
|
+
ChatPage,
|
|
693
|
+
{
|
|
694
|
+
chat: { ...chat, assistantMode: void 0, setAssistantMode: void 0 },
|
|
695
|
+
documentsRequired: false,
|
|
696
|
+
compactHeader: true,
|
|
697
|
+
surface: "dock",
|
|
698
|
+
emptyTitle: "What would you like me to do?",
|
|
699
|
+
emptyDescription: "This agent works through its own login. Upload files here to stage them in its sandbox.",
|
|
700
|
+
className: "h-[min(65vh,650px)] min-h-[380px]"
|
|
701
|
+
}
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
function ConnectedAgentChatPanel({
|
|
705
|
+
agentId,
|
|
706
|
+
workspaceId,
|
|
707
|
+
agentName = "Agent"
|
|
708
|
+
}) {
|
|
709
|
+
const session = useAgentSession(agentId);
|
|
710
|
+
const start = useStartAgentSession();
|
|
711
|
+
const close = useCloseAgentSession();
|
|
712
|
+
const ready = session.data?.active && session.data.workspace_ext_id === workspaceId;
|
|
713
|
+
const busy = start.isPending || close.isPending;
|
|
714
|
+
const error = start.error ?? close.error ?? session.error;
|
|
715
|
+
return /* @__PURE__ */ jsxs("section", { className: "space-y-3", "data-testid": "agent-chat-panel", children: [
|
|
716
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
717
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm", "data-testid": "agent-chat-session-status", children: [
|
|
718
|
+
agentName,
|
|
719
|
+
" \xB7",
|
|
720
|
+
" ",
|
|
721
|
+
ready ? "Signed in to this workspace" : session.data?.active ? `Signed in to ${session.data.workspace_name ?? "another workspace"}` : "Signed out"
|
|
722
|
+
] }),
|
|
723
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
724
|
+
!ready && /* @__PURE__ */ jsx(
|
|
725
|
+
Button,
|
|
726
|
+
{
|
|
727
|
+
type: "button",
|
|
728
|
+
disabled: busy || session.isLoading,
|
|
729
|
+
onClick: () => start.mutate({ agentId, workspaceId }),
|
|
730
|
+
"data-testid": "agent-chat-login",
|
|
731
|
+
children: start.isPending ? "Signing in\u2026" : "Sign in here"
|
|
732
|
+
}
|
|
733
|
+
),
|
|
734
|
+
session.data?.active && /* @__PURE__ */ jsx(
|
|
735
|
+
Button,
|
|
736
|
+
{
|
|
737
|
+
type: "button",
|
|
738
|
+
variant: "outline",
|
|
739
|
+
disabled: busy,
|
|
740
|
+
onClick: () => close.mutate(agentId),
|
|
741
|
+
"data-testid": "agent-chat-logout",
|
|
742
|
+
children: close.isPending ? "Signing out\u2026" : "Sign out agent"
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] })
|
|
746
|
+
] }),
|
|
747
|
+
error && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: error.message }),
|
|
748
|
+
ready && /* @__PURE__ */ jsx(ActiveChat, { agentId, workspaceId }, `${agentId}:${workspaceId}`)
|
|
749
|
+
] });
|
|
750
|
+
}
|
|
513
751
|
|
|
514
|
-
export { ArbiAppProvider, ConnectedDangerZone, ConnectedLogoutDialog, ConnectedNotificationPreferences, ConnectedProfileCard, ConnectedSecuritySection, ConnectedSessionsRow, StreamedArtifact, defaultUnmetPasswordRequirement, useConnectedDocxNotifications, useConnectedShellWorkspaces };
|
|
752
|
+
export { ArbiAppProvider, ConnectedAgentChatPanel, ConnectedDangerZone, ConnectedLogoutDialog, ConnectedNotificationPreferences, ConnectedProfileCard, ConnectedSecuritySection, ConnectedSessionsRow, ConnectedSkillUpload, ConnectedTaskAccessRequest, StreamedArtifact, defaultUnmetPasswordRequirement, useConnectedDocxNotifications, useConnectedShellWorkspaces, useConnectedWorkNotifications };
|
|
515
753
|
//# sourceMappingURL=index.js.map
|
|
516
754
|
//# sourceMappingURL=index.js.map
|