@arbidocs/react 0.4.4 → 0.4.5
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 +11 -0
- package/dist/artifacts/index.cjs +458 -0
- package/dist/artifacts/index.cjs.map +1 -0
- package/dist/artifacts/index.d.cts +276 -0
- package/dist/artifacts/index.d.ts +276 -0
- package/dist/artifacts/index.js +434 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/artifacts/redline-core.cjs +20 -0
- package/dist/artifacts/redline-core.cjs.map +1 -0
- package/dist/artifacts/redline-core.d.cts +36 -0
- package/dist/artifacts/redline-core.d.ts +36 -0
- package/dist/artifacts/redline-core.js +3 -0
- package/dist/artifacts/redline-core.js.map +1 -0
- package/dist/chunk-2DXS7L7M.cjs +302 -0
- package/dist/chunk-2DXS7L7M.cjs.map +1 -0
- package/dist/{chunk-ORKGCXG3.cjs → chunk-7BDGLRQX.cjs} +123 -427
- package/dist/chunk-7BDGLRQX.cjs.map +1 -0
- package/dist/chunk-7V7B7OEM.cjs +318 -0
- package/dist/chunk-7V7B7OEM.cjs.map +1 -0
- package/dist/{chunk-MIJRORQL.js → chunk-DVRJFLE7.js} +8 -302
- package/dist/chunk-DVRJFLE7.js.map +1 -0
- package/dist/{chunk-EJ2BMHYK.js → chunk-FSMIN5VX.js} +4 -3
- package/dist/chunk-FSMIN5VX.js.map +1 -0
- package/dist/chunk-H7ZZQ4ZV.js +305 -0
- package/dist/chunk-H7ZZQ4ZV.js.map +1 -0
- package/dist/{chunk-JKO3NR5L.js → chunk-HDCRPPBW.js} +5 -23
- package/dist/chunk-HDCRPPBW.js.map +1 -0
- package/dist/chunk-J4MX2W4H.js +26 -0
- package/dist/chunk-J4MX2W4H.js.map +1 -0
- package/dist/{chunk-6ALMBER7.js → chunk-N5SVBDLC.js} +4 -9
- package/dist/chunk-N5SVBDLC.js.map +1 -0
- package/dist/{chunk-RZQACYNQ.cjs → chunk-OBNTJEEO.cjs} +14 -20
- package/dist/chunk-OBNTJEEO.cjs.map +1 -0
- package/dist/{chunk-BXP6S34V.cjs → chunk-PGLV23SB.cjs} +13 -12
- package/dist/chunk-PGLV23SB.cjs.map +1 -0
- package/dist/chunk-RKWNX32A.js +299 -0
- package/dist/chunk-RKWNX32A.js.map +1 -0
- package/dist/chunk-S6A6FSG7.cjs +13 -0
- package/dist/chunk-S6A6FSG7.cjs.map +1 -0
- package/dist/chunk-SN5YV6FF.js +11 -0
- package/dist/chunk-SN5YV6FF.js.map +1 -0
- package/dist/{chunk-7IOCMCC5.cjs → chunk-TMPDW7J5.cjs} +3 -23
- package/dist/chunk-TMPDW7J5.cjs.map +1 -0
- package/dist/chunk-VJWAP2HJ.cjs +303 -0
- package/dist/chunk-VJWAP2HJ.cjs.map +1 -0
- package/dist/chunk-ZMTLGO3K.cjs +29 -0
- package/dist/chunk-ZMTLGO3K.cjs.map +1 -0
- package/dist/chunk-ZY53R6I4.js +276 -0
- package/dist/chunk-ZY53R6I4.js.map +1 -0
- package/dist/index.cjs +497 -690
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -282
- package/dist/index.js.map +1 -1
- package/dist/shell/index.cjs +8 -7
- package/dist/shell/index.js +3 -2
- package/dist/ui/index.cjs +156 -154
- package/dist/ui/index.js +4 -2
- package/dist/viewers/index.cjs +9 -8
- package/dist/viewers/index.cjs.map +1 -1
- package/dist/viewers/index.js +3 -2
- package/dist/viewers/index.js.map +1 -1
- package/package.json +19 -3
- package/dist/chunk-6ALMBER7.js.map +0 -1
- package/dist/chunk-7IOCMCC5.cjs.map +0 -1
- package/dist/chunk-BXP6S34V.cjs.map +0 -1
- package/dist/chunk-EJ2BMHYK.js.map +0 -1
- package/dist/chunk-JKO3NR5L.js.map +0 -1
- package/dist/chunk-MIJRORQL.js.map +0 -1
- package/dist/chunk-ORKGCXG3.cjs.map +0 -1
- package/dist/chunk-RZQACYNQ.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import {
|
|
8
|
-
export {
|
|
1
|
+
import { useDocuments, useAssistantQuery, arbiQueryKeys, useWorkspaces, useParsedDocument, useTags, useActivity, useThumbnails } from './chunk-ZY53R6I4.js';
|
|
2
|
+
export { DEFAULT_USD_PER_CREDIT, arbiQueryKeys, creditsToUsd, formatCredits, isUsageMetered, useActivity, useAgents, useAssistantQuery, useConfigs, useConversations, useDeleteAgents, useDocuments, useFacts, useHealth, useParsedDocument, useProjectInvoices, useProjectUsage, useProjects, useProjectsUsage, useSessions, useTags, useTasks, useThumbnails, useUserUsageToday, useWorkspaces } from './chunk-ZY53R6I4.js';
|
|
3
|
+
import { formatRelativeTime } from './chunk-FSMIN5VX.js';
|
|
4
|
+
export { DEFAULT_NOTIFY_TONE, NotificationBell, Toaster, formatRelativeTime, notify, seedNotifications, selectUnread, toast, useNotify } from './chunk-FSMIN5VX.js';
|
|
5
|
+
import { MarkMenu, AiMarkdown, Card, Button, Badge, TagEntity, Input, FILE_TYPE_COLORS, getEntityIcon, UserEntity, getEntityColorStyles, AgentBadge, Textarea, Label, Slider, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DocumentEntity, DocumentCard, useAudioRecorder, MicWaveformIndicator, IconToggle, classifyMediaError, formatElapsed, PassageCard } from './chunk-DVRJFLE7.js';
|
|
6
|
+
export { AgentBadge, AiMarkdown, ArbiBotHeadIcon, AudIcon, Avatar, AvatarFallback, AvatarImage, BASE_COLORS, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DictateProvider, DocumentCard, DocumentEntity, ENTITY_MAPPINGS, EmlIcon, EntityIcon, EntityPill, FILE_TYPE_COLORS, HoverCard, HoverCardContent, HoverCardTrigger, IconToggle, ImgIcon, InlineMicButton, Input, Label, MarkMenu, MicRecordingOverlay, MicWaveformIndicator, NEUTRAL_GRAY, PLACEHOLDER_COLOR, PassageCard, PdfIcon, Popover, PopoverAnchor, PopoverContent, PopoverTrigger, PresenceLabel, Progress, ProjectEntity, RadioGroup, RadioGroupItem, RagDot, RelevanceDot, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Slider, StatusPill, 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, UserEntity, UserMenu, VISIBILITY_ICONS, VidIcon, VisibilityIcon, badgeVariants, buttonVariants, cardVariants, configureEntityRegistry, configureRagLabels, configureStatusRegistry, formatElapsed, getDocIcon, getEntityColor, getEntityColorStyles, getEntityIcon, getEntityLabel, getStatusVariant, getTagTypeIcon, getTagTypeLabel, getWorkspaceColor, toggleVariants, useAudioRecorder } from './chunk-DVRJFLE7.js';
|
|
7
|
+
import { normalizeCitationMarkup, MarkdownRenderer } from './chunk-H7ZZQ4ZV.js';
|
|
8
|
+
export { MarkdownRenderer, MarkdownStreamingContext, markdownBaseComponents, normalizeCitationMarkup, splitMarkdownBlocks } from './chunk-H7ZZQ4ZV.js';
|
|
9
|
+
import { ScrollArea, DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator } from './chunk-N5SVBDLC.js';
|
|
10
|
+
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, ScrollArea, ScrollBar } from './chunk-N5SVBDLC.js';
|
|
11
|
+
import { cn } from './chunk-SN5YV6FF.js';
|
|
12
|
+
export { cn } from './chunk-SN5YV6FF.js';
|
|
13
|
+
import { AudioViewer, ImageViewer, VideoViewer } from './chunk-HDCRPPBW.js';
|
|
14
|
+
import { useArbi } from './chunk-J4MX2W4H.js';
|
|
15
|
+
export { ArbiProvider, useArbi } from './chunk-J4MX2W4H.js';
|
|
9
16
|
import React, { memo, useState, createContext, useMemo, useCallback, useEffect, useRef, useLayoutEffect, useContext, useId, Fragment as Fragment$1 } from 'react';
|
|
10
|
-
import { useQuery, useMutation, useQueries, useQueryClient } from '@tanstack/react-query';
|
|
11
17
|
import { Link, Trash2, CheckCheck, Check, Loader2, AlertTriangle, ShieldCheck, Copy, Sparkles, FileText, GitCompareArrows, Download, Image as Image$1, Search, CornerDownLeft, X, ArrowLeft, Send, Tags, Crown, Info, Activity, Gauge, Gift, PartyPopper, UserCheck, MessageCircleMore, FileX2, FileCheck2, Pencil, FolderPlus, SquareArrowOutUpRight, MessagesSquare, ArrowRight, MoreHorizontal, SquarePen, Mic, Pause, Play, Square, RotateCcw, Camera, Circle } from 'lucide-react';
|
|
12
18
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
19
|
import { connectWithReconnect } from '@arbidocs/sdk/browser';
|
|
@@ -15,6 +21,7 @@ export { Arbi, ArbiError } from '@arbidocs/sdk/browser';
|
|
|
15
21
|
import { isMessageType } from '@arbidocs/client';
|
|
16
22
|
export { isMessageType } from '@arbidocs/client';
|
|
17
23
|
import { create } from 'zustand';
|
|
24
|
+
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
18
25
|
import { diffWords } from 'diff';
|
|
19
26
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
20
27
|
import { createPortal } from 'react-dom';
|
|
@@ -23,278 +30,6 @@ import Cropper from 'react-easy-crop';
|
|
|
23
30
|
import { AgGridReact } from 'ag-grid-react';
|
|
24
31
|
import { ModuleRegistry, AllCommunityModule } from 'ag-grid-community';
|
|
25
32
|
|
|
26
|
-
// src/credits.ts
|
|
27
|
-
var DEFAULT_USD_PER_CREDIT = 0.01;
|
|
28
|
-
function formatCredits(credits, options = {}) {
|
|
29
|
-
const { unit = true, locale = "en-US" } = options;
|
|
30
|
-
const whole = Math.round(Number.isFinite(credits) ? credits : 0);
|
|
31
|
-
const digits = whole.toLocaleString(locale);
|
|
32
|
-
return unit ? `${digits} ${whole === 1 ? "credit" : "credits"}` : digits;
|
|
33
|
-
}
|
|
34
|
-
function creditsToUsd(credits, usdPerCredit = DEFAULT_USD_PER_CREDIT) {
|
|
35
|
-
return credits * usdPerCredit;
|
|
36
|
-
}
|
|
37
|
-
function isUsageMetered(usage, subscription) {
|
|
38
|
-
const empty = usage.total_spend === 0 && usage.total_tokens === 0 && usage.total_requests === 0;
|
|
39
|
-
return !(empty && subscription === "dev");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// src/hooks.ts
|
|
43
|
-
var arbiQueryKeys = {
|
|
44
|
-
workspaces: () => ["arbi", "workspaces"],
|
|
45
|
-
documents: (workspaceId) => ["arbi", "documents", workspaceId],
|
|
46
|
-
conversations: (workspaceId) => ["arbi", "conversations", workspaceId],
|
|
47
|
-
tags: (workspaceId) => ["arbi", "tags", workspaceId],
|
|
48
|
-
thumbnails: (docIds) => ["arbi", "thumbnails", [...docIds].sort().join(",")],
|
|
49
|
-
parsedDoc: (docId, stage) => ["arbi", "parsedDoc", docId, stage],
|
|
50
|
-
agents: () => ["arbi", "agents"],
|
|
51
|
-
sessions: () => ["arbi", "sessions"],
|
|
52
|
-
health: () => ["arbi", "health"],
|
|
53
|
-
tasks: () => ["arbi", "tasks"],
|
|
54
|
-
facts: (workspaceId) => ["arbi", "facts", workspaceId],
|
|
55
|
-
configs: () => ["arbi", "configs"],
|
|
56
|
-
activity: () => ["arbi", "activity"],
|
|
57
|
-
projects: () => ["arbi", "projects"],
|
|
58
|
-
projectUsage: (projectExtId, monthsBack) => ["arbi", "projectUsage", projectExtId, monthsBack],
|
|
59
|
-
projectInvoices: (projectExtId) => ["arbi", "projectInvoices", projectExtId],
|
|
60
|
-
userUsageToday: () => ["arbi", "userUsageToday"],
|
|
61
|
-
contacts: () => ["arbi", "contacts"],
|
|
62
|
-
skills: () => ["arbi", "skills"],
|
|
63
|
-
taskRuns: (taskId) => ["arbi", "taskRuns", taskId],
|
|
64
|
-
/** An agent's pinned config; `undefined` = the library default config. */
|
|
65
|
-
agentConfig: (agentExtId) => ["arbi", "agentConfig", agentExtId ?? "default"],
|
|
66
|
-
agentWorkspaces: (agentExtId) => ["arbi", "agentWorkspaces", agentExtId],
|
|
67
|
-
models: () => ["arbi", "models"]
|
|
68
|
-
};
|
|
69
|
-
function useWorkspaces(options) {
|
|
70
|
-
const arbi = useArbi();
|
|
71
|
-
return useQuery({
|
|
72
|
-
queryKey: arbiQueryKeys.workspaces(),
|
|
73
|
-
queryFn: () => arbi.workspaces.list(),
|
|
74
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
function useDocuments(workspaceId, options) {
|
|
78
|
-
const arbi = useArbi();
|
|
79
|
-
return useQuery({
|
|
80
|
-
queryKey: arbiQueryKeys.documents(workspaceId ?? ""),
|
|
81
|
-
queryFn: () => arbi.documents.list(),
|
|
82
|
-
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
function useConversations(workspaceId, options) {
|
|
86
|
-
const arbi = useArbi();
|
|
87
|
-
return useQuery({
|
|
88
|
-
queryKey: arbiQueryKeys.conversations(workspaceId ?? ""),
|
|
89
|
-
queryFn: () => arbi.conversations.list(),
|
|
90
|
-
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function useTags(workspaceId, options) {
|
|
94
|
-
const arbi = useArbi();
|
|
95
|
-
return useQuery({
|
|
96
|
-
queryKey: arbiQueryKeys.tags(workspaceId ?? ""),
|
|
97
|
-
queryFn: () => arbi.tags.list(),
|
|
98
|
-
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
function useThumbnails(docIds, options) {
|
|
102
|
-
const arbi = useArbi();
|
|
103
|
-
return useQuery({
|
|
104
|
-
queryKey: arbiQueryKeys.thumbnails(docIds),
|
|
105
|
-
queryFn: () => arbi.documents.getThumbnails(docIds),
|
|
106
|
-
enabled: (options?.enabled ?? true) && docIds.length > 0 && arbi.hasWorkspace,
|
|
107
|
-
staleTime: 5 * 6e4
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function useParsedDocument(docId, stage = "final", options) {
|
|
111
|
-
const arbi = useArbi();
|
|
112
|
-
return useQuery({
|
|
113
|
-
queryKey: arbiQueryKeys.parsedDoc(docId ?? "", stage),
|
|
114
|
-
queryFn: () => arbi.documents.getParsedContent(docId, stage),
|
|
115
|
-
enabled: (options?.enabled ?? true) && !!docId && arbi.hasWorkspace
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function useAssistantQuery() {
|
|
119
|
-
const arbi = useArbi();
|
|
120
|
-
return useMutation({
|
|
121
|
-
mutationFn: ({ question, ...options }) => arbi.assistant.query(question, options)
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function useAgents(options) {
|
|
125
|
-
const arbi = useArbi();
|
|
126
|
-
return useQuery({
|
|
127
|
-
queryKey: arbiQueryKeys.agents(),
|
|
128
|
-
queryFn: () => arbi.agents.list(),
|
|
129
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function useDeleteAgents() {
|
|
133
|
-
const arbi = useArbi();
|
|
134
|
-
return useMutation({
|
|
135
|
-
mutationFn: ({ agentExtIds }) => arbi.agents.delete(agentExtIds)
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
function useSessions(options) {
|
|
139
|
-
const arbi = useArbi();
|
|
140
|
-
return useQuery({
|
|
141
|
-
queryKey: arbiQueryKeys.sessions(),
|
|
142
|
-
queryFn: () => arbi.sessions.list(),
|
|
143
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
function useHealth(options) {
|
|
147
|
-
const arbi = useArbi();
|
|
148
|
-
return useQuery({
|
|
149
|
-
queryKey: arbiQueryKeys.health(),
|
|
150
|
-
queryFn: () => arbi.health.check(),
|
|
151
|
-
enabled: options?.enabled
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
function useTasks(options) {
|
|
155
|
-
const arbi = useArbi();
|
|
156
|
-
return useQuery({
|
|
157
|
-
queryKey: arbiQueryKeys.tasks(),
|
|
158
|
-
queryFn: () => arbi.tasks.list(),
|
|
159
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
function useFacts(workspaceId, options) {
|
|
163
|
-
const arbi = useArbi();
|
|
164
|
-
return useQuery({
|
|
165
|
-
queryKey: arbiQueryKeys.facts(workspaceId ?? ""),
|
|
166
|
-
queryFn: () => arbi.facts.list({ pinnedOnly: options?.pinnedOnly }),
|
|
167
|
-
enabled: (options?.enabled ?? true) && !!workspaceId && arbi.hasWorkspace
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function useConfigs(options) {
|
|
171
|
-
const arbi = useArbi();
|
|
172
|
-
return useQuery({
|
|
173
|
-
queryKey: arbiQueryKeys.configs(),
|
|
174
|
-
queryFn: () => arbi.agentConfig.list(),
|
|
175
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function useActivity(options) {
|
|
179
|
-
const arbi = useArbi();
|
|
180
|
-
return useQuery({
|
|
181
|
-
queryKey: arbiQueryKeys.activity(),
|
|
182
|
-
queryFn: () => arbi.dm.listActivity({ limit: options?.limit, offset: options?.offset }),
|
|
183
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function useProjects(options) {
|
|
187
|
-
const arbi = useArbi();
|
|
188
|
-
return useQuery({
|
|
189
|
-
queryKey: arbiQueryKeys.projects(),
|
|
190
|
-
queryFn: () => arbi.projects.list(),
|
|
191
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function useProjectUsage(projectExtId, monthsBack = 0, options) {
|
|
195
|
-
const arbi = useArbi();
|
|
196
|
-
const usage = useQuery({
|
|
197
|
-
queryKey: arbiQueryKeys.projectUsage(projectExtId ?? "", monthsBack),
|
|
198
|
-
queryFn: () => arbi.projects.usage(projectExtId, monthsBack),
|
|
199
|
-
enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
|
|
200
|
-
});
|
|
201
|
-
const projects = useProjects({ enabled: !!projectExtId && (options?.enabled ?? true) });
|
|
202
|
-
const subscription = projects.data?.find((p) => p.external_id === projectExtId)?.subscription;
|
|
203
|
-
const metered = usage.data ? isUsageMetered(usage.data, subscription) : void 0;
|
|
204
|
-
return { ...usage, metered };
|
|
205
|
-
}
|
|
206
|
-
function useProjectsUsage(projectExtIds, monthsBack = 0, options) {
|
|
207
|
-
const arbi = useArbi();
|
|
208
|
-
const enabled = (options?.enabled ?? true) && arbi.isLoggedIn;
|
|
209
|
-
const projects = useProjects({ enabled: enabled && projectExtIds.length > 0 });
|
|
210
|
-
const results = useQueries({
|
|
211
|
-
queries: projectExtIds.map((id) => ({
|
|
212
|
-
queryKey: arbiQueryKeys.projectUsage(id, monthsBack),
|
|
213
|
-
queryFn: () => arbi.projects.usage(id, monthsBack),
|
|
214
|
-
enabled: enabled && !!id
|
|
215
|
-
}))
|
|
216
|
-
});
|
|
217
|
-
const signature = results.map((r) => `${r.status}:${r.dataUpdatedAt ?? 0}`).join("|") + `#${projects.dataUpdatedAt}`;
|
|
218
|
-
return useMemo(() => {
|
|
219
|
-
const dailyMap = /* @__PURE__ */ new Map();
|
|
220
|
-
const modelMap = /* @__PURE__ */ new Map();
|
|
221
|
-
let totalCredits = 0;
|
|
222
|
-
let anyData = false;
|
|
223
|
-
let anyMetered = false;
|
|
224
|
-
let totalTokens = 0;
|
|
225
|
-
let totalRequests = 0;
|
|
226
|
-
results.forEach((r, i) => {
|
|
227
|
-
const d = r.data;
|
|
228
|
-
if (!d) return;
|
|
229
|
-
anyData = true;
|
|
230
|
-
const subscription = projects.data?.find(
|
|
231
|
-
(p) => p.external_id === projectExtIds[i]
|
|
232
|
-
)?.subscription;
|
|
233
|
-
if (isUsageMetered(d, subscription)) anyMetered = true;
|
|
234
|
-
totalCredits += d.total_spend ?? 0;
|
|
235
|
-
totalTokens += d.total_tokens ?? 0;
|
|
236
|
-
totalRequests += d.total_requests ?? 0;
|
|
237
|
-
for (const day of d.daily ?? []) {
|
|
238
|
-
const cur = dailyMap.get(day.date) ?? {
|
|
239
|
-
date: day.date,
|
|
240
|
-
credits: 0,
|
|
241
|
-
totalTokens: 0,
|
|
242
|
-
apiRequests: 0
|
|
243
|
-
};
|
|
244
|
-
cur.credits += day.spend ?? 0;
|
|
245
|
-
cur.totalTokens += day.total_tokens ?? 0;
|
|
246
|
-
cur.apiRequests += day.api_requests ?? 0;
|
|
247
|
-
dailyMap.set(day.date, cur);
|
|
248
|
-
}
|
|
249
|
-
for (const [model, mg] of Object.entries(d.model_groups ?? {})) {
|
|
250
|
-
const cur = modelMap.get(model) ?? {
|
|
251
|
-
model,
|
|
252
|
-
credits: 0,
|
|
253
|
-
totalTokens: 0,
|
|
254
|
-
promptTokens: 0,
|
|
255
|
-
completionTokens: 0,
|
|
256
|
-
successfulRequests: 0
|
|
257
|
-
};
|
|
258
|
-
cur.credits += mg.spend ?? 0;
|
|
259
|
-
cur.totalTokens += mg.total_tokens ?? 0;
|
|
260
|
-
cur.promptTokens += mg.prompt_tokens ?? 0;
|
|
261
|
-
cur.completionTokens += mg.completion_tokens ?? 0;
|
|
262
|
-
cur.successfulRequests += mg.successful_requests ?? 0;
|
|
263
|
-
modelMap.set(model, cur);
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
return {
|
|
267
|
-
totalCredits,
|
|
268
|
-
totalTokens,
|
|
269
|
-
totalRequests,
|
|
270
|
-
daily: [...dailyMap.values()].sort((a, b) => a.date.localeCompare(b.date)),
|
|
271
|
-
modelGroups: [...modelMap.values()].sort(
|
|
272
|
-
(a, b) => b.credits - a.credits || b.totalTokens - a.totalTokens
|
|
273
|
-
),
|
|
274
|
-
metered: !anyData || anyMetered,
|
|
275
|
-
isLoading: results.some((r) => r.isLoading),
|
|
276
|
-
isError: results.some((r) => r.isError)
|
|
277
|
-
};
|
|
278
|
-
}, [signature]);
|
|
279
|
-
}
|
|
280
|
-
function useProjectInvoices(projectExtId, options) {
|
|
281
|
-
const arbi = useArbi();
|
|
282
|
-
return useQuery({
|
|
283
|
-
queryKey: arbiQueryKeys.projectInvoices(projectExtId ?? ""),
|
|
284
|
-
queryFn: () => arbi.projects.invoices(projectExtId),
|
|
285
|
-
enabled: (options?.enabled ?? true) && !!projectExtId && arbi.isLoggedIn
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
function useUserUsageToday(options) {
|
|
289
|
-
const arbi = useArbi();
|
|
290
|
-
return useQuery({
|
|
291
|
-
queryKey: arbiQueryKeys.userUsageToday(),
|
|
292
|
-
queryFn: () => arbi.user.usageToday(),
|
|
293
|
-
enabled: options?.enabled ?? arbi.isLoggedIn
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// src/chat/useArbiChat.ts
|
|
298
33
|
var counter = 0;
|
|
299
34
|
var nextId = (prefix) => `${prefix}-${Date.now().toString(36)}-${(counter++).toString(36)}`;
|
|
300
35
|
var emptyThread = () => ({
|
|
@@ -5332,6 +5067,6 @@ function hasVideoTrack(blob) {
|
|
|
5332
5067
|
});
|
|
5333
5068
|
}
|
|
5334
5069
|
|
|
5335
|
-
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_START_BY_EMAIL_LABELS,
|
|
5070
|
+
export { ActivityFeed, AiActionCard, AiAnswer, AppleIcon, ArbiBotIcon, ArbiIcon, ArbiWebSocketProvider, ArtifactCanvas, ChatBubble, CitationRenderer, ClaudeIcon, CommandPalette, CommandPaletteProvider, ConversationList, DEFAULT_ASPECT_OPTIONS, DEFAULT_START_BY_EMAIL_LABELS, DateSeparator, DirectMessages, DmAvatar, DmComposer, DocIcon, DocQaPanel, DocSearch, DocumentCardMenu, DocumentGallery, DocumentReview, DocumentTable, DraftTitleControls, FileIcon, FireworksIcon, GeminiIcon, GitHubIcon, GoogleIcon, HtmlIcon, ImageCropModal, ImageCropper, LinkedInIcon, MessageArtifactCard, MessageBubble, MessageThread, OpenAIIcon, PhotoCapture, ProviderIcon, RUN_WINDOW_MS, SemanticSearch, StartByEmail, TxtIcon, TypingIndicator, VideoCapture, VoiceNoteRecorder, XlsIcon, annotateThread, captureFrameAsBlob, cropImage, dayKey, describeActivity, getNotificationTypeMeta, getWorkspaceActionText, getWorkspaceKind, getWorkspaceSentPhrase, hasVideoTrack, isWorkspaceNotificationType, parseActivityContent, pickRecentWorkspaces, redlineStats, resolveActiveWorkspace, textToArtifact, titleFromQuestion, toRedlineMarkdown, toShellWorkspace, useAddContacts, useAgentConfig, useAgentModels, useAgentWorkspaces, useAiTask, useArbiChat, useArbiConnected, useArbiDocumentSync, useArbiShellWorkspaces, useArbiUiStore, useArbiWebSocket, useArbiWsContext, useArbiWsMessage, useArbiWsStatus, useArbiWsStore, useArbiWsTask, useArbiWsTasks, useCameraStream, useCommandPalette, useContacts, useCreateAgent, useCreateTask, useDeleteTask, useDirectMessages, useGrantAgentAccess, usePendingContacts, useRemoveContacts, useRevokeAgentAccess, useRunTask, useSaveAgentConfig, useSemanticSearch, useShellWorkspaces, useSkills, useTaskRuns, useUpdateTask, useVideoRecorder, useWorkspaceDocs, userDisplayName, userInitials };
|
|
5336
5071
|
//# sourceMappingURL=index.js.map
|
|
5337
5072
|
//# sourceMappingURL=index.js.map
|