@autobe/agent 0.14.6 → 0.15.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/AutoBeMockAgent.js +1 -1
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +10 -8
- package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/index.mjs +1276 -834
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js +4 -9
- package/lib/orchestrate/analyze/orchestrateAnalyzeReviewer.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -8
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeReviewerHistories.js.map +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js +1 -1
- package/lib/orchestrate/analyze/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +65 -0
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +62 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +63 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +28 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterface.js +14 -9
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +13 -40
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +3 -2
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +52 -32
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +350 -0
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +249 -225
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +411 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +55 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.d.ts +23 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +108 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +122 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +75 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js +3 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.js.map +1 -0
- package/lib/orchestrate/interface/{OpenApiEndpointComparator.d.ts → utils/OpenApiEndpointComparator.d.ts} +1 -0
- package/lib/orchestrate/interface/{OpenApiEndpointComparator.js → utils/OpenApiEndpointComparator.js} +6 -0
- package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +1 -0
- package/lib/orchestrate/realize/orchestrateRealize.js +16 -2
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js +5 -7
- package/lib/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +2 -2
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js +3 -2
- package/lib/orchestrate/realize/orchestrateRealizeCoder.js.map +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +34 -13
- package/lib/orchestrate/realize/transformRealizeAuthorization.js +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorization.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js +1 -1
- package/lib/orchestrate/realize/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js +5 -5
- package/lib/orchestrate/realize/transformRealizeCoderHistories.js.map +1 -1
- package/lib/orchestrate/realize/utils/InternalFileSystem.d.ts +8 -0
- package/lib/orchestrate/realize/utils/InternalFileSystem.js +17 -0
- package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.d.ts +3 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.js +8 -0
- package/lib/orchestrate/realize/utils/ProviderFileSystem.js.map +1 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.js +2 -2
- package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js +36 -36
- package/lib/orchestrate/realize/writeCodeUntilCompilePassed.js.map +1 -1
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js +1 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +29 -13
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/transformTestWriteHistories.js +3 -2
- package/lib/orchestrate/test/transformTestWriteHistories.js.map +1 -1
- package/lib/utils/arrayToRecord.d.ts +17 -0
- package/lib/utils/arrayToRecord.js +19 -0
- package/lib/utils/arrayToRecord.js.map +1 -0
- package/lib/utils/backoffRetry.js +0 -1
- package/lib/utils/backoffRetry.js.map +1 -1
- package/package.json +5 -5
- package/src/AutoBeMockAgent.ts +1 -1
- package/src/constants/AutoBeSystemPromptConstant.ts +10 -8
- package/src/orchestrate/analyze/orchestrateAnalyzeReviewer.ts +1 -3
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +1 -3
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +75 -0
- package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +69 -0
- package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +34 -0
- package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +32 -0
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +34 -0
- package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +66 -0
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +34 -0
- package/src/orchestrate/interface/orchestrateInterface.ts +17 -8
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +22 -97
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +48 -55
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +109 -0
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +81 -120
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +197 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +58 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointApplication.ts +24 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +112 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +125 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +76 -0
- package/src/orchestrate/interface/{OpenApiEndpointComparator.ts → utils/OpenApiEndpointComparator.ts} +8 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +19 -2
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +6 -19
- package/src/orchestrate/realize/orchestrateRealizeCoder.ts +3 -6
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +1 -1
- package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +42 -24
- package/src/orchestrate/realize/transformRealizeCoderHistories.ts +4 -4
- package/src/orchestrate/realize/utils/InternalFileSystem.ts +12 -0
- package/src/orchestrate/realize/utils/ProviderFileSystem.ts +4 -0
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +2 -2
- package/src/orchestrate/realize/writeCodeUntilCompilePassed.ts +59 -53
- package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +1 -0
- package/src/orchestrate/test/orchestrateTestScenario.ts +4 -2
- package/src/utils/arrayToRecord.ts +49 -0
- package/src/utils/backoffRetry.ts +0 -1
- package/lib/orchestrate/interface/OpenApiEndpointComparator.js.map +0 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.d.ts +0 -4
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js +0 -473
- package/lib/orchestrate/interface/orchestrateInterfaceComponents.js.map +0 -1
- package/lib/orchestrate/interface/transformInterfaceHistories.d.ts +0 -3
- package/lib/orchestrate/interface/transformInterfaceHistories.js +0 -149
- package/lib/orchestrate/interface/transformInterfaceHistories.js.map +0 -1
- package/src/orchestrate/interface/orchestrateInterfaceComponents.ts +0 -292
- package/src/orchestrate/interface/transformInterfaceHistories.ts +0 -152
|
@@ -5,8 +5,6 @@ import {
|
|
|
5
5
|
IAutoBeTypeScriptCompileResult,
|
|
6
6
|
} from "@autobe/interface";
|
|
7
7
|
import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
|
|
8
|
-
import fs from "fs/promises";
|
|
9
|
-
import path from "path";
|
|
10
8
|
import { IPointer } from "tstl";
|
|
11
9
|
import typia from "typia";
|
|
12
10
|
|
|
@@ -18,6 +16,7 @@ import { IAutoBeRealizeAuthorizationApplication } from "./structures/IAutoBeReal
|
|
|
18
16
|
import { transformRealizeAuthorizationHistories } from "./transformRealizeAuthorization";
|
|
19
17
|
import { transformRealizeAuthorizationCorrectHistories } from "./transformRealizeAuthorizationCorrectHistories";
|
|
20
18
|
import { AuthorizationFileSystem } from "./utils/AuthorizationFileSystem";
|
|
19
|
+
import { InternalFileSystem } from "./utils/InternalFileSystem";
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* 1. Create decorator and its parameters. and design the Authorization Provider.
|
|
@@ -36,34 +35,22 @@ export async function orchestrateRealizeAuthorization<
|
|
|
36
35
|
|
|
37
36
|
let completed = 0;
|
|
38
37
|
|
|
39
|
-
const templateFiles =
|
|
40
|
-
"src/MyGlobal.ts": await fs.readFile(
|
|
41
|
-
path.join(
|
|
42
|
-
__dirname,
|
|
43
|
-
"../../../../../internals/template/realize/src/MyGlobal.ts",
|
|
44
|
-
),
|
|
45
|
-
"utf-8",
|
|
46
|
-
),
|
|
47
|
-
[AuthorizationFileSystem.providerPath("jwtAuthorize")]: await fs.readFile(
|
|
48
|
-
path.join(
|
|
49
|
-
__dirname,
|
|
50
|
-
"../../../../../internals/template/realize/src/providers/jwtAuthorize.ts",
|
|
51
|
-
),
|
|
52
|
-
"utf-8",
|
|
53
|
-
),
|
|
54
|
-
};
|
|
38
|
+
const templateFiles = await (await ctx.compiler()).realize.getTemplate();
|
|
55
39
|
|
|
56
40
|
ctx.dispatch({
|
|
57
41
|
type: "realizeAuthorizationStart",
|
|
58
42
|
step: ctx.state().test?.step ?? 0,
|
|
59
43
|
created_at: new Date().toISOString(),
|
|
60
44
|
});
|
|
45
|
+
|
|
61
46
|
const authorizations: AutoBeRealizeAuthorization[] = await Promise.all(
|
|
62
47
|
roles.map(async (role) => {
|
|
63
48
|
const authorization: AutoBeRealizeAuthorization = await process(
|
|
64
49
|
ctx,
|
|
65
50
|
role,
|
|
66
|
-
|
|
51
|
+
InternalFileSystem.DEFAULT.map((el) => ({
|
|
52
|
+
[el]: templateFiles[el],
|
|
53
|
+
})).reduce((acc, cur) => Object.assign(acc, cur), {}),
|
|
67
54
|
);
|
|
68
55
|
ctx.dispatch({
|
|
69
56
|
type: "realizeAuthorizationWrite",
|
|
@@ -9,10 +9,7 @@ import typia from "typia";
|
|
|
9
9
|
|
|
10
10
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
11
11
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
12
|
-
import {
|
|
13
|
-
randomBackoffRetry,
|
|
14
|
-
randomBackoffStrategy,
|
|
15
|
-
} from "../../utils/backoffRetry";
|
|
12
|
+
import { randomBackoffRetry } from "../../utils/backoffRetry";
|
|
16
13
|
import { enforceToolCall } from "../../utils/enforceToolCall";
|
|
17
14
|
import { getTestScenarioArtifacts } from "../test/compile/getTestScenarioArtifacts";
|
|
18
15
|
import { IAutoBeTestScenarioArtifacts } from "../test/structures/IAutoBeTestScenarioArtifacts";
|
|
@@ -20,6 +17,7 @@ import { RealizePlannerOutput } from "./orchestrateRealizePlanner";
|
|
|
20
17
|
import { IAutoBeRealizeCoderApplication } from "./structures/IAutoBeRealizeCoderApplication";
|
|
21
18
|
import { FAILED } from "./structures/IAutoBeRealizeFailedSymbol";
|
|
22
19
|
import { transformRealizeCoderHistories } from "./transformRealizeCoderHistories";
|
|
20
|
+
import { RealizeFileSystem } from "./utils/ProviderFileSystem";
|
|
23
21
|
import { replaceImportStatements } from "./utils/replaceImportStatements";
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -85,7 +83,6 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
|
85
83
|
vendor: ctx.vendor,
|
|
86
84
|
config: {
|
|
87
85
|
...ctx.config,
|
|
88
|
-
backoffStrategy: randomBackoffStrategy,
|
|
89
86
|
executor: {
|
|
90
87
|
describe: null,
|
|
91
88
|
},
|
|
@@ -138,7 +135,7 @@ export const orchestrateRealizeCoder = async <Model extends ILlmSchema.Model>(
|
|
|
138
135
|
|
|
139
136
|
return {
|
|
140
137
|
...pointer.value,
|
|
141
|
-
filename:
|
|
138
|
+
filename: RealizeFileSystem.providerPath(props.functionName),
|
|
142
139
|
};
|
|
143
140
|
};
|
|
144
141
|
|
|
@@ -13,7 +13,7 @@ export namespace IAutoBeRealizeAuthorizationCorrectApplication {
|
|
|
13
13
|
* Step 1: TypeScript compilation error analysis and diagnosis.
|
|
14
14
|
*
|
|
15
15
|
* AI identifies all compilation errors (type mismatches, imports, syntax)
|
|
16
|
-
* and categorizes them by component (
|
|
16
|
+
* and categorizes them by component (providers/decorator/payload). Analyzes
|
|
17
17
|
* error dependencies and determines fix priorities for systematic
|
|
18
18
|
* resolution.
|
|
19
19
|
*/
|
|
@@ -4,42 +4,60 @@ import {
|
|
|
4
4
|
} from "@autobe/interface";
|
|
5
5
|
import { tags } from "typia";
|
|
6
6
|
|
|
7
|
-
import { IAutoBeRealizeCoderApplication } from "./IAutoBeRealizeCoderApplication";
|
|
8
7
|
import { FAILED } from "./IAutoBeRealizeFailedSymbol";
|
|
9
8
|
|
|
10
9
|
export namespace IAutoBeRealizeCompile {
|
|
11
|
-
|
|
12
|
-
type:
|
|
10
|
+
type IBase<T extends "success" | "failed"> = {
|
|
11
|
+
type: T;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface IOperation {
|
|
15
|
+
/**
|
|
16
|
+
* Operation: An object containing the function specification including the
|
|
17
|
+
* endpoint
|
|
18
|
+
*/
|
|
13
19
|
op: AutoBeOpenApi.IOperation;
|
|
14
|
-
result: Pick<
|
|
15
|
-
IAutoBeRealizeCoderApplication.RealizeCoderOutput,
|
|
16
|
-
"filename" | "implementationCode"
|
|
17
|
-
> & {
|
|
18
|
-
/** Function name */
|
|
19
|
-
name: string;
|
|
20
|
-
};
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
interface SuccessResult {
|
|
23
|
+
/** The name of the file where the implementation will be written */
|
|
24
|
+
filename: string;
|
|
25
|
+
/** The generated implementation code for the function */
|
|
26
|
+
implementationCode: string;
|
|
27
|
+
/** Function name */
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Success extends IBase<"success">, IOperation {
|
|
32
|
+
result: SuccessResult;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface Fail extends IBase<"failed">, IOperation {
|
|
26
36
|
result: FAILED;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
>;
|
|
39
|
+
export interface FileContentMapEntry {
|
|
40
|
+
result: "failed" | "success";
|
|
41
|
+
content: string;
|
|
42
|
+
role?: (string & tags.MinLength<1>) | null;
|
|
43
|
+
endpoint?: AutoBeOpenApi.IEndpoint;
|
|
44
|
+
location?: string;
|
|
45
|
+
name?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type FileContentMap = Record<string, FileContentMapEntry>;
|
|
40
49
|
|
|
41
50
|
export interface CompileDiagnostics {
|
|
51
|
+
/**
|
|
52
|
+
* Array containing all errors including previous attempts. Includes errors
|
|
53
|
+
* that have already been resolved. Used to preserve error context and
|
|
54
|
+
* identify recurring error patterns.
|
|
55
|
+
*/
|
|
42
56
|
total: IAutoBeTypeScriptCompileResult.IDiagnostic[];
|
|
57
|
+
/**
|
|
58
|
+
* Array containing errors from the most recent code compilation. These are
|
|
59
|
+
* the errors that need to be resolved in the current iteration.
|
|
60
|
+
*/
|
|
43
61
|
current: IAutoBeTypeScriptCompileResult.IDiagnostic[];
|
|
44
62
|
}
|
|
45
63
|
}
|
|
@@ -101,12 +101,12 @@ export const transformRealizeCoderHistories = (
|
|
|
101
101
|
`- Decorator implementation: decorators/${props.decoratorEvent.decorator.name}.ts`,
|
|
102
102
|
` - NestJS parameter decorator`,
|
|
103
103
|
` - When importing from providers folder, use: '../decorators/${props.decoratorEvent.decorator.name}'`,
|
|
104
|
-
`- Authentication provider:
|
|
104
|
+
`- Authentication provider: decorators/${props.decoratorEvent.provider.name}.ts`,
|
|
105
105
|
` - Contains JWT validation, role checking, and authorization logic`,
|
|
106
|
-
` - When importing from providers folder, use: '../
|
|
107
|
-
`- Type definition:
|
|
106
|
+
` - When importing from providers folder, use: '../decorators/${props.decoratorEvent.provider.name}'`,
|
|
107
|
+
`- Type definition: decorators/payload/${props.decoratorEvent.payload.name}.ts`,
|
|
108
108
|
` - TypeScript interface for authenticated user payload`,
|
|
109
|
-
` - When importing from providers folder, use: '../
|
|
109
|
+
` - When importing from providers folder, use: '../decorators/payload/${props.decoratorEvent.payload.name}'`,
|
|
110
110
|
].join("\n")
|
|
111
111
|
: "",
|
|
112
112
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export namespace InternalFileSystem {
|
|
2
|
+
/**
|
|
3
|
+
* Get template files for all of realize agents
|
|
4
|
+
*
|
|
5
|
+
* @returns Template file paths
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT = [
|
|
8
|
+
"src/providers/authorize/jwtAuthorize.ts",
|
|
9
|
+
"src/MyGlobal.ts",
|
|
10
|
+
"src/util/toISOStringSafe.ts",
|
|
11
|
+
];
|
|
12
|
+
}
|
|
@@ -38,7 +38,7 @@ export function replaceImportStatements<Model extends ILlmSchema.Model>(
|
|
|
38
38
|
// Remove any existing decoratorType imports if LLM mistakenly added them
|
|
39
39
|
if (decoratorType) {
|
|
40
40
|
const decoratorTypeRegex = new RegExp(
|
|
41
|
-
`import\\s*{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/
|
|
41
|
+
`import\\s*{\\s*${decoratorType}\\s*}\\s*from\\s*["']\\.\\.\/decorators\/payload\/${decoratorType}["']\\s*;?\\s*`,
|
|
42
42
|
"gm",
|
|
43
43
|
);
|
|
44
44
|
code = code.replace(decoratorTypeRegex, "");
|
|
@@ -56,7 +56,7 @@ export function replaceImportStatements<Model extends ILlmSchema.Model>(
|
|
|
56
56
|
// Only add decoratorType import if it exists
|
|
57
57
|
if (decoratorType) {
|
|
58
58
|
imports.push(
|
|
59
|
-
`import { ${decoratorType} } from "../
|
|
59
|
+
`import { ${decoratorType} } from "../decorators/payload/${decoratorType}"`,
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
IAutoBeTypeScriptCompileResult,
|
|
6
6
|
} from "@autobe/interface";
|
|
7
7
|
import { ILlmSchema } from "@samchon/openapi";
|
|
8
|
-
import { readFile } from "fs/promises";
|
|
9
|
-
import path from "path";
|
|
10
8
|
|
|
11
9
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
10
|
+
import { arrayToRecord } from "../../utils/arrayToRecord";
|
|
12
11
|
import { pipe } from "./RealizePipe";
|
|
13
12
|
import { orchestrateRealizeCoder } from "./orchestrateRealizeCoder";
|
|
14
13
|
import { orchestrateRealizePlanner } from "./orchestrateRealizePlanner";
|
|
15
14
|
import { IAutoBeRealizeCompile } from "./structures/IAutoBeRealizeCompile";
|
|
16
15
|
import { FAILED } from "./structures/IAutoBeRealizeFailedSymbol";
|
|
16
|
+
import { RealizeFileSystem } from "./utils/ProviderFileSystem";
|
|
17
17
|
|
|
18
18
|
export async function writeCodeUntilCompilePassed<
|
|
19
19
|
Model extends ILlmSchema.Model,
|
|
@@ -23,26 +23,20 @@ export async function writeCodeUntilCompilePassed<
|
|
|
23
23
|
authorizations: AutoBeRealizeAuthorization[],
|
|
24
24
|
retry: number,
|
|
25
25
|
): Promise<AutoBeRealizeFunction[]> {
|
|
26
|
-
const payloads =
|
|
27
|
-
.map((el) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
.reduce(
|
|
39
|
-
(acc, [filename, content]) => Object.assign(acc, { [filename]: content }),
|
|
40
|
-
{},
|
|
41
|
-
);
|
|
26
|
+
const payloads = arrayToRecord(
|
|
27
|
+
authorizations.map((el) => el.payload),
|
|
28
|
+
"location",
|
|
29
|
+
"content",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const files = arrayToRecord(
|
|
33
|
+
Object.entries(await ctx.files({ dbms: "postgres" })).filter(([key]) =>
|
|
34
|
+
key.startsWith("src"),
|
|
35
|
+
),
|
|
36
|
+
);
|
|
42
37
|
|
|
43
|
-
const templateFiles = ["src/MyGlobal.ts", "src/util/toISOStringSafe.ts"];
|
|
44
38
|
const entireCodes: IAutoBeRealizeCompile.FileContentMap = {
|
|
45
|
-
...(await loadTemplateFiles(
|
|
39
|
+
...(await loadTemplateFiles(ctx)),
|
|
46
40
|
};
|
|
47
41
|
|
|
48
42
|
let diagnostics: IAutoBeRealizeCompile.CompileDiagnostics = {
|
|
@@ -91,16 +85,12 @@ export async function writeCodeUntilCompilePassed<
|
|
|
91
85
|
...payloads,
|
|
92
86
|
...files,
|
|
93
87
|
...nodeModules,
|
|
94
|
-
...
|
|
95
|
-
.map(([filename, { content }]) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.reduce<Record<string, string>>(
|
|
101
|
-
(acc, cur) => Object.assign(acc, cur),
|
|
102
|
-
{},
|
|
103
|
-
),
|
|
88
|
+
...arrayToRecord(
|
|
89
|
+
Object.entries(entireCodes).map(([filename, { content }]) => [
|
|
90
|
+
filename,
|
|
91
|
+
content,
|
|
92
|
+
]),
|
|
93
|
+
),
|
|
104
94
|
},
|
|
105
95
|
});
|
|
106
96
|
|
|
@@ -121,35 +111,33 @@ export async function writeCodeUntilCompilePassed<
|
|
|
121
111
|
}
|
|
122
112
|
}
|
|
123
113
|
|
|
124
|
-
return
|
|
125
|
-
.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
114
|
+
return (
|
|
115
|
+
Object.entries(entireCodes)
|
|
116
|
+
// .filter(([filename]) => filename.startsWith("src/providers")) // filter only provider files
|
|
117
|
+
.map(([filename, value]) => {
|
|
118
|
+
return {
|
|
119
|
+
filename,
|
|
120
|
+
content: value.content,
|
|
121
|
+
endpoint: value.endpoint!,
|
|
122
|
+
location: value.location!,
|
|
123
|
+
name: value.name!,
|
|
124
|
+
role: value.role!,
|
|
125
|
+
};
|
|
126
|
+
})
|
|
127
|
+
);
|
|
136
128
|
}
|
|
137
129
|
|
|
138
|
-
async function loadTemplateFiles(
|
|
139
|
-
|
|
130
|
+
async function loadTemplateFiles<Model extends ILlmSchema.Model>(
|
|
131
|
+
ctx: AutoBeContext<Model>,
|
|
140
132
|
): Promise<IAutoBeRealizeCompile.FileContentMap> {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
"../../../../../internals/template/realize",
|
|
144
|
-
);
|
|
133
|
+
const templateFiles = await (await ctx.compiler()).realize.getTemplate();
|
|
134
|
+
const targets = ["src/MyGlobal.ts", "src/util/toISOStringSafe.ts"];
|
|
145
135
|
|
|
146
136
|
const result: IAutoBeRealizeCompile.FileContentMap = {};
|
|
147
137
|
|
|
148
|
-
for (const filePath of
|
|
138
|
+
for (const filePath of targets) {
|
|
149
139
|
result[filePath] = {
|
|
150
|
-
content:
|
|
151
|
-
encoding: "utf-8",
|
|
152
|
-
}),
|
|
140
|
+
content: templateFiles[filePath],
|
|
153
141
|
result: "success",
|
|
154
142
|
location: filePath,
|
|
155
143
|
role: null,
|
|
@@ -171,7 +159,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
171
159
|
op,
|
|
172
160
|
(op) => orchestrateRealizePlanner(ctx, op, decorator),
|
|
173
161
|
async (p) => {
|
|
174
|
-
const filename =
|
|
162
|
+
const filename = RealizeFileSystem.providerPath(p.functionName);
|
|
175
163
|
const t = diagnostics.total.filter((el) => el.file === filename);
|
|
176
164
|
|
|
177
165
|
const d = diagnostics.current.filter((el) => el.file === filename);
|
|
@@ -204,6 +192,16 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
204
192
|
return { type: "success", op: op, result } as const;
|
|
205
193
|
}
|
|
206
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Determines whether an operation should be processed in the current iteration.
|
|
197
|
+
* In the initial case (no errors), all operations are processed. When errors
|
|
198
|
+
* exist, only operations with compilation errors are targeted for reprocessing
|
|
199
|
+
* in the next iteration.
|
|
200
|
+
*
|
|
201
|
+
* @param op - The operation to check
|
|
202
|
+
* @param currentDiagnostics - Current compilation errors
|
|
203
|
+
* @returns True if the operation should be processed
|
|
204
|
+
*/
|
|
207
205
|
function shouldProcessOperation(
|
|
208
206
|
op: AutoBeOpenApi.IOperation,
|
|
209
207
|
currentDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
|
|
@@ -219,6 +217,14 @@ function shouldProcessOperation(
|
|
|
219
217
|
);
|
|
220
218
|
}
|
|
221
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Generates a provider filename for an operation. Converts the operation's HTTP
|
|
222
|
+
* method and path into a valid TypeScript filename. The filename serves as both
|
|
223
|
+
* the function name and the file identifier.
|
|
224
|
+
*
|
|
225
|
+
* @param op - The operation to generate a filename for
|
|
226
|
+
* @returns The generated provider filename with path
|
|
227
|
+
*/
|
|
222
228
|
function generateProviderFilename(op: AutoBeOpenApi.IOperation): string {
|
|
223
229
|
return `src/providers/${op.method}_${op.path
|
|
224
230
|
.replaceAll("/", "_")
|
|
@@ -150,9 +150,11 @@ const execute = async <Model extends ILlmSchema.Model>(
|
|
|
150
150
|
ctx.usage().record(tokenUsage, ["test"]);
|
|
151
151
|
});
|
|
152
152
|
if (pointer.value.length === 0) {
|
|
153
|
-
|
|
153
|
+
console.error("Failed to create test plans. No function called.");
|
|
154
|
+
return [];
|
|
155
|
+
// @todo
|
|
156
|
+
// throw new Error("Failed to create test plans.");
|
|
154
157
|
}
|
|
155
|
-
|
|
156
158
|
return pointer.value;
|
|
157
159
|
};
|
|
158
160
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts an array of key-value pairs (entries) into a Record.
|
|
3
|
+
*
|
|
4
|
+
* @param entries - Array of [key, value] tuples
|
|
5
|
+
* @returns Record object from the entries
|
|
6
|
+
*/
|
|
7
|
+
export function arrayToRecord<V>(
|
|
8
|
+
entries: Array<[string, V]>,
|
|
9
|
+
): Record<string, V>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Converts an array of objects into a Record using specified key and value
|
|
13
|
+
* properties.
|
|
14
|
+
*
|
|
15
|
+
* @param items - Array of items to convert
|
|
16
|
+
* @param keyProp - Property name to use as the key
|
|
17
|
+
* @param valueProp - Property name to use as the value
|
|
18
|
+
* @returns Record object with the extracted key-value pairs
|
|
19
|
+
*/
|
|
20
|
+
export function arrayToRecord<T, K extends keyof T, V extends keyof T>(
|
|
21
|
+
items: T[],
|
|
22
|
+
keyProp: K,
|
|
23
|
+
valueProp: V,
|
|
24
|
+
): Record<string, T[V]>;
|
|
25
|
+
|
|
26
|
+
export function arrayToRecord<T, K extends keyof T, V extends keyof T>(
|
|
27
|
+
items: T[] | Array<[string, any]>,
|
|
28
|
+
keyProp?: K,
|
|
29
|
+
valueProp?: V,
|
|
30
|
+
): Record<string, any> {
|
|
31
|
+
// Handle entries format [string, value][]
|
|
32
|
+
if (items.length > 0 && Array.isArray(items[0]) && items[0].length === 2) {
|
|
33
|
+
return (items as Array<[string, any]>).reduce(
|
|
34
|
+
(acc, [key, value]) => Object.assign(acc, { [key]: value }),
|
|
35
|
+
{},
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Handle object array format with key and value properties
|
|
40
|
+
if (keyProp !== undefined && valueProp !== undefined) {
|
|
41
|
+
return (items as T[])
|
|
42
|
+
.map((item) => ({
|
|
43
|
+
[String(item[keyProp])]: item[valueProp],
|
|
44
|
+
}))
|
|
45
|
+
.reduce((acc, cur) => Object.assign(acc, cur), {});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
throw new Error("Invalid arguments for arrayToRecord");
|
|
49
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiEndpointComparator.js","sourceRoot":"","sources":["../../../src/orchestrate/interface/OpenApiEndpointComparator.ts"],"names":[],"mappings":";;;AACA,+BAA4B;AAE5B,IAAiB,yBAAyB,CAWzC;AAXD,WAAiB,yBAAyB;IACxC,SAAgB,QAAQ,CAAC,CAA0B;QACjD,OAAO,IAAA,WAAI,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAFe,kCAAQ,WAEvB,CAAA;IAED,SAAgB,MAAM,CACpB,CAA0B,EAC1B,CAA0B;QAE1B,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC;IACpD,CAAC;IALe,gCAAM,SAKrB,CAAA;AACH,CAAC,EAXgB,yBAAyB,yCAAzB,yBAAyB,QAWzC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
-
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
4
|
-
export declare function orchestrateInterfaceComponents<Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, operations: AutoBeOpenApi.IOperation[], capacity?: number): Promise<AutoBeOpenApi.IComponents>;
|