@arbidocs/react 0.3.114 → 0.3.116
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/dist/index.cjs +641 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +608 -2
- package/dist/index.d.ts +608 -2
- package/dist/index.js +617 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import React__default, { createContext, memo, useState, forwardRef, useMemo, use
|
|
|
3
3
|
import { Arbi, connectWithReconnect, resolveCitations, summarizeCitations } from '@arbidocs/sdk/browser';
|
|
4
4
|
export { Arbi, ArbiError } from '@arbidocs/sdk/browser';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
|
-
import { useQuery, useMutation, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
7
|
-
import { Trash2, CheckCheck, Check, Circle, X, ChevronRight, ChevronDown, ChevronUp, Search, MoreVertical, MessageCircleMore,
|
|
6
|
+
import { useQuery, useMutation, useQueries, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
|
|
7
|
+
import { Trash2, CheckCheck, Check, Circle, X, ChevronRight, ChevronDown, ChevronUp, Search, MoreVertical, MessageCircleMore, MessageSquareLock, Info, FileQuestion, BookOpen, Upload, LogOut, LayoutGrid, Bell, MessageSquare, CircleUserRound, Wrench, Package, ClipboardList, UserPlus, Contact, Settings2, Users, User, StickyNote, FolderPlus, Hash, EyeOff, Eye, CaptionsOff, FolderOpen, MessageSquareMore, MessageSquarePlus, MessageSquareText, MessageSquareOff, MessagesSquare, Columns3Cog, SquarePlus, SquareM, ChevronsDown, Bot, Calendar, Folder, List, SquareCheckBig, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image, CornerDownLeft, Send, Tags, Crown, Activity, Gauge, Gift, PartyPopper, UserCheck, FileX2, FileCheck2, Pencil, SquareArrowOutUpRight } from 'lucide-react';
|
|
8
8
|
import { clsx } from 'clsx';
|
|
9
9
|
import { twMerge } from 'tailwind-merge';
|
|
10
10
|
import { isMessageType } from '@arbidocs/client';
|
|
@@ -630,7 +630,13 @@ var arbiQueryKeys = {
|
|
|
630
630
|
health: () => ["arbi", "health"],
|
|
631
631
|
tasks: () => ["arbi", "tasks"],
|
|
632
632
|
memories: (workspaceId) => ["arbi", "memories", workspaceId],
|
|
633
|
-
configs: () => ["arbi", "configs"]
|
|
633
|
+
configs: () => ["arbi", "configs"],
|
|
634
|
+
activity: () => ["arbi", "activity"],
|
|
635
|
+
projects: () => ["arbi", "projects"],
|
|
636
|
+
projectUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, monthsBack],
|
|
637
|
+
projectInvoices: (projectExtId) => ["arbi", "projectInvoices", projectExtId],
|
|
638
|
+
userUsageToday: () => ["arbi", "userUsageToday"],
|
|
639
|
+
workspaceChronology: (workspaceId) => ["arbi", "workspaceChronology", workspaceId]
|
|
634
640
|
};
|
|
635
641
|
function useWorkspaces(options) {
|
|
636
642
|
const arbi = useArbi();
|
|
@@ -741,6 +747,119 @@ function useConfigs(options) {
|
|
|
741
747
|
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
742
748
|
});
|
|
743
749
|
}
|
|
750
|
+
function useActivity(options) {
|
|
751
|
+
const arbi = useArbi();
|
|
752
|
+
return useQuery({
|
|
753
|
+
queryKey: arbiQueryKeys.activity(),
|
|
754
|
+
queryFn: () => arbi.dm.listActivity({ limit: options?.limit, offset: options?.offset }),
|
|
755
|
+
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
function useProjects(options) {
|
|
759
|
+
const arbi = useArbi();
|
|
760
|
+
return useQuery({
|
|
761
|
+
queryKey: arbiQueryKeys.projects(),
|
|
762
|
+
queryFn: () => arbi.projects.list(),
|
|
763
|
+
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
function useProjectUsage(projectExtId, monthsBack = 0, options) {
|
|
767
|
+
const arbi = useArbi();
|
|
768
|
+
return useQuery({
|
|
769
|
+
queryKey: arbiQueryKeys.projectUsage(projectExtId ?? "", monthsBack),
|
|
770
|
+
queryFn: () => arbi.projects.usage(projectExtId, monthsBack),
|
|
771
|
+
enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
function useProjectsUsage(projectExtIds, monthsBack = 0, options) {
|
|
775
|
+
const arbi = useArbi();
|
|
776
|
+
const enabled = (options?.enabled ?? true) && arbi.isLoggedIn;
|
|
777
|
+
const results = useQueries({
|
|
778
|
+
queries: projectExtIds.map((id) => ({
|
|
779
|
+
queryKey: arbiQueryKeys.projectUsage(id, monthsBack),
|
|
780
|
+
queryFn: () => arbi.projects.usage(id, monthsBack),
|
|
781
|
+
enabled: enabled && !!id
|
|
782
|
+
}))
|
|
783
|
+
});
|
|
784
|
+
const signature = results.map((r) => `${r.status}:${r.dataUpdatedAt ?? 0}`).join("|");
|
|
785
|
+
return useMemo(() => {
|
|
786
|
+
const dailyMap = /* @__PURE__ */ new Map();
|
|
787
|
+
const modelMap = /* @__PURE__ */ new Map();
|
|
788
|
+
let totalSpend = 0;
|
|
789
|
+
let totalTokens = 0;
|
|
790
|
+
let totalRequests = 0;
|
|
791
|
+
for (const r of results) {
|
|
792
|
+
const d = r.data;
|
|
793
|
+
if (!d) continue;
|
|
794
|
+
totalSpend += d.total_spend ?? 0;
|
|
795
|
+
totalTokens += d.total_tokens ?? 0;
|
|
796
|
+
totalRequests += d.total_requests ?? 0;
|
|
797
|
+
for (const day of d.daily ?? []) {
|
|
798
|
+
const cur = dailyMap.get(day.date) ?? {
|
|
799
|
+
date: day.date,
|
|
800
|
+
spend: 0,
|
|
801
|
+
totalTokens: 0,
|
|
802
|
+
apiRequests: 0
|
|
803
|
+
};
|
|
804
|
+
cur.spend += day.spend ?? 0;
|
|
805
|
+
cur.totalTokens += day.total_tokens ?? 0;
|
|
806
|
+
cur.apiRequests += day.api_requests ?? 0;
|
|
807
|
+
dailyMap.set(day.date, cur);
|
|
808
|
+
}
|
|
809
|
+
for (const [model, mg] of Object.entries(d.model_groups ?? {})) {
|
|
810
|
+
const cur = modelMap.get(model) ?? {
|
|
811
|
+
model,
|
|
812
|
+
spend: 0,
|
|
813
|
+
totalTokens: 0,
|
|
814
|
+
promptTokens: 0,
|
|
815
|
+
completionTokens: 0,
|
|
816
|
+
successfulRequests: 0
|
|
817
|
+
};
|
|
818
|
+
cur.spend += mg.spend ?? 0;
|
|
819
|
+
cur.totalTokens += mg.total_tokens ?? 0;
|
|
820
|
+
cur.promptTokens += mg.prompt_tokens ?? 0;
|
|
821
|
+
cur.completionTokens += mg.completion_tokens ?? 0;
|
|
822
|
+
cur.successfulRequests += mg.successful_requests ?? 0;
|
|
823
|
+
modelMap.set(model, cur);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return {
|
|
827
|
+
totalSpend,
|
|
828
|
+
totalTokens,
|
|
829
|
+
totalRequests,
|
|
830
|
+
daily: [...dailyMap.values()].sort((a, b) => a.date.localeCompare(b.date)),
|
|
831
|
+
modelGroups: [...modelMap.values()].sort(
|
|
832
|
+
(a, b) => b.spend - a.spend || b.totalTokens - a.totalTokens
|
|
833
|
+
),
|
|
834
|
+
isLoading: results.some((r) => r.isLoading),
|
|
835
|
+
isError: results.some((r) => r.isError)
|
|
836
|
+
};
|
|
837
|
+
}, [signature]);
|
|
838
|
+
}
|
|
839
|
+
function useProjectInvoices(projectExtId, options) {
|
|
840
|
+
const arbi = useArbi();
|
|
841
|
+
return useQuery({
|
|
842
|
+
queryKey: arbiQueryKeys.projectInvoices(projectExtId ?? ""),
|
|
843
|
+
queryFn: () => arbi.projects.invoices(projectExtId),
|
|
844
|
+
enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
function useUserUsageToday(options) {
|
|
848
|
+
const arbi = useArbi();
|
|
849
|
+
return useQuery({
|
|
850
|
+
queryKey: arbiQueryKeys.userUsageToday(),
|
|
851
|
+
queryFn: () => arbi.user.usageToday(),
|
|
852
|
+
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
function useWorkspaceChronology(workspaceId, options) {
|
|
856
|
+
const arbi = useArbi();
|
|
857
|
+
return useQuery({
|
|
858
|
+
queryKey: arbiQueryKeys.workspaceChronology(workspaceId ?? ""),
|
|
859
|
+
queryFn: () => arbi.workspaces.chronology(workspaceId),
|
|
860
|
+
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
861
|
+
});
|
|
862
|
+
}
|
|
744
863
|
function WorkspaceScreen({ theme, labels, onSelect }) {
|
|
745
864
|
const arbi = useArbi();
|
|
746
865
|
const { data: workspaces, isLoading } = useWorkspaces();
|
|
@@ -5125,6 +5244,500 @@ var UserEntity = memo(function UserEntity2({
|
|
|
5125
5244
|
}
|
|
5126
5245
|
return avatarElement;
|
|
5127
5246
|
});
|
|
5247
|
+
var ENTITY_MAPPINGS = {
|
|
5248
|
+
PRODUCT: {
|
|
5249
|
+
NAMES: {
|
|
5250
|
+
SINGULAR: "ARBI Docs"
|
|
5251
|
+
},
|
|
5252
|
+
ICONS: {
|
|
5253
|
+
DEFAULT: MessageSquareLock
|
|
5254
|
+
}
|
|
5255
|
+
},
|
|
5256
|
+
SECTION: {
|
|
5257
|
+
NAMES: {
|
|
5258
|
+
SINGULAR: "Section"
|
|
5259
|
+
},
|
|
5260
|
+
ICONS: {
|
|
5261
|
+
DEFAULT: ChevronsDown
|
|
5262
|
+
}
|
|
5263
|
+
},
|
|
5264
|
+
WORKSPACE: {
|
|
5265
|
+
NAMES: {
|
|
5266
|
+
SINGULAR: "Workspace",
|
|
5267
|
+
PLURAL: "Workspaces"
|
|
5268
|
+
},
|
|
5269
|
+
ICONS: {
|
|
5270
|
+
DEFAULT: SquareM,
|
|
5271
|
+
NEW: SquarePlus,
|
|
5272
|
+
LIST: LayoutGrid,
|
|
5273
|
+
SETTINGS: Columns3Cog
|
|
5274
|
+
}
|
|
5275
|
+
},
|
|
5276
|
+
CONVERSATION: {
|
|
5277
|
+
NAMES: {
|
|
5278
|
+
SINGULAR: "Chat",
|
|
5279
|
+
PLURAL: "Chats",
|
|
5280
|
+
NEW: "New ARBI Chat"
|
|
5281
|
+
},
|
|
5282
|
+
ICONS: {
|
|
5283
|
+
DEFAULT: MessagesSquare,
|
|
5284
|
+
OFF: MessageSquareOff,
|
|
5285
|
+
ACTIVE: MessageSquareText,
|
|
5286
|
+
NEW: MessageSquarePlus,
|
|
5287
|
+
LIST: MessageSquareMore
|
|
5288
|
+
}
|
|
5289
|
+
},
|
|
5290
|
+
DOCUMENT: {
|
|
5291
|
+
NAMES: {
|
|
5292
|
+
SINGULAR: "File",
|
|
5293
|
+
PLURAL: "Files"
|
|
5294
|
+
},
|
|
5295
|
+
ICONS: {
|
|
5296
|
+
DEFAULT: FolderOpen,
|
|
5297
|
+
OFF: CaptionsOff
|
|
5298
|
+
}
|
|
5299
|
+
},
|
|
5300
|
+
VIEWER: {
|
|
5301
|
+
NAMES: {
|
|
5302
|
+
SINGULAR: "Viewer",
|
|
5303
|
+
PLURAL: "Viewers"
|
|
5304
|
+
},
|
|
5305
|
+
ICONS: {
|
|
5306
|
+
DEFAULT: Eye,
|
|
5307
|
+
OFF: EyeOff
|
|
5308
|
+
}
|
|
5309
|
+
},
|
|
5310
|
+
TAG: {
|
|
5311
|
+
NAMES: {
|
|
5312
|
+
SINGULAR: "Field",
|
|
5313
|
+
PLURAL: "Fields"
|
|
5314
|
+
},
|
|
5315
|
+
ICONS: {
|
|
5316
|
+
DEFAULT: Hash,
|
|
5317
|
+
NEW: FolderPlus
|
|
5318
|
+
}
|
|
5319
|
+
},
|
|
5320
|
+
ANNOTATION: {
|
|
5321
|
+
NAMES: {
|
|
5322
|
+
SINGULAR: "Annotation",
|
|
5323
|
+
PLURAL: "Annotations"
|
|
5324
|
+
},
|
|
5325
|
+
ICONS: {
|
|
5326
|
+
DEFAULT: StickyNote,
|
|
5327
|
+
NEW: StickyNote
|
|
5328
|
+
}
|
|
5329
|
+
},
|
|
5330
|
+
USER: {
|
|
5331
|
+
NAMES: {
|
|
5332
|
+
SINGULAR: "User",
|
|
5333
|
+
PLURAL: "Users"
|
|
5334
|
+
},
|
|
5335
|
+
ICONS: {
|
|
5336
|
+
DEFAULT: User,
|
|
5337
|
+
NEW: UserPlus,
|
|
5338
|
+
SETTINGS: Settings2
|
|
5339
|
+
}
|
|
5340
|
+
},
|
|
5341
|
+
WORKSPACEUSER: {
|
|
5342
|
+
NAMES: {
|
|
5343
|
+
SINGULAR: "Member",
|
|
5344
|
+
PLURAL: "Members"
|
|
5345
|
+
},
|
|
5346
|
+
ICONS: {
|
|
5347
|
+
DEFAULT: User,
|
|
5348
|
+
PLURAL: Users,
|
|
5349
|
+
NEW: UserPlus,
|
|
5350
|
+
SETTINGS: Settings2
|
|
5351
|
+
}
|
|
5352
|
+
},
|
|
5353
|
+
CONTACT: {
|
|
5354
|
+
NAMES: {
|
|
5355
|
+
SINGULAR: "Contact",
|
|
5356
|
+
PLURAL: "Contacts"
|
|
5357
|
+
},
|
|
5358
|
+
ICONS: {
|
|
5359
|
+
DEFAULT: Contact,
|
|
5360
|
+
NEW: UserPlus
|
|
5361
|
+
}
|
|
5362
|
+
},
|
|
5363
|
+
TASK: {
|
|
5364
|
+
NAMES: {
|
|
5365
|
+
SINGULAR: "Job",
|
|
5366
|
+
PLURAL: "Jobs"
|
|
5367
|
+
},
|
|
5368
|
+
ICONS: {
|
|
5369
|
+
DEFAULT: ClipboardList
|
|
5370
|
+
}
|
|
5371
|
+
},
|
|
5372
|
+
PROJECT: {
|
|
5373
|
+
NAMES: {
|
|
5374
|
+
SINGULAR: "Project",
|
|
5375
|
+
PLURAL: "Projects"
|
|
5376
|
+
},
|
|
5377
|
+
ICONS: {
|
|
5378
|
+
DEFAULT: Package
|
|
5379
|
+
}
|
|
5380
|
+
},
|
|
5381
|
+
SKILL: {
|
|
5382
|
+
NAMES: {
|
|
5383
|
+
SINGULAR: "Skill",
|
|
5384
|
+
PLURAL: "Skills"
|
|
5385
|
+
},
|
|
5386
|
+
ICONS: {
|
|
5387
|
+
DEFAULT: Wrench
|
|
5388
|
+
}
|
|
5389
|
+
},
|
|
5390
|
+
ACCOUNT: {
|
|
5391
|
+
NAMES: {
|
|
5392
|
+
SINGULAR: "Account"
|
|
5393
|
+
},
|
|
5394
|
+
ICONS: {
|
|
5395
|
+
DEFAULT: CircleUserRound
|
|
5396
|
+
}
|
|
5397
|
+
},
|
|
5398
|
+
NOTIFICATIONS: {
|
|
5399
|
+
NAMES: {
|
|
5400
|
+
SINGULAR: "Activity",
|
|
5401
|
+
PLURAL: "Activities"
|
|
5402
|
+
},
|
|
5403
|
+
ICONS: {
|
|
5404
|
+
DEFAULT: Bell
|
|
5405
|
+
}
|
|
5406
|
+
},
|
|
5407
|
+
MESSAGE: {
|
|
5408
|
+
NAMES: {
|
|
5409
|
+
SINGULAR: "Message",
|
|
5410
|
+
PLURAL: "Messages"
|
|
5411
|
+
},
|
|
5412
|
+
ICONS: {
|
|
5413
|
+
DEFAULT: MessageSquare
|
|
5414
|
+
}
|
|
5415
|
+
},
|
|
5416
|
+
NOTIFICATION: {
|
|
5417
|
+
NAMES: {
|
|
5418
|
+
SINGULAR: "Notification",
|
|
5419
|
+
PLURAL: "Notifications"
|
|
5420
|
+
},
|
|
5421
|
+
ICONS: {
|
|
5422
|
+
DEFAULT: Bell
|
|
5423
|
+
}
|
|
5424
|
+
},
|
|
5425
|
+
APP: {
|
|
5426
|
+
NAMES: {
|
|
5427
|
+
SINGULAR: "Application",
|
|
5428
|
+
PLURAL: "Applications"
|
|
5429
|
+
},
|
|
5430
|
+
ICONS: {
|
|
5431
|
+
DEFAULT: LayoutGrid,
|
|
5432
|
+
HOME: LayoutGrid,
|
|
5433
|
+
LOGOUT: LogOut,
|
|
5434
|
+
UPLOAD: Upload
|
|
5435
|
+
}
|
|
5436
|
+
},
|
|
5437
|
+
HELP: {
|
|
5438
|
+
NAMES: {
|
|
5439
|
+
SINGULAR: "Help",
|
|
5440
|
+
PLURAL: "Help"
|
|
5441
|
+
},
|
|
5442
|
+
ICONS: {
|
|
5443
|
+
DEFAULT: MessageSquareLock,
|
|
5444
|
+
DOCS: BookOpen,
|
|
5445
|
+
FAQ: FileQuestion,
|
|
5446
|
+
ABOUT: Info
|
|
5447
|
+
}
|
|
5448
|
+
},
|
|
5449
|
+
USERSHIELD: {
|
|
5450
|
+
NAMES: {
|
|
5451
|
+
SINGULAR: "User Shield",
|
|
5452
|
+
PLURAL: "User Shields"
|
|
5453
|
+
},
|
|
5454
|
+
ICONS: {
|
|
5455
|
+
DEFAULT: MessageSquareLock
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
};
|
|
5459
|
+
function configureEntityRegistry(overrides) {
|
|
5460
|
+
for (const [type, def] of Object.entries(overrides)) {
|
|
5461
|
+
const target = ENTITY_MAPPINGS[type];
|
|
5462
|
+
if (!target) continue;
|
|
5463
|
+
if (def?.NAMES) Object.assign(target.NAMES, def.NAMES);
|
|
5464
|
+
if (def?.ICONS) Object.assign(target.ICONS, def.ICONS);
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5467
|
+
var getEntityIcon = (entityType, variant = "DEFAULT") => {
|
|
5468
|
+
const icons = ENTITY_MAPPINGS[entityType]?.ICONS;
|
|
5469
|
+
return icons?.[variant] || icons?.DEFAULT;
|
|
5470
|
+
};
|
|
5471
|
+
var getEntityLabel = (entityType, form = "SINGULAR") => {
|
|
5472
|
+
const entityMapping = ENTITY_MAPPINGS[entityType];
|
|
5473
|
+
if (!entityMapping) return "";
|
|
5474
|
+
const names = entityMapping.NAMES;
|
|
5475
|
+
const singularName = names.SINGULAR || "";
|
|
5476
|
+
if (form === "NEW") return names.NEW !== void 0 ? names.NEW : "New " + singularName;
|
|
5477
|
+
if (form === "SHORT")
|
|
5478
|
+
return names.SHORT !== void 0 ? names.SHORT : singularName.substring(0, 3) + ".";
|
|
5479
|
+
if (form === "PLURAL") return names.PLURAL !== void 0 ? names.PLURAL : singularName + "s";
|
|
5480
|
+
return singularName;
|
|
5481
|
+
};
|
|
5482
|
+
var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
|
|
5483
|
+
const IconComponent = getEntityIcon(entityType, variant);
|
|
5484
|
+
return IconComponent ? React__default.createElement(IconComponent, props) : null;
|
|
5485
|
+
};
|
|
5486
|
+
var VISIBILITY_ICONS = {
|
|
5487
|
+
PRIVATE: MessageSquareLock,
|
|
5488
|
+
SHARED: Users
|
|
5489
|
+
};
|
|
5490
|
+
var VisibilityIcon = ({
|
|
5491
|
+
isShared,
|
|
5492
|
+
...props
|
|
5493
|
+
}) => {
|
|
5494
|
+
const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
|
|
5495
|
+
return React__default.createElement(IconComponent, props);
|
|
5496
|
+
};
|
|
5497
|
+
|
|
5498
|
+
// src/entities/colors.ts
|
|
5499
|
+
var OPACITY_LIGHT = 0.15;
|
|
5500
|
+
var OPACITY_MEDIUM = 1;
|
|
5501
|
+
var OPACITY_BORDER = 0.3;
|
|
5502
|
+
var PLACEHOLDER_COLOR = "#9ca3af";
|
|
5503
|
+
var NEUTRAL_GRAY2 = "#64748b";
|
|
5504
|
+
var BASE_COLORS2 = {
|
|
5505
|
+
"0": "#10b981",
|
|
5506
|
+
"1": "#3b82f6",
|
|
5507
|
+
"2": "#8b5cf6",
|
|
5508
|
+
"3": "#f43f5e",
|
|
5509
|
+
"4": "#f59e0b",
|
|
5510
|
+
"5": "#84cc16",
|
|
5511
|
+
"6": "#a855f7",
|
|
5512
|
+
"7": "#06b6d4",
|
|
5513
|
+
"8": "#f97316",
|
|
5514
|
+
"9": "#14b8a6",
|
|
5515
|
+
a: "#ef4444",
|
|
5516
|
+
b: "#6366f1",
|
|
5517
|
+
c: "#ec4899",
|
|
5518
|
+
d: "#22c55e",
|
|
5519
|
+
e: "#eab308",
|
|
5520
|
+
f: "#0ea5e9"
|
|
5521
|
+
};
|
|
5522
|
+
function hexToRgba(hex, opacity) {
|
|
5523
|
+
const r = parseInt(hex.slice(1, 3), 16);
|
|
5524
|
+
const g = parseInt(hex.slice(3, 5), 16);
|
|
5525
|
+
const b = parseInt(hex.slice(5, 7), 16);
|
|
5526
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
5527
|
+
}
|
|
5528
|
+
function getEntityColor2(entityId, variant = "medium") {
|
|
5529
|
+
const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
|
|
5530
|
+
switch (variant) {
|
|
5531
|
+
case "light":
|
|
5532
|
+
return hexToRgba(baseColor, OPACITY_LIGHT);
|
|
5533
|
+
case "medium":
|
|
5534
|
+
return hexToRgba(baseColor, OPACITY_MEDIUM);
|
|
5535
|
+
case "text":
|
|
5536
|
+
return baseColor;
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
function getEntityColorStyles(entityId) {
|
|
5540
|
+
const baseColor = BASE_COLORS2[entityId[4]] || BASE_COLORS2["0"];
|
|
5541
|
+
return {
|
|
5542
|
+
backgroundColor: getEntityColor2(entityId, "light"),
|
|
5543
|
+
color: baseColor,
|
|
5544
|
+
borderColor: hexToRgba(baseColor, OPACITY_BORDER)
|
|
5545
|
+
};
|
|
5546
|
+
}
|
|
5547
|
+
var getWorkspaceColor = (workspaceId, useWorkspaceColors) => {
|
|
5548
|
+
const shouldUseWorkspaceColors = useWorkspaceColors !== void 0 ? useWorkspaceColors : true;
|
|
5549
|
+
if (!shouldUseWorkspaceColors) return "hsl(var(--primary))";
|
|
5550
|
+
const isValidId = workspaceId && workspaceId.startsWith("wrk-") && workspaceId.length >= 5;
|
|
5551
|
+
if (!isValidId) return "hsl(var(--primary))";
|
|
5552
|
+
return getEntityColor2(workspaceId, "medium");
|
|
5553
|
+
};
|
|
5554
|
+
function getNotificationTypeMeta(type) {
|
|
5555
|
+
const WorkspaceIcon = getEntityIcon("WORKSPACE");
|
|
5556
|
+
switch (type) {
|
|
5557
|
+
case "user_message":
|
|
5558
|
+
return { Icon: MessageCircleMore, iconClassName: "text-primary", label: "Message" };
|
|
5559
|
+
case "workspaceuser_added_owner":
|
|
5560
|
+
case "workspaceuser_added_collaborator":
|
|
5561
|
+
case "workspaceuser_added_guest":
|
|
5562
|
+
return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Added" };
|
|
5563
|
+
case "workspaceuser_removed":
|
|
5564
|
+
return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Removed" };
|
|
5565
|
+
case "workspaceuser_updated_owner":
|
|
5566
|
+
case "workspaceuser_updated_collaborator":
|
|
5567
|
+
case "workspaceuser_updated_guest":
|
|
5568
|
+
return { Icon: WorkspaceIcon, iconClassName: "text-primary", label: "Role changed" };
|
|
5569
|
+
case "contact_accepted":
|
|
5570
|
+
return { Icon: UserCheck, iconClassName: "text-green-500", label: "Invitation" };
|
|
5571
|
+
case "signup_reward":
|
|
5572
|
+
return { Icon: PartyPopper, iconClassName: "text-green-600", label: "Signup bonus" };
|
|
5573
|
+
case "referral_reward":
|
|
5574
|
+
return { Icon: Gift, iconClassName: "text-green-600", label: "Reward earned" };
|
|
5575
|
+
case "quota_threshold_50":
|
|
5576
|
+
return { Icon: Gauge, iconClassName: "text-blue-500", label: "Usage 50%" };
|
|
5577
|
+
case "quota_threshold_90":
|
|
5578
|
+
return { Icon: Gauge, iconClassName: "text-orange-500", label: "Usage 90%" };
|
|
5579
|
+
case "quota_threshold_100":
|
|
5580
|
+
return { Icon: Gauge, iconClassName: "text-red-500", label: "Usage limit" };
|
|
5581
|
+
case "activity":
|
|
5582
|
+
return { Icon: Activity, iconClassName: "text-muted-foreground", label: "Activity" };
|
|
5583
|
+
default:
|
|
5584
|
+
return { Icon: Info, iconClassName: "text-blue-500", label: type || "Notification" };
|
|
5585
|
+
}
|
|
5586
|
+
}
|
|
5587
|
+
function isWorkspaceNotificationType(type) {
|
|
5588
|
+
return type.startsWith("workspaceuser_");
|
|
5589
|
+
}
|
|
5590
|
+
function getWorkspaceActionText(type) {
|
|
5591
|
+
switch (type) {
|
|
5592
|
+
case "workspaceuser_added_owner":
|
|
5593
|
+
return "added you as owner";
|
|
5594
|
+
case "workspaceuser_added_collaborator":
|
|
5595
|
+
return "added you as collaborator";
|
|
5596
|
+
case "workspaceuser_added_guest":
|
|
5597
|
+
return "added you as guest";
|
|
5598
|
+
case "workspaceuser_removed":
|
|
5599
|
+
return "removed you";
|
|
5600
|
+
case "workspaceuser_updated_owner":
|
|
5601
|
+
return "changed your role to owner";
|
|
5602
|
+
case "workspaceuser_updated_collaborator":
|
|
5603
|
+
return "changed your role to collaborator";
|
|
5604
|
+
case "workspaceuser_updated_guest":
|
|
5605
|
+
return "changed your role to guest";
|
|
5606
|
+
default:
|
|
5607
|
+
return "updated your access";
|
|
5608
|
+
}
|
|
5609
|
+
}
|
|
5610
|
+
function getWorkspaceSentPhrase(type) {
|
|
5611
|
+
switch (type) {
|
|
5612
|
+
case "workspaceuser_added_owner":
|
|
5613
|
+
return { before: "You added", after: "as owner" };
|
|
5614
|
+
case "workspaceuser_added_collaborator":
|
|
5615
|
+
return { before: "You added", after: "as collaborator" };
|
|
5616
|
+
case "workspaceuser_added_guest":
|
|
5617
|
+
return { before: "You added", after: "as guest" };
|
|
5618
|
+
case "workspaceuser_removed":
|
|
5619
|
+
return { before: "You removed", after: "" };
|
|
5620
|
+
case "workspaceuser_updated_owner":
|
|
5621
|
+
return { before: "You set", after: "as owner" };
|
|
5622
|
+
case "workspaceuser_updated_collaborator":
|
|
5623
|
+
return { before: "You set", after: "as collaborator" };
|
|
5624
|
+
case "workspaceuser_updated_guest":
|
|
5625
|
+
return { before: "You set", after: "as guest" };
|
|
5626
|
+
default:
|
|
5627
|
+
return { before: "You updated access for", after: "" };
|
|
5628
|
+
}
|
|
5629
|
+
}
|
|
5630
|
+
function parseActivityContent(content) {
|
|
5631
|
+
if (!content) return null;
|
|
5632
|
+
try {
|
|
5633
|
+
const parsed = JSON.parse(content);
|
|
5634
|
+
if (parsed && typeof parsed === "object" && typeof parsed.event === "string") {
|
|
5635
|
+
return parsed;
|
|
5636
|
+
}
|
|
5637
|
+
} catch {
|
|
5638
|
+
}
|
|
5639
|
+
return null;
|
|
5640
|
+
}
|
|
5641
|
+
function str(v) {
|
|
5642
|
+
return typeof v === "string" && v ? v : void 0;
|
|
5643
|
+
}
|
|
5644
|
+
function describeActivity(content) {
|
|
5645
|
+
const parsed = typeof content === "string" || content == null ? parseActivityContent(content) : content;
|
|
5646
|
+
if (!parsed) {
|
|
5647
|
+
return { Icon: Activity, iconClassName: "text-muted-foreground", title: "Activity" };
|
|
5648
|
+
}
|
|
5649
|
+
const fileName = str(parsed.file_name);
|
|
5650
|
+
switch (parsed.event) {
|
|
5651
|
+
case "workspace_opened":
|
|
5652
|
+
return {
|
|
5653
|
+
Icon: SquareArrowOutUpRight,
|
|
5654
|
+
iconClassName: "text-primary",
|
|
5655
|
+
title: "Opened a workspace"
|
|
5656
|
+
};
|
|
5657
|
+
case "workspace_created":
|
|
5658
|
+
return { Icon: FolderPlus, iconClassName: "text-green-600", title: "Created a workspace" };
|
|
5659
|
+
case "workspace_updated":
|
|
5660
|
+
return { Icon: Pencil, iconClassName: "text-primary", title: "Updated workspace settings" };
|
|
5661
|
+
case "workspace_deleted":
|
|
5662
|
+
return { Icon: Trash2, iconClassName: "text-red-500", title: "Deleted a workspace" };
|
|
5663
|
+
case "document_processing": {
|
|
5664
|
+
const failed = str(parsed.status) === "failed";
|
|
5665
|
+
const noun = fileName ? `\u201C${fileName}\u201D` : "a document";
|
|
5666
|
+
return failed ? { Icon: FileX2, iconClassName: "text-red-500", title: `Failed to process ${noun}` } : { Icon: FileCheck2, iconClassName: "text-green-600", title: `Processed ${noun}` };
|
|
5667
|
+
}
|
|
5668
|
+
default:
|
|
5669
|
+
return {
|
|
5670
|
+
Icon: parsed.workspace_ext_id ? getEntityIcon("WORKSPACE") : Activity,
|
|
5671
|
+
iconClassName: "text-muted-foreground",
|
|
5672
|
+
title: humaniseEvent(parsed.event)
|
|
5673
|
+
};
|
|
5674
|
+
}
|
|
5675
|
+
}
|
|
5676
|
+
function humaniseEvent(event) {
|
|
5677
|
+
const words = event.replace(/[_-]+/g, " ").trim();
|
|
5678
|
+
return words ? words.charAt(0).toUpperCase() + words.slice(1) : "Activity";
|
|
5679
|
+
}
|
|
5680
|
+
function formatRelative(iso) {
|
|
5681
|
+
const then = new Date(iso).getTime();
|
|
5682
|
+
if (Number.isNaN(then)) return "";
|
|
5683
|
+
const secs = Math.round((Date.now() - then) / 1e3);
|
|
5684
|
+
if (secs < 45) return "just now";
|
|
5685
|
+
const mins = Math.round(secs / 60);
|
|
5686
|
+
if (mins < 60) return `${mins}m`;
|
|
5687
|
+
const hours = Math.round(mins / 60);
|
|
5688
|
+
if (hours < 24) return `${hours}h`;
|
|
5689
|
+
const days = Math.round(hours / 24);
|
|
5690
|
+
if (days < 7) return `${days}d`;
|
|
5691
|
+
return new Date(iso).toLocaleDateString();
|
|
5692
|
+
}
|
|
5693
|
+
function ActivityFeed({
|
|
5694
|
+
limit = 20,
|
|
5695
|
+
className,
|
|
5696
|
+
emptyLabel = "No recent activity",
|
|
5697
|
+
enabled,
|
|
5698
|
+
"data-testid": testId = "activity-feed"
|
|
5699
|
+
}) {
|
|
5700
|
+
const { data, isLoading, isError } = useActivity({ limit, enabled });
|
|
5701
|
+
if (isLoading) {
|
|
5702
|
+
return /* @__PURE__ */ jsx("div", { className: cn("space-y-2", className), "data-testid": testId, "aria-busy": "true", children: Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 py-1.5", children: [
|
|
5703
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-4 shrink-0 animate-pulse rounded-full bg-muted" }),
|
|
5704
|
+
/* @__PURE__ */ jsx("div", { className: "h-3 flex-1 animate-pulse rounded bg-muted" })
|
|
5705
|
+
] }, i)) });
|
|
5706
|
+
}
|
|
5707
|
+
if (isError) {
|
|
5708
|
+
return /* @__PURE__ */ jsx("div", { className: cn("text-sm text-muted-foreground", className), "data-testid": testId, children: "Couldn\u2019t load activity." });
|
|
5709
|
+
}
|
|
5710
|
+
const items = data ?? [];
|
|
5711
|
+
if (items.length === 0) {
|
|
5712
|
+
return /* @__PURE__ */ jsxs(
|
|
5713
|
+
"div",
|
|
5714
|
+
{
|
|
5715
|
+
className: cn("flex items-center gap-2 text-sm text-muted-foreground", className),
|
|
5716
|
+
"data-testid": testId,
|
|
5717
|
+
children: [
|
|
5718
|
+
/* @__PURE__ */ jsx(Activity, { className: "h-4 w-4 shrink-0" }),
|
|
5719
|
+
/* @__PURE__ */ jsx("span", { children: emptyLabel })
|
|
5720
|
+
]
|
|
5721
|
+
}
|
|
5722
|
+
);
|
|
5723
|
+
}
|
|
5724
|
+
return /* @__PURE__ */ jsx("ul", { className: cn("divide-y divide-border", className), "data-testid": testId, children: items.map((item) => {
|
|
5725
|
+
const desc = describeActivity(item.content);
|
|
5726
|
+
return /* @__PURE__ */ jsxs(
|
|
5727
|
+
"li",
|
|
5728
|
+
{
|
|
5729
|
+
className: "flex items-center gap-3 py-2",
|
|
5730
|
+
"data-testid": "activity-feed-item",
|
|
5731
|
+
children: [
|
|
5732
|
+
/* @__PURE__ */ jsx(desc.Icon, { className: cn("h-4 w-4 shrink-0", desc.iconClassName) }),
|
|
5733
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-foreground", children: desc.title }),
|
|
5734
|
+
/* @__PURE__ */ jsx("time", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: formatRelative(item.created_at) })
|
|
5735
|
+
]
|
|
5736
|
+
},
|
|
5737
|
+
item.external_id
|
|
5738
|
+
);
|
|
5739
|
+
}) });
|
|
5740
|
+
}
|
|
5128
5741
|
var useArbiUiStore = create((set) => ({
|
|
5129
5742
|
selectedDocIds: [],
|
|
5130
5743
|
setSelectedDocIds: (ids) => set({ selectedDocIds: ids }),
|
|
@@ -5693,6 +6306,6 @@ function DocumentReview({
|
|
|
5693
6306
|
);
|
|
5694
6307
|
}
|
|
5695
6308
|
|
|
5696
|
-
export { AiActionCard, AiAnswer, AiMarkdown, AppleIcon, ArbiBotHeadIcon, ArbiBotIcon, ArbiChat, ArbiChatPanel, ArbiIcon, ArbiProvider, ArbiWebSocketProvider, ArtifactCanvas, AudIcon, Avatar, AvatarFallback, AvatarImage, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatBubble, Checkbox, CitationRenderer, ClaudeIcon, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DocIcon, DocQaPanel, DocSearch, DocumentEntity, DocumentGallery, DocumentReview, DocumentTable, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmlIcon, EntityPill, FILE_TYPE_COLORS, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, ImgIcon, Input, Label, LinkedInIcon, MessageArtifactCard, OpenAIIcon, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, ProjectEntity, ProviderIcon, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, TypingIndicator, UserEntity, VidIcon, XlsIcon, arbiQueryKeys, badgeVariants, buttonVariants, cardVariants, cn, getTagTypeIcon, getTagTypeLabel, markdownBaseComponents, redlineStats, textToArtifact, toRedlineMarkdown, toggleVariants, useAgents, useAiTask, useArbi, useArbiConnected, useArbiDocumentSync, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssistantQuery, useConfigs, useConversations, useDeleteAgents, useDocuments, useHealth, useMemories, useParsedDocument, useSemanticSearch, useSessions, useTags, useTasks, useThumbnails, useWorkspaceDocs, useWorkspaces };
|
|
6309
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AiMarkdown, AppleIcon, ArbiBotHeadIcon, ArbiBotIcon, ArbiChat, ArbiChatPanel, ArbiIcon, ArbiProvider, ArbiWebSocketProvider, ArtifactCanvas, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS2 as BASE_COLORS, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChatBubble, Checkbox, CitationRenderer, ClaudeIcon, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DocIcon, DocQaPanel, DocSearch, DocumentEntity, DocumentGallery, DocumentReview, DocumentTable, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HoverCard, HoverCardContent, HoverCardTrigger, HtmlIcon, ImgIcon, Input, Label, LinkedInIcon, MessageArtifactCard, NEUTRAL_GRAY2 as NEUTRAL_GRAY, OpenAIIcon, PLACEHOLDER_COLOR, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, Progress, ProjectEntity, ProviderIcon, RadioGroup, RadioGroupItem, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, Switch, TAG_TYPE_ICONS, TAG_TYPE_LABELS, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, TagEntity, Textarea, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TxtIcon, TypingIndicator, UserEntity, VISIBILITY_ICONS, VidIcon, VisibilityIcon, XlsIcon, arbiQueryKeys, badgeVariants, buttonVariants, cardVariants, cn, configureEntityRegistry, describeActivity, getEntityColor2 as getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getNotificationTypeMeta, getTagTypeIcon, getTagTypeLabel, getWorkspaceActionText, getWorkspaceColor, getWorkspaceSentPhrase, isWorkspaceNotificationType, markdownBaseComponents, parseActivityContent, redlineStats, textToArtifact, toRedlineMarkdown, toggleVariants, useActivity, useAgents, useAiTask, useArbi, useArbiConnected, useArbiDocumentSync, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useAssistantQuery, useConfigs, useConversations, useDeleteAgents, useDocuments, useHealth, useMemories, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSemanticSearch, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaceChronology, useWorkspaceDocs, useWorkspaces };
|
|
5697
6310
|
//# sourceMappingURL=index.js.map
|
|
5698
6311
|
//# sourceMappingURL=index.js.map
|