@autobe/ui 0.29.2 → 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/lib/components/AutoBeChatMain.js.map +1 -1
- package/lib/components/AutoBeStatusModal.js +4 -4
- package/lib/components/AutoBeStatusModal.js.map +1 -1
- package/lib/components/AutoBeUserMessageMovie.d.ts +2 -2
- package/lib/components/common/ChatBubble.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.d.ts +2 -2
- package/lib/components/common/openai/OpenAIContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserAudioContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js +1 -1
- package/lib/components/common/openai/OpenAIUserFileContent.js.map +1 -1
- package/lib/components/common/openai/OpenAIUserImageContent.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCompleteEventMovie.js +5 -5
- package/lib/components/events/AutoBeCompleteEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeCorrectEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeCorrectEventMovie.js +4 -4
- package/lib/components/events/AutoBeCorrectEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeEventMovie.js +38 -17
- package/lib/components/events/AutoBeEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeProgressEventMovie.js +73 -13
- package/lib/components/events/AutoBeProgressEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeScenarioEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeScenarioEventMovie.js +18 -5
- package/lib/components/events/AutoBeScenarioEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeStartEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js +2 -2
- package/lib/components/events/AutoBeStartEventMovie.js.map +1 -1
- package/lib/components/events/AutoBeValidateEventMovie.d.ts +2 -2
- package/lib/components/events/AutoBeValidateEventMovie.js +3 -11
- package/lib/components/events/AutoBeValidateEventMovie.js.map +1 -1
- package/lib/components/events/groups/CorrectEventGroup.d.ts +2 -2
- package/lib/components/events/groups/CorrectEventGroup.js +1 -1
- package/lib/components/events/groups/CorrectEventGroup.js.map +1 -1
- package/lib/components/events/groups/ValidateEventGroup.d.ts +2 -2
- package/lib/components/events/groups/ValidateEventGroup.js +1 -2
- package/lib/components/events/groups/ValidateEventGroup.js.map +1 -1
- package/lib/components/events/utils/eventGrouper.js +1 -2
- package/lib/components/events/utils/eventGrouper.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadBox.d.ts +3 -4
- package/lib/components/upload/AutoBeChatUploadBox.js +2 -1
- package/lib/components/upload/AutoBeChatUploadBox.js.map +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js +1 -1
- package/lib/components/upload/AutoBeChatUploadSendButton.js.map +1 -1
- package/lib/context/AutoBeAgentContext.d.ts +1 -3
- package/lib/context/AutoBeAgentContext.js +0 -4
- package/lib/context/AutoBeAgentContext.js.map +1 -1
- package/lib/hooks/useSessionStorage.d.ts +4 -0
- package/lib/hooks/useSessionStorage.js +16 -0
- package/lib/hooks/useSessionStorage.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.d.ts +10 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js +117 -0
- package/lib/strategy/AutoBeAgentSessionStorageStrategy.js.map +1 -0
- package/lib/structure/AutoBeListener.js +91 -23
- package/lib/structure/AutoBeListener.js.map +1 -1
- package/lib/structure/AutoBeListenerState.d.ts +3 -3
- package/lib/structure/AutoBeListenerState.js +4 -4
- package/lib/structure/AutoBeListenerState.js.map +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js +1 -1
- package/lib/structure/IAutoBeAgentSessionStorageStrategy.js.map +1 -1
- package/lib/utils/AutoBeFileUploader.d.ts +2 -2
- package/lib/utils/AutoBeFileUploader.js.map +1 -1
- package/package.json +3 -4
- package/src/components/AutoBeChatMain.tsx +2 -2
- package/src/components/AutoBeStatusModal.tsx +6 -4
- package/src/components/AutoBeUserMessageMovie.tsx +2 -2
- package/src/components/common/ChatBubble.tsx +2 -2
- package/src/components/common/openai/OpenAIContent.tsx +3 -3
- package/src/components/common/openai/OpenAIUserAudioContent.tsx +1 -1
- package/src/components/common/openai/OpenAIUserFileContent.tsx +1 -1
- package/src/components/common/openai/OpenAIUserImageContent.tsx +2 -2
- package/src/components/events/AutoBeCompleteEventMovie.tsx +6 -6
- package/src/components/events/AutoBeCorrectEventMovie.tsx +12 -26
- package/src/components/events/AutoBeEventMovie.tsx +38 -19
- package/src/components/events/AutoBeProgressEventMovie.tsx +73 -13
- package/src/components/events/AutoBeScenarioEventMovie.tsx +53 -13
- package/src/components/events/AutoBeStartEventMovie.tsx +4 -4
- package/src/components/events/AutoBeValidateEventMovie.tsx +7 -44
- package/src/components/events/README.md +5 -5
- package/src/components/events/groups/CorrectEventGroup.tsx +3 -3
- package/src/components/events/groups/ValidateEventGroup.tsx +3 -6
- package/src/components/events/utils/eventGrouper.tsx +1 -2
- package/src/components/upload/AutoBeChatUploadBox.tsx +8 -7
- package/src/components/upload/AutoBeChatUploadSendButton.tsx +1 -1
- package/src/context/AutoBeAgentContext.tsx +4 -17
- package/src/hooks/useSessionStorage.ts +10 -0
- package/src/index.ts +1 -0
- package/src/strategy/AutoBeAgentSessionStorageStrategy.ts +127 -0
- package/src/structure/AutoBeListener.ts +92 -23
- package/src/structure/AutoBeListenerState.ts +6 -6
- package/src/structure/IAutoBeAgentSessionStorageStrategy.ts +1 -1
- package/src/utils/AutoBeFileUploader.ts +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutoBeDatabaseValidateEvent,
|
|
2
3
|
AutoBeInterfaceOperationReviewEvent,
|
|
3
|
-
AutoBePrismaInsufficientEvent,
|
|
4
|
-
AutoBePrismaValidateEvent,
|
|
5
4
|
AutoBeRealizeAuthorizationValidateEvent,
|
|
6
5
|
AutoBeRealizeValidateEvent,
|
|
7
6
|
AutoBeTestValidateEvent,
|
|
@@ -12,8 +11,7 @@ import { EventCard, EventContent, EventHeader } from "./common";
|
|
|
12
11
|
|
|
13
12
|
export interface IAutoBeValidateEventMovieProps {
|
|
14
13
|
event:
|
|
15
|
-
|
|
|
16
|
-
| AutoBePrismaValidateEvent
|
|
14
|
+
| AutoBeDatabaseValidateEvent
|
|
17
15
|
| AutoBeInterfaceOperationReviewEvent
|
|
18
16
|
| AutoBeTestValidateEvent
|
|
19
17
|
| AutoBeRealizeValidateEvent
|
|
@@ -63,7 +61,7 @@ interface IState {
|
|
|
63
61
|
|
|
64
62
|
function getState(event: IAutoBeValidateEventMovieProps["event"]): IState {
|
|
65
63
|
switch (event.type) {
|
|
66
|
-
case "
|
|
64
|
+
case "databaseValidate":
|
|
67
65
|
return {
|
|
68
66
|
title: "Prisma Validation Failed",
|
|
69
67
|
description: (
|
|
@@ -103,7 +101,7 @@ function getState(event: IAutoBeValidateEventMovieProps["event"]): IState {
|
|
|
103
101
|
Test file validation completed.
|
|
104
102
|
<br />
|
|
105
103
|
<br />
|
|
106
|
-
<strong>
|
|
104
|
+
<strong>Function:</strong> {event.function.location}
|
|
107
105
|
<br />
|
|
108
106
|
<strong>Status:</strong> {isTestSuccess ? "Success" : "Failed"}
|
|
109
107
|
{!isTestSuccess && (
|
|
@@ -208,43 +206,6 @@ function getState(event: IAutoBeValidateEventMovieProps["event"]): IState {
|
|
|
208
206
|
isSuccess: isAuthSuccess,
|
|
209
207
|
step: event.step,
|
|
210
208
|
};
|
|
211
|
-
case "prismaInsufficient":
|
|
212
|
-
return {
|
|
213
|
-
title: "Prisma Model Generation Insufficient",
|
|
214
|
-
description: (
|
|
215
|
-
<>
|
|
216
|
-
Prisma model generation was incomplete for the assigned component.
|
|
217
|
-
<br />
|
|
218
|
-
<br />
|
|
219
|
-
<strong>Component:</strong> {event.component.namespace}
|
|
220
|
-
<br />
|
|
221
|
-
<strong>Generated Models:</strong> {event.actual.length}
|
|
222
|
-
<br />
|
|
223
|
-
<strong>Missing Models:</strong> {event.missed.length}
|
|
224
|
-
<br />
|
|
225
|
-
<br />
|
|
226
|
-
{event.missed.length > 0 && (
|
|
227
|
-
<>
|
|
228
|
-
<strong>Missed Tables:</strong>
|
|
229
|
-
<br />
|
|
230
|
-
{event.missed.slice(0, 5).map((table: string, idx: number) => (
|
|
231
|
-
<div key={idx} style={{ marginTop: "0.25rem" }}>
|
|
232
|
-
• {table}
|
|
233
|
-
</div>
|
|
234
|
-
))}
|
|
235
|
-
{event.missed.length > 5 && (
|
|
236
|
-
<div style={{ marginTop: "0.25rem" }}>
|
|
237
|
-
... and {event.missed.length - 5} more
|
|
238
|
-
</div>
|
|
239
|
-
)}
|
|
240
|
-
</>
|
|
241
|
-
)}
|
|
242
|
-
</>
|
|
243
|
-
),
|
|
244
|
-
isError: true,
|
|
245
|
-
isSuccess: false,
|
|
246
|
-
step: undefined, // prismaInsufficient doesn't have step
|
|
247
|
-
};
|
|
248
209
|
case "interfaceOperationReview":
|
|
249
210
|
return {
|
|
250
211
|
title: "Interface Operations Review",
|
|
@@ -253,7 +214,9 @@ function getState(event: IAutoBeValidateEventMovieProps["event"]): IState {
|
|
|
253
214
|
API operations are being reviewed for quality and consistency.
|
|
254
215
|
<br />
|
|
255
216
|
<br />
|
|
256
|
-
<strong>
|
|
217
|
+
<strong>Method:</strong> {event.operation.method.toUpperCase()}
|
|
218
|
+
<br />
|
|
219
|
+
<strong>Path:</strong> {event.operation.path}
|
|
257
220
|
<br />
|
|
258
221
|
<strong>Status:</strong> Review in progress
|
|
259
222
|
<br />
|
|
@@ -23,11 +23,11 @@ import { AutoBeEventMovie } from "@autobe/ui/events";
|
|
|
23
23
|
|
|
24
24
|
**Supported Event Types:**
|
|
25
25
|
- **Message Events**: `userMessage`, `assistantMessage`
|
|
26
|
-
- **Start Events**: `analyzeStart`, `
|
|
27
|
-
- **Scenario Events**: `analyzeScenario`, `
|
|
28
|
-
- **Progress Events**: `analyzeWrite`, `analyzeReview`, `interfaceEndpoints`, `
|
|
29
|
-
- **Validate Events**: `
|
|
30
|
-
- **Complete Events**: `analyzeComplete`, `
|
|
26
|
+
- **Start Events**: `analyzeStart`, `databaseStart`, `interfaceStart`, `testStart`, `realizeStart`, `realizeTestStart`, `realizeAuthorizationStart`
|
|
27
|
+
- **Scenario Events**: `analyzeScenario`, `databaseComponent`, `interfaceGroups`, `realizeTestReset`
|
|
28
|
+
- **Progress Events**: `analyzeWrite`, `analyzeReview`, `interfaceEndpoints`, `databaseSchema`, `databaseReview`, `interfaceOperations`, `interfaceOperationsReview`, `interfaceAuthorization`, `interfaceSchemas`, `interfaceSchemasReview`, `testWrite`, `testScenarios`, `realizeWrite`, `realizeAuthorizationWrite`, `realizeTestOperation`
|
|
29
|
+
- **Validate Events**: `databaseInsufficient`, `databaseValidate`, `interfaceComplement`, `testValidate`, `realizeValidate`, `realizeAuthorizationValidate`
|
|
30
|
+
- **Complete Events**: `analyzeComplete`, `databaseComplete`, `interfaceComplete`, `testComplete`, `realizeComplete`
|
|
31
31
|
|
|
32
32
|
## Individual Event Components
|
|
33
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
AutoBeDatabaseCorrectEvent,
|
|
3
3
|
AutoBeRealizeAuthorizationCorrectEvent,
|
|
4
4
|
AutoBeRealizeCorrectEvent,
|
|
5
5
|
AutoBeTestCorrectEvent,
|
|
@@ -9,7 +9,7 @@ import { AutoBeCorrectEventMovie } from "../AutoBeCorrectEventMovie";
|
|
|
9
9
|
import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
|
|
10
10
|
|
|
11
11
|
type CorrectEvent =
|
|
12
|
-
|
|
|
12
|
+
| AutoBeDatabaseCorrectEvent
|
|
13
13
|
| AutoBeTestCorrectEvent
|
|
14
14
|
| AutoBeRealizeCorrectEvent
|
|
15
15
|
| AutoBeRealizeAuthorizationCorrectEvent;
|
|
@@ -71,7 +71,7 @@ export const CorrectEventGroup = (props: ICorrectEventGroupProps) => {
|
|
|
71
71
|
>
|
|
72
72
|
{eventTypes.map((type) => {
|
|
73
73
|
const typeDisplayNames = {
|
|
74
|
-
|
|
74
|
+
databaseCorrect: "🗄️ Database Schema",
|
|
75
75
|
testCorrect: "🧪 Test Suite",
|
|
76
76
|
realizeCorrect: "⚙️ Implementation",
|
|
77
77
|
realizeAuthorizationCorrect: "🔐 Authorization",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutoBeDatabaseValidateEvent,
|
|
2
3
|
AutoBeInterfaceOperationReviewEvent,
|
|
3
|
-
AutoBePrismaInsufficientEvent,
|
|
4
|
-
AutoBePrismaValidateEvent,
|
|
5
4
|
AutoBeRealizeAuthorizationValidateEvent,
|
|
6
5
|
AutoBeRealizeValidateEvent,
|
|
7
6
|
AutoBeTestValidateEvent,
|
|
@@ -11,8 +10,7 @@ import { AutoBeValidateEventMovie } from "../AutoBeValidateEventMovie";
|
|
|
11
10
|
import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
|
|
12
11
|
|
|
13
12
|
export type ValidateEvent =
|
|
14
|
-
|
|
|
15
|
-
| AutoBePrismaValidateEvent
|
|
13
|
+
| AutoBeDatabaseValidateEvent
|
|
16
14
|
| AutoBeInterfaceOperationReviewEvent
|
|
17
15
|
| AutoBeTestValidateEvent
|
|
18
16
|
| AutoBeRealizeValidateEvent
|
|
@@ -37,9 +35,8 @@ export const ValidateEventGroup = (props: IValidateEventGroupProps) => {
|
|
|
37
35
|
// Calculate validation statistics
|
|
38
36
|
const errorEvents = events.filter((event) => {
|
|
39
37
|
switch (event.type) {
|
|
40
|
-
case "
|
|
38
|
+
case "databaseValidate":
|
|
41
39
|
case "realizeValidate":
|
|
42
|
-
case "prismaInsufficient":
|
|
43
40
|
return true;
|
|
44
41
|
case "testValidate":
|
|
45
42
|
case "realizeAuthorizationValidate":
|
|
@@ -79,11 +79,10 @@ function groupEventsByCategory(events: AutoBeEvent[]) {
|
|
|
79
79
|
events.forEach((event) => {
|
|
80
80
|
switch (event.type) {
|
|
81
81
|
// Validation events
|
|
82
|
-
case "
|
|
82
|
+
case "databaseValidate":
|
|
83
83
|
case "testValidate":
|
|
84
84
|
case "realizeValidate":
|
|
85
85
|
case "realizeAuthorizationValidate":
|
|
86
|
-
case "prismaInsufficient":
|
|
87
86
|
case "interfaceOperationReview":
|
|
88
87
|
grouped.validate.push(event);
|
|
89
88
|
break;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AutoBeUserMessageContent } from "@autobe/interface";
|
|
2
1
|
import {
|
|
2
|
+
AutoBeUserConversateContent,
|
|
3
|
+
AutoBeUserImageConversateContent,
|
|
3
4
|
AutoBeUserMessageAudioContent,
|
|
4
5
|
AutoBeUserMessageFileContent,
|
|
5
|
-
AutoBeUserMessageImageContent,
|
|
6
6
|
} from "@autobe/interface";
|
|
7
7
|
import { ReactNode, RefObject, useEffect, useRef, useState } from "react";
|
|
8
8
|
|
|
@@ -20,7 +20,7 @@ export interface IAutoBeBucket {
|
|
|
20
20
|
content:
|
|
21
21
|
| AutoBeUserMessageAudioContent
|
|
22
22
|
| AutoBeUserMessageFileContent
|
|
23
|
-
|
|
|
23
|
+
| AutoBeUserImageConversateContent;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface IAutoBeChatUploadConfig {
|
|
@@ -72,13 +72,13 @@ export const AutoBeChatUploadBox = (props: AutoBeChatUploadBox.IProps) => {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const messages = [
|
|
75
|
+
const messages: AutoBeUserConversateContent[] = [
|
|
76
76
|
{
|
|
77
77
|
type: "text",
|
|
78
78
|
text: text.trim(),
|
|
79
79
|
},
|
|
80
80
|
...buckets.map(({ content }) => content),
|
|
81
|
-
]
|
|
81
|
+
];
|
|
82
82
|
|
|
83
83
|
setEmptyText(false);
|
|
84
84
|
setText("");
|
|
@@ -102,7 +102,8 @@ export const AutoBeChatUploadBox = (props: AutoBeChatUploadBox.IProps) => {
|
|
|
102
102
|
const newFiles: IAutoBeBucket[] = [];
|
|
103
103
|
const errorFileNames: string[] = [];
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
const files = Array.from(fileList);
|
|
106
|
+
for (const file of files) {
|
|
106
107
|
try {
|
|
107
108
|
newFiles.push(
|
|
108
109
|
await AutoBeFileUploader.compose(props.uploadConfig ?? {}, file),
|
|
@@ -412,7 +413,7 @@ export namespace AutoBeChatUploadBox {
|
|
|
412
413
|
export interface IProps {
|
|
413
414
|
listener: RefObject<IListener>;
|
|
414
415
|
uploadConfig?: IAutoBeChatUploadConfig;
|
|
415
|
-
conversate: (messages:
|
|
416
|
+
conversate: (messages: AutoBeUserConversateContent[]) => Promise<void>;
|
|
416
417
|
setError: (error: Error) => void;
|
|
417
418
|
}
|
|
418
419
|
export interface IListener {
|
|
@@ -18,7 +18,7 @@ export const AutoBeChatUploadSendButton = (
|
|
|
18
18
|
const baseStyles: React.CSSProperties = {
|
|
19
19
|
padding: "6px",
|
|
20
20
|
border: "none",
|
|
21
|
-
borderRadius: "50%",
|
|
21
|
+
borderRadius: "50%",
|
|
22
22
|
backgroundColor: props.enabled ? "#1976d2" : "#e0e0e0",
|
|
23
23
|
color: props.enabled ? "#ffffff" : "#9e9e9e",
|
|
24
24
|
cursor: props.enabled ? "pointer" : "not-allowed",
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IAutoBeRpcListener,
|
|
3
|
-
IAutoBeRpcService,
|
|
4
|
-
IAutoBeTokenUsageJson,
|
|
5
|
-
} from "@autobe/interface";
|
|
1
|
+
import { IAutoBeRpcService, IAutoBeTokenUsageJson } from "@autobe/interface";
|
|
6
2
|
import {
|
|
7
3
|
ReactNode,
|
|
8
4
|
createContext,
|
|
@@ -11,7 +7,6 @@ import {
|
|
|
11
7
|
useEffect,
|
|
12
8
|
useState,
|
|
13
9
|
} from "react";
|
|
14
|
-
import { Communicator } from "tgrid";
|
|
15
10
|
|
|
16
11
|
import {
|
|
17
12
|
AutoBeListener,
|
|
@@ -26,7 +21,6 @@ import { useSearchParams } from "./SearchParamsContext";
|
|
|
26
21
|
export interface IAutoBeServiceData {
|
|
27
22
|
service: IAutoBeRpcService;
|
|
28
23
|
listener: AutoBeListener;
|
|
29
|
-
connector: Communicator<IAutoBeRpcListener, IAutoBeRpcService>;
|
|
30
24
|
close: () => void | Promise<void>;
|
|
31
25
|
sessionId: string;
|
|
32
26
|
}
|
|
@@ -36,9 +30,9 @@ export type AutoBeServiceFactory = (
|
|
|
36
30
|
) => Promise<IAutoBeServiceData>;
|
|
37
31
|
|
|
38
32
|
export type AutoBeConnectionStatus =
|
|
39
|
-
| "disconnected"
|
|
40
|
-
| "connecting"
|
|
41
|
-
| "connected";
|
|
33
|
+
| "disconnected"
|
|
34
|
+
| "connecting"
|
|
35
|
+
| "connected";
|
|
42
36
|
|
|
43
37
|
interface AutoBeAgentContextType {
|
|
44
38
|
// Service state
|
|
@@ -113,13 +107,6 @@ export function AutoBeAgentProvider({
|
|
|
113
107
|
...config,
|
|
114
108
|
sessionId: activeConversationId,
|
|
115
109
|
});
|
|
116
|
-
newServiceData.connector.join().then(async () => {
|
|
117
|
-
const res = await serviceFactory({
|
|
118
|
-
...config,
|
|
119
|
-
sessionId: activeConversationId,
|
|
120
|
-
});
|
|
121
|
-
setServiceInstance(res);
|
|
122
|
-
});
|
|
123
110
|
setServiceInstance(newServiceData);
|
|
124
111
|
|
|
125
112
|
setSearchParams((sp) => {
|
package/src/index.ts
CHANGED
|
@@ -0,0 +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
|
+
}
|
|
@@ -34,56 +34,110 @@ export class AutoBeListener {
|
|
|
34
34
|
this.insert(event);
|
|
35
35
|
},
|
|
36
36
|
|
|
37
|
+
// DESCRIBE
|
|
38
|
+
imageDescribeStart: async (event) => {
|
|
39
|
+
this.dict_.delete("imageDescribeDraft");
|
|
40
|
+
this.insert(event);
|
|
41
|
+
},
|
|
42
|
+
imageDescribeDraft: async (event) => {
|
|
43
|
+
this.insert(event);
|
|
44
|
+
},
|
|
45
|
+
imageDescribeComplete: async (event) => {
|
|
46
|
+
this.dict_.delete("imageDescribeDraft");
|
|
47
|
+
this.insert(event);
|
|
48
|
+
},
|
|
49
|
+
|
|
37
50
|
// ANALYZE
|
|
38
51
|
analyzeStart: async (event) => {
|
|
39
|
-
this.dict_.delete("
|
|
40
|
-
this.dict_.delete("
|
|
52
|
+
this.dict_.delete("analyzeWriteModule");
|
|
53
|
+
this.dict_.delete("analyzeModuleReview");
|
|
54
|
+
this.dict_.delete("analyzeWriteUnit");
|
|
55
|
+
this.dict_.delete("analyzeUnitReview");
|
|
56
|
+
this.dict_.delete("analyzeWriteSection");
|
|
57
|
+
this.dict_.delete("analyzeSectionReview");
|
|
41
58
|
this.insert(event);
|
|
42
59
|
},
|
|
43
60
|
analyzeScenario: async (event) => {
|
|
44
61
|
this.accumulate(event);
|
|
45
62
|
},
|
|
46
|
-
|
|
63
|
+
analyzeWriteModule: async (event) => {
|
|
64
|
+
this.accumulate(event);
|
|
65
|
+
},
|
|
66
|
+
analyzeModuleReview: async (event) => {
|
|
67
|
+
this.accumulate(event);
|
|
68
|
+
},
|
|
69
|
+
analyzeWriteUnit: async (event) => {
|
|
70
|
+
this.accumulate(event);
|
|
71
|
+
},
|
|
72
|
+
analyzeUnitReview: async (event) => {
|
|
73
|
+
this.accumulate(event);
|
|
74
|
+
},
|
|
75
|
+
analyzeWriteSection: async (event) => {
|
|
76
|
+
this.accumulate(event);
|
|
77
|
+
},
|
|
78
|
+
analyzeSectionReview: async (event) => {
|
|
47
79
|
this.accumulate(event);
|
|
48
80
|
},
|
|
49
|
-
|
|
81
|
+
analyzeScenarioReview: async (event) => {
|
|
50
82
|
this.accumulate(event);
|
|
51
83
|
},
|
|
52
84
|
analyzeComplete: async (event) => {
|
|
53
|
-
this.dict_.delete("
|
|
54
|
-
this.dict_.delete("
|
|
85
|
+
this.dict_.delete("analyzeWriteModule");
|
|
86
|
+
this.dict_.delete("analyzeModuleReview");
|
|
87
|
+
this.dict_.delete("analyzeWriteUnit");
|
|
88
|
+
this.dict_.delete("analyzeUnitReview");
|
|
89
|
+
this.dict_.delete("analyzeWriteSection");
|
|
90
|
+
this.dict_.delete("analyzeSectionReview");
|
|
55
91
|
this.state_.setAnalyze(event);
|
|
56
92
|
this.insert(event);
|
|
57
93
|
},
|
|
58
94
|
|
|
59
95
|
// PRISMA
|
|
60
|
-
|
|
61
|
-
this.dict_.delete("
|
|
62
|
-
this.dict_.delete("
|
|
96
|
+
databaseStart: async (event) => {
|
|
97
|
+
this.dict_.delete("databaseAuthorizationReview");
|
|
98
|
+
this.dict_.delete("databaseComponent");
|
|
99
|
+
this.dict_.delete("databaseComponentReview");
|
|
100
|
+
this.dict_.delete("databaseSchema");
|
|
101
|
+
this.dict_.delete("databaseSchemaReview");
|
|
63
102
|
this.insert(event);
|
|
64
103
|
},
|
|
65
|
-
|
|
104
|
+
databaseGroup: async (event) => {
|
|
66
105
|
this.insert(event);
|
|
67
106
|
},
|
|
68
|
-
|
|
107
|
+
databaseGroupReview: async (event) => {
|
|
108
|
+
this.insert(event);
|
|
109
|
+
},
|
|
110
|
+
databaseAuthorization: async (event) => {
|
|
69
111
|
this.accumulate(event);
|
|
70
112
|
},
|
|
71
|
-
|
|
72
|
-
this.
|
|
113
|
+
databaseAuthorizationReview: async (event) => {
|
|
114
|
+
this.accumulate(event);
|
|
115
|
+
},
|
|
116
|
+
databaseComponent: async (event) => {
|
|
117
|
+
this.accumulate(event);
|
|
118
|
+
},
|
|
119
|
+
databaseComponentReview: async (event) => {
|
|
120
|
+
this.accumulate(event);
|
|
73
121
|
},
|
|
74
|
-
|
|
122
|
+
databaseSchema: async (event) => {
|
|
75
123
|
this.accumulate(event);
|
|
76
124
|
},
|
|
77
|
-
|
|
125
|
+
databaseSchemaReview: async (event) => {
|
|
126
|
+
this.accumulate(event);
|
|
127
|
+
},
|
|
128
|
+
databaseValidate: async (event) => {
|
|
78
129
|
this.insert(event);
|
|
79
130
|
},
|
|
80
|
-
|
|
131
|
+
databaseCorrect: async (event) => {
|
|
81
132
|
this.insert(event);
|
|
82
133
|
},
|
|
83
|
-
|
|
84
|
-
this.dict_.delete("
|
|
85
|
-
this.dict_.delete("
|
|
86
|
-
this.
|
|
134
|
+
databaseComplete: async (event) => {
|
|
135
|
+
this.dict_.delete("databaseAuthorizationReview");
|
|
136
|
+
this.dict_.delete("databaseComponent");
|
|
137
|
+
this.dict_.delete("databaseComponentReview");
|
|
138
|
+
this.dict_.delete("databaseSchema");
|
|
139
|
+
this.dict_.delete("databaseSchemaReview");
|
|
140
|
+
this.state_.setDatabase(event);
|
|
87
141
|
this.insert(event);
|
|
88
142
|
},
|
|
89
143
|
|
|
@@ -94,8 +148,10 @@ export class AutoBeListener {
|
|
|
94
148
|
this.dict_.delete("interfaceOperation");
|
|
95
149
|
this.dict_.delete("interfaceOperationReview");
|
|
96
150
|
this.dict_.delete("interfaceSchema");
|
|
151
|
+
this.dict_.delete("interfaceSchemaCasting");
|
|
152
|
+
this.dict_.delete("interfaceSchemaRefine");
|
|
97
153
|
this.dict_.delete("interfaceSchemaReview");
|
|
98
|
-
this.dict_.delete("
|
|
154
|
+
this.dict_.delete("interfaceSchemaComplement");
|
|
99
155
|
this.dict_.delete("interfaceSchemaRename");
|
|
100
156
|
this.dict_.delete("interfacePrerequisite");
|
|
101
157
|
this.insert(event);
|
|
@@ -121,13 +177,19 @@ export class AutoBeListener {
|
|
|
121
177
|
interfaceSchema: async (event) => {
|
|
122
178
|
this.accumulate(event);
|
|
123
179
|
},
|
|
180
|
+
interfaceSchemaCasting: async (event) => {
|
|
181
|
+
this.accumulate(event);
|
|
182
|
+
},
|
|
183
|
+
interfaceSchemaRefine: async (event) => {
|
|
184
|
+
this.accumulate(event);
|
|
185
|
+
},
|
|
124
186
|
interfaceSchemaReview: async (event) => {
|
|
125
187
|
this.accumulate(event);
|
|
126
188
|
},
|
|
127
189
|
interfaceSchemaRename: async (event) => {
|
|
128
190
|
this.accumulate(event);
|
|
129
191
|
},
|
|
130
|
-
|
|
192
|
+
interfaceSchemaComplement: async (event) => {
|
|
131
193
|
this.accumulate(event);
|
|
132
194
|
},
|
|
133
195
|
interfacePrerequisite: async (event) => {
|
|
@@ -139,9 +201,11 @@ export class AutoBeListener {
|
|
|
139
201
|
this.dict_.delete("interfaceOperationReview");
|
|
140
202
|
this.dict_.delete("interfaceAuthorization");
|
|
141
203
|
this.dict_.delete("interfaceSchema");
|
|
204
|
+
this.dict_.delete("interfaceSchemaCasting");
|
|
205
|
+
this.dict_.delete("interfaceSchemaRefine");
|
|
142
206
|
this.dict_.delete("interfaceSchemaReview");
|
|
143
207
|
this.dict_.delete("interfaceSchemaRename");
|
|
144
|
-
this.dict_.delete("
|
|
208
|
+
this.dict_.delete("interfaceSchemaComplement");
|
|
145
209
|
this.dict_.delete("interfacePrerequisite");
|
|
146
210
|
this.state_.setInterface(event);
|
|
147
211
|
this.insert(event);
|
|
@@ -184,10 +248,14 @@ export class AutoBeListener {
|
|
|
184
248
|
//----
|
|
185
249
|
// REALIZE-MAIN
|
|
186
250
|
realizeStart: async (event) => {
|
|
251
|
+
this.dict_.delete("realizePlan");
|
|
187
252
|
this.dict_.delete("realizeWrite");
|
|
188
253
|
this.dict_.delete("realizeValidate");
|
|
189
254
|
this.insert(event);
|
|
190
255
|
},
|
|
256
|
+
realizePlan: async (event) => {
|
|
257
|
+
this.accumulate(event);
|
|
258
|
+
},
|
|
191
259
|
realizeWrite: async (event) => {
|
|
192
260
|
this.accumulate(event);
|
|
193
261
|
},
|
|
@@ -199,6 +267,7 @@ export class AutoBeListener {
|
|
|
199
267
|
this.accumulate(event);
|
|
200
268
|
},
|
|
201
269
|
realizeComplete: async (event) => {
|
|
270
|
+
this.dict_.delete("realizePlan");
|
|
202
271
|
this.dict_.delete("realizeWrite");
|
|
203
272
|
this.dict_.delete("realizeValidate");
|
|
204
273
|
this.state_.setRealize(event);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AutoBeAnalyzeCompleteEvent,
|
|
3
|
+
AutoBeDatabaseCompleteEvent,
|
|
3
4
|
AutoBeInterfaceCompleteEvent,
|
|
4
|
-
AutoBePrismaCompleteEvent,
|
|
5
5
|
AutoBeRealizeCompleteEvent,
|
|
6
6
|
AutoBeTestCompleteEvent,
|
|
7
7
|
} from "@autobe/interface";
|
|
8
8
|
|
|
9
9
|
export class AutoBeListenerState {
|
|
10
10
|
public analyze: AutoBeAnalyzeCompleteEvent | null;
|
|
11
|
-
public
|
|
11
|
+
public database: AutoBeDatabaseCompleteEvent | null;
|
|
12
12
|
public interface: AutoBeInterfaceCompleteEvent | null;
|
|
13
13
|
public test: AutoBeTestCompleteEvent | null;
|
|
14
14
|
public realize: AutoBeRealizeCompleteEvent | null;
|
|
15
15
|
|
|
16
16
|
public constructor() {
|
|
17
17
|
this.analyze = null;
|
|
18
|
-
this.
|
|
18
|
+
this.database = null;
|
|
19
19
|
this.interface = null;
|
|
20
20
|
this.test = null;
|
|
21
21
|
this.realize = null;
|
|
@@ -23,14 +23,14 @@ export class AutoBeListenerState {
|
|
|
23
23
|
|
|
24
24
|
public setAnalyze(event: AutoBeAnalyzeCompleteEvent): void {
|
|
25
25
|
this.analyze = event;
|
|
26
|
-
this.
|
|
26
|
+
this.database = null;
|
|
27
27
|
this.interface = null;
|
|
28
28
|
this.test = null;
|
|
29
29
|
this.realize = null;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
public
|
|
33
|
-
this.
|
|
32
|
+
public setDatabase(event: AutoBeDatabaseCompleteEvent): void {
|
|
33
|
+
this.database = event;
|
|
34
34
|
this.interface = null;
|
|
35
35
|
this.test = null;
|
|
36
36
|
this.realize = null;
|