@autobe/agent 0.4.1 → 0.4.2

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.
Files changed (32) hide show
  1. package/lib/analyze/AnalyzeAgent.d.ts +2 -2
  2. package/lib/analyze/AnalyzeAgent.js +75 -40
  3. package/lib/analyze/AnalyzeAgent.js.map +1 -1
  4. package/lib/analyze/AutoBeAnalyzeAgent.d.ts +24 -0
  5. package/lib/analyze/AutoBeAnalyzeAgent.js +972 -0
  6. package/lib/analyze/AutoBeAnalyzeAgent.js.map +1 -0
  7. package/lib/analyze/AutoBeAnalyzeFileSystem.d.ts +65 -0
  8. package/lib/analyze/{Planning.js → AutoBeAnalyzeFileSystem.js} +4 -4
  9. package/lib/analyze/AutoBeAnalyzeFileSystem.js.map +1 -0
  10. package/lib/analyze/AutoBeAnalyzeReviewer.d.ts +15 -0
  11. package/lib/analyze/AutoBeAnalyzeReviewer.js +42 -0
  12. package/lib/analyze/AutoBeAnalyzeReviewer.js.map +1 -0
  13. package/lib/constants/AutoBeSystemPromptConstant.d.ts +3 -2
  14. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  15. package/lib/index.mjs +571 -112
  16. package/lib/index.mjs.map +1 -1
  17. package/lib/orchestrate/orchestrateAnalyze.js +512 -16
  18. package/lib/orchestrate/orchestrateAnalyze.js.map +1 -1
  19. package/package.json +4 -4
  20. package/src/analyze/AnalyzeAgent.ts +24 -19
  21. package/src/analyze/AutoBeAnalyzeAgent.ts +217 -0
  22. package/src/analyze/AutoBeAnalyzeFileSystem.ts +81 -0
  23. package/src/analyze/AutoBeAnalyzeReviewer.ts +60 -0
  24. package/src/constants/AutoBeSystemPromptConstant.ts +3 -2
  25. package/src/orchestrate/orchestrateAnalyze.ts +178 -17
  26. package/lib/analyze/CreateReviewerAgent.d.ts +0 -16
  27. package/lib/analyze/CreateReviewerAgent.js +0 -98
  28. package/lib/analyze/CreateReviewerAgent.js.map +0 -1
  29. package/lib/analyze/Planning.d.ts +0 -67
  30. package/lib/analyze/Planning.js.map +0 -1
  31. package/src/analyze/CreateReviewerAgent.ts +0 -126
  32. package/src/analyze/Planning.ts +0 -77
@@ -1,67 +0,0 @@
1
- type Filename = string;
2
- type FileContent = string;
3
- export interface IPlanning {
4
- /**
5
- * Generate multiple markdown files. if there is already created files,
6
- * overwrite it. Generate several markdown files at once.
7
- */
8
- createOrUpdateFiles(input: {
9
- files: Array<{
10
- /**
11
- * Describe briefly why you made this document, and if you have any plans
12
- * for the next one.
13
- */
14
- reason: string;
15
- /** Filename to generate or overwrite. */
16
- filename: `${string}.md`;
17
- /**
18
- * Markdown file content. Only write the content of the file. Do not
19
- * include any questions. This should contain only the contents of the
20
- * file. Do not write down any questions or appreciation.
21
- */
22
- markdown: string;
23
- }>;
24
- }): Promise<void>;
25
- /**
26
- * Remove markdown file.
27
- *
28
- * @param input.name Filename to remove
29
- */
30
- removeFile(input: {
31
- filename: `${string}.md`;
32
- }): Promise<void>;
33
- /**
34
- * If you decide that you no longer need any reviews, or if the reviewer
35
- * refuses to do so, call abort. This is a function to end document creation
36
- * and review, and to respond to users.
37
- *
38
- * When there is content you are unsure about and need to ask the user a
39
- * question, abort the process and ask the user directly. The reason for
40
- * aborting should be included as the content of the question.
41
- *
42
- * @param input.reason Should contain the reason for the abort.
43
- */
44
- abort(input: {
45
- reason: string;
46
- }): "OK";
47
- }
48
- export declare class Planning implements IPlanning {
49
- private readonly fileMap;
50
- constructor(fileMap?: Record<Filename, FileContent>);
51
- createOrUpdateFiles(input: {
52
- files: Array<{
53
- reason: string;
54
- filename: `${string}.md`;
55
- markdown: string;
56
- }>;
57
- }): Promise<void>;
58
- removeFile(input: {
59
- filename: `${string}.md`;
60
- }): Promise<void>;
61
- abort(_input: {
62
- reason: string;
63
- }): "OK";
64
- /** @ignore */
65
- allFiles(): Record<string, string>;
66
- }
67
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"Planning.js","sourceRoot":"","sources":["../../src/analyze/Planning.ts"],"names":[],"mappings":";;;;;;;;;;;;AAiDA,MAAa,QAAQ;IACnB,YAA6B,UAAyC,EAAE;QAA3C,YAAO,GAAP,OAAO,CAAoC;IAAG,CAAC;IAEtE,mBAAmB,CAAC,KAMzB;;YACC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAEK,UAAU,CAAC,KAAmC;;YAClD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;KAAA;IAED,KAAK,CAAC,MAA0B;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc;IACd,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AA3BD,4BA2BC"}
@@ -1,126 +0,0 @@
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
- const agent = 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).map(([filename, content]) => {
74
- return {
75
- filename,
76
- content,
77
- content_length: content.length,
78
- };
79
- }),
80
- ),
81
- "</CurrentFiles>",
82
- "",
83
- `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.`,
84
- `<Linked Files>`,
85
- markdownFiles.map((filename) => {
86
- const isChecked = Object.keys(input.currentFiles).includes(
87
- filename,
88
- );
89
- return `- [${isChecked}] ${filename}`;
90
- }),
91
- `</Linked Files>`,
92
- "",
93
- "Write a long document, but keep your answer short.",
94
- "If you say the document is complete, the planner will finish writing the document.",
95
- "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.",
96
- "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.",
97
- "Be cautious: the planner will try to avoid work by interpreting your words in a way that lets them do less.",
98
- "The correct response from you should be:",
99
- "\“The document's quality is sufficient, so mark it as complete without any further requests. Now, proceed to write the next documents immediately.\”",
100
- "When requesting the next document to be written, you must include both the document title and a brief description of its content.",
101
- ].join("\n");
102
- },
103
- describe: () => {
104
- return "Answer only 'completion' or 'failure'.";
105
- },
106
- },
107
- },
108
- tokenUsage: ctx.usage(),
109
- });
110
-
111
- return agent;
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
- }
@@ -1,77 +0,0 @@
1
- type Filename = string;
2
- type FileContent = string;
3
-
4
- export interface IPlanning {
5
- /**
6
- * Generate multiple markdown files. if there is already created files,
7
- * overwrite it. Generate several markdown files at once.
8
- */
9
- createOrUpdateFiles(input: {
10
- files: Array<{
11
- /**
12
- * Describe briefly why you made this document, and if you have any plans
13
- * for the next one.
14
- */
15
- reason: string;
16
-
17
- /** Filename to generate or overwrite. */
18
- filename: `${string}.md`;
19
-
20
- /**
21
- * Markdown file content. Only write the content of the file. Do not
22
- * include any questions. This should contain only the contents of the
23
- * file. Do not write down any questions or appreciation.
24
- */
25
- markdown: string;
26
- }>;
27
- }): Promise<void>;
28
-
29
- /**
30
- * Remove markdown file.
31
- *
32
- * @param input.name Filename to remove
33
- */
34
- removeFile(input: { filename: `${string}.md` }): Promise<void>;
35
-
36
- /**
37
- * If you decide that you no longer need any reviews, or if the reviewer
38
- * refuses to do so, call abort. This is a function to end document creation
39
- * and review, and to respond to users.
40
- *
41
- * When there is content you are unsure about and need to ask the user a
42
- * question, abort the process and ask the user directly. The reason for
43
- * aborting should be included as the content of the question.
44
- *
45
- * @param input.reason Should contain the reason for the abort.
46
- */
47
- abort(input: { reason: string }): "OK";
48
- }
49
-
50
- export class Planning implements IPlanning {
51
- constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
52
-
53
- async createOrUpdateFiles(input: {
54
- files: Array<{
55
- reason: string;
56
- filename: `${string}.md`;
57
- markdown: string;
58
- }>;
59
- }): Promise<void> {
60
- input.files.forEach((file) => {
61
- this.fileMap[file.filename] = file.markdown;
62
- });
63
- }
64
-
65
- async removeFile(input: { filename: `${string}.md` }): Promise<void> {
66
- delete this.fileMap[input.filename];
67
- }
68
-
69
- abort(_input: { reason: string }): "OK" {
70
- return "OK";
71
- }
72
-
73
- /** @ignore */
74
- allFiles(): Record<string, string> {
75
- return this.fileMap;
76
- }
77
- }