@autobe/agent 0.0.0 → 0.3.9
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 +21 -21
- package/lib/AutoBeAgent.d.ts +9 -7
- package/lib/AutoBeAgent.js +106 -14
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/analyze/AnalyzeAgent.d.ts +24 -0
- package/lib/analyze/AnalyzeAgent.js +817 -0
- package/lib/analyze/AnalyzeAgent.js.map +1 -0
- package/lib/analyze/CreateReviewerAgent.d.ts +16 -0
- package/lib/analyze/CreateReviewerAgent.js +97 -0
- package/lib/analyze/CreateReviewerAgent.js.map +1 -0
- package/lib/analyze/Planning.d.ts +63 -0
- package/lib/{orchestrate/orchestratePrisma.js → analyze/Planning.js} +28 -11
- package/lib/analyze/Planning.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +14 -0
- package/lib/constants/AutoBeSystemPromptConstant.js +4 -0
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -0
- package/lib/context/AutoBeContext.d.ts +7 -3
- package/lib/context/IAutoBeApplication.d.ts +72 -32
- package/lib/context/IAutoBeApplicationProps.d.ts +22 -2
- package/lib/context/IAutoBeApplicationResult.d.ts +0 -1
- package/lib/context/assertSchemaModel.d.ts +2 -0
- package/lib/context/assertSchemaModel.js +15 -0
- package/lib/context/assertSchemaModel.js.map +1 -0
- package/lib/{internal/transformAgenticaHistory.d.ts → factory/createAgenticaHistory.d.ts} +1 -1
- package/lib/{internal/transformAgenticaHistory.js → factory/createAgenticaHistory.js} +3 -4
- package/lib/factory/createAgenticaHistory.js.map +1 -0
- package/lib/factory/createAutoBeApplication.js +1195 -0
- package/lib/factory/createAutoBeApplication.js.map +1 -0
- package/lib/factory/createAutoBeState.js.map +1 -0
- package/lib/factory/index.d.ts +2 -0
- package/lib/factory/index.js +19 -0
- package/lib/factory/index.js.map +1 -0
- package/lib/factory/invertOpenApiDocument.d.ts +3 -0
- package/lib/factory/invertOpenApiDocument.js +51 -0
- package/lib/factory/invertOpenApiDocument.js.map +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +4 -4
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +5455 -547
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.d.ts +2 -0
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +46 -0
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -0
- package/lib/orchestrate/index.d.ts +2 -2
- package/lib/orchestrate/index.js +2 -2
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/OpenApiEndpointComparator.d.ts +5 -0
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js +16 -0
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterface.d.ts +5 -0
- package/lib/orchestrate/interface/orchestrateInterface.js +61 -0
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +702 -0
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +452 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +2065 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +3 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js +94 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -0
- package/lib/orchestrate/orchestrateAnalyze.d.ts +1 -3
- package/lib/orchestrate/orchestrateAnalyze.js +60 -6
- package/lib/orchestrate/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/{orchestratePrisma.d.ts → prisma/orchestratePrisma.d.ts} +3 -6
- package/lib/orchestrate/prisma/orchestratePrisma.js +103 -0
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.d.ts +6 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.js +436 -0
- package/lib/orchestrate/prisma/orchestratePrismaCompiler.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +5 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +437 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.d.ts +7 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +369 -0
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.js +44 -0
- package/lib/orchestrate/prisma/transformPrismaCompilerHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +42 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.js +46 -0
- package/lib/orchestrate/prisma/transformPrismaHistories.js.map +1 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.d.ts +3 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +46 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -0
- package/lib/structures/IAutoBeConfig.d.ts +4 -4
- package/lib/utils/StringUtil.d.ts +4 -0
- package/lib/utils/StringUtil.js +43 -0
- package/lib/utils/StringUtil.js.map +1 -0
- package/lib/utils/divideArray.d.ts +4 -0
- package/lib/utils/divideArray.js +19 -0
- package/lib/utils/divideArray.js.map +1 -0
- package/lib/utils/emplaceMap.d.ts +1 -0
- package/lib/utils/emplaceMap.js +13 -0
- package/lib/utils/emplaceMap.js.map +1 -0
- package/package.json +29 -8
- package/src/AutoBeAgent.ts +227 -101
- package/src/analyze/AnalyzeAgent.ts +167 -0
- package/src/analyze/CreateReviewerAgent.ts +126 -0
- package/src/analyze/Planning.ts +75 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +15 -0
- package/src/context/AutoBeContext.ts +19 -15
- package/src/context/AutoBeState.ts +15 -15
- package/src/context/AutoBeTokenUsage.ts +3 -3
- package/src/context/IAutoBeApplication.ts +112 -72
- package/src/context/IAutoBeApplicationProps.ts +27 -6
- package/src/context/IAutoBeApplicationResult.ts +3 -4
- package/src/context/assertSchemaModel.ts +17 -0
- package/src/{internal/transformAgenticaHistory.ts → factory/createAgenticaHistory.ts} +51 -54
- package/src/{internal → factory}/createAutoBeApplication.ts +52 -47
- package/src/{internal → factory}/createAutoBeState.ts +14 -14
- package/src/factory/index.ts +2 -0
- package/src/factory/invertOpenApiDocument.ts +63 -0
- package/src/index.ts +13 -12
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +58 -0
- package/src/orchestrate/index.ts +5 -5
- package/src/orchestrate/interface/OpenApiEndpointComparator.ts +15 -0
- package/src/orchestrate/interface/orchestrateInterface.ts +66 -0
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +324 -0
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +140 -0
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +247 -0
- package/src/orchestrate/interface/transformInterfaceHistories.ts +98 -0
- package/src/orchestrate/orchestrateAnalyze.ts +86 -21
- package/src/orchestrate/orchestrateRealize.ts +18 -18
- package/src/orchestrate/orchestrateTest.ts +18 -18
- package/src/orchestrate/prisma/orchestratePrisma.ts +117 -0
- package/src/orchestrate/prisma/orchestratePrismaCompiler.ts +194 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +176 -0
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +181 -0
- package/src/orchestrate/prisma/transformPrismaCompilerHistories.ts +49 -0
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +46 -0
- package/src/orchestrate/prisma/transformPrismaHistories.ts +50 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +50 -0
- package/src/structures/IAutoBeConfig.ts +25 -25
- package/src/structures/IAutoBeProps.ts +13 -13
- package/src/structures/IAutoBeVendor.ts +3 -3
- package/src/utils/StringUtil.ts +45 -0
- package/src/utils/divideArray.ts +16 -0
- package/src/utils/emplaceMap.ts +14 -0
- package/lib/factory/transformRouteDocument.d.ts +0 -3
- package/lib/factory/transformRouteDocument.js +0 -50
- package/lib/factory/transformRouteDocument.js.map +0 -1
- package/lib/internal/createAutoBeApplication.js +0 -1452
- package/lib/internal/createAutoBeApplication.js.map +0 -1
- package/lib/internal/createAutoBeState.js.map +0 -1
- package/lib/internal/transformAgenticaHistory.js.map +0 -1
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.d.ts +0 -0
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.js +0 -2
- package/lib/orchestrate/interface/AutoBeInterfaceAgent.js.map +0 -1
- package/lib/orchestrate/orchestrateInterface.d.ts +0 -8
- package/lib/orchestrate/orchestrateInterface.js +0 -22
- package/lib/orchestrate/orchestrateInterface.js.map +0 -1
- package/lib/orchestrate/orchestratePrisma.js.map +0 -1
- package/src/factory/transformRouteDocument.ts +0 -49
- package/src/orchestrate/interface/AutoBeInterfaceAgent.ts +0 -0
- package/src/orchestrate/orchestrateInterface.ts +0 -21
- package/src/orchestrate/orchestratePrisma.ts +0 -21
- /package/lib/{internal → factory}/createAutoBeApplication.d.ts +0 -0
- /package/lib/{internal → factory}/createAutoBeState.d.ts +0 -0
- /package/lib/{internal → factory}/createAutoBeState.js +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AutoBeContext } from "../context/AutoBeContext";
|
|
5
|
+
|
|
6
|
+
export const createReviewerAgent = <Model extends ILlmSchema.Model>(
|
|
7
|
+
ctx: AutoBeContext<Model>,
|
|
8
|
+
input: ICreateReviewerAgentInput,
|
|
9
|
+
) => {
|
|
10
|
+
// All links specified in the markdown are drawn in advance and provided to LLM.
|
|
11
|
+
const markdownFiles = Array.from(
|
|
12
|
+
new Set(
|
|
13
|
+
Object.values(input.currentFiles).flatMap((content) => {
|
|
14
|
+
const fileExtensions = ["md"];
|
|
15
|
+
|
|
16
|
+
const regex = /\[[^\]]*\]\(([^)]+)\)/g;
|
|
17
|
+
|
|
18
|
+
const fileLinks = [...content.matchAll(regex)]
|
|
19
|
+
.map((match) => match[1])
|
|
20
|
+
.filter((link) => {
|
|
21
|
+
const ext = link.split(".").pop()?.toLowerCase();
|
|
22
|
+
return ext && fileExtensions.includes(ext);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return fileLinks;
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return new MicroAgentica({
|
|
31
|
+
model: ctx.model,
|
|
32
|
+
vendor: ctx.vendor,
|
|
33
|
+
controllers: [],
|
|
34
|
+
config: {
|
|
35
|
+
systemPrompt: {
|
|
36
|
+
common: () => {
|
|
37
|
+
return [
|
|
38
|
+
"You are an excellent requirements analyst & reviewer agent.",
|
|
39
|
+
"",
|
|
40
|
+
`The reviewer's role is to ensure that this document contains sufficient information before it is delivered to developers`,
|
|
41
|
+
`These are all the links that are currently referenced in the markdown. Please make sure to refer to them and don't forget to create the corresponding files.`,
|
|
42
|
+
"Also, you should not create files that are not specified in the table of contents.",
|
|
43
|
+
"If you request the creation of a file that is not specified in the table of contents, instruct them to modify the table of contents first.",
|
|
44
|
+
"If the user specifies the exact number of pages, please follow it precisely.",
|
|
45
|
+
"",
|
|
46
|
+
"You should not write your own writing in any case, but only direct the modifications.",
|
|
47
|
+
"Also, reviewers are independent beings, and should never be instructed.",
|
|
48
|
+
"Your words should be instructions that must be followed, not recommendations.",
|
|
49
|
+
"",
|
|
50
|
+
`user said, "${input.query}"`,
|
|
51
|
+
"user requests will take precedence over the other system prompts below unless they are a security concern.",
|
|
52
|
+
"",
|
|
53
|
+
"If there are any changes that need to be made, please provide detailed instructions.",
|
|
54
|
+
"Just give clear and concise instructions, but don't say anything unnecessary.",
|
|
55
|
+
"",
|
|
56
|
+
"If you feel that the current level of analysis is sufficient, please do not make any further requests and notify us that it is complete.",
|
|
57
|
+
"",
|
|
58
|
+
"It is recommended to ask the planner to write a longer document (more than 1,000 letters) until it gives sufficient utility value.",
|
|
59
|
+
"However, even if the length of the document is less than 1,000 letters, pass it if the quality is compliant.",
|
|
60
|
+
"When increasing the volume of a document, explain to the planner how many letters the document currently has and how many more should be increased.",
|
|
61
|
+
"Rather than simply telling them to increase the text, it is better to count the number of tables of contents compared to the existing text and instruct them to double the amount if they want to double the amount.",
|
|
62
|
+
"When you add something about the table of contents, please clearly state the name of the table of contents.",
|
|
63
|
+
"",
|
|
64
|
+
"If the planner agent asks a question, the reviewer should answer on behalf of the user.",
|
|
65
|
+
"Please do not ask any questions.",
|
|
66
|
+
"Just give orders.",
|
|
67
|
+
"",
|
|
68
|
+
"If you have a hyperlink that is not yet complete, even if the document is of good quality, the document is considered incomplete.",
|
|
69
|
+
"You should also ask for the rest of the document to be created.",
|
|
70
|
+
"At this time, the document should be newly created with the name attached to the link, not modified.",
|
|
71
|
+
"<CurrentFiles>",
|
|
72
|
+
JSON.stringify(
|
|
73
|
+
Object.entries(input.currentFiles)
|
|
74
|
+
.slice(-2)
|
|
75
|
+
.map(([filename, content]) => {
|
|
76
|
+
return {
|
|
77
|
+
filename,
|
|
78
|
+
content,
|
|
79
|
+
content_length: content.length,
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
null,
|
|
83
|
+
2,
|
|
84
|
+
),
|
|
85
|
+
"</CurrentFiles>",
|
|
86
|
+
"",
|
|
87
|
+
`These are all the links that are currently referenced in the markdown. Please make sure to refer to them and don't forget to create the corresponding files.`,
|
|
88
|
+
`<Linked Files>`,
|
|
89
|
+
markdownFiles.map((filename) => {
|
|
90
|
+
const isChecked = Object.keys(input.currentFiles).includes(
|
|
91
|
+
filename,
|
|
92
|
+
);
|
|
93
|
+
return `- [${isChecked}] ${filename}`;
|
|
94
|
+
}),
|
|
95
|
+
`</Linked Files>`,
|
|
96
|
+
"",
|
|
97
|
+
"Write a long document, but keep your answer short.",
|
|
98
|
+
"The planner agent can only create and modify one document at a time, so do not ask to create or modify multiple documents at a time.",
|
|
99
|
+
"If you say the document is complete, the planner will finish writing the document.",
|
|
100
|
+
"If only one document has been written out of several that need to be completed, do not simply state that it is complete—also provide instructions for what should be done next.",
|
|
101
|
+
"For example, if you say, “The document internal_bulletin_board_service_plan.md has already been written with over 1,000 characters. Its quality is sufficient, so mark it as complete without any further requests,” then the planner will respond with “Got it!” and stop writing—even if there are still remaining documents.",
|
|
102
|
+
"Be cautious: the planner will try to avoid work by interpreting your words in a way that lets them do less.",
|
|
103
|
+
"The correct response from you should be:",
|
|
104
|
+
"\“The document's quality is sufficient, so mark it as complete without any further requests. Now, proceed to write the next document immediately.\”",
|
|
105
|
+
"When requesting the next document to be written, you must include both the document title and a brief description of its content.",
|
|
106
|
+
].join("\n");
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
tokenUsage: ctx.usage(),
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export interface ICreateReviewerAgentInput {
|
|
115
|
+
/**
|
|
116
|
+
* Indicates the initial utterance of the user. Identify the purpose of your
|
|
117
|
+
* documentation for better review.
|
|
118
|
+
*/
|
|
119
|
+
query: string;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Hand over the title and name of the file that has been created so far to
|
|
123
|
+
* the list.
|
|
124
|
+
*/
|
|
125
|
+
currentFiles: Record<string, string>;
|
|
126
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
type Filename = string;
|
|
2
|
+
type FileContent = string;
|
|
3
|
+
|
|
4
|
+
export interface IPlanning {
|
|
5
|
+
/**
|
|
6
|
+
* Generate markdown file. if there is already created file, overwrite it.
|
|
7
|
+
*
|
|
8
|
+
* @param input.reason Describe briefly why you made this document, and if you
|
|
9
|
+
* have any plans for the next one.
|
|
10
|
+
* @param input.filename Filename to generate or overwrite.
|
|
11
|
+
* @param input.markdown Markdown file content. Only write the content of the
|
|
12
|
+
* file. Do not include any questions.
|
|
13
|
+
*/
|
|
14
|
+
createOrUpdateFile(input: {
|
|
15
|
+
reason: string;
|
|
16
|
+
filename: `${string}.md`;
|
|
17
|
+
markdown: string;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Read markdown file content.
|
|
22
|
+
*
|
|
23
|
+
* @param input.filename Filename to read.
|
|
24
|
+
*/
|
|
25
|
+
// readFile(input: { filename: `${string}.md` }): Promise<string>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Remove markdown file.
|
|
29
|
+
*
|
|
30
|
+
* @param input.name Filename to remove
|
|
31
|
+
*/
|
|
32
|
+
removeFile(input: { filename: `${string}.md` }): Promise<void>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* If you decide that you no longer need any reviews, or if the reviewer
|
|
36
|
+
* refuses to do so, call abort. This is a function to end document creation
|
|
37
|
+
* and review, and to respond to users.
|
|
38
|
+
*
|
|
39
|
+
* When there is content you are unsure about and need to ask the user a
|
|
40
|
+
* question, abort the process and ask the user directly. The reason for
|
|
41
|
+
* aborting should be included as the content of the question.
|
|
42
|
+
*
|
|
43
|
+
* @param input.reason Should contain the reason for the abort.
|
|
44
|
+
*/
|
|
45
|
+
abort(input: { reason: string }): "OK";
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class Planning implements IPlanning {
|
|
49
|
+
constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
|
|
50
|
+
|
|
51
|
+
async createOrUpdateFile(input: {
|
|
52
|
+
reason: string;
|
|
53
|
+
filename: `${string}.md`;
|
|
54
|
+
markdown: string;
|
|
55
|
+
}): Promise<void> {
|
|
56
|
+
this.fileMap[input.filename] = input.markdown;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// async readFile(input: { filename: `${string}.md` }): Promise<string> {
|
|
60
|
+
// return this.fileMap[input.filename];
|
|
61
|
+
// }
|
|
62
|
+
|
|
63
|
+
async removeFile(input: { filename: `${string}.md` }): Promise<void> {
|
|
64
|
+
delete this.fileMap[input.filename];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
abort(_input: { reason: string }): "OK" {
|
|
68
|
+
return "OK";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @ignore */
|
|
72
|
+
allFiles(): Record<string, string> {
|
|
73
|
+
return this.fileMap;
|
|
74
|
+
}
|
|
75
|
+
}
|