@autobe/agent 0.3.9 → 0.3.12
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/analyze/AnalyzeAgent.d.ts +1 -1
- package/lib/analyze/AnalyzeAgent.js +149 -59
- package/lib/analyze/AnalyzeAgent.js.map +1 -1
- package/lib/analyze/CreateReviewerAgent.js +8 -7
- package/lib/analyze/CreateReviewerAgent.js.map +1 -1
- package/lib/analyze/Planning.d.ts +23 -20
- package/lib/analyze/Planning.js +4 -5
- package/lib/analyze/Planning.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +1 -1
- package/lib/index.mjs +158 -60
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +11 -5
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/package.json +4 -4
- package/src/analyze/AnalyzeAgent.ts +33 -22
- package/src/analyze/CreateReviewerAgent.ts +14 -14
- package/src/analyze/Planning.ts +28 -27
- package/src/constants/AutoBeSystemPromptConstant.ts +1 -1
- package/src/orchestrate/prisma/orchestratePrisma.ts +11 -3
|
@@ -26,13 +26,19 @@ const orchestratePrismaCompiler_1 = require("./orchestratePrismaCompiler");
|
|
|
26
26
|
const orchestratePrismaComponent_1 = require("./orchestratePrismaComponent");
|
|
27
27
|
const orchestratePrismaSchema_1 = require("./orchestratePrismaSchema");
|
|
28
28
|
const orchestratePrisma = (ctx) => (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
var _a, _b, _c, _d;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f;
|
|
30
30
|
const start = new Date();
|
|
31
|
+
ctx.dispatch({
|
|
32
|
+
type: "prismaStart",
|
|
33
|
+
created_at: start.toISOString(),
|
|
34
|
+
reason: props.reason,
|
|
35
|
+
step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
|
|
36
|
+
});
|
|
31
37
|
// COMPONENTS
|
|
32
38
|
const components = yield (0, orchestratePrismaComponent_1.orchestratePrismaComponents)(ctx);
|
|
33
39
|
if (components.type === "assistantMessage") {
|
|
34
|
-
ctx.dispatch(components);
|
|
35
40
|
ctx.histories().push(components);
|
|
41
|
+
ctx.dispatch(components);
|
|
36
42
|
return components;
|
|
37
43
|
}
|
|
38
44
|
else
|
|
@@ -41,7 +47,7 @@ const orchestratePrisma = (ctx) => (props) => __awaiter(void 0, void 0, void 0,
|
|
|
41
47
|
const events = yield (0, orchestratePrismaSchema_1.orchestratePrismaSchemas)(ctx, components.components);
|
|
42
48
|
// COMPILER
|
|
43
49
|
const files = Object.fromEntries(events.map((e) => [e.filename, e.content]));
|
|
44
|
-
const
|
|
50
|
+
const _g = yield (0, orchestratePrismaCompiler_1.orchestratePrismaCompiler)(ctx, files), { description } = _g, compiledResult = __rest(_g, ["description"]);
|
|
45
51
|
const result = processCompilerResult(compiledResult);
|
|
46
52
|
const history = {
|
|
47
53
|
type: "prisma",
|
|
@@ -51,7 +57,7 @@ const orchestratePrisma = (ctx) => (props) => __awaiter(void 0, void 0, void 0,
|
|
|
51
57
|
reason: props.reason,
|
|
52
58
|
description,
|
|
53
59
|
result: result,
|
|
54
|
-
step: (
|
|
60
|
+
step: (_d = (_c = ctx.state().analyze) === null || _c === void 0 ? void 0 : _c.step) !== null && _d !== void 0 ? _d : 0,
|
|
55
61
|
};
|
|
56
62
|
ctx.state().prisma = history;
|
|
57
63
|
ctx.histories().push(history);
|
|
@@ -61,7 +67,7 @@ const orchestratePrisma = (ctx) => (props) => __awaiter(void 0, void 0, void 0,
|
|
|
61
67
|
schemas: result.schemas,
|
|
62
68
|
document: result.document,
|
|
63
69
|
diagrams: result.diagrams,
|
|
64
|
-
step: (
|
|
70
|
+
step: (_f = (_e = ctx.state().analyze) === null || _e === void 0 ? void 0 : _e.step) !== null && _f !== void 0 ? _f : 0,
|
|
65
71
|
created_at: new Date().toISOString(),
|
|
66
72
|
});
|
|
67
73
|
return history;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestratePrisma.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/orchestratePrisma.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"orchestratePrisma.js","sourceRoot":"","sources":["../../../src/orchestrate/prisma/orchestratePrisma.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA,+BAA0B;AAI1B,2EAAwE;AACxE,6EAA2E;AAC3E,uEAAqE;AAE9D,MAAM,iBAAiB,GAC5B,CAAiC,GAAyB,EAAE,EAAE,CAC9D,CACE,KAA8B,EACgC,EAAE;;IAChE,MAAM,KAAK,GAAS,IAAI,IAAI,EAAE,CAAC;IAC/B,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,aAAa;QACnB,UAAU,EAAE,KAAK,CAAC,WAAW,EAAE;QAC/B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,IAAI,EAAE,MAAA,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,OAAO,0CAAE,IAAI,mCAAI,CAAC;KACrC,CAAC,CAAC;IAEH,aAAa;IACb,MAAM,UAAU,GAEkB,MAAM,IAAA,wDAA2B,EAAC,GAAG,CAAC,CAAC;IACzE,IAAI,UAAU,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QAC3C,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QACzB,OAAO,UAAU,CAAC;IACpB,CAAC;;QAAM,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEhC,UAAU;IACV,MAAM,MAAM,GAA+B,MAAM,IAAA,kDAAwB,EACvE,GAAG,EACH,UAAU,CAAC,UAAU,CACtB,CAAC;IAEF,WAAW;IACX,MAAM,KAAK,GAA2B,MAAM,CAAC,WAAW,CAC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AAhES,QAAA,iBAAiB,qBAgE1B;AAEJ;;;;;;;;GAQG;AACH,SAAS,qBAAqB,CAC5B,MAAmC;IAEnC,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;GAiBf,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC9B,uCACK,MAAM,KACT,OAAO,kCACF,MAAM,CAAC,OAAO,KACjB,aAAa,EAAE,OAAO,OAExB;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"tstl": "^3.0.0",
|
|
31
31
|
"typia": "^9.3.1",
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
|
-
"@autobe/interface": "^0.3.
|
|
33
|
+
"@autobe/interface": "^0.3.12"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
44
|
"ts-patch": "^3.3.0",
|
|
45
45
|
"typescript": "~5.8.3",
|
|
46
|
-
"@autobe/filesystem": "^0.3.
|
|
47
|
-
"@autobe/compiler": "^0.3.
|
|
46
|
+
"@autobe/filesystem": "^0.3.12",
|
|
47
|
+
"@autobe/compiler": "^0.3.12"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|
|
50
50
|
"ai",
|
|
@@ -13,7 +13,7 @@ type Filename = string;
|
|
|
13
13
|
type FileContent = string;
|
|
14
14
|
|
|
15
15
|
export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
16
|
-
private readonly
|
|
16
|
+
private readonly createInnerAgent: () => MicroAgentica<Model>;
|
|
17
17
|
private readonly fileMap: Record<Filename, FileContent> = {};
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
@@ -32,27 +32,36 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
32
32
|
this.pointer.value = { files };
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
AutoBeSystemPromptConstant.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"{% Example Documentation %}",
|
|
48
|
-
AutoBeSystemPromptConstant.ANALYZE_EXAMPLE,
|
|
35
|
+
|
|
36
|
+
this.createInnerAgent = (): MicroAgentica<Model> => {
|
|
37
|
+
const agent = new MicroAgentica({
|
|
38
|
+
controllers: [controller],
|
|
39
|
+
model: ctx.model,
|
|
40
|
+
vendor: ctx.vendor,
|
|
41
|
+
config: {
|
|
42
|
+
systemPrompt: {
|
|
43
|
+
common: () => {
|
|
44
|
+
return AutoBeSystemPromptConstant.ANALYZE.replace(
|
|
45
|
+
"{% Guidelines %}",
|
|
46
|
+
AutoBeSystemPromptConstant.ANALYZE_GUIDELINE,
|
|
49
47
|
)
|
|
50
|
-
|
|
48
|
+
.replace(
|
|
49
|
+
"{% Example Documentation %}",
|
|
50
|
+
AutoBeSystemPromptConstant.ANALYZE_EXAMPLE,
|
|
51
|
+
)
|
|
52
|
+
.replace("{% User Locale %}", ctx.config?.locale ?? "en-US");
|
|
53
|
+
},
|
|
54
|
+
describe: () => {
|
|
55
|
+
return "Answer only 'completion' or 'failure'.";
|
|
56
|
+
},
|
|
51
57
|
},
|
|
52
58
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
tokenUsage: ctx.usage(),
|
|
60
|
+
histories: [],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return agent;
|
|
64
|
+
};
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
/**
|
|
@@ -62,7 +71,7 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
62
71
|
* @returns
|
|
63
72
|
*/
|
|
64
73
|
async conversate(content: string): Promise<string> {
|
|
65
|
-
const response = await this.
|
|
74
|
+
const response = await this.createInnerAgent().conversate(content);
|
|
66
75
|
const lastMessage = response[response.length - 1]!;
|
|
67
76
|
|
|
68
77
|
if ("text" in lastMessage) {
|
|
@@ -116,6 +125,8 @@ export class AnalyzeAgent<Model extends ILlmSchema.Model> {
|
|
|
116
125
|
);
|
|
117
126
|
}
|
|
118
127
|
}
|
|
128
|
+
|
|
129
|
+
return `If the document is not 1,000 characters, please fill it out in more abundance, and if it exceeds 1,000 characters, please fill out the next document. If you don't have the next document, you can exit now.`;
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
return "COMPLETE";
|
|
@@ -147,8 +158,8 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
147
158
|
props.build(props.execute.allFiles());
|
|
148
159
|
return response;
|
|
149
160
|
},
|
|
150
|
-
|
|
151
|
-
const response = props.execute.
|
|
161
|
+
createOrUpdateFiles: (input) => {
|
|
162
|
+
const response = props.execute.createOrUpdateFiles(input);
|
|
152
163
|
props.build(props.execute.allFiles());
|
|
153
164
|
return response;
|
|
154
165
|
},
|
|
@@ -27,7 +27,7 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
|
|
|
27
27
|
),
|
|
28
28
|
);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const agent = new MicroAgentica({
|
|
31
31
|
model: ctx.model,
|
|
32
32
|
vendor: ctx.vendor,
|
|
33
33
|
controllers: [],
|
|
@@ -70,17 +70,13 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
|
|
|
70
70
|
"At this time, the document should be newly created with the name attached to the link, not modified.",
|
|
71
71
|
"<CurrentFiles>",
|
|
72
72
|
JSON.stringify(
|
|
73
|
-
Object.entries(input.currentFiles)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
};
|
|
81
|
-
}),
|
|
82
|
-
null,
|
|
83
|
-
2,
|
|
73
|
+
Object.entries(input.currentFiles).map(([filename, content]) => {
|
|
74
|
+
return {
|
|
75
|
+
filename,
|
|
76
|
+
content,
|
|
77
|
+
content_length: content.length,
|
|
78
|
+
};
|
|
79
|
+
}),
|
|
84
80
|
),
|
|
85
81
|
"</CurrentFiles>",
|
|
86
82
|
"",
|
|
@@ -95,20 +91,24 @@ export const createReviewerAgent = <Model extends ILlmSchema.Model>(
|
|
|
95
91
|
`</Linked Files>`,
|
|
96
92
|
"",
|
|
97
93
|
"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
94
|
"If you say the document is complete, the planner will finish writing the document.",
|
|
100
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.",
|
|
101
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.",
|
|
102
97
|
"Be cautious: the planner will try to avoid work by interpreting your words in a way that lets them do less.",
|
|
103
98
|
"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
|
|
99
|
+
"\“The document's quality is sufficient, so mark it as complete without any further requests. Now, proceed to write the next documents immediately.\”",
|
|
105
100
|
"When requesting the next document to be written, you must include both the document title and a brief description of its content.",
|
|
106
101
|
].join("\n");
|
|
107
102
|
},
|
|
103
|
+
describe: () => {
|
|
104
|
+
return "Answer only 'completion' or 'failure'.";
|
|
105
|
+
},
|
|
108
106
|
},
|
|
109
107
|
},
|
|
110
108
|
tokenUsage: ctx.usage(),
|
|
111
109
|
});
|
|
110
|
+
|
|
111
|
+
return agent;
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
export interface ICreateReviewerAgentInput {
|
package/src/analyze/Planning.ts
CHANGED
|
@@ -3,26 +3,27 @@ type FileContent = string;
|
|
|
3
3
|
|
|
4
4
|
export interface IPlanning {
|
|
5
5
|
/**
|
|
6
|
-
* Generate markdown
|
|
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.
|
|
6
|
+
* Generate multiple markdown files. if there is already created files,
|
|
7
|
+
* overwrite it. Generate several markdown files at once.
|
|
13
8
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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;
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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.
|
|
23
|
+
*/
|
|
24
|
+
markdown: string;
|
|
25
|
+
}>;
|
|
26
|
+
}): Promise<void>;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Remove markdown file.
|
|
@@ -48,18 +49,18 @@ export interface IPlanning {
|
|
|
48
49
|
export class Planning implements IPlanning {
|
|
49
50
|
constructor(private readonly fileMap: Record<Filename, FileContent> = {}) {}
|
|
50
51
|
|
|
51
|
-
async
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
async createOrUpdateFiles(input: {
|
|
53
|
+
files: Array<{
|
|
54
|
+
reason: string;
|
|
55
|
+
filename: `${string}.md`;
|
|
56
|
+
markdown: string;
|
|
57
|
+
}>;
|
|
55
58
|
}): Promise<void> {
|
|
56
|
-
|
|
59
|
+
input.files.forEach((file) => {
|
|
60
|
+
this.fileMap[file.filename] = file.markdown;
|
|
61
|
+
});
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
// async readFile(input: { filename: `${string}.md` }): Promise<string> {
|
|
60
|
-
// return this.fileMap[input.filename];
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
64
|
async removeFile(input: { filename: `${string}.md` }): Promise<void> {
|
|
64
65
|
delete this.fileMap[input.filename];
|
|
65
66
|
}
|