@autobe/agent 0.11.2 → 0.13.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/AutoBeAgent.d.ts +3 -146
- package/lib/AutoBeAgent.js +6 -180
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeAgentBase.d.ts +18 -0
- package/lib/AutoBeAgentBase.js +54 -0
- package/lib/AutoBeAgentBase.js.map +1 -0
- package/lib/AutoBeMockAgent.d.ts +14 -0
- package/lib/AutoBeMockAgent.js +136 -0
- package/lib/AutoBeMockAgent.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +8 -4
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/factory/getAutoBeGenerated.d.ts +3 -4
- package/lib/factory/getAutoBeGenerated.js +6 -250
- package/lib/factory/getAutoBeGenerated.js.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +886 -396
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +6 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.d.ts +4 -1
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js +8 -3
- package/lib/orchestrate/analyze/writeDocumentUntilReviewPassed.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +11 -2
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +46 -15
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.d.ts +10 -0
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.js +545 -0
- package/lib/orchestrate/realize/orchestrateRealizeDecorator.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +12 -9
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.d.ts +85 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +1 -1
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +24 -30
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeDecorator.d.ts +4 -0
- package/lib/orchestrate/realize/transformRealizeDecorator.js +32 -0
- package/lib/orchestrate/realize/transformRealizeDecorator.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.d.ts +6 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js +49 -0
- package/lib/orchestrate/realize/transformRealizeDecoratorCorrectHistories.js.map +1 -0
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +30 -11
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +2 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/utils/backoffRetry.d.ts +18 -0
- package/lib/utils/backoffRetry.js +38 -0
- package/lib/utils/backoffRetry.js.map +1 -1
- package/package.json +8 -8
- package/src/AutoBeAgent.ts +10 -203
- package/src/AutoBeAgentBase.ts +78 -0
- package/src/AutoBeMockAgent.ts +164 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +8 -4
- package/src/factory/getAutoBeGenerated.ts +8 -13
- package/src/index.ts +3 -1
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +7 -1
- package/src/orchestrate/analyze/writeDocumentUntilReviewPassed.ts +14 -1
- package/src/orchestrate/realize/orchestrateRealize.ts +11 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +26 -4
- package/src/orchestrate/realize/orchestrateRealizeDecorator.ts +286 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +12 -9
- package/src/orchestrate/realize/structures/IAutoBeRealizeDecoratorApplication.ts +94 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +22 -29
- package/src/orchestrate/realize/transformRealizeDecorator.ts +37 -0
- package/src/orchestrate/realize/transformRealizeDecoratorCorrectHistories.ts +58 -0
- package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +34 -9
- package/src/orchestrate/test/orchestrateTest.ts +1 -0
- package/src/orchestrate/test/orchestrateTestCorrect.ts +1 -1
- package/src/utils/backoffRetry.ts +56 -0
|
@@ -20,7 +20,7 @@ const orchestrateRealizeCoder_1 = require("./orchestrateRealizeCoder");
|
|
|
20
20
|
const orchestrateRealizePlanner_1 = require("./orchestrateRealizePlanner");
|
|
21
21
|
const IAutoBeRealizeFailedSymbol_1 = require("./structures/IAutoBeRealizeFailedSymbol");
|
|
22
22
|
function writeCodeUntilCompilePassed(ctx_1, ops_1) {
|
|
23
|
-
return __awaiter(this, arguments, void 0, function* (ctx, ops, retry =
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* (ctx, ops, retry = 3) {
|
|
24
24
|
var _a;
|
|
25
25
|
const files = Object.entries(yield ctx.files({ dbms: "postgres" }))
|
|
26
26
|
.filter(([key]) => {
|
|
@@ -33,10 +33,13 @@ function writeCodeUntilCompilePassed(ctx_1, ops_1) {
|
|
|
33
33
|
current: [],
|
|
34
34
|
total: [],
|
|
35
35
|
};
|
|
36
|
+
ops = ops.filter((_el, i) => i < 10);
|
|
36
37
|
for (let i = 0; i < retry; i++) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const targets = ops.filter((op) => shouldProcessOperation(op, diagnostics.current));
|
|
39
|
+
const metadata = { total: targets.length, count: 0 };
|
|
40
|
+
const generatedCodes = yield Promise.all(targets.map((op) => {
|
|
41
|
+
return process(ctx, metadata, op, diagnostics, entireCodes);
|
|
42
|
+
}));
|
|
40
43
|
for (const c of generatedCodes) {
|
|
41
44
|
if (c.type === "success") {
|
|
42
45
|
entireCodes[c.result.filename] = {
|
|
@@ -64,7 +67,7 @@ function writeCodeUntilCompilePassed(ctx_1, ops_1) {
|
|
|
64
67
|
else if (compiled.type === "failure") {
|
|
65
68
|
diagnostics.current = compiled.diagnostics;
|
|
66
69
|
diagnostics.total = [...diagnostics.total, ...compiled.diagnostics];
|
|
67
|
-
console.log(JSON.stringify(diagnostics, null, 2), i);
|
|
70
|
+
console.log(JSON.stringify(diagnostics.current, null, 2), `현재 에러의 수: ${diagnostics.current.length}\n`, `현재 시도 수: ${i}`);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
73
|
return Object.entries(entireCodes).map(([filename, { content }]) => {
|
|
@@ -90,20 +93,36 @@ function loadTemplateFiles(templateFiles) {
|
|
|
90
93
|
return result;
|
|
91
94
|
});
|
|
92
95
|
}
|
|
93
|
-
function process(ctx, op, diagnostics, entireCodes) {
|
|
96
|
+
function process(ctx, metadata, op, diagnostics, entireCodes) {
|
|
94
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
const result = yield (0, RealizePipe_1.pipe)(op, (op) => (0, orchestrateRealizePlanner_1.orchestrateRealizePlanner)(ctx, op), (p) => {
|
|
98
|
+
const result = yield (0, RealizePipe_1.pipe)(op, (op) => (0, orchestrateRealizePlanner_1.orchestrateRealizePlanner)(ctx, op), (p) => __awaiter(this, void 0, void 0, function* () {
|
|
96
99
|
var _a, _b;
|
|
97
100
|
const filename = `src/providers/${p.functionName}.ts`;
|
|
98
101
|
const t = diagnostics.total.filter((el) => el.file === filename);
|
|
99
102
|
const d = diagnostics.current.filter((el) => el.file === filename);
|
|
100
103
|
const c = (_b = (_a = entireCodes[filename]) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : null;
|
|
101
|
-
return (0, orchestrateRealizeCoder_1.orchestrateRealizeCoder)(ctx, op, p, c, t, d)
|
|
102
|
-
|
|
104
|
+
return (0, orchestrateRealizeCoder_1.orchestrateRealizeCoder)(ctx, op, p, c, t, d).then((res) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
if (res === IAutoBeRealizeFailedSymbol_1.FAILED) {
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
ctx.dispatch({
|
|
110
|
+
type: "realizeProgress",
|
|
111
|
+
filename: res.filename,
|
|
112
|
+
content: res.implementationCode,
|
|
113
|
+
completed: ++metadata.count,
|
|
114
|
+
created_at: new Date().toISOString(),
|
|
115
|
+
step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
|
|
116
|
+
total: metadata.total,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return res;
|
|
120
|
+
});
|
|
121
|
+
}));
|
|
103
122
|
if (result === IAutoBeRealizeFailedSymbol_1.FAILED) {
|
|
104
|
-
return { type: "failed", op, result };
|
|
123
|
+
return { type: "failed", op: op, result };
|
|
105
124
|
}
|
|
106
|
-
return { type: "success", op, result: result };
|
|
125
|
+
return { type: "success", op: op, result: result };
|
|
107
126
|
});
|
|
108
127
|
}
|
|
109
128
|
function shouldProcessOperation(op, currentDiagnostics) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeCodeUntilCompilePassed.js","sourceRoot":"","sources":["../../../src/orchestrate/realize/writeCodeUntilCompilePassed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,
|
|
1
|
+
{"version":3,"file":"writeCodeUntilCompilePassed.js","sourceRoot":"","sources":["../../../src/orchestrate/realize/writeCodeUntilCompilePassed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,kEAmGC;AA9GD,0CAAuC;AACvC,gDAAwB;AAGxB,+CAAqC;AACrC,uEAAoE;AACpE,2EAAwE;AAGxE,wFAAiE;AAEjE,SAAsB,2BAA2B;yDAG/C,GAAyB,EACzB,GA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AC,KAAK,EAAE,CAAC,SAAS,0CAAE,IAAI,mCAAI,CAAC;KACvC,CAAC;IACF,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,KAAK,CAAC,WAAW,EAAE;QAC/B,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACrE,QAAQ;QACR,IAAI,EAAE,MAAA,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,SAAS,0CAAE,IAAI,mCAAI,CAAC;KACvC,CAAC,CAAC;IACH,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,OAAO,CAAC;IAC3B,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC,CAAA,CAAC;AApFS,QAAA,eAAe,mBAoFxB"}
|
|
@@ -98,7 +98,8 @@ const compile = (ctx, func) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
98
98
|
};
|
|
99
99
|
});
|
|
100
100
|
const predicate = (ctx, content, event, life) => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
-
|
|
101
|
+
if (event.result.type === "failure")
|
|
102
|
+
ctx.dispatch(event);
|
|
102
103
|
return event.result.type === "failure"
|
|
103
104
|
? correct(ctx, content, event, life - 1)
|
|
104
105
|
: event;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrateTestCorrect.js","sourceRoot":"","sources":["../../../src/orchestrate/test/orchestrateTestCorrect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAoE;AAQpE,kDAA0B;AAG1B,uEAAoE;AACpE,iEAA8D;AAC9D,uDAAoD;AACpD,iEAA8D;AA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AC;AACvD,CAAC,CAAA,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAiC,KAI1D,EAAqC,EAAE;IACtC,IAAA,qCAAiB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE/B,MAAM,WAAW,GAA2B,UAAU,CACpD,KAAK,CAAC,KAAK,CACyB,CAAC;IACvC,OAAO;QACL,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,kBAAkB;QACxB,WAAW;QACX,OAAO,EAAE;YACP,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,IAAI,CAAC,KAAK,GAAG,IAAA,mCAAgB,EAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC3D,IAAI,CAAC,KAAK,GAAG,IAAA,mCAAgB,EAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC3D,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;SACsC;KAC1C,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMT,CAAC;AACJ,MAAM,UAAU,GAAG;IACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIJ;IACH,MAAM;IACN,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;CACd,CAAC"}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
export interface RetryOptions {
|
|
2
|
+
/** Maximum number of retry attempts (default: 5) */
|
|
3
|
+
maxRetries: number;
|
|
4
|
+
/** Base delay in milliseconds (default: 2000) */
|
|
5
|
+
baseDelay: number;
|
|
6
|
+
/** Maximum delay in milliseconds (default: 60_000) */
|
|
7
|
+
maxDelay: number;
|
|
8
|
+
/** Jitter factor for randomization (0-1, default: 0.3) */
|
|
9
|
+
jitter: number;
|
|
10
|
+
/** Function to determine if error should trigger retry (default: isRetryError) */
|
|
11
|
+
handleError: (error: any) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @param fn Function to Apply the retry logic.
|
|
15
|
+
* @param maxRetries How many time to try. Max Retry is 5.
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function randomBackoffRetry<T>(fn: () => Promise<T>, options?: Partial<RetryOptions>): Promise<T>;
|
|
1
19
|
export declare function randomBackoffStrategy(props: {
|
|
2
20
|
count: number;
|
|
3
21
|
error: unknown;
|
|
@@ -1,7 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.randomBackoffRetry = randomBackoffRetry;
|
|
3
13
|
exports.randomBackoffStrategy = randomBackoffStrategy;
|
|
14
|
+
/**
|
|
15
|
+
* @param fn Function to Apply the retry logic.
|
|
16
|
+
* @param maxRetries How many time to try. Max Retry is 5.
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
function randomBackoffRetry(fn_1) {
|
|
20
|
+
return __awaiter(this, arguments, void 0, function* (fn, options = {}) {
|
|
21
|
+
const { maxRetries = 5, baseDelay = 4000, maxDelay = 60000, jitter = 0.8, handleError = isRetryError, } = options;
|
|
22
|
+
let lastError;
|
|
23
|
+
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
24
|
+
try {
|
|
25
|
+
return yield fn();
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
lastError = err;
|
|
29
|
+
if (attempt === maxRetries - 1)
|
|
30
|
+
throw err;
|
|
31
|
+
if (!handleError(err))
|
|
32
|
+
throw err;
|
|
33
|
+
const tempDelay = Math.min(baseDelay * 2 ** attempt, maxDelay);
|
|
34
|
+
const delay = tempDelay * (1 + Math.random() * jitter);
|
|
35
|
+
yield new Promise((res) => setTimeout(res, delay));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
throw lastError;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
4
41
|
function randomBackoffStrategy(props) {
|
|
42
|
+
console.log("randomBackoffStrategy");
|
|
5
43
|
const { count, error } = props;
|
|
6
44
|
if (count > 5) {
|
|
7
45
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backoffRetry.js","sourceRoot":"","sources":["../../src/utils/backoffRetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backoffRetry.js","sourceRoot":"","sources":["../../src/utils/backoffRetry.ts"],"names":[],"mappings":";;;;;;;;;;;AAqBA,gDAgCC;AAED,sDAqBC;AA5DD;;;;GAIG;AACH,SAAsB,kBAAkB;yDACtC,EAAoB,EACpB,UAAiC,EAAE;QAEnC,MAAM,EACJ,UAAU,GAAG,CAAC,EACd,SAAS,GAAG,IAAK,EACjB,QAAQ,GAAG,KAAM,EACjB,MAAM,GAAG,GAAG,EACZ,WAAW,GAAG,YAAY,GAC3B,GAAG,OAAO,CAAC;QAEZ,IAAI,SAAkB,CAAC;QAEvB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,G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AK,uBAAL,KAAK,CAAE,IAAI,MAAK,YAAY,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,MAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAkB,0CAAE,UAAU,CACpC,2EAA2E,CAC5E,EACD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@agentica/core": "^0.30.
|
|
23
|
+
"@agentica/core": "^0.30.5",
|
|
24
24
|
"@prisma/internals": "^6.7.0",
|
|
25
|
-
"@samchon/openapi": "^4.
|
|
25
|
+
"@samchon/openapi": "^4.6.0",
|
|
26
26
|
"openai": "^5.2.0",
|
|
27
27
|
"tstl": "^3.0.0",
|
|
28
|
-
"typia": "^9.
|
|
28
|
+
"typia": "^9.6.0",
|
|
29
29
|
"uuid": "^11.1.0",
|
|
30
|
-
"@autobe/interface": "^0.
|
|
31
|
-
"@autobe/utils": "^0.
|
|
30
|
+
"@autobe/interface": "^0.13.0",
|
|
31
|
+
"@autobe/utils": "^0.13.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"ts-node": "^10.9.2",
|
|
41
41
|
"ts-patch": "^3.3.0",
|
|
42
42
|
"typescript": "~5.8.3",
|
|
43
|
-
"@autobe/
|
|
44
|
-
"@autobe/
|
|
43
|
+
"@autobe/compiler": "^0.13.0",
|
|
44
|
+
"@autobe/filesystem": "^0.13.0"
|
|
45
45
|
},
|
|
46
46
|
"keywords": [
|
|
47
47
|
"ai",
|
package/src/AutoBeAgent.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
import { IAgenticaVendor, MicroAgentica } from "@agentica/core";
|
|
2
2
|
import {
|
|
3
3
|
AutoBeAssistantMessageHistory,
|
|
4
|
-
AutoBeEvent,
|
|
5
4
|
AutoBeHistory,
|
|
6
5
|
AutoBeUserMessageContent,
|
|
7
6
|
AutoBeUserMessageHistory,
|
|
7
|
+
IAutoBeAgent,
|
|
8
8
|
IAutoBeCompilerListener,
|
|
9
|
-
IAutoBeGetFilesOptions,
|
|
10
9
|
} from "@autobe/interface";
|
|
11
10
|
import { ILlmSchema } from "@samchon/openapi";
|
|
12
11
|
import { Semaphore, Singleton } from "tstl";
|
|
13
12
|
import { v4 } from "uuid";
|
|
14
13
|
|
|
14
|
+
import { AutoBeAgentBase } from "./AutoBeAgentBase";
|
|
15
15
|
import { AutoBeContext } from "./context/AutoBeContext";
|
|
16
16
|
import { AutoBeState } from "./context/AutoBeState";
|
|
17
17
|
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
18
18
|
import { createAgenticaHistory } from "./factory/createAgenticaHistory";
|
|
19
19
|
import { createAutoBeController } from "./factory/createAutoBeApplication";
|
|
20
20
|
import { createAutoBeState } from "./factory/createAutoBeState";
|
|
21
|
-
import { getAutoBeGenerated } from "./factory/getAutoBeGenerated";
|
|
22
21
|
import { transformFacadeStateMessage } from "./orchestrate/facade/transformFacadeStateMessage";
|
|
23
22
|
import { IAutoBeProps } from "./structures/IAutoBeProps";
|
|
24
23
|
import { randomBackoffStrategy } from "./utils/backoffRetry";
|
|
25
|
-
import { emplaceMap } from "./utils/emplaceMap";
|
|
26
24
|
|
|
27
25
|
/**
|
|
28
26
|
* Main agent class that orchestrates the entire vibe coding pipeline through
|
|
@@ -48,7 +46,10 @@ import { emplaceMap } from "./utils/emplaceMap";
|
|
|
48
46
|
*
|
|
49
47
|
* @author Samchon
|
|
50
48
|
*/
|
|
51
|
-
export class AutoBeAgent<Model extends ILlmSchema.Model>
|
|
49
|
+
export class AutoBeAgent<Model extends ILlmSchema.Model>
|
|
50
|
+
extends AutoBeAgentBase
|
|
51
|
+
implements IAutoBeAgent
|
|
52
|
+
{
|
|
52
53
|
/** @internal */
|
|
53
54
|
private readonly props_: IAutoBeProps<Model>;
|
|
54
55
|
|
|
@@ -67,12 +68,6 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
67
68
|
/** @internal */
|
|
68
69
|
private readonly usage_: AutoBeTokenUsage;
|
|
69
70
|
|
|
70
|
-
/** @internal */
|
|
71
|
-
private readonly listeners_: Map<
|
|
72
|
-
string,
|
|
73
|
-
Set<(event: AutoBeEvent) => Promise<void> | void>
|
|
74
|
-
>;
|
|
75
|
-
|
|
76
71
|
/* -----------------------------------------------------------
|
|
77
72
|
CONSTRUCTOR
|
|
78
73
|
----------------------------------------------------------- */
|
|
@@ -95,11 +90,13 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
95
90
|
*/
|
|
96
91
|
public constructor(props: IAutoBeProps<Model>) {
|
|
97
92
|
// INITIALIZE MEMBERS
|
|
93
|
+
super({
|
|
94
|
+
compiler: () => this.context_.compiler(),
|
|
95
|
+
state: () => this.state_,
|
|
96
|
+
});
|
|
98
97
|
this.props_ = props;
|
|
99
98
|
this.histories_ = props.histories?.slice() ?? [];
|
|
100
99
|
this.state_ = createAutoBeState(this.histories_);
|
|
101
|
-
this.listeners_ = new Map();
|
|
102
|
-
|
|
103
100
|
this.usage_ =
|
|
104
101
|
props.tokenUsage instanceof AutoBeTokenUsage
|
|
105
102
|
? props.tokenUsage
|
|
@@ -202,30 +199,6 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
202
199
|
/* -----------------------------------------------------------
|
|
203
200
|
ACCESSORS
|
|
204
201
|
----------------------------------------------------------- */
|
|
205
|
-
/**
|
|
206
|
-
* Engages in conversation with the agent to drive the vibe coding process.
|
|
207
|
-
*
|
|
208
|
-
* Accepts user input in multiple formats including simple text strings,
|
|
209
|
-
* single multimodal content items, or arrays of content supporting text,
|
|
210
|
-
* images, file uploads, and audio input. The conversation serves as the
|
|
211
|
-
* primary interface for expressing requirements, providing feedback, and
|
|
212
|
-
* guiding the development process through natural language interaction.
|
|
213
|
-
*
|
|
214
|
-
* The agent analyzes the conversation context to determine appropriate
|
|
215
|
-
* actions, potentially activating specialized agents (Analyze, Prisma,
|
|
216
|
-
* Interface, Test, Realize) through function calling based on user needs.
|
|
217
|
-
* Real-time progress events are fired through registered listeners while the
|
|
218
|
-
* conversation processes.
|
|
219
|
-
*
|
|
220
|
-
* Returns all history records generated during this conversation turn,
|
|
221
|
-
* including user messages, assistant responses, and any development
|
|
222
|
-
* activities triggered by the interaction. This enables clients to track both
|
|
223
|
-
* conversational flow and development progress.
|
|
224
|
-
*
|
|
225
|
-
* @param content User input as text, single content item, or multimodal array
|
|
226
|
-
* @returns Promise resolving to array of history records from this
|
|
227
|
-
* conversation
|
|
228
|
-
*/
|
|
229
202
|
public async conversate(
|
|
230
203
|
content: string | AutoBeUserMessageContent | AutoBeUserMessageContent[],
|
|
231
204
|
): Promise<AutoBeHistory[]> {
|
|
@@ -253,103 +226,10 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
253
226
|
return this.histories_.slice(index);
|
|
254
227
|
}
|
|
255
228
|
|
|
256
|
-
/**
|
|
257
|
-
* Retrieves all generated files from the current development session.
|
|
258
|
-
*
|
|
259
|
-
* Transforms the complete conversation-driven development process into a
|
|
260
|
-
* comprehensive collection of deployable artifacts, including requirements
|
|
261
|
-
* documentation, database schemas, API specifications, NestJS implementation
|
|
262
|
-
* code, and test suites. The generated files represent a fully functional
|
|
263
|
-
* backend application ready for immediate deployment or further
|
|
264
|
-
* customization.
|
|
265
|
-
*
|
|
266
|
-
* The method produces a meticulously organized project structure that
|
|
267
|
-
* reflects professional software development standards. Requirements analysis
|
|
268
|
-
* documents capture and formalize your conversational input into structured
|
|
269
|
-
* technical specifications, providing clear traceability from user intent to
|
|
270
|
-
* final implementation. Database artifacts include Prisma schemas with
|
|
271
|
-
* precise type definitions, relationships, and constraints, along with
|
|
272
|
-
* migration files for proper database initialization and evolution.
|
|
273
|
-
*
|
|
274
|
-
* The API layer emerges through comprehensive OpenAPI specifications
|
|
275
|
-
* documenting every endpoint, request format, response structure, and error
|
|
276
|
-
* condition. Generated NestJS controllers, DTOs, and service classes
|
|
277
|
-
* implement these specifications with TypeScript's strong typing system
|
|
278
|
-
* providing compile-time safety. Quality assurance is embedded throughout
|
|
279
|
-
* with complete test suites covering both unit and end-to-end scenarios.
|
|
280
|
-
*
|
|
281
|
-
* The database configuration specified through the `dbms` option
|
|
282
|
-
* fundamentally shapes the entire generated codebase. PostgreSQL
|
|
283
|
-
* configuration produces production-ready code with robust connection pooling
|
|
284
|
-
* and enterprise-grade optimizations, while SQLite generates lightweight code
|
|
285
|
-
* perfect for local development and rapid prototyping without external
|
|
286
|
-
* dependencies.
|
|
287
|
-
*
|
|
288
|
-
* All artifacts maintain perfect consistency across the chosen database
|
|
289
|
-
* system, from Prisma configurations and connection strings to Docker compose
|
|
290
|
-
* files and environment templates. This deep integration ensures immediate
|
|
291
|
-
* deployment compatibility without manual configuration adjustments.
|
|
292
|
-
*
|
|
293
|
-
* @param options Configuration specifying the target database management
|
|
294
|
-
* system and other code generation preferences that influence the structure
|
|
295
|
-
* and characteristics of the generated project files
|
|
296
|
-
* @returns Promise resolving to key-value pairs mapping logical file paths to
|
|
297
|
-
* complete file contents for all generated development artifacts, ready for
|
|
298
|
-
* immediate file system operations, build integration, or deployment
|
|
299
|
-
* workflows
|
|
300
|
-
*/
|
|
301
|
-
public async getFiles(
|
|
302
|
-
options?: Partial<IAutoBeGetFilesOptions>,
|
|
303
|
-
): Promise<Record<string, string>> {
|
|
304
|
-
return getAutoBeGenerated(
|
|
305
|
-
await this.getContext(),
|
|
306
|
-
this.histories_,
|
|
307
|
-
this.usage_,
|
|
308
|
-
options,
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Retrieves the complete conversation and development history.
|
|
314
|
-
*
|
|
315
|
-
* Returns the chronologically ordered record of all events from the current
|
|
316
|
-
* session including user messages, assistant responses, development phase
|
|
317
|
-
* activities, progress events, and completion notifications. This
|
|
318
|
-
* comprehensive history enables conversation replay, development process
|
|
319
|
-
* analysis, and understanding of how requirements evolved into working
|
|
320
|
-
* software.
|
|
321
|
-
*
|
|
322
|
-
* The history provides complete transparency into the vibe coding process,
|
|
323
|
-
* showing both conversational interactions and behind-the-scenes development
|
|
324
|
-
* activities. This information is valuable for debugging, process
|
|
325
|
-
* improvement, and educational purposes to understand the agent's
|
|
326
|
-
* decision-making process.
|
|
327
|
-
*
|
|
328
|
-
* @returns Chronologically ordered array of all history records including
|
|
329
|
-
* messages, events, and development activities
|
|
330
|
-
*/
|
|
331
229
|
public getHistories(): AutoBeHistory[] {
|
|
332
230
|
return this.histories_;
|
|
333
231
|
}
|
|
334
232
|
|
|
335
|
-
/**
|
|
336
|
-
* Retrieves comprehensive AI token usage statistics for the current session.
|
|
337
|
-
*
|
|
338
|
-
* Returns detailed breakdown of token consumption across all specialized
|
|
339
|
-
* agents and processing phases, enabling cost monitoring, performance
|
|
340
|
-
* analysis, and optimization of AI resource utilization. Statistics include
|
|
341
|
-
* aggregate totals and component-specific breakdowns with input/output
|
|
342
|
-
* categorization, caching analysis, and reasoning token tracking.
|
|
343
|
-
*
|
|
344
|
-
* Token usage data is essential for understanding the computational costs of
|
|
345
|
-
* different development phases and optimizing AI efficiency. The breakdown
|
|
346
|
-
* helps identify which agents or operations consume the most resources,
|
|
347
|
-
* enabling targeted optimization efforts while maintaining development
|
|
348
|
-
* quality.
|
|
349
|
-
*
|
|
350
|
-
* @returns Comprehensive token usage statistics with detailed breakdowns by
|
|
351
|
-
* agent, operation type, and consumption category
|
|
352
|
-
*/
|
|
353
233
|
public getTokenUsage(): AutoBeTokenUsage {
|
|
354
234
|
return this.usage_;
|
|
355
235
|
}
|
|
@@ -358,77 +238,4 @@ export class AutoBeAgent<Model extends ILlmSchema.Model> {
|
|
|
358
238
|
public getContext(): AutoBeContext<Model> {
|
|
359
239
|
return this.context_;
|
|
360
240
|
}
|
|
361
|
-
|
|
362
|
-
/* -----------------------------------------------------------
|
|
363
|
-
EVENT HANDLERS
|
|
364
|
-
----------------------------------------------------------- */
|
|
365
|
-
/**
|
|
366
|
-
* Registers an event listener for specific development phase events.
|
|
367
|
-
*
|
|
368
|
-
* Enables client applications to receive real-time notifications about
|
|
369
|
-
* conversation flow, development progress, and completion events throughout
|
|
370
|
-
* the vibe coding pipeline. Event listeners provide visibility into agent
|
|
371
|
-
* activities and enable responsive user interfaces that can display progress,
|
|
372
|
-
* handle artifacts, and provide feedback.
|
|
373
|
-
*
|
|
374
|
-
* The type-safe event system ensures that listeners receive properly typed
|
|
375
|
-
* events corresponding to their registration type, enabling robust event
|
|
376
|
-
* handling without runtime type issues. Multiple listeners can be registered
|
|
377
|
-
* for the same event type to support complex notification requirements.
|
|
378
|
-
*
|
|
379
|
-
* @param type Event type to listen for (e.g., "analyzeComplete",
|
|
380
|
-
* "prismaStart")
|
|
381
|
-
* @param listener Callback function that receives the typed event when fired
|
|
382
|
-
* @returns The agent instance for method chaining
|
|
383
|
-
*/
|
|
384
|
-
public on<Type extends AutoBeEvent.Type>(
|
|
385
|
-
type: Type,
|
|
386
|
-
listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void,
|
|
387
|
-
): this {
|
|
388
|
-
emplaceMap(this.listeners_, type, () => new Set()).add(
|
|
389
|
-
listener as (event: AutoBeEvent) => any,
|
|
390
|
-
);
|
|
391
|
-
return this;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Unregisters a previously registered event listener.
|
|
396
|
-
*
|
|
397
|
-
* Removes the specified event listener from the agent's notification system,
|
|
398
|
-
* stopping further event notifications for that particular listener function.
|
|
399
|
-
* This is useful for cleanup, dynamic listener management, or when components
|
|
400
|
-
* no longer need to receive specific event notifications.
|
|
401
|
-
*
|
|
402
|
-
* The listener function reference must exactly match the function that was
|
|
403
|
-
* originally registered with {@link on} for successful removal. If no matching
|
|
404
|
-
* listener is found, the operation has no effect.
|
|
405
|
-
*
|
|
406
|
-
* @param type Event type the listener was registered for
|
|
407
|
-
* @param listener The exact listener function reference to remove
|
|
408
|
-
* @returns The agent instance for method chaining
|
|
409
|
-
*/
|
|
410
|
-
public off<Type extends AutoBeEvent.Type>(
|
|
411
|
-
type: Type,
|
|
412
|
-
listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void,
|
|
413
|
-
): this {
|
|
414
|
-
const set = this.listeners_.get(type);
|
|
415
|
-
if (set === undefined) return this;
|
|
416
|
-
|
|
417
|
-
set.delete(listener as (event: AutoBeEvent) => any);
|
|
418
|
-
if (set.size === 0) this.listeners_.delete(type);
|
|
419
|
-
return this;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/** @internal */
|
|
423
|
-
private async dispatch(event: AutoBeEvent): Promise<void> {
|
|
424
|
-
const set = this.listeners_.get(event.type);
|
|
425
|
-
if (set === undefined) return;
|
|
426
|
-
await Promise.all(
|
|
427
|
-
Array.from(set).map(async (listener) => {
|
|
428
|
-
try {
|
|
429
|
-
await listener(event);
|
|
430
|
-
} catch {}
|
|
431
|
-
}),
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
241
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeEvent,
|
|
3
|
+
AutoBeHistory,
|
|
4
|
+
IAutoBeCompiler,
|
|
5
|
+
IAutoBeGetFilesOptions,
|
|
6
|
+
} from "@autobe/interface";
|
|
7
|
+
|
|
8
|
+
import { AutoBeState } from "./context/AutoBeState";
|
|
9
|
+
import { AutoBeTokenUsage } from "./context/AutoBeTokenUsage";
|
|
10
|
+
import { getAutoBeGenerated } from "./factory/getAutoBeGenerated";
|
|
11
|
+
import { emplaceMap } from "./utils/emplaceMap";
|
|
12
|
+
|
|
13
|
+
export abstract class AutoBeAgentBase {
|
|
14
|
+
/** @internal */
|
|
15
|
+
private readonly listeners_: Map<
|
|
16
|
+
string,
|
|
17
|
+
Set<(event: AutoBeEvent) => Promise<void> | void>
|
|
18
|
+
>;
|
|
19
|
+
|
|
20
|
+
public constructor(private readonly asset: AutoBeAgentBase.IAsset) {
|
|
21
|
+
this.listeners_ = new Map();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async getFiles(
|
|
25
|
+
options?: Partial<IAutoBeGetFilesOptions>,
|
|
26
|
+
): Promise<Record<string, string>> {
|
|
27
|
+
return getAutoBeGenerated(
|
|
28
|
+
await this.asset.compiler(),
|
|
29
|
+
this.asset.state(),
|
|
30
|
+
this.getHistories(),
|
|
31
|
+
this.getTokenUsage(),
|
|
32
|
+
options,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
public abstract getHistories(): AutoBeHistory[];
|
|
36
|
+
public abstract getTokenUsage(): AutoBeTokenUsage;
|
|
37
|
+
|
|
38
|
+
public on<Type extends AutoBeEvent.Type>(
|
|
39
|
+
type: Type,
|
|
40
|
+
listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void,
|
|
41
|
+
): this {
|
|
42
|
+
emplaceMap(this.listeners_, type, () => new Set()).add(
|
|
43
|
+
listener as (event: AutoBeEvent) => any,
|
|
44
|
+
);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public off<Type extends AutoBeEvent.Type>(
|
|
49
|
+
type: Type,
|
|
50
|
+
listener: (event: AutoBeEvent.Mapper[Type]) => Promise<void> | void,
|
|
51
|
+
): this {
|
|
52
|
+
const set = this.listeners_.get(type);
|
|
53
|
+
if (set === undefined) return this;
|
|
54
|
+
|
|
55
|
+
set.delete(listener as (event: AutoBeEvent) => any);
|
|
56
|
+
if (set.size === 0) this.listeners_.delete(type);
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
protected async dispatch(event: AutoBeEvent): Promise<void> {
|
|
62
|
+
const set = this.listeners_.get(event.type);
|
|
63
|
+
if (set === undefined) return;
|
|
64
|
+
await Promise.all(
|
|
65
|
+
Array.from(set).map(async (listener) => {
|
|
66
|
+
try {
|
|
67
|
+
await listener(event);
|
|
68
|
+
} catch {}
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export namespace AutoBeAgentBase {
|
|
74
|
+
export interface IAsset {
|
|
75
|
+
compiler: () => Promise<IAutoBeCompiler>;
|
|
76
|
+
state: () => AutoBeState;
|
|
77
|
+
}
|
|
78
|
+
}
|