@autobe/agent 0.9.2 → 0.10.1
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.js +11 -4
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +7 -6
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/context/AutoBeTokenUsage.d.ts +15 -1
- package/lib/context/AutoBeTokenUsage.js +56 -1
- package/lib/context/AutoBeTokenUsage.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +288 -653
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/index.mjs +4225 -6681
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js +80 -321
- package/lib/orchestrate/analyze/AutoBeAnalyzeAgent.js.map +1 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js +0 -1
- package/lib/orchestrate/analyze/AutoBeAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +93 -266
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +2 -2
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/index.d.ts +2 -2
- package/lib/orchestrate/index.js +4 -4
- package/lib/orchestrate/index.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +54 -142
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +189 -201
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +71 -174
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +706 -1099
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.js +2 -0
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +60 -177
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js +502 -1073
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js +519 -1125
- package/lib/orchestrate/prisma/orchestratePrismaSchema.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js +9 -0
- package/lib/orchestrate/prisma/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js +8 -0
- package/lib/orchestrate/prisma/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.d.ts +11 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +78 -0
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.d.ts +25 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +326 -0
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.d.ts +80 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js +53 -0
- package/lib/orchestrate/realize/orchestrateRealizePlanner.js.map +1 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +39 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js +3 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +1 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.d.ts +5 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +127 -0
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -0
- package/lib/orchestrate/test/compile/completeTestCode.d.ts +2 -0
- package/lib/orchestrate/test/compile/completeTestCode.js +21 -0
- package/lib/orchestrate/test/compile/completeTestCode.js.map +1 -0
- package/lib/orchestrate/test/{filterTestFileName.js → compile/filterTestFileName.js} +1 -1
- package/lib/orchestrate/test/compile/filterTestFileName.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.d.ts +3 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js +27 -0
- package/lib/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +5 -0
- package/lib/orchestrate/test/{compileTestScenario.js → compile/getTestScenarioArtifacts.js} +10 -5
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -0
- package/lib/orchestrate/test/orchestrateTest.js +14 -9
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.js +142 -448
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +258 -532
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +3 -2
- package/lib/orchestrate/test/orchestrateTestWrite.js +124 -90
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +121 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.d.ts +8 -0
- package/lib/{utils/types/BackoffOptions.js → orchestrate/test/structures/IAutoBeTestFunction.js} +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestFunction.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +14 -2
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +112 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.js.map +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.d.ts +7 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js +3 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteResult.js.map +1 -0
- package/lib/orchestrate/test/transformTestCorrectHistories.d.ts +3 -2
- package/lib/orchestrate/test/transformTestCorrectHistories.js +28 -67
- package/lib/orchestrate/test/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.d.ts +5 -4
- package/lib/orchestrate/test/transformTestWriteHistories.js +161 -43
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/structures/IAutoBeConfig.d.ts +11 -0
- package/lib/utils/backoffRetry.d.ts +4 -7
- package/lib/utils/backoffRetry.js +19 -37
- package/lib/utils/backoffRetry.js.map +1 -1
- package/lib/utils/forceRetry.d.ts +1 -0
- package/lib/{orchestrate/orchestrateRealize.js → utils/forceRetry.js} +15 -8
- package/lib/utils/forceRetry.js.map +1 -0
- package/package.json +9 -12
- package/src/AutoBeAgent.ts +17 -3
- package/src/constants/AutoBeSystemPromptConstant.ts +7 -6
- package/src/context/AutoBeTokenUsage.ts +85 -1
- package/src/factory/createAutoBeApplication.ts +2 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeAgent.ts +8 -3
- package/src/orchestrate/analyze/AutoBeAnalyzeReviewer.ts +0 -1
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +6 -5
- package/src/orchestrate/facade/transformFacadeStateMessage.ts +2 -1
- package/src/orchestrate/index.ts +2 -2
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +4 -3
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +26 -23
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +6 -4
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +14 -11
- package/src/orchestrate/interface/transformInterfaceHistories.ts +2 -0
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +10 -5
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +11 -5
- package/src/orchestrate/prisma/orchestratePrismaSchema.ts +16 -8
- package/src/orchestrate/prisma/transformPrismaComponentsHistories.ts +9 -0
- package/src/orchestrate/prisma/transformPrismaSchemaHistories.ts +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +129 -0
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +148 -0
- package/src/orchestrate/realize/orchestrateRealizePlanner.ts +115 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +46 -0
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +136 -0
- package/src/orchestrate/test/compile/completeTestCode.ts +35 -0
- package/src/orchestrate/test/{filterTestFileName.ts → compile/filterTestFileName.ts} +1 -1
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +24 -0
- package/src/orchestrate/test/{compileTestScenario.ts → compile/getTestScenarioArtifacts.ts} +16 -8
- package/src/orchestrate/test/experimental/orchestrateTestCorrect.ast +240 -0
- package/src/orchestrate/test/experimental/orchestrateTestWrite.ast +316 -0
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +52 -0
- package/src/orchestrate/test/orchestrateTest.ts +33 -16
- package/src/orchestrate/test/orchestrateTestCorrect.ts +109 -497
- package/src/orchestrate/test/orchestrateTestScenario.ts +102 -71
- package/src/orchestrate/test/orchestrateTestWrite.ts +55 -181
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +126 -0
- package/src/orchestrate/test/structures/IAutoBeTestFunction.ts +10 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +14 -2
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +117 -0
- package/src/orchestrate/test/structures/IAutoBeTestWriteResult.ts +9 -0
- package/src/orchestrate/test/transformTestCorrectHistories.ts +38 -71
- package/src/orchestrate/test/transformTestWriteHistories.ts +88 -46
- package/src/structures/IAutoBeConfig.ts +9 -0
- package/src/utils/backoffRetry.ts +25 -36
- package/src/utils/forceRetry.ts +13 -0
- package/lib/factory/invertOpenApiDocument.d.ts +0 -3
- package/lib/factory/invertOpenApiDocument.js +0 -51
- package/lib/factory/invertOpenApiDocument.js.map +0 -1
- package/lib/orchestrate/orchestrateRealize.d.ts +0 -5
- package/lib/orchestrate/orchestrateRealize.js.map +0 -1
- package/lib/orchestrate/test/compileTestScenario.d.ts +0 -5
- package/lib/orchestrate/test/compileTestScenario.js.map +0 -1
- package/lib/orchestrate/test/filterTestFileName.js.map +0 -1
- package/lib/utils/StringUtil.d.ts +0 -4
- package/lib/utils/StringUtil.js +0 -43
- package/lib/utils/StringUtil.js.map +0 -1
- package/lib/utils/types/BackoffOptions.d.ts +0 -12
- package/lib/utils/types/BackoffOptions.js.map +0 -1
- package/src/factory/invertOpenApiDocument.ts +0 -63
- package/src/orchestrate/orchestrateRealize.ts +0 -18
- package/src/utils/StringUtil.ts +0 -45
- package/src/utils/types/BackoffOptions.ts +0 -15
- /package/lib/orchestrate/test/{filterTestFileName.d.ts → compile/filterTestFileName.d.ts} +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeAssistantMessageHistory,
|
|
3
|
+
AutoBeOpenApi,
|
|
4
|
+
AutoBeRealizeHistory,
|
|
5
|
+
} from "@autobe/interface";
|
|
6
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
7
|
+
import { v4 } from "uuid";
|
|
8
|
+
|
|
9
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
10
|
+
import { IAutoBeApplicationProps } from "../../context/IAutoBeApplicationProps";
|
|
11
|
+
import { orchestrateRealizeCoder } from "./orchestrateRealizeCoder";
|
|
12
|
+
import { orchestrateRealizePlanner } from "./orchestrateRealizePlanner";
|
|
13
|
+
import { IAutoBeRealizeCoderApplication } from "./structures/IAutoBeRealizeCoderApplication";
|
|
14
|
+
|
|
15
|
+
export const orchestrateRealize =
|
|
16
|
+
<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>) =>
|
|
17
|
+
async (
|
|
18
|
+
props: IAutoBeApplicationProps,
|
|
19
|
+
): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
|
|
20
|
+
props;
|
|
21
|
+
const ops = ctx.state().interface?.document.operations;
|
|
22
|
+
if (!ops) {
|
|
23
|
+
throw new Error();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const files: Record<string, string> = {
|
|
27
|
+
...ctx.state().interface?.files,
|
|
28
|
+
...ctx.state().test?.files.reduce(
|
|
29
|
+
(acc, file) => {
|
|
30
|
+
acc[file.location] = file.content;
|
|
31
|
+
return acc;
|
|
32
|
+
},
|
|
33
|
+
{} as Record<string, string>,
|
|
34
|
+
),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const codes: IAutoBeRealizeCoderApplication.IPipeOutput[] =
|
|
38
|
+
await Promise.all(
|
|
39
|
+
ops.map(async (op) => ({
|
|
40
|
+
operation: op,
|
|
41
|
+
result: await pipe(
|
|
42
|
+
op,
|
|
43
|
+
(op) => orchestrateRealizePlanner(ctx, op),
|
|
44
|
+
(p) => orchestrateRealizeCoder(ctx, op, p, files),
|
|
45
|
+
),
|
|
46
|
+
})),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const successes: Array<{
|
|
50
|
+
operation: AutoBeOpenApi.IOperation;
|
|
51
|
+
result: IAutoBeRealizeCoderApplication.RealizeCoderOutput;
|
|
52
|
+
}> = [];
|
|
53
|
+
const failures: Array<{
|
|
54
|
+
operation: AutoBeOpenApi.IOperation;
|
|
55
|
+
result: FAILED;
|
|
56
|
+
}> = [];
|
|
57
|
+
|
|
58
|
+
for (const code of codes) {
|
|
59
|
+
if (code.result === FAILED) {
|
|
60
|
+
failures.push({
|
|
61
|
+
operation: code.operation,
|
|
62
|
+
result: code.result,
|
|
63
|
+
});
|
|
64
|
+
} else {
|
|
65
|
+
successes.push({
|
|
66
|
+
operation: code.operation,
|
|
67
|
+
result: code.result,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const now = new Date().toISOString();
|
|
73
|
+
ctx.dispatch({
|
|
74
|
+
type: "assistantMessage",
|
|
75
|
+
text: "Any codes can not be generated.",
|
|
76
|
+
created_at: now,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
type: "realize",
|
|
81
|
+
compiled: 1 as any,
|
|
82
|
+
files: {},
|
|
83
|
+
completed_at: now,
|
|
84
|
+
created_at: now,
|
|
85
|
+
id: v4(),
|
|
86
|
+
reason: props.reason,
|
|
87
|
+
step: ctx.state().test?.step ?? 0,
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const FAILED = Symbol("FAILED");
|
|
92
|
+
export type FAILED = typeof FAILED;
|
|
93
|
+
|
|
94
|
+
export function pipe<A, B>(
|
|
95
|
+
a: A,
|
|
96
|
+
ab: (a: A) => Promise<B | FAILED>,
|
|
97
|
+
): Promise<B | FAILED>;
|
|
98
|
+
|
|
99
|
+
export function pipe<A, B, C>(
|
|
100
|
+
a: A,
|
|
101
|
+
ab: (a: A) => Promise<B | FAILED>,
|
|
102
|
+
bc: (b: B) => Promise<C | FAILED>,
|
|
103
|
+
): Promise<C | FAILED>;
|
|
104
|
+
|
|
105
|
+
export function pipe<A, B, C, D>(
|
|
106
|
+
a: A,
|
|
107
|
+
ab: (a: A) => Promise<B | FAILED>,
|
|
108
|
+
bc: (b: B) => Promise<C | FAILED>,
|
|
109
|
+
cd: (c: C) => Promise<D | FAILED>,
|
|
110
|
+
): Promise<D | FAILED>;
|
|
111
|
+
|
|
112
|
+
export function pipe<A, B, C, D>(
|
|
113
|
+
a: A,
|
|
114
|
+
ab: (a: A) => Promise<B | FAILED>,
|
|
115
|
+
bc: (b: B) => Promise<C | FAILED>,
|
|
116
|
+
cd: (c: C) => Promise<D | FAILED>,
|
|
117
|
+
): Promise<D | FAILED>;
|
|
118
|
+
|
|
119
|
+
export function pipe(
|
|
120
|
+
a: any,
|
|
121
|
+
...fns: Array<(arg: any) => Promise<any>>
|
|
122
|
+
): Promise<any> {
|
|
123
|
+
return fns.reduce((prev, fn) => {
|
|
124
|
+
return prev.then((result) => {
|
|
125
|
+
if (result === FAILED) return FAILED;
|
|
126
|
+
return fn(result);
|
|
127
|
+
});
|
|
128
|
+
}, Promise.resolve(a));
|
|
129
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { IAgenticaController, MicroAgentica } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
4
|
+
import { IPointer } from "tstl";
|
|
5
|
+
import typia from "typia";
|
|
6
|
+
|
|
7
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
8
|
+
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
9
|
+
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
10
|
+
import { getTestScenarioArtifacts } from "../test/compile/getTestScenarioArtifacts";
|
|
11
|
+
import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
|
|
12
|
+
import { FAILED } from "./orchestrateRealize";
|
|
13
|
+
import { RealizePlannerOutput } from "./orchestrateRealizePlanner";
|
|
14
|
+
import { IAutoBeRealizeCoderApplication } from "./structures/IAutoBeRealizeCoderApplication";
|
|
15
|
+
import { transformRealizeCoderHistories } from "./transformRealizeCoderHistories";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generates a TypeScript function implementation based on the given plan.
|
|
19
|
+
*
|
|
20
|
+
* This function transforms the plan (function name, input/output schema,
|
|
21
|
+
* constraints, and scenarios) into a complete TypeScript function as a string.
|
|
22
|
+
* It is responsible only for producing the code logic, and does not handle
|
|
23
|
+
* imports, exports, or formatting.
|
|
24
|
+
*
|
|
25
|
+
* Import statements are handled separately and will be injected automatically.
|
|
26
|
+
* Any unused imports will be removed by tooling (e.g. eslint).
|
|
27
|
+
*
|
|
28
|
+
* Type annotations should be omitted whenever possible to favor TypeScript's
|
|
29
|
+
* type inference, unless explicit types are critical to correctness.
|
|
30
|
+
*
|
|
31
|
+
* @param ctx - AutoBE execution context
|
|
32
|
+
* @param props - Planning result describing what function to generate
|
|
33
|
+
* @returns The generated function name and TypeScript code
|
|
34
|
+
*/
|
|
35
|
+
export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
36
|
+
ctx: AutoBeContext<Model>,
|
|
37
|
+
operation: AutoBeOpenApi.IOperation,
|
|
38
|
+
props: RealizePlannerOutput,
|
|
39
|
+
files: Record<string, string>,
|
|
40
|
+
): Promise<IAutoBeRealizeCoderApplication.RealizeCoderOutput | FAILED> => {
|
|
41
|
+
const artifacts: IAutoBeTestScenarioArtifacts =
|
|
42
|
+
await getTestScenarioArtifacts(ctx, {
|
|
43
|
+
endpoint: {
|
|
44
|
+
method: operation.method,
|
|
45
|
+
path: operation.path,
|
|
46
|
+
},
|
|
47
|
+
dependencies: [],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const pointer: IPointer<Pick<
|
|
51
|
+
IAutoBeRealizeCoderApplication.RealizeCoderOutput,
|
|
52
|
+
"implementationCode"
|
|
53
|
+
> | null> = {
|
|
54
|
+
value: null,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const controller = createApplication({
|
|
58
|
+
model: ctx.model,
|
|
59
|
+
build: (props) => {
|
|
60
|
+
pointer.value = props.result;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const agent = new MicroAgentica({
|
|
65
|
+
controllers: [controller],
|
|
66
|
+
model: ctx.model,
|
|
67
|
+
vendor: ctx.vendor,
|
|
68
|
+
config: {
|
|
69
|
+
...ctx.config,
|
|
70
|
+
executor: {
|
|
71
|
+
describe: null,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
histories: transformRealizeCoderHistories(ctx.state(), props, artifacts),
|
|
75
|
+
});
|
|
76
|
+
enforceToolCall(agent);
|
|
77
|
+
|
|
78
|
+
await agent.conversate("Write code.");
|
|
79
|
+
const tokenUsage = agent.getTokenUsage();
|
|
80
|
+
ctx.usage().record(tokenUsage, ["realize"]);
|
|
81
|
+
|
|
82
|
+
if (pointer.value === null) {
|
|
83
|
+
return FAILED;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
pointer.value.implementationCode = await ctx.compiler.typescript.beautify(
|
|
87
|
+
pointer.value.implementationCode,
|
|
88
|
+
);
|
|
89
|
+
pointer.value.implementationCode = pointer.value.implementationCode
|
|
90
|
+
.replaceAll('import { MyGlobal } from "../MyGlobal";', "")
|
|
91
|
+
.replaceAll('import typia, { tags } from "typia";', "")
|
|
92
|
+
.replaceAll('import { Prisma } from "@prisma/client";', "")
|
|
93
|
+
.replaceAll('import { jwtDecode } from "./jwtDecode"', "");
|
|
94
|
+
pointer.value.implementationCode = [
|
|
95
|
+
'import { MyGlobal } from "../MyGlobal";',
|
|
96
|
+
'import typia, { tags } from "typia";',
|
|
97
|
+
'import { Prisma } from "@prisma/client";',
|
|
98
|
+
'import { jwtDecode } from "./jwtDecode"',
|
|
99
|
+
"",
|
|
100
|
+
pointer.value.implementationCode,
|
|
101
|
+
].join("\n");
|
|
102
|
+
|
|
103
|
+
files[`src/providers/${props.functionName}.ts`] =
|
|
104
|
+
pointer.value.implementationCode;
|
|
105
|
+
|
|
106
|
+
return { ...pointer.value, functionName: props.functionName };
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
function createApplication<Model extends ILlmSchema.Model>(props: {
|
|
110
|
+
model: Model;
|
|
111
|
+
build: (next: IAutoBeRealizeCoderApplication.IProps) => void;
|
|
112
|
+
}): IAgenticaController.IClass<Model> {
|
|
113
|
+
assertSchemaModel(props.model);
|
|
114
|
+
|
|
115
|
+
const application: ILlmApplication<Model> = collection[
|
|
116
|
+
props.model
|
|
117
|
+
] as unknown as ILlmApplication<Model>;
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
protocol: "class",
|
|
121
|
+
name: "Write code",
|
|
122
|
+
application,
|
|
123
|
+
execute: {
|
|
124
|
+
programing: (next) => {
|
|
125
|
+
props.build(next);
|
|
126
|
+
},
|
|
127
|
+
} satisfies IAutoBeRealizeCoderApplication,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const claude = typia.llm.application<
|
|
132
|
+
IAutoBeRealizeCoderApplication,
|
|
133
|
+
"claude",
|
|
134
|
+
{
|
|
135
|
+
reference: true;
|
|
136
|
+
}
|
|
137
|
+
>();
|
|
138
|
+
const collection = {
|
|
139
|
+
chatgpt: typia.llm.application<
|
|
140
|
+
IAutoBeRealizeCoderApplication,
|
|
141
|
+
"chatgpt",
|
|
142
|
+
{ reference: true }
|
|
143
|
+
>(),
|
|
144
|
+
claude,
|
|
145
|
+
llama: claude,
|
|
146
|
+
deepseek: claude,
|
|
147
|
+
"3.1": claude,
|
|
148
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
5
|
+
|
|
6
|
+
export interface RealizePlannerOutput {
|
|
7
|
+
/**
|
|
8
|
+
* The name of the function to be generated.
|
|
9
|
+
*
|
|
10
|
+
* Derived from the Swagger path and method. The function name must be written
|
|
11
|
+
* in snake_case. It serves as the entry point in both code generation and
|
|
12
|
+
* test code.
|
|
13
|
+
*
|
|
14
|
+
* Once the function is generated, the function name and file name will be the
|
|
15
|
+
* same. The generated file will be located at
|
|
16
|
+
* `src/providers/${function_name}.ts`.
|
|
17
|
+
*/
|
|
18
|
+
functionName: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Definition of path and query parameters extracted from the OpenAPI spec.
|
|
22
|
+
*
|
|
23
|
+
* Includes input values passed via URL path or query string. Used for type
|
|
24
|
+
* definitions, validation, and function signature construction.
|
|
25
|
+
*/
|
|
26
|
+
parameters: AutoBeOpenApi.IParameter[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Schema definition for the request body input.
|
|
30
|
+
*
|
|
31
|
+
* Extracted from the requestBody section of Swagger. Represents the input
|
|
32
|
+
* data passed in the body (e.g., JSON). Used for generating function
|
|
33
|
+
* arguments or DTOs.
|
|
34
|
+
*/
|
|
35
|
+
inputSchema: AutoBeOpenApi.IRequestBody | null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Schema definition for the response body.
|
|
39
|
+
*
|
|
40
|
+
* Extracted from the responses section of Swagger. Used to define the return
|
|
41
|
+
* type and expected output in test code.
|
|
42
|
+
*/
|
|
43
|
+
outputSchema: AutoBeOpenApi.IResponseBody | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Natural language description of the function’s purpose.
|
|
47
|
+
*
|
|
48
|
+
* Extracted from the summary or description field of Swagger. Used for code
|
|
49
|
+
* documentation, test scenario generation, and conveying function intent.
|
|
50
|
+
*/
|
|
51
|
+
description: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* HTTP method information.
|
|
55
|
+
*
|
|
56
|
+
* Extracted from the Swagger operation method. Used to define the request
|
|
57
|
+
* type during code and test generation.
|
|
58
|
+
*/
|
|
59
|
+
operationType: "get" | "post" | "put" | "delete" | "patch";
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* List of scenario descriptions for test code generation.
|
|
63
|
+
*
|
|
64
|
+
* Each scenario describes the expected behavior of the function under certain
|
|
65
|
+
* conditions. Used as a basis for TDD-style automated test generation.
|
|
66
|
+
*/
|
|
67
|
+
testScenarios: string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generates a planning result that defines what kind of function should be
|
|
72
|
+
* created, based solely on the provided Swagger (OpenAPI) operation — without
|
|
73
|
+
* using an LLM.
|
|
74
|
+
*
|
|
75
|
+
* This function analyzes the structure of the OpenAPI operation (such as the
|
|
76
|
+
* path, method, parameters, request/response schema, and descriptions) to
|
|
77
|
+
* determine the appropriate function name, input/output types, and purpose of
|
|
78
|
+
* the function.
|
|
79
|
+
*
|
|
80
|
+
* The result of this function (`RealizePlannerOutput`) will be passed to the
|
|
81
|
+
* next step in the AutoBE pipeline, which is responsible for generating the
|
|
82
|
+
* actual implementation code.
|
|
83
|
+
*
|
|
84
|
+
* @param ctx - AutoBE context including model and configuration
|
|
85
|
+
* @param operation - A single OpenAPI operation object to analyze and plan
|
|
86
|
+
* @returns A planning object containing all structural information needed to
|
|
87
|
+
* generate the function
|
|
88
|
+
*/
|
|
89
|
+
export const orchestrateRealizePlanner = async <Model extends ILlmSchema.Model>(
|
|
90
|
+
ctx: AutoBeContext<Model>,
|
|
91
|
+
operation: AutoBeOpenApi.IOperation,
|
|
92
|
+
): Promise<RealizePlannerOutput> => {
|
|
93
|
+
const testScenarios =
|
|
94
|
+
ctx
|
|
95
|
+
.state()
|
|
96
|
+
.test?.files.filter(
|
|
97
|
+
(el) =>
|
|
98
|
+
el.scenario.endpoint.method === operation.method &&
|
|
99
|
+
el.scenario.endpoint.path === operation.path,
|
|
100
|
+
) ?? [];
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
description: operation.description,
|
|
104
|
+
parameters: operation.parameters,
|
|
105
|
+
inputSchema: operation.requestBody,
|
|
106
|
+
outputSchema: operation.responseBody,
|
|
107
|
+
operationType: operation.method,
|
|
108
|
+
testScenarios: testScenarios.map((el) => el.scenario.draft),
|
|
109
|
+
functionName: `${operation.method}_${operation.path
|
|
110
|
+
.replaceAll("/", "_")
|
|
111
|
+
.replaceAll("-", "_")
|
|
112
|
+
.replaceAll("{", "$")
|
|
113
|
+
.replaceAll("}", "")}`,
|
|
114
|
+
} satisfies RealizePlannerOutput;
|
|
115
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
|
|
3
|
+
import { FAILED } from "../orchestrateRealize";
|
|
4
|
+
|
|
5
|
+
export interface IAutoBeRealizeCoderApplication {
|
|
6
|
+
programing: (next: IAutoBeRealizeCoderApplication.IProps) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export namespace IAutoBeRealizeCoderApplication {
|
|
10
|
+
export interface IProps {
|
|
11
|
+
result: RealizeCoderOutput;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The result of the code generation step, representing a fully generated
|
|
16
|
+
* TypeScript function.
|
|
17
|
+
*/
|
|
18
|
+
export interface RealizeCoderOutput {
|
|
19
|
+
/**
|
|
20
|
+
* The name of the function to be generated.
|
|
21
|
+
*
|
|
22
|
+
* This name will be used as the function's identifier and as the export
|
|
23
|
+
* name in the provider file.
|
|
24
|
+
*/
|
|
25
|
+
functionName: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The raw TypeScript code string implementing the function.
|
|
29
|
+
*
|
|
30
|
+
* - The implementation must be valid TypeScript code.
|
|
31
|
+
* - It should focus solely on the logic of the function.
|
|
32
|
+
* - Import statements do **not** need to be included. They will be
|
|
33
|
+
* automatically inserted by the system.
|
|
34
|
+
* - Any unused imports will be automatically removed by eslint.
|
|
35
|
+
* - Type annotations (e.g. for parameters and return types) should be omitted
|
|
36
|
+
* if they can be inferred.
|
|
37
|
+
*/
|
|
38
|
+
implementationCode: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IPipeOutput {
|
|
42
|
+
result: RealizeCoderOutput | FAILED;
|
|
43
|
+
|
|
44
|
+
operation: AutoBeOpenApi.IOperation;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
|
|
4
|
+
import { AutoBeSystemPromptConstant } from "../../constants/AutoBeSystemPromptConstant";
|
|
5
|
+
import { AutoBeState } from "../../context/AutoBeState";
|
|
6
|
+
import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
|
|
7
|
+
import { RealizePlannerOutput } from "./orchestrateRealizePlanner";
|
|
8
|
+
|
|
9
|
+
export const transformRealizeCoderHistories = (
|
|
10
|
+
state: AutoBeState,
|
|
11
|
+
props: RealizePlannerOutput,
|
|
12
|
+
artifacts: IAutoBeTestScenarioArtifacts,
|
|
13
|
+
): Array<
|
|
14
|
+
IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage
|
|
15
|
+
> => {
|
|
16
|
+
if (state.analyze === null)
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
id: v4(),
|
|
20
|
+
created_at: new Date().toISOString(),
|
|
21
|
+
type: "systemMessage",
|
|
22
|
+
text: [
|
|
23
|
+
"Requirement analysis is not yet completed.",
|
|
24
|
+
"Don't call the any tool function,",
|
|
25
|
+
"but say to process the requirement analysis.",
|
|
26
|
+
].join(" "),
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
else if (state.prisma === null)
|
|
30
|
+
return [
|
|
31
|
+
{
|
|
32
|
+
id: v4(),
|
|
33
|
+
created_at: new Date().toISOString(),
|
|
34
|
+
type: "systemMessage",
|
|
35
|
+
text: [
|
|
36
|
+
"Prisma DB schema generation is not yet completed.",
|
|
37
|
+
"Don't call the any tool function,",
|
|
38
|
+
"but say to process the Prisma DB schema generation.",
|
|
39
|
+
].join(" "),
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
else if (state.analyze.step !== state.prisma.step)
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
id: v4(),
|
|
46
|
+
created_at: new Date().toISOString(),
|
|
47
|
+
type: "systemMessage",
|
|
48
|
+
text: [
|
|
49
|
+
"Prisma DB schema generation has not been updated",
|
|
50
|
+
"for the latest requirement analysis.",
|
|
51
|
+
"Don't call the any tool function,",
|
|
52
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
53
|
+
].join(" "),
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
else if (state.prisma.compiled.type !== "success")
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
id: v4(),
|
|
60
|
+
created_at: new Date().toISOString(),
|
|
61
|
+
type: "systemMessage",
|
|
62
|
+
text: [
|
|
63
|
+
"Prisma DB schema generation has not been updated",
|
|
64
|
+
"for the latest requirement analysis.",
|
|
65
|
+
"Don't call the any tool function,",
|
|
66
|
+
"but say to re-process the Prisma DB schema generation.",
|
|
67
|
+
].join(" "),
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
else if (state.interface === null)
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
id: v4(),
|
|
74
|
+
created_at: new Date().toISOString(),
|
|
75
|
+
type: "systemMessage",
|
|
76
|
+
text: [
|
|
77
|
+
"Interface generation is not yet completed.",
|
|
78
|
+
"Don't call the any tool function,",
|
|
79
|
+
"but say to process the interface generation.",
|
|
80
|
+
].join(" "),
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
return [
|
|
85
|
+
{
|
|
86
|
+
id: v4(),
|
|
87
|
+
created_at: new Date().toISOString(),
|
|
88
|
+
type: "systemMessage",
|
|
89
|
+
text: [
|
|
90
|
+
AutoBeSystemPromptConstant.REALIZE_CODER,
|
|
91
|
+
"",
|
|
92
|
+
"# Prisma Schemas",
|
|
93
|
+
"```json",
|
|
94
|
+
JSON.stringify(state.prisma.schemas),
|
|
95
|
+
"```",
|
|
96
|
+
"",
|
|
97
|
+
// "# Prisma Types",
|
|
98
|
+
// "```json",
|
|
99
|
+
// JSON.stringify(state.prisma.compiled.nodeModules),
|
|
100
|
+
// "```",
|
|
101
|
+
"# SDK",
|
|
102
|
+
"",
|
|
103
|
+
"The following is the SDK for the API. Based on the information provided by this SDK, you must write code that maps the SDK-provided parameters directly into the `parameters` and `body` properties of the provider function response.",
|
|
104
|
+
"If there are no parameters, define `parameters` as `Record<string, never>`. Similarly, if there is no body, define `body` as `Record<string, never>`.",
|
|
105
|
+
"**Every function must be implemented to accept both `parameters` and `body`, without exception.**",
|
|
106
|
+
"If any required type information is referenced in the SDK, refer to the definitions in the DTO section.",
|
|
107
|
+
"",
|
|
108
|
+
"```json",
|
|
109
|
+
JSON.stringify(artifacts.sdk),
|
|
110
|
+
"```",
|
|
111
|
+
"",
|
|
112
|
+
"# DTO",
|
|
113
|
+
"if you want to import this files, write this: 'import { something } from '../api/structures/something';'",
|
|
114
|
+
"",
|
|
115
|
+
"```json",
|
|
116
|
+
JSON.stringify(artifacts.dto),
|
|
117
|
+
"```",
|
|
118
|
+
"# Document",
|
|
119
|
+
"```json",
|
|
120
|
+
JSON.stringify(artifacts.document),
|
|
121
|
+
"```",
|
|
122
|
+
].join("\n"),
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: v4(),
|
|
126
|
+
created_at: new Date().toISOString(),
|
|
127
|
+
type: "systemMessage",
|
|
128
|
+
text: [
|
|
129
|
+
"write code by following information of operation.",
|
|
130
|
+
"```json",
|
|
131
|
+
JSON.stringify(props),
|
|
132
|
+
"```",
|
|
133
|
+
].join("\n"),
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IAutoBeTestScenarioArtifacts } from "../structures/IAutoBeTestScenarioArtifacts";
|
|
2
|
+
|
|
3
|
+
export function completeTestCode(
|
|
4
|
+
artifacts: IAutoBeTestScenarioArtifacts,
|
|
5
|
+
code: string,
|
|
6
|
+
): string {
|
|
7
|
+
const typeReferences: string[] = Array.from(
|
|
8
|
+
new Set(
|
|
9
|
+
Object.keys(artifacts.document.components.schemas).map(
|
|
10
|
+
(key) => key.split(".")[0]!,
|
|
11
|
+
),
|
|
12
|
+
),
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
|
|
16
|
+
code = code.replace(/^[ \t]*import\b[\s\S]*?;[ \t]*$/gm, "").trim();
|
|
17
|
+
code = code.replaceAll(
|
|
18
|
+
'string & Format<"uuid">',
|
|
19
|
+
'string & tags.Format<"uuid">',
|
|
20
|
+
);
|
|
21
|
+
code = [
|
|
22
|
+
`import { ArrayUtil, RandomGenerator, TestValidator } from "@nestia/e2e";`,
|
|
23
|
+
`import { IConnection } from "@nestia/fetcher";`,
|
|
24
|
+
`import typia, { tags } from "typia";`,
|
|
25
|
+
"",
|
|
26
|
+
`import api from "@ORGANIZATION/PROJECT-api";`,
|
|
27
|
+
...typeReferences.map(
|
|
28
|
+
(ref) =>
|
|
29
|
+
`import type { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
|
|
30
|
+
),
|
|
31
|
+
"",
|
|
32
|
+
code,
|
|
33
|
+
].join("\n");
|
|
34
|
+
return code;
|
|
35
|
+
}
|
|
@@ -3,7 +3,7 @@ export function filterTestFileName(key: string): boolean {
|
|
|
3
3
|
else if (key.startsWith("src/") === true) return true;
|
|
4
4
|
return (
|
|
5
5
|
key.startsWith("test/") === true &&
|
|
6
|
-
key.startsWith("test/features/") ===
|
|
6
|
+
key.startsWith("test/features/") === true &&
|
|
7
7
|
key.startsWith("test/benchmark/") === false
|
|
8
8
|
);
|
|
9
9
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IAutoBeTestCompiler } from "@autobe/interface";
|
|
2
|
+
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
+
import { Singleton } from "tstl";
|
|
4
|
+
|
|
5
|
+
import { AutoBeContext } from "../../../context/AutoBeContext";
|
|
6
|
+
|
|
7
|
+
export function getTestExternalDeclarations<Model extends ILlmSchema.Model>(
|
|
8
|
+
ctx: AutoBeContext<Model>,
|
|
9
|
+
): Promise<Record<string, string>> {
|
|
10
|
+
return singleton.get(ctx.compiler.test);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const singleton = new Singleton(async (compiler: IAutoBeTestCompiler) => {
|
|
14
|
+
const records: Record<string, string> = await compiler.getExternal();
|
|
15
|
+
const external = (location: string): Record<string, string> => {
|
|
16
|
+
const content: string | undefined = records[location];
|
|
17
|
+
if (content === undefined) throw new Error(`File not found: ${location}`);
|
|
18
|
+
return { [location]: content };
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
...external("node_modules/@nestia/e2e/lib/TestValidator.d.ts"),
|
|
22
|
+
...external("node_modules/@nestia/fetcher/lib/IConnection.d.ts"),
|
|
23
|
+
} satisfies Record<string, string>;
|
|
24
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AutoBeOpenApi, AutoBeTestScenario } from "@autobe/interface";
|
|
2
2
|
import { ILlmSchema, OpenApiTypeChecker } from "@samchon/openapi";
|
|
3
3
|
|
|
4
|
-
import { AutoBeContext } from "
|
|
5
|
-
import { IAutoBeTestScenarioArtifacts } from "
|
|
4
|
+
import { AutoBeContext } from "../../../context/AutoBeContext";
|
|
5
|
+
import { IAutoBeTestScenarioArtifacts } from "../structures/IAutoBeTestScenarioArtifacts";
|
|
6
6
|
|
|
7
|
-
export async function
|
|
7
|
+
export async function getTestScenarioArtifacts<Model extends ILlmSchema.Model>(
|
|
8
8
|
ctx: AutoBeContext<Model>,
|
|
9
|
-
scenario: AutoBeTestScenario,
|
|
9
|
+
scenario: Pick<AutoBeTestScenario, "endpoint" | "dependencies">,
|
|
10
10
|
): Promise<IAutoBeTestScenarioArtifacts> {
|
|
11
11
|
const document: AutoBeOpenApi.IDocument = filterDocument(
|
|
12
12
|
scenario,
|
|
@@ -15,18 +15,26 @@ export async function compileTestScenario<Model extends ILlmSchema.Model>(
|
|
|
15
15
|
const entries: [string, string][] = Object.entries(
|
|
16
16
|
await ctx.compiler.interface.compile(document),
|
|
17
17
|
);
|
|
18
|
-
const filter = (prefix: string) =>
|
|
19
|
-
|
|
18
|
+
const filter = (prefix: string, exclude?: string) => {
|
|
19
|
+
const result: [string, string][] = entries.filter(
|
|
20
|
+
([key]) => key.startsWith(prefix) === true,
|
|
21
|
+
);
|
|
22
|
+
return Object.fromEntries(
|
|
23
|
+
exclude
|
|
24
|
+
? result.filter(([key]) => key.startsWith(exclude) === false)
|
|
25
|
+
: result,
|
|
26
|
+
);
|
|
27
|
+
};
|
|
20
28
|
return {
|
|
21
29
|
document,
|
|
22
|
-
sdk: filter("src/api/
|
|
30
|
+
sdk: filter("src/api", "src/api/structures"),
|
|
23
31
|
dto: filter("src/api/structures"),
|
|
24
32
|
e2e: filter("test/features"),
|
|
25
33
|
};
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
function filterDocument(
|
|
29
|
-
scenario: AutoBeTestScenario,
|
|
37
|
+
scenario: Pick<AutoBeTestScenario, "endpoint" | "dependencies">,
|
|
30
38
|
document: AutoBeOpenApi.IDocument,
|
|
31
39
|
): AutoBeOpenApi.IDocument {
|
|
32
40
|
const operations: AutoBeOpenApi.IOperation[] = document.operations.filter(
|