@autobe/ui 0.30.0-dev.20260315 → 0.30.0
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/LICENSE +661 -661
- package/lib/components/AutoBeChatMain.js +5 -5
- package/lib/components/AutoBeConfigModal.js +9 -9
- package/package.json +2 -2
- package/src/components/AutoBeAssistantMessageMovie.tsx +22 -22
- package/src/components/AutoBeChatMain.tsx +376 -376
- package/src/components/AutoBeChatSidebar.tsx +414 -414
- package/src/components/AutoBeConfigButton.tsx +83 -83
- package/src/components/AutoBeConfigModal.tsx +443 -443
- package/src/components/AutoBeStatusButton.tsx +75 -75
- package/src/components/AutoBeStatusModal.tsx +486 -486
- package/src/components/AutoBeUserMessageMovie.tsx +27 -27
- package/src/components/common/ActionButton.tsx +205 -205
- package/src/components/common/ActionButtonGroup.tsx +80 -80
- package/src/components/common/AutoBeConfigInput.tsx +185 -185
- package/src/components/common/ChatBubble.tsx +119 -119
- package/src/components/common/Collapsible.tsx +95 -95
- package/src/components/common/CompactSessionIndicator.tsx +73 -73
- package/src/components/common/CompactSessionList.tsx +82 -82
- package/src/components/common/index.ts +8 -8
- package/src/components/common/openai/OpenAIContent.tsx +53 -53
- package/src/components/common/openai/OpenAIUserAudioContent.tsx +70 -70
- package/src/components/common/openai/OpenAIUserFileContent.tsx +76 -76
- package/src/components/common/openai/OpenAIUserImageContent.tsx +34 -34
- package/src/components/common/openai/OpenAIUserTextContent.tsx +15 -15
- package/src/components/common/openai/index.ts +5 -5
- package/src/components/events/AutoBeCompleteEventMovie.tsx +402 -402
- package/src/components/events/AutoBeCorrectEventMovie.tsx +354 -354
- package/src/components/events/AutoBeEventGroupMovie.tsx +18 -18
- package/src/components/events/AutoBeEventMovie.tsx +158 -158
- package/src/components/events/AutoBeProgressEventMovie.tsx +217 -217
- package/src/components/events/AutoBeScenarioEventMovie.tsx +135 -135
- package/src/components/events/AutoBeStartEventMovie.tsx +82 -82
- package/src/components/events/AutoBeValidateEventMovie.tsx +249 -249
- package/src/components/events/README.md +300 -300
- package/src/components/events/common/CollapsibleEventGroup.tsx +211 -211
- package/src/components/events/common/EventCard.tsx +61 -61
- package/src/components/events/common/EventContent.tsx +31 -31
- package/src/components/events/common/EventHeader.tsx +85 -85
- package/src/components/events/common/EventIcon.tsx +82 -82
- package/src/components/events/common/ProgressBar.tsx +64 -64
- package/src/components/events/common/index.ts +13 -13
- package/src/components/events/groups/CorrectEventGroup.tsx +183 -183
- package/src/components/events/groups/ValidateEventGroup.tsx +143 -143
- package/src/components/events/groups/index.ts +8 -8
- package/src/components/events/index.ts +16 -16
- package/src/components/events/utils/eventGrouper.tsx +116 -116
- package/src/components/events/utils/index.ts +1 -1
- package/src/components/index.ts +13 -13
- package/src/components/upload/AutoBeChatUploadBox.tsx +425 -425
- package/src/components/upload/AutoBeChatUploadSendButton.tsx +66 -66
- package/src/components/upload/AutoBeFileUploadBox.tsx +123 -123
- package/src/components/upload/AutoBeUploadConfig.ts +5 -5
- package/src/components/upload/AutoBeVoiceRecoderButton.tsx +100 -100
- package/src/components/upload/index.ts +5 -5
- package/src/constant/color.ts +28 -28
- package/src/context/AutoBeAgentContext.tsx +245 -245
- package/src/context/AutoBeAgentSessionList.tsx +58 -58
- package/src/context/SearchParamsContext.tsx +49 -49
- package/src/hooks/index.ts +3 -3
- package/src/hooks/useEscapeKey.ts +24 -24
- package/src/hooks/useIsomorphicLayoutEffect.ts +8 -8
- package/src/hooks/useMediaQuery.ts +73 -73
- package/src/hooks/useSessionStorage.ts +10 -10
- package/src/icons/Receipt.tsx +74 -74
- package/src/index.ts +9 -9
- package/src/strategy/AutoBeAgentSessionStorageStrategy.ts +127 -127
- package/src/structure/AutoBeListener.ts +373 -373
- package/src/structure/AutoBeListenerState.ts +53 -53
- package/src/structure/IAutoBeAgentSessionStorageStrategy.ts +87 -87
- package/src/structure/IAutoBeEventGroup.ts +6 -6
- package/src/structure/index.ts +4 -4
- package/src/types/config.ts +44 -44
- package/src/types/index.ts +1 -1
- package/src/utils/AutoBeFileUploader.ts +279 -279
- package/src/utils/AutoBeVoiceRecorder.ts +95 -95
- package/src/utils/__tests__/crypto.test.ts +286 -286
- package/src/utils/__tests__/storage.test.ts +229 -229
- package/src/utils/crypto.ts +95 -95
- package/src/utils/index.ts +6 -6
- package/src/utils/number.ts +17 -17
- package/src/utils/storage.ts +96 -96
- package/src/utils/time.ts +14 -14
- package/tsconfig.json +9 -9
- package/vitest.config.ts +15 -15
- package/README.md +0 -261
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import { AutoBeEventSnapshot } from "@autobe/interface";
|
|
2
|
-
|
|
3
|
-
import { useSessionStorage } from "../hooks/useSessionStorage";
|
|
4
|
-
import {
|
|
5
|
-
IAutoBeAgentSession,
|
|
6
|
-
IAutoBeAgentSessionStorageStrategy,
|
|
7
|
-
} from "../structure";
|
|
8
|
-
|
|
9
|
-
const SESSION_KEY = "autobe_session_list";
|
|
10
|
-
|
|
11
|
-
export class AutoBeAgentSessionStorageStrategy implements IAutoBeAgentSessionStorageStrategy {
|
|
12
|
-
appendEvent(): Promise<void> {
|
|
13
|
-
return Promise.resolve();
|
|
14
|
-
}
|
|
15
|
-
setTokenUsage(): Promise<void> {
|
|
16
|
-
return Promise.resolve();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async getSession(
|
|
20
|
-
props: Pick<IAutoBeAgentSession, "id">,
|
|
21
|
-
): Promise<IAutoBeAgentSession> {
|
|
22
|
-
const { getItem } = useSessionStorage();
|
|
23
|
-
|
|
24
|
-
const session = getItem(SESSION_KEY);
|
|
25
|
-
if (!session) {
|
|
26
|
-
throw new Error("Session not found");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const sessionList = JSON.parse(session);
|
|
30
|
-
|
|
31
|
-
if (sessionList instanceof Array === false) {
|
|
32
|
-
throw new Error("Session list is not an array");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const result = sessionList.find(
|
|
36
|
-
(s: IAutoBeAgentSession) => s.id === props.id,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
id: result.id,
|
|
41
|
-
title: result.participant.name,
|
|
42
|
-
history: result.histories,
|
|
43
|
-
tokenUsage: result.token_usage,
|
|
44
|
-
createdAt: new Date(result.created_at),
|
|
45
|
-
updatedAt: new Date(result.completed_at ?? result.created_at),
|
|
46
|
-
events: result.event_snapshots.map((event: AutoBeEventSnapshot) => ({
|
|
47
|
-
type: event.event.type,
|
|
48
|
-
events: [event.event],
|
|
49
|
-
})),
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async getSessionList(): Promise<IAutoBeAgentSession[]> {
|
|
54
|
-
const { getItem } = useSessionStorage();
|
|
55
|
-
const sessionList = getItem(SESSION_KEY);
|
|
56
|
-
if (!sessionList) {
|
|
57
|
-
throw new Error("Session list not found");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const result = JSON.parse(sessionList);
|
|
61
|
-
if (result instanceof Array === false) {
|
|
62
|
-
throw new Error("Session list is not an array");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return result.map((session) => ({
|
|
66
|
-
id: session.id,
|
|
67
|
-
title: session.title ?? "Untitled",
|
|
68
|
-
history: [],
|
|
69
|
-
tokenUsage: session.token_usage,
|
|
70
|
-
createdAt: new Date(session.created_at),
|
|
71
|
-
updatedAt: new Date(session.completed_at ?? session.created_at),
|
|
72
|
-
completedAt: session.completed_at,
|
|
73
|
-
events: [],
|
|
74
|
-
phase: session.phase,
|
|
75
|
-
model: session.model,
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async deleteSession(props: Pick<IAutoBeAgentSession, "id">): Promise<void> {
|
|
80
|
-
const { getItem, setItem } = useSessionStorage();
|
|
81
|
-
|
|
82
|
-
const sessionList = getItem(SESSION_KEY);
|
|
83
|
-
if (!sessionList) {
|
|
84
|
-
throw new Error("Session list not found");
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const result = JSON.parse(sessionList);
|
|
88
|
-
if (result instanceof Array === false) {
|
|
89
|
-
throw new Error("Session list is not an array");
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
setItem(
|
|
93
|
-
SESSION_KEY,
|
|
94
|
-
JSON.stringify(
|
|
95
|
-
result.filter((s: IAutoBeAgentSession) => s.id !== props.id),
|
|
96
|
-
),
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
async appendHistory(): Promise<void> {
|
|
101
|
-
return Promise.resolve();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async editSessionTitle(
|
|
105
|
-
props: Pick<IAutoBeAgentSession, "id" | "title">,
|
|
106
|
-
): Promise<void> {
|
|
107
|
-
const { getItem, setItem } = useSessionStorage();
|
|
108
|
-
|
|
109
|
-
const sessionList = getItem(SESSION_KEY);
|
|
110
|
-
if (!sessionList) {
|
|
111
|
-
throw new Error("Session list not found");
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const result = JSON.parse(sessionList);
|
|
115
|
-
if (result instanceof Array === false) {
|
|
116
|
-
throw new Error("Session list is not an array");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const session = result.find((s: IAutoBeAgentSession) => s.id === props.id);
|
|
120
|
-
if (!session) {
|
|
121
|
-
throw new Error("Session not found");
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
session.title = props.title;
|
|
125
|
-
setItem(SESSION_KEY, JSON.stringify(result));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
1
|
+
import { AutoBeEventSnapshot } from "@autobe/interface";
|
|
2
|
+
|
|
3
|
+
import { useSessionStorage } from "../hooks/useSessionStorage";
|
|
4
|
+
import {
|
|
5
|
+
IAutoBeAgentSession,
|
|
6
|
+
IAutoBeAgentSessionStorageStrategy,
|
|
7
|
+
} from "../structure";
|
|
8
|
+
|
|
9
|
+
const SESSION_KEY = "autobe_session_list";
|
|
10
|
+
|
|
11
|
+
export class AutoBeAgentSessionStorageStrategy implements IAutoBeAgentSessionStorageStrategy {
|
|
12
|
+
appendEvent(): Promise<void> {
|
|
13
|
+
return Promise.resolve();
|
|
14
|
+
}
|
|
15
|
+
setTokenUsage(): Promise<void> {
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getSession(
|
|
20
|
+
props: Pick<IAutoBeAgentSession, "id">,
|
|
21
|
+
): Promise<IAutoBeAgentSession> {
|
|
22
|
+
const { getItem } = useSessionStorage();
|
|
23
|
+
|
|
24
|
+
const session = getItem(SESSION_KEY);
|
|
25
|
+
if (!session) {
|
|
26
|
+
throw new Error("Session not found");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const sessionList = JSON.parse(session);
|
|
30
|
+
|
|
31
|
+
if (sessionList instanceof Array === false) {
|
|
32
|
+
throw new Error("Session list is not an array");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const result = sessionList.find(
|
|
36
|
+
(s: IAutoBeAgentSession) => s.id === props.id,
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
id: result.id,
|
|
41
|
+
title: result.participant.name,
|
|
42
|
+
history: result.histories,
|
|
43
|
+
tokenUsage: result.token_usage,
|
|
44
|
+
createdAt: new Date(result.created_at),
|
|
45
|
+
updatedAt: new Date(result.completed_at ?? result.created_at),
|
|
46
|
+
events: result.event_snapshots.map((event: AutoBeEventSnapshot) => ({
|
|
47
|
+
type: event.event.type,
|
|
48
|
+
events: [event.event],
|
|
49
|
+
})),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async getSessionList(): Promise<IAutoBeAgentSession[]> {
|
|
54
|
+
const { getItem } = useSessionStorage();
|
|
55
|
+
const sessionList = getItem(SESSION_KEY);
|
|
56
|
+
if (!sessionList) {
|
|
57
|
+
throw new Error("Session list not found");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const result = JSON.parse(sessionList);
|
|
61
|
+
if (result instanceof Array === false) {
|
|
62
|
+
throw new Error("Session list is not an array");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result.map((session) => ({
|
|
66
|
+
id: session.id,
|
|
67
|
+
title: session.title ?? "Untitled",
|
|
68
|
+
history: [],
|
|
69
|
+
tokenUsage: session.token_usage,
|
|
70
|
+
createdAt: new Date(session.created_at),
|
|
71
|
+
updatedAt: new Date(session.completed_at ?? session.created_at),
|
|
72
|
+
completedAt: session.completed_at,
|
|
73
|
+
events: [],
|
|
74
|
+
phase: session.phase,
|
|
75
|
+
model: session.model,
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async deleteSession(props: Pick<IAutoBeAgentSession, "id">): Promise<void> {
|
|
80
|
+
const { getItem, setItem } = useSessionStorage();
|
|
81
|
+
|
|
82
|
+
const sessionList = getItem(SESSION_KEY);
|
|
83
|
+
if (!sessionList) {
|
|
84
|
+
throw new Error("Session list not found");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const result = JSON.parse(sessionList);
|
|
88
|
+
if (result instanceof Array === false) {
|
|
89
|
+
throw new Error("Session list is not an array");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setItem(
|
|
93
|
+
SESSION_KEY,
|
|
94
|
+
JSON.stringify(
|
|
95
|
+
result.filter((s: IAutoBeAgentSession) => s.id !== props.id),
|
|
96
|
+
),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async appendHistory(): Promise<void> {
|
|
101
|
+
return Promise.resolve();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async editSessionTitle(
|
|
105
|
+
props: Pick<IAutoBeAgentSession, "id" | "title">,
|
|
106
|
+
): Promise<void> {
|
|
107
|
+
const { getItem, setItem } = useSessionStorage();
|
|
108
|
+
|
|
109
|
+
const sessionList = getItem(SESSION_KEY);
|
|
110
|
+
if (!sessionList) {
|
|
111
|
+
throw new Error("Session list not found");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const result = JSON.parse(sessionList);
|
|
115
|
+
if (result instanceof Array === false) {
|
|
116
|
+
throw new Error("Session list is not an array");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const session = result.find((s: IAutoBeAgentSession) => s.id === props.id);
|
|
120
|
+
if (!session) {
|
|
121
|
+
throw new Error("Session not found");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
session.title = props.title;
|
|
125
|
+
setItem(SESSION_KEY, JSON.stringify(result));
|
|
126
|
+
}
|
|
127
|
+
}
|