Skip to content

Commit e7682c4

Browse files
authored
feat(agent): separate interface schema review agent (#709)
* feat(agent): separate interface schema review agent * rename events to be from plural to singular * complete implementation * complete UI * renaming from relationship to relation * Relation concept separating create/read DTOs * complete complementation too * fix typo * change name again * website again * enhance agent system * also migration
1 parent 127a0d8 commit e7682c4

File tree

196 files changed

+5519
-2524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+5519
-2524
lines changed

packages/agent/prompts/INTERFACE_SCHEMA.md

Lines changed: 565 additions & 138 deletions
Large diffs are not rendered by default.

packages/agent/prompts/INTERFACE_SCHEMA_CONTENT_REVIEW.md

Lines changed: 884 additions & 0 deletions
Large diffs are not rendered by default.

packages/agent/prompts/INTERFACE_SCHEMA_RELATION_REVIEW.md

Lines changed: 1638 additions & 0 deletions
Large diffs are not rendered by default.

packages/agent/prompts/INTERFACE_SCHEMA_REVIEW.md

Lines changed: 0 additions & 1396 deletions
This file was deleted.

packages/agent/prompts/INTERFACE_SCHEMA_SECURITY_REVIEW.md

Lines changed: 1094 additions & 0 deletions
Large diffs are not rendered by default.

packages/agent/src/AutoBeMockAgent.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,32 @@ const sleepMap: Record<AutoBeEvent.Type, number> = {
174174
analyzeComplete: 1_000,
175175
// PRISMA
176176
prismaStart: 1_000,
177-
prismaComponents: 1_000,
178-
prismaSchemas: 500,
177+
prismaComponent: 1_000,
178+
prismaSchema: 500,
179179
prismaInsufficient: 1_000,
180180
prismaReview: 500,
181181
prismaValidate: 2_000,
182182
prismaCorrect: 500,
183183
prismaComplete: 1_000,
184184
// INTERFACE
185185
interfaceStart: 1_000,
186-
interfaceGroups: 1_000,
187-
interfaceEndpoints: 1_000,
188-
interfaceEndpointsReview: 1_000,
189-
interfaceOperations: 400,
190-
interfaceOperationsReview: 400,
186+
interfaceGroup: 1_000,
187+
interfaceEndpoint: 1_000,
188+
interfaceEndpointReview: 1_000,
189+
interfaceOperation: 400,
190+
interfaceOperationReview: 400,
191191
interfaceAuthorization: 400,
192-
interfaceSchemas: 400,
193-
interfaceSchemasReview: 400,
192+
interfaceSchema: 400,
193+
interfaceSchemaSecurityReview: 400,
194+
interfaceSchemaRelationReview: 400,
195+
interfaceSchemaContentReview: 400,
194196
interfaceComplement: 2_000,
195197
interfaceComplete: 1_000,
196-
interfacePrerequisites: 400,
198+
interfacePrerequisite: 400,
197199
// TEST
198200
testStart: 1_000,
199-
testScenarios: 40,
200-
testScenariosReview: 40,
201+
testScenario: 40,
202+
testScenarioReview: 40,
201203
testWrite: 40,
202204
testValidate: 100,
203205
testCorrect: 100,

packages/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ export const transformInterfaceComplementHistories = (props: {
2828
created_at: new Date().toISOString(),
2929
text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA,
3030
},
31-
{
32-
type: "systemMessage",
33-
id: v7(),
34-
created_at: new Date().toISOString(),
35-
text: AutoBeSystemPromptConstant.INTERFACE_SCHEMA_REVIEW,
36-
},
3731
{
3832
type: "systemMessage",
3933
id: v7(),

packages/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHisto
1010
export const transformInterfaceSchemaHistories = (props: {
1111
state: AutoBeState;
1212
operations: AutoBeOpenApi.IOperation[];
13+
typeNames: string[];
1314
instruction: string;
1415
}): Array<
1516
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
@@ -39,19 +40,23 @@ export const transformInterfaceSchemaHistories = (props: {
3940
such as endpoint patterns, request/response formats, DTO schemas,
4041
and operation specifications.
4142
42-
Follow these instructions when creating JSON schema components.
43+
Follow these instructions when creating JSON schema components.
4344
Carefully distinguish between:
4445
- Suggestions or recommendations (consider these as guidance)
4546
- Direct specifications or explicit commands (these must be followed exactly)
46-
47-
When instructions contain direct specifications or explicit design decisions,
47+
48+
When instructions contain direct specifications or explicit design decisions,
4849
follow them precisely even if you believe you have better alternatives.
4950
5051
${props.instruction}
5152
52-
## Operations
53+
## Operations (Filtered for Target Schemas)
54+
55+
Here is the list of API operations that directly use the schemas
56+
you need to generate (via requestBody.typeName or responseBody.typeName).
5357
54-
Here is the list of API operations you have to implement its types:
58+
These are the ONLY operations relevant to your current task - other
59+
operations have been filtered out to reduce noise and improve focus:
5560
5661
\`\`\`json
5762
${JSON.stringify(props.operations)}
@@ -60,8 +65,8 @@ export const transformInterfaceSchemaHistories = (props: {
6065
## Schemas
6166
6267
Here is the list of request/response bodies' type names from
63-
OpenAPI operations.
64-
68+
OpenAPI operations.
69+
6570
Reference them when creating DTO schema components, especially
6671
considering the DTO relationships.
6772
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { IAgenticaHistoryJson } from "@agentica/core";
2+
import { AutoBeOpenApi } from "@autobe/interface";
3+
import { StringUtil } from "@autobe/utils";
4+
import { v7 } from "uuid";
5+
6+
import { AutoBeState } from "../../../context/AutoBeState";
7+
import { transformInterfaceAssetHistories } from "./transformInterfaceAssetHistories";
8+
9+
export const transformInterfaceSchemaReviewHistories = (props: {
10+
state: AutoBeState;
11+
systemPrompt: string;
12+
operations: AutoBeOpenApi.IOperation[];
13+
everySchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
14+
reviewSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
15+
}): Array<
16+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
17+
> => {
18+
return [
19+
{
20+
type: "systemMessage",
21+
id: v7(),
22+
created_at: new Date().toISOString(),
23+
text: props.systemPrompt,
24+
},
25+
...transformInterfaceAssetHistories(props.state),
26+
{
27+
type: "assistantMessage",
28+
id: v7(),
29+
created_at: new Date().toISOString(),
30+
text: StringUtil.trim`
31+
## Schemas (Complete Set for Reference)
32+
33+
Here is the COMPLETE set of all schemas in the system for
34+
reference context:
35+
36+
\`\`\`json
37+
${JSON.stringify(props.everySchemas)}
38+
\`\`\`
39+
`,
40+
},
41+
{
42+
id: v7(),
43+
type: "assistantMessage",
44+
created_at: new Date().toISOString(),
45+
text: StringUtil.trim`
46+
## Schemas Needing Review
47+
48+
From the complete schema set above, here are the SPECIFIC schemas that need review:
49+
50+
\`\`\`json
51+
${JSON.stringify(props.reviewSchemas)}
52+
\`\`\`
53+
54+
IMPORTANT: Only these ${Object.keys(props.reviewSchemas).length} schemas
55+
need review and potential modification. The other schemas in
56+
the full set are provided for reference only.
57+
58+
## Operations (Filtered for Target Schemas)
59+
60+
Here are the API operations that directly use the schemas under review.
61+
These operations reference at least one of the target schemas via
62+
requestBody.typeName or responseBody.typeName.
63+
64+
This FILTERED list helps you understand the exact usage context for
65+
the schemas you're reviewing:
66+
67+
\`\`\`json
68+
${JSON.stringify(props.operations)}
69+
\`\`\`
70+
`,
71+
},
72+
];
73+
};

packages/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)