@autobe/agent 0.24.2 → 0.25.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 -1
- package/lib/AutoBeAgent.js.map +1 -1
- package/lib/AutoBeMockAgent.js +1 -0
- package/lib/AutoBeMockAgent.js.map +1 -1
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +21 -21
- package/lib/context/IAutoBeApplication.d.ts +101 -6
- package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
- package/lib/factory/createAgenticaHistory.js +1 -1
- package/lib/factory/createAgenticaHistory.js.map +1 -1
- package/lib/factory/createAutoBeApplication.js +80 -90
- package/lib/factory/createAutoBeApplication.js.map +1 -1
- package/lib/factory/createAutoBeContext.js +6 -5
- package/lib/factory/createAutoBeContext.js.map +1 -1
- package/lib/index.mjs +3914 -2594
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
- package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
- package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
- package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
- package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js +36 -23
- package/lib/orchestrate/common/orchestrateCommonCorrectCasting.js.map +1 -1
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.d.ts +22 -42
- package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
- package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
- package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.js → transformInterfaceCommonPrerequisiteHistories.js} +4 -4
- package/lib/orchestrate/interface/histories/transformInterfaceCommonPrerequisiteHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
- package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +27 -6
- package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
- package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.d.ts +3 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js +102 -0
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.js.map +1 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
- package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +45 -11
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +277 -37
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +69 -70
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +28 -13
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +11 -8
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +36 -21
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js +260 -29
- package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.d.ts +5 -0
- package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js +713 -0
- package/lib/orchestrate/interface/orchestrateInterfacePrerequisites.js.map +1 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +83 -53
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js +41 -7
- package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +0 -38
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +6 -10
- package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.d.ts +52 -0
- package/lib/orchestrate/{common/structures/IAutoBeCommonCorrectDateApplication.js → interface/structures/IAutoBeInterfacePrerequisitesApplication.js} +1 -1
- package/lib/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.js.map +1 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +0 -33
- package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +6 -2
- package/lib/orchestrate/interface/utils/JsonSchemaFactory.js +105 -5
- package/lib/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -1
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js +20 -1
- package/lib/orchestrate/interface/utils/JsonSchemaValidator.js.map +1 -1
- package/lib/orchestrate/interface/utils/OperationValidator.d.ts +3 -4
- package/lib/orchestrate/interface/utils/OperationValidator.js +1 -1
- package/lib/orchestrate/interface/utils/OperationValidator.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
- package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
- package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
- package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
- package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
- package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
- package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
- package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +32 -0
- package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +14 -22
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +6 -6
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +8 -2
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js +1 -2
- package/lib/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.d.ts +2 -1
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +119 -42
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +82 -52
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +128 -88
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -1
- package/lib/orchestrate/realize/orchestrateRealizeWrite.js +117 -54
- package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +52 -26
- package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +44 -34
- package/lib/orchestrate/realize/utils/InternalFileSystem.js +1 -1
- package/lib/orchestrate/realize/utils/InternalFileSystem.js.map +1 -1
- package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
- package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +8 -3
- package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +44 -17
- package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +4 -1
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js +24 -9
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -1
- package/lib/orchestrate/realize/utils/printErrorHints.d.ts +8 -0
- package/lib/orchestrate/realize/utils/printErrorHints.js +48 -0
- package/lib/orchestrate/realize/utils/printErrorHints.js.map +1 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +1 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.js +93 -53
- package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
- package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +35 -96
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +6 -3
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +33 -77
- package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
- package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
- package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
- package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTest.js +20 -14
- package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
- package/lib/orchestrate/test/orchestrateTestCorrect.js +81 -50
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js +31 -13
- package/lib/orchestrate/test/orchestrateTestCorrectInvalidRequest.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +18 -7
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js +20 -12
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +46 -25
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +9 -5
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.d.ts +8 -2
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +11 -7
- package/lib/orchestrate/test/utils/getPrerequisites.d.ts +5 -0
- package/lib/orchestrate/test/utils/getPrerequisites.js +36 -0
- package/lib/orchestrate/test/utils/getPrerequisites.js.map +1 -0
- package/lib/orchestrate/test/utils/getReferenceIds.js +1 -1
- package/lib/orchestrate/test/utils/getReferenceIds.js.map +1 -1
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +17 -1
- package/src/AutoBeMockAgent.ts +1 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +21 -21
- package/src/context/IAutoBeApplication.ts +101 -6
- package/src/context/IAutoBeApplicationProps.ts +6 -2
- package/src/factory/createAgenticaHistory.ts +11 -5
- package/src/factory/createAutoBeContext.ts +6 -5
- package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
- package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
- package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
- package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
- package/src/orchestrate/common/orchestrateCommonCorrectCasting.ts +2 -2
- package/src/orchestrate/common/structures/IAutoBeCommonCorrectCastingApplication.ts +25 -45
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
- package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
- package/src/orchestrate/interface/histories/{transformInterfacePrerequisiteHistories.ts → transformInterfaceCommonPrerequisiteHistories.ts} +1 -1
- package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
- package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
- package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +30 -6
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
- package/src/orchestrate/interface/histories/transformInterfacePrerequisitesHistories.ts +118 -0
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
- package/src/orchestrate/interface/orchestrateInterface.ts +65 -20
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +34 -47
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +40 -28
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +51 -35
- package/src/orchestrate/interface/orchestrateInterfacePrerequisites.ts +274 -0
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +52 -33
- package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +1 -1
- package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +0 -39
- package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +6 -10
- package/src/orchestrate/interface/structures/IAutoBeInterfacePrerequisitesApplication.ts +58 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +0 -34
- package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +92 -4
- package/src/orchestrate/interface/utils/JsonSchemaValidator.ts +19 -1
- package/src/orchestrate/interface/utils/OperationValidator.ts +9 -7
- package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
- package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
- package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
- package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
- package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +44 -0
- package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +13 -24
- package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +6 -6
- package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +6 -4
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +1 -5
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +102 -16
- package/src/orchestrate/realize/orchestrateRealize.ts +121 -81
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +50 -7
- package/src/orchestrate/realize/orchestrateRealizeWrite.ts +14 -4
- package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +54 -29
- package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +46 -35
- package/src/orchestrate/realize/utils/InternalFileSystem.ts +1 -1
- package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
- package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +54 -22
- package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +28 -16
- package/src/orchestrate/realize/utils/printErrorHints.ts +55 -0
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +99 -97
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +50 -115
- package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +41 -111
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
- package/src/orchestrate/test/orchestrateTest.ts +19 -13
- package/src/orchestrate/test/orchestrateTestCorrect.ts +71 -51
- package/src/orchestrate/test/orchestrateTestCorrectInvalidRequest.ts +13 -1
- package/src/orchestrate/test/orchestrateTestScenario.ts +27 -17
- package/src/orchestrate/test/orchestrateTestScenarioReview.ts +32 -19
- package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +9 -228
- package/src/orchestrate/test/structures/IAutoBeTestCorrectInvalidRequestApplication.ts +8 -2
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +11 -78
- package/src/orchestrate/test/utils/getPrerequisites.ts +51 -0
- package/src/orchestrate/test/utils/getReferenceIds.ts +2 -1
- package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
- package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.d.ts +0 -3
- package/lib/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js.map +0 -1
- package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.d.ts +0 -6
- package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js +0 -22
- package/lib/orchestrate/interface/utils/OpenApiEndpointComparator.js.map +0 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
- package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
- package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
- package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
- package/src/orchestrate/interface/utils/OpenApiEndpointComparator.ts +0 -23
- package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
|
@@ -14,9 +14,12 @@ import { v7 } from "uuid";
|
|
|
14
14
|
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
15
15
|
import { assertSchemaModel } from "../../context/assertSchemaModel";
|
|
16
16
|
import { executeCachedBatch } from "../../utils/executeCachedBatch";
|
|
17
|
-
import { transformCommonCorrectCastingHistories } from "../common/histories/transformCommonCorrectCastingHistories";
|
|
18
17
|
import { IAutoBeCommonCorrectCastingApplication } from "../common/structures/IAutoBeCommonCorrectCastingApplication";
|
|
18
|
+
import { transformRealizeCorrectCastingHistories } from "./histories/transformRealizeCorrectCastingHistories";
|
|
19
19
|
import { compileRealizeFiles } from "./internal/compileRealizeFiles";
|
|
20
|
+
import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
|
|
21
|
+
import { getRealizeWriteCodeTemplate } from "./utils/getRealizeWriteCodeTemplate";
|
|
22
|
+
import { replaceImportStatements } from "./utils/replaceImportStatements";
|
|
20
23
|
|
|
21
24
|
/** Result of attempting to correct a single function */
|
|
22
25
|
type CorrectionResult = {
|
|
@@ -28,6 +31,7 @@ export const orchestrateRealizeCorrectCasting = async <
|
|
|
28
31
|
Model extends ILlmSchema.Model,
|
|
29
32
|
>(
|
|
30
33
|
ctx: AutoBeContext<Model>,
|
|
34
|
+
scenarios: IAutoBeRealizeScenarioResult[],
|
|
31
35
|
authorizations: AutoBeRealizeAuthorization[],
|
|
32
36
|
functions: AutoBeRealizeFunction[],
|
|
33
37
|
progress: AutoBeProgressEventBase,
|
|
@@ -40,9 +44,9 @@ export const orchestrateRealizeCorrectCasting = async <
|
|
|
40
44
|
functions,
|
|
41
45
|
},
|
|
42
46
|
);
|
|
43
|
-
|
|
44
47
|
return predicate(
|
|
45
48
|
ctx,
|
|
49
|
+
scenarios,
|
|
46
50
|
authorizations,
|
|
47
51
|
functions,
|
|
48
52
|
[],
|
|
@@ -54,6 +58,7 @@ export const orchestrateRealizeCorrectCasting = async <
|
|
|
54
58
|
|
|
55
59
|
const predicate = async <Model extends ILlmSchema.Model>(
|
|
56
60
|
ctx: AutoBeContext<Model>,
|
|
61
|
+
scenarios: IAutoBeRealizeScenarioResult[],
|
|
57
62
|
authorizations: AutoBeRealizeAuthorization[],
|
|
58
63
|
functions: AutoBeRealizeFunction[],
|
|
59
64
|
failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
|
|
@@ -63,9 +68,9 @@ const predicate = async <Model extends ILlmSchema.Model>(
|
|
|
63
68
|
): Promise<AutoBeRealizeFunction[]> => {
|
|
64
69
|
if (event.result.type === "failure") {
|
|
65
70
|
ctx.dispatch(event);
|
|
66
|
-
|
|
67
71
|
return await correct(
|
|
68
72
|
ctx,
|
|
73
|
+
scenarios,
|
|
69
74
|
authorizations,
|
|
70
75
|
functions,
|
|
71
76
|
[...failures, ...event.result.diagnostics],
|
|
@@ -79,6 +84,7 @@ const predicate = async <Model extends ILlmSchema.Model>(
|
|
|
79
84
|
|
|
80
85
|
const correct = async <Model extends ILlmSchema.Model>(
|
|
81
86
|
ctx: AutoBeContext<Model>,
|
|
87
|
+
scenarios: IAutoBeRealizeScenarioResult[],
|
|
82
88
|
authorizations: AutoBeRealizeAuthorization[],
|
|
83
89
|
functions: AutoBeRealizeFunction[],
|
|
84
90
|
failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
|
|
@@ -94,6 +100,12 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
94
100
|
const locations: string[] = diagnose(event).filter((l) =>
|
|
95
101
|
functions.map((f) => f.location).includes(l),
|
|
96
102
|
);
|
|
103
|
+
|
|
104
|
+
// If no locations to correct, return original functions
|
|
105
|
+
if (locations.length === 0) {
|
|
106
|
+
return functions;
|
|
107
|
+
}
|
|
108
|
+
|
|
97
109
|
progress.total += locations.length;
|
|
98
110
|
|
|
99
111
|
const converted: CorrectionResult[] = await executeCachedBatch(
|
|
@@ -102,6 +114,13 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
102
114
|
(f) => f.location === location,
|
|
103
115
|
)!;
|
|
104
116
|
|
|
117
|
+
const scenario = scenarios.find((s) => s.location === func.location)!;
|
|
118
|
+
|
|
119
|
+
const operation = scenario.operation;
|
|
120
|
+
const authorization = authorizations.find(
|
|
121
|
+
(a) => a.role.name === operation.authorizationRole,
|
|
122
|
+
);
|
|
123
|
+
|
|
105
124
|
const pointer: IPointer<
|
|
106
125
|
IAutoBeCommonCorrectCastingApplication.IProps | false | null
|
|
107
126
|
> = {
|
|
@@ -110,7 +129,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
110
129
|
|
|
111
130
|
const { tokenUsage } = await ctx.conversate({
|
|
112
131
|
source: "realizeCorrect",
|
|
113
|
-
histories:
|
|
132
|
+
histories: transformRealizeCorrectCastingHistories([
|
|
114
133
|
{
|
|
115
134
|
script: func.content,
|
|
116
135
|
diagnostics: failures.filter((d) => d.file === location),
|
|
@@ -137,18 +156,62 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
137
156
|
|
|
138
157
|
You don't need to explain me anything, but just fix or give it up
|
|
139
158
|
immediately without any hesitation, explanation, and questions.
|
|
159
|
+
|
|
160
|
+
The instruction to write at first was as follows, and the code you received is the code you wrote according to this instruction.
|
|
161
|
+
When modifying, modify the entire code, but not the import statement.
|
|
162
|
+
|
|
163
|
+
Below is template code you wrote:
|
|
164
|
+
|
|
165
|
+
${getRealizeWriteCodeTemplate({
|
|
166
|
+
scenario,
|
|
167
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
168
|
+
operation: scenario.operation,
|
|
169
|
+
authorization: authorization ?? null,
|
|
170
|
+
})}
|
|
171
|
+
|
|
172
|
+
Current code is as follows:
|
|
173
|
+
|
|
174
|
+
\`\`\`typescript
|
|
175
|
+
${func.content}
|
|
176
|
+
\`\`\`
|
|
177
|
+
|
|
178
|
+
Also, never use typia.assert and typia.assertGuard like functions
|
|
179
|
+
to the Prisma types. Your mission is to fix the casting problem of
|
|
180
|
+
primitive types like string or number. Prisma type is not your scope.
|
|
181
|
+
|
|
182
|
+
If you take a mistake that casting the Prisma type with the typia.assert
|
|
183
|
+
function, it would be fallen into the infinite compilation due to extremely
|
|
184
|
+
complicated Prisma type. Note that, the typia.assert function is allowed
|
|
185
|
+
only in the individual property level string or literal type.
|
|
186
|
+
|
|
187
|
+
I repeat that, never assert the Prisma type. It's not your mission.
|
|
140
188
|
`,
|
|
141
189
|
});
|
|
142
190
|
++progress.completed;
|
|
191
|
+
|
|
143
192
|
if (pointer.value === null)
|
|
144
193
|
return { result: "exception" as const, func: func };
|
|
145
194
|
else if (pointer.value === false)
|
|
146
195
|
return { result: "ignore" as const, func: func };
|
|
147
196
|
|
|
197
|
+
pointer.value.draft = await replaceImportStatements(ctx, {
|
|
198
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
199
|
+
operation: operation,
|
|
200
|
+
code: pointer.value.draft,
|
|
201
|
+
decoratorType: authorization?.payload.name,
|
|
202
|
+
});
|
|
203
|
+
if (pointer.value.revise.final)
|
|
204
|
+
pointer.value.revise.final = await replaceImportStatements(ctx, {
|
|
205
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
206
|
+
operation: operation,
|
|
207
|
+
code: pointer.value.revise.final,
|
|
208
|
+
decoratorType: authorization?.payload.name,
|
|
209
|
+
});
|
|
210
|
+
|
|
148
211
|
ctx.dispatch({
|
|
149
212
|
id: v7(),
|
|
150
213
|
type: "realizeCorrect",
|
|
151
|
-
content: pointer.value.revise.final,
|
|
214
|
+
content: pointer.value.revise.final ?? pointer.value.draft,
|
|
152
215
|
created_at: new Date().toISOString(),
|
|
153
216
|
location: func.location,
|
|
154
217
|
step: ctx.state().analyze?.step ?? 0,
|
|
@@ -156,24 +219,48 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
156
219
|
completed: progress.completed,
|
|
157
220
|
total: progress.total,
|
|
158
221
|
});
|
|
159
|
-
|
|
160
222
|
return {
|
|
161
223
|
result: "success" as const,
|
|
162
|
-
func: {
|
|
224
|
+
func: {
|
|
225
|
+
...func,
|
|
226
|
+
content: pointer.value.revise.final ?? pointer.value.draft,
|
|
227
|
+
},
|
|
163
228
|
};
|
|
164
229
|
}),
|
|
165
230
|
);
|
|
166
231
|
|
|
232
|
+
// Get functions that were not modified (not in locations array)
|
|
233
|
+
const unchangedFunctions: AutoBeRealizeFunction[] = functions.filter(
|
|
234
|
+
(f) => !locations.includes(f.location),
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
// Merge converted functions with unchanged functions for validation
|
|
238
|
+
const allFunctionsForValidation = [
|
|
239
|
+
...converted.map((c) => c.func),
|
|
240
|
+
...unchangedFunctions,
|
|
241
|
+
];
|
|
242
|
+
|
|
167
243
|
const newValidate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
|
|
168
244
|
ctx,
|
|
169
245
|
{
|
|
170
246
|
authorizations,
|
|
171
|
-
functions:
|
|
247
|
+
functions: allFunctionsForValidation,
|
|
172
248
|
},
|
|
173
249
|
);
|
|
174
250
|
|
|
175
|
-
|
|
176
|
-
|
|
251
|
+
const newResult: IAutoBeTypeScriptCompileResult = newValidate.result;
|
|
252
|
+
if (newResult.type === "success") {
|
|
253
|
+
return allFunctionsForValidation;
|
|
254
|
+
} else if (newResult.type === "exception") {
|
|
255
|
+
// Compilation exception, return current functions. because retrying won't help.
|
|
256
|
+
return functions;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (
|
|
260
|
+
newResult.diagnostics.every((d) => !d.file?.startsWith("src/providers"))
|
|
261
|
+
) {
|
|
262
|
+
// No diagnostics related to provider functions, stop correcting
|
|
263
|
+
return allFunctionsForValidation;
|
|
177
264
|
}
|
|
178
265
|
|
|
179
266
|
const newLocations: string[] = diagnose(newValidate);
|
|
@@ -184,18 +271,16 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
184
271
|
newLocations,
|
|
185
272
|
);
|
|
186
273
|
|
|
187
|
-
// If no failures to retry, return
|
|
274
|
+
// If no failures to retry, return all functions
|
|
188
275
|
if (failed.length === 0) {
|
|
189
|
-
return [...success, ...ignored];
|
|
276
|
+
return [...success, ...ignored, ...unchangedFunctions];
|
|
190
277
|
}
|
|
191
278
|
|
|
192
279
|
// Collect diagnostics relevant to failed functions
|
|
193
280
|
const failedLocations: string[] = failed.map((f) => f.location);
|
|
194
281
|
const allDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] = [
|
|
195
282
|
...failures,
|
|
196
|
-
...(
|
|
197
|
-
? newValidate.result.diagnostics
|
|
198
|
-
: []),
|
|
283
|
+
...(newResult.type === "failure" ? newResult.diagnostics : []),
|
|
199
284
|
];
|
|
200
285
|
const relevantDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] =
|
|
201
286
|
filterRelevantDiagnostics(allDiagnostics, failedLocations);
|
|
@@ -203,6 +288,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
203
288
|
// Recursively retry failed functions
|
|
204
289
|
const retriedFunctions: AutoBeRealizeFunction[] = await predicate(
|
|
205
290
|
ctx,
|
|
291
|
+
scenarios,
|
|
206
292
|
authorizations,
|
|
207
293
|
failed,
|
|
208
294
|
relevantDiagnostics,
|
|
@@ -211,7 +297,7 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
211
297
|
life - 1,
|
|
212
298
|
);
|
|
213
299
|
|
|
214
|
-
return [...success, ...ignored, ...retriedFunctions];
|
|
300
|
+
return [...success, ...ignored, ...retriedFunctions, ...unchangedFunctions];
|
|
215
301
|
};
|
|
216
302
|
|
|
217
303
|
/**
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
AutoBeRealizeAuthorization,
|
|
6
6
|
AutoBeRealizeFunction,
|
|
7
7
|
AutoBeRealizeHistory,
|
|
8
|
+
AutoBeRealizeValidateEvent,
|
|
8
9
|
AutoBeRealizeWriteEvent,
|
|
9
10
|
IAutoBeCompiler,
|
|
10
11
|
} from "@autobe/interface";
|
|
@@ -19,7 +20,6 @@ import { compileRealizeFiles } from "./internal/compileRealizeFiles";
|
|
|
19
20
|
import { orchestrateRealizeCorrectCasting } from "./orchestRateRealizeCorrectCasting";
|
|
20
21
|
import { orchestrateRealizeAuthorization } from "./orchestrateRealizeAuthorization";
|
|
21
22
|
import { orchestrateRealizeCorrect } from "./orchestrateRealizeCorrect";
|
|
22
|
-
import { orchestrateRealizeCorrectDate } from "./orchestrateRealizeCorrectDate";
|
|
23
23
|
import { orchestrateRealizeWrite } from "./orchestrateRealizeWrite";
|
|
24
24
|
import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
|
|
25
25
|
import { generateRealizeScenario } from "./utils/generateRealizeScenario";
|
|
@@ -30,9 +30,9 @@ export const orchestrateRealize =
|
|
|
30
30
|
props: IAutoBeApplicationProps,
|
|
31
31
|
): Promise<AutoBeAssistantMessageHistory | AutoBeRealizeHistory> => {
|
|
32
32
|
// PREDICATION
|
|
33
|
-
const
|
|
34
|
-
ctx.state().interface?.document
|
|
35
|
-
if (
|
|
33
|
+
const document: AutoBeOpenApi.IDocument | undefined =
|
|
34
|
+
ctx.state().interface?.document;
|
|
35
|
+
if (document === undefined)
|
|
36
36
|
throw new Error("Can't do realize agent because operations are nothing.");
|
|
37
37
|
|
|
38
38
|
const start: Date = new Date();
|
|
@@ -52,116 +52,156 @@ export const orchestrateRealize =
|
|
|
52
52
|
type: "realizeStart",
|
|
53
53
|
id: v7(),
|
|
54
54
|
created_at: start.toISOString(),
|
|
55
|
-
reason: props.
|
|
55
|
+
reason: props.instruction,
|
|
56
56
|
step: ctx.state().test?.step ?? 0,
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
//
|
|
59
|
+
// PREPARE ASSETS
|
|
60
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
60
61
|
const authorizations: AutoBeRealizeAuthorization[] =
|
|
61
62
|
await orchestrateRealizeAuthorization(ctx);
|
|
62
63
|
|
|
63
|
-
// SCENARIOS
|
|
64
|
-
const scenarios: IAutoBeRealizeScenarioResult[] = operations.map(
|
|
65
|
-
(operation) => generateRealizeScenario(ctx, operation, authorizations),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
64
|
const writeProgress: AutoBeProgressEventBase = {
|
|
69
|
-
total:
|
|
65
|
+
total: document.operations.length,
|
|
70
66
|
completed: 0,
|
|
71
67
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const props = {
|
|
76
|
-
totalAuthorizations: authorizations,
|
|
77
|
-
authorization: scenario.decoratorEvent ?? null,
|
|
78
|
-
scenario,
|
|
79
|
-
progress: writeProgress,
|
|
80
|
-
promptCacheKey,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const code: AutoBeRealizeWriteEvent | null =
|
|
84
|
-
await orchestrateRealizeWrite(ctx, props).catch(() => {
|
|
85
|
-
return orchestrateRealizeWrite(ctx, props).catch(() => null);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return code;
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const functions: AutoBeRealizeFunction[] = Object.entries(
|
|
93
|
-
Object.fromEntries(
|
|
94
|
-
writeEvents
|
|
95
|
-
.filter((w) => w !== null)
|
|
96
|
-
.map((event) => [event.location, event.content]),
|
|
97
|
-
),
|
|
98
|
-
).map(([location, content]) => {
|
|
99
|
-
const scenario = scenarios.find((el) => el.location === location)!;
|
|
100
|
-
return {
|
|
101
|
-
location,
|
|
102
|
-
content,
|
|
103
|
-
endpoint: {
|
|
104
|
-
method: scenario.operation.method,
|
|
105
|
-
path: scenario.operation.path,
|
|
106
|
-
},
|
|
107
|
-
name: scenario.functionName,
|
|
108
|
-
};
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
const reviewProgress: AutoBeProgressEventBase = {
|
|
112
|
-
total: writeEvents.length,
|
|
113
|
-
completed: writeEvents.length,
|
|
68
|
+
const correctProgress: AutoBeProgressEventBase = {
|
|
69
|
+
total: document.operations.length,
|
|
70
|
+
completed: 0,
|
|
114
71
|
};
|
|
115
72
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
73
|
+
const process = async (
|
|
74
|
+
artifacts: IAutoBeRealizeScenarioResult[],
|
|
75
|
+
): Promise<IBucket> => {
|
|
76
|
+
const writes: AutoBeRealizeWriteEvent[] = (
|
|
77
|
+
await executeCachedBatch(
|
|
78
|
+
artifacts.map((art) => async (promptCacheKey) => {
|
|
79
|
+
const props = {
|
|
80
|
+
totalAuthorizations: authorizations,
|
|
81
|
+
authorization: art.decoratorEvent ?? null,
|
|
82
|
+
scenario: art,
|
|
83
|
+
document,
|
|
84
|
+
progress: writeProgress,
|
|
85
|
+
promptCacheKey,
|
|
86
|
+
};
|
|
87
|
+
try {
|
|
88
|
+
return await orchestrateRealizeWrite(ctx, props);
|
|
89
|
+
} catch {
|
|
90
|
+
try {
|
|
91
|
+
return await orchestrateRealizeWrite(ctx, props);
|
|
92
|
+
} catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
97
|
+
)
|
|
98
|
+
).filter((w) => w !== null);
|
|
99
|
+
const functions: AutoBeRealizeFunction[] = Object.entries(
|
|
100
|
+
Object.fromEntries(writes.map((w) => [w.location, w.content])),
|
|
101
|
+
).map(([location, content]) => {
|
|
102
|
+
const scenario: IAutoBeRealizeScenarioResult = artifacts.find(
|
|
103
|
+
(el) => el.location === location,
|
|
104
|
+
)!;
|
|
105
|
+
return {
|
|
106
|
+
location,
|
|
107
|
+
content,
|
|
108
|
+
endpoint: {
|
|
109
|
+
method: scenario.operation.method,
|
|
110
|
+
path: scenario.operation.path,
|
|
111
|
+
},
|
|
112
|
+
name: scenario.functionName,
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const corrected: AutoBeRealizeFunction[] =
|
|
116
|
+
await orchestrateRealizeCorrectCasting(
|
|
126
117
|
ctx,
|
|
118
|
+
artifacts,
|
|
127
119
|
authorizations,
|
|
128
|
-
|
|
129
|
-
|
|
120
|
+
functions,
|
|
121
|
+
correctProgress,
|
|
130
122
|
).then(async (res) => {
|
|
131
|
-
|
|
132
|
-
return orchestrateRealizeCorrect(
|
|
123
|
+
return await orchestrateRealizeCorrect(
|
|
133
124
|
ctx,
|
|
134
|
-
|
|
125
|
+
artifacts,
|
|
135
126
|
authorizations,
|
|
136
127
|
res,
|
|
137
128
|
[],
|
|
138
|
-
|
|
129
|
+
correctProgress,
|
|
139
130
|
);
|
|
140
131
|
});
|
|
141
|
-
|
|
132
|
+
const validate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
|
|
133
|
+
ctx,
|
|
134
|
+
{
|
|
135
|
+
authorizations,
|
|
136
|
+
functions: corrected,
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
return {
|
|
140
|
+
corrected,
|
|
141
|
+
validate,
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// SCENARIOS
|
|
146
|
+
const entireScenarios: IAutoBeRealizeScenarioResult[] =
|
|
147
|
+
document.operations.map((operation) =>
|
|
148
|
+
generateRealizeScenario(ctx, operation, authorizations),
|
|
149
|
+
);
|
|
150
|
+
let bucket: IBucket = await process(entireScenarios);
|
|
151
|
+
for (let i: number = 0; i < 2; ++i) {
|
|
152
|
+
if (bucket.validate.result.type !== "failure") break;
|
|
153
|
+
|
|
154
|
+
const failedScenarios: IAutoBeRealizeScenarioResult[] = Array.from(
|
|
155
|
+
new Set(bucket.validate.result.diagnostics.map((f) => f.file)),
|
|
156
|
+
)
|
|
157
|
+
.map((location) =>
|
|
158
|
+
bucket.corrected.find((f) => f.location === location),
|
|
159
|
+
)
|
|
160
|
+
.filter((f) => f !== undefined)
|
|
161
|
+
.map((f) =>
|
|
162
|
+
entireScenarios.find(
|
|
163
|
+
(s) =>
|
|
164
|
+
s.operation.path === f.endpoint.path &&
|
|
165
|
+
s.operation.method === f.endpoint.method,
|
|
166
|
+
),
|
|
167
|
+
)
|
|
168
|
+
.filter((o) => o !== undefined);
|
|
169
|
+
if (failedScenarios.length === 0) break;
|
|
170
|
+
|
|
171
|
+
writeProgress.total += failedScenarios.length;
|
|
172
|
+
correctProgress.total += failedScenarios.length;
|
|
173
|
+
|
|
174
|
+
const newBucket: IBucket = await process(failedScenarios);
|
|
175
|
+
const corrected: Map<string, AutoBeRealizeFunction> = new Map([
|
|
176
|
+
...bucket.corrected.map((f) => [f.location, f] as const),
|
|
177
|
+
...newBucket.corrected.map((f) => [f.location, f] as const),
|
|
178
|
+
]);
|
|
179
|
+
bucket = {
|
|
180
|
+
corrected: Array.from(corrected.values()),
|
|
181
|
+
validate: newBucket.validate,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
142
184
|
|
|
143
|
-
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
144
185
|
const controllers: Record<string, string> =
|
|
145
186
|
await compiler.realize.controller({
|
|
146
187
|
document: ctx.state().interface!.document,
|
|
147
|
-
functions:
|
|
188
|
+
functions: bucket.corrected,
|
|
148
189
|
authorizations,
|
|
149
190
|
});
|
|
150
|
-
|
|
151
|
-
const { result } = await compileRealizeFiles(ctx, {
|
|
152
|
-
authorizations,
|
|
153
|
-
functions: totalCorrected,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
191
|
return ctx.dispatch({
|
|
157
192
|
type: "realizeComplete",
|
|
158
193
|
id: v7(),
|
|
159
194
|
created_at: new Date().toISOString(),
|
|
160
|
-
functions,
|
|
195
|
+
functions: bucket.corrected,
|
|
161
196
|
authorizations,
|
|
162
197
|
controllers,
|
|
163
|
-
compiled: result,
|
|
198
|
+
compiled: bucket.validate.result,
|
|
164
199
|
step: ctx.state().analyze?.step ?? 0,
|
|
165
200
|
elapsed: new Date().getTime() - start.getTime(),
|
|
166
201
|
});
|
|
167
202
|
};
|
|
203
|
+
|
|
204
|
+
interface IBucket {
|
|
205
|
+
corrected: AutoBeRealizeFunction[];
|
|
206
|
+
validate: AutoBeRealizeValidateEvent;
|
|
207
|
+
}
|
|
@@ -19,6 +19,7 @@ import { IAutoBeRealizeCorrectApplication } from "./structures/IAutoBeRealizeCor
|
|
|
19
19
|
import { IAutoBeRealizeFunctionFailure } from "./structures/IAutoBeRealizeFunctionFailure";
|
|
20
20
|
import { IAutoBeRealizeScenarioResult } from "./structures/IAutoBeRealizeScenarioResult";
|
|
21
21
|
import { filterDiagnostics } from "./utils/filterDiagnostics";
|
|
22
|
+
import { getRealizeWriteCodeTemplate } from "./utils/getRealizeWriteCodeTemplate";
|
|
22
23
|
import { getRealizeWriteDto } from "./utils/getRealizeWriteDto";
|
|
23
24
|
import { replaceImportStatements } from "./utils/replaceImportStatements";
|
|
24
25
|
|
|
@@ -40,6 +41,16 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
|
|
|
40
41
|
|
|
41
42
|
// Extract and process diagnostics
|
|
42
43
|
const diagnostics = event.result.diagnostics;
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
event.result.diagnostics.every(
|
|
47
|
+
(d) => !d.file?.startsWith("src/providers"),
|
|
48
|
+
) === true
|
|
49
|
+
) {
|
|
50
|
+
// No diagnostics related to provider functions, stop correcting
|
|
51
|
+
return functions;
|
|
52
|
+
}
|
|
53
|
+
|
|
43
54
|
const locations: string[] = Array.from(
|
|
44
55
|
new Set(
|
|
45
56
|
diagnostics
|
|
@@ -91,7 +102,6 @@ export async function orchestrateRealizeCorrect<Model extends ILlmSchema.Model>(
|
|
|
91
102
|
),
|
|
92
103
|
progress,
|
|
93
104
|
);
|
|
94
|
-
|
|
95
105
|
return orchestrateRealizeCorrect(
|
|
96
106
|
ctx,
|
|
97
107
|
scenarios,
|
|
@@ -115,7 +125,11 @@ async function correct<Model extends ILlmSchema.Model>(
|
|
|
115
125
|
failures: IAutoBeRealizeFunctionFailure[],
|
|
116
126
|
progress: AutoBeProgressEventBase,
|
|
117
127
|
): Promise<AutoBeRealizeFunction[]> {
|
|
118
|
-
|
|
128
|
+
if (locations.length === 0) {
|
|
129
|
+
return functions;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const corrected: AutoBeRealizeFunction[] = await executeCachedBatch(
|
|
119
133
|
locations.map((location) => async (): Promise<AutoBeRealizeFunction> => {
|
|
120
134
|
const scenario = scenarios.find((el) => el.location === location);
|
|
121
135
|
const func = functions.find((el) => el.location === location);
|
|
@@ -154,7 +168,11 @@ async function correct<Model extends ILlmSchema.Model>(
|
|
|
154
168
|
}),
|
|
155
169
|
);
|
|
156
170
|
|
|
157
|
-
|
|
171
|
+
// Create a map of corrected functions for efficient lookup
|
|
172
|
+
const correctedMap = new Map(corrected.map((f) => [f.location, f]));
|
|
173
|
+
|
|
174
|
+
// Return all functions, with corrected ones replaced
|
|
175
|
+
return functions.map((func) => correctedMap.get(func.location) || func);
|
|
158
176
|
}
|
|
159
177
|
|
|
160
178
|
async function step<Model extends ILlmSchema.Model>(
|
|
@@ -195,6 +213,23 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
195
213
|
enforceFunctionCall: true,
|
|
196
214
|
message: StringUtil.trim`
|
|
197
215
|
Correct the TypeScript code implementation.
|
|
216
|
+
|
|
217
|
+
The instruction to write at first was as follows, and the code you received is the code you wrote according to this instruction.
|
|
218
|
+
When modifying, modify the entire code, but not the import statement.
|
|
219
|
+
|
|
220
|
+
Below is template code you wrote:
|
|
221
|
+
|
|
222
|
+
${getRealizeWriteCodeTemplate({
|
|
223
|
+
scenario: props.scenario,
|
|
224
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
225
|
+
operation: props.scenario.operation,
|
|
226
|
+
authorization: props.authorization ?? null,
|
|
227
|
+
})}
|
|
228
|
+
|
|
229
|
+
Current code is as follows:
|
|
230
|
+
\`\`\`typescript
|
|
231
|
+
${props.function.content}
|
|
232
|
+
\`\`\`
|
|
198
233
|
`,
|
|
199
234
|
});
|
|
200
235
|
|
|
@@ -202,17 +237,25 @@ async function step<Model extends ILlmSchema.Model>(
|
|
|
202
237
|
return null;
|
|
203
238
|
}
|
|
204
239
|
|
|
205
|
-
pointer.value.
|
|
240
|
+
pointer.value.draft = await replaceImportStatements(ctx, {
|
|
206
241
|
operation: props.scenario.operation,
|
|
207
|
-
|
|
242
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
243
|
+
code: pointer.value.draft,
|
|
208
244
|
decoratorType: props.authorization?.payload.name,
|
|
209
245
|
});
|
|
246
|
+
if (pointer.value.revise.final)
|
|
247
|
+
pointer.value.revise.final = await replaceImportStatements(ctx, {
|
|
248
|
+
operation: props.scenario.operation,
|
|
249
|
+
schemas: ctx.state().interface!.document.components.schemas,
|
|
250
|
+
code: pointer.value.revise.final,
|
|
251
|
+
decoratorType: props.authorization?.payload.name,
|
|
252
|
+
});
|
|
210
253
|
|
|
211
254
|
const event: AutoBeRealizeCorrectEvent = {
|
|
212
255
|
type: "realizeCorrect",
|
|
213
256
|
id: v7(),
|
|
214
257
|
location: props.scenario.location,
|
|
215
|
-
content: pointer.value.revise.final,
|
|
258
|
+
content: pointer.value.revise.final ?? pointer.value.draft,
|
|
216
259
|
tokenUsage,
|
|
217
260
|
completed: ++props.progress.completed,
|
|
218
261
|
total: props.progress.total,
|
|
@@ -237,7 +280,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
237
280
|
name: "Write code",
|
|
238
281
|
application,
|
|
239
282
|
execute: {
|
|
240
|
-
|
|
283
|
+
correct: (next) => {
|
|
241
284
|
props.build(next);
|
|
242
285
|
},
|
|
243
286
|
} satisfies IAutoBeRealizeCorrectApplication,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutoBeOpenApi,
|
|
2
3
|
AutoBeProgressEventBase,
|
|
3
4
|
AutoBeRealizeAuthorization,
|
|
4
5
|
AutoBeRealizeWriteEvent,
|
|
@@ -20,6 +21,7 @@ import { replaceImportStatements } from "./utils/replaceImportStatements";
|
|
|
20
21
|
export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
|
|
21
22
|
ctx: AutoBeContext<Model>,
|
|
22
23
|
props: {
|
|
24
|
+
document: AutoBeOpenApi.IDocument;
|
|
23
25
|
totalAuthorizations: AutoBeRealizeAuthorization[];
|
|
24
26
|
authorization: AutoBeRealizeAuthorization | null;
|
|
25
27
|
scenario: IAutoBeRealizeScenarioResult;
|
|
@@ -69,17 +71,25 @@ export async function orchestrateRealizeWrite<Model extends ILlmSchema.Model>(
|
|
|
69
71
|
});
|
|
70
72
|
if (pointer.value === null) throw new Error("Failed to write code.");
|
|
71
73
|
|
|
72
|
-
pointer.value.
|
|
74
|
+
pointer.value.draft = await replaceImportStatements(ctx, {
|
|
73
75
|
operation: props.scenario.operation,
|
|
74
|
-
|
|
76
|
+
schemas: props.document.components.schemas,
|
|
77
|
+
code: pointer.value.draft,
|
|
75
78
|
decoratorType: props.authorization?.payload.name,
|
|
76
79
|
});
|
|
80
|
+
if (pointer.value.revise.final)
|
|
81
|
+
pointer.value.revise.final = await replaceImportStatements(ctx, {
|
|
82
|
+
operation: props.scenario.operation,
|
|
83
|
+
schemas: props.document.components.schemas,
|
|
84
|
+
code: pointer.value.revise.final,
|
|
85
|
+
decoratorType: props.authorization?.payload.name,
|
|
86
|
+
});
|
|
77
87
|
|
|
78
88
|
const event: AutoBeRealizeWriteEvent = {
|
|
79
89
|
type: "realizeWrite",
|
|
80
90
|
id: v7(),
|
|
81
91
|
location: props.scenario.location,
|
|
82
|
-
content: pointer.value.final,
|
|
92
|
+
content: pointer.value.revise.final ?? pointer.value.draft,
|
|
83
93
|
tokenUsage,
|
|
84
94
|
completed: ++props.progress.completed,
|
|
85
95
|
total: props.progress.total,
|
|
@@ -105,7 +115,7 @@ function createController<Model extends ILlmSchema.Model>(props: {
|
|
|
105
115
|
name: "Write code",
|
|
106
116
|
application,
|
|
107
117
|
execute: {
|
|
108
|
-
|
|
118
|
+
write: (next) => {
|
|
109
119
|
props.build(next);
|
|
110
120
|
},
|
|
111
121
|
} satisfies IAutoBeRealizeWriteApplication,
|