@autobe/agent 0.24.2 → 0.25.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/constants/AutoBeSystemPromptConstant.d.ts +16 -16
- 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 +5 -5
- package/lib/factory/createAutoBeContext.js.map +1 -1
- package/lib/index.mjs +941 -1065
- 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/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/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 +26 -5
- 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/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 +1 -1
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterface.js +25 -7
- package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +17 -8
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +18 -11
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +25 -10
- package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +9 -6
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +33 -17
- package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +36 -18
- package/lib/orchestrate/interface/orchestrateInterfaceSchemas.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 +33 -0
- package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +21 -7
- package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealize.js +3 -9
- package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +12 -2
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.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/replaceImportStatements.js +3 -1
- 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/transformTestScenarioHistories.d.ts +7 -1
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +39 -31
- 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 +32 -26
- 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 +51 -35
- package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
- package/lib/orchestrate/test/orchestrateTestScenario.js +14 -3
- package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js +19 -11
- package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
- package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
- package/lib/orchestrate/test/orchestrateTestWrite.js +9 -4
- package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/package.json +5 -5
- package/src/constants/AutoBeSystemPromptConstant.ts +16 -16
- 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 +5 -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/interface/histories/transformInterfaceAssetHistories.ts +2 -1
- package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
- 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 +27 -5
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
- package/src/orchestrate/interface/orchestrateInterface.ts +29 -10
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +25 -17
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +35 -23
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +44 -29
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +51 -32
- 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 +45 -0
- package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +26 -7
- package/src/orchestrate/realize/orchestrateRealize.ts +6 -17
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +18 -2
- package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +5 -0
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +44 -36
- package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +74 -71
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
- package/src/orchestrate/test/orchestrateTest.ts +19 -13
- package/src/orchestrate/test/orchestrateTestCorrect.ts +65 -46
- package/src/orchestrate/test/orchestrateTestScenario.ts +15 -11
- package/src/orchestrate/test/orchestrateTestScenarioReview.ts +29 -16
- package/src/orchestrate/test/orchestrateTestWrite.ts +13 -4
- 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 +0 -3
- package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.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/realize/orchestrateRealizeCorrectDate.ts +0 -372
|
@@ -38,7 +38,7 @@ export const orchestrateTest =
|
|
|
38
38
|
type: "testStart",
|
|
39
39
|
id: v7(),
|
|
40
40
|
created_at: start.toISOString(),
|
|
41
|
-
reason: props.
|
|
41
|
+
reason: props.instruction,
|
|
42
42
|
step: ctx.state().analyze?.step ?? 0,
|
|
43
43
|
});
|
|
44
44
|
|
|
@@ -57,31 +57,37 @@ export const orchestrateTest =
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
// PLAN
|
|
60
|
-
const scenarios: AutoBeTestScenario[] = await orchestrateTestScenario(
|
|
60
|
+
const scenarios: AutoBeTestScenario[] = await orchestrateTestScenario(
|
|
61
|
+
ctx,
|
|
62
|
+
props.instruction,
|
|
63
|
+
);
|
|
61
64
|
if (scenarios.length === 0)
|
|
62
65
|
throw new Error("No scenarios generated. Please check the logs.");
|
|
63
66
|
|
|
64
67
|
// TEST CODE
|
|
65
|
-
const written: IAutoBeTestWriteResult[] = await orchestrateTestWrite(
|
|
66
|
-
|
|
68
|
+
const written: IAutoBeTestWriteResult[] = await orchestrateTestWrite(ctx, {
|
|
69
|
+
instruction: props.instruction,
|
|
67
70
|
scenarios,
|
|
68
|
-
);
|
|
71
|
+
});
|
|
69
72
|
if (written.length === 0)
|
|
70
73
|
throw new Error("No test code written. Please check the logs.");
|
|
71
74
|
|
|
72
75
|
const corrects: AutoBeTestValidateEvent[] = await orchestrateTestCorrect(
|
|
73
76
|
ctx,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
{
|
|
78
|
+
instruction: props.instruction,
|
|
79
|
+
functions: written.map((w) => ({
|
|
80
|
+
scenario: w.scenario,
|
|
81
|
+
artifacts: w.artifacts,
|
|
82
|
+
location: w.event.location,
|
|
83
|
+
script: w.event.final ?? w.event.draft,
|
|
84
|
+
})),
|
|
85
|
+
},
|
|
80
86
|
);
|
|
81
87
|
|
|
82
88
|
// DO COMPILE
|
|
83
89
|
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
84
|
-
const
|
|
90
|
+
const compileResult: IAutoBeTypeScriptCompileResult =
|
|
85
91
|
await compiler.typescript.compile({
|
|
86
92
|
files: Object.fromEntries([
|
|
87
93
|
...Object.entries(
|
|
@@ -97,7 +103,7 @@ export const orchestrateTest =
|
|
|
97
103
|
id: v7(),
|
|
98
104
|
created_at: new Date().toISOString(),
|
|
99
105
|
files: corrects.map((s) => s.file),
|
|
100
|
-
compiled,
|
|
106
|
+
compiled: compileResult,
|
|
101
107
|
step: ctx.state().interface?.step ?? 0,
|
|
102
108
|
elapsed: new Date().getTime() - start.getTime(),
|
|
103
109
|
});
|
|
@@ -25,11 +25,14 @@ import { IAutoBeTestFunctionFailure } from "./structures/IAutoBeTestFunctionFail
|
|
|
25
25
|
|
|
26
26
|
export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
|
|
27
27
|
ctx: AutoBeContext<Model>,
|
|
28
|
-
|
|
28
|
+
props: {
|
|
29
|
+
instruction: string;
|
|
30
|
+
functions: IAutoBeTestFunction[];
|
|
31
|
+
},
|
|
29
32
|
): Promise<AutoBeTestValidateEvent[]> => {
|
|
30
33
|
const result: Array<AutoBeTestValidateEvent | null> =
|
|
31
34
|
await executeCachedBatch(
|
|
32
|
-
|
|
35
|
+
props.functions.map((w) => async (promptCacheKey) => {
|
|
33
36
|
try {
|
|
34
37
|
const compile = (script: string) =>
|
|
35
38
|
compileTestFile(ctx, {
|
|
@@ -68,10 +71,13 @@ export const orchestrateTestCorrect = async <Model extends ILlmSchema.Model>(
|
|
|
68
71
|
);
|
|
69
72
|
return await predicate(
|
|
70
73
|
ctx,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
{
|
|
75
|
+
function: transformTestValidateEvent(y, w.artifacts),
|
|
76
|
+
failures: [],
|
|
77
|
+
validate: y,
|
|
78
|
+
promptCacheKey,
|
|
79
|
+
instruction: props.instruction,
|
|
80
|
+
},
|
|
75
81
|
ctx.retry,
|
|
76
82
|
);
|
|
77
83
|
} catch {
|
|
@@ -110,44 +116,54 @@ const compileTestFile = async <Model extends ILlmSchema.Model>(
|
|
|
110
116
|
|
|
111
117
|
const predicate = async <Model extends ILlmSchema.Model>(
|
|
112
118
|
ctx: AutoBeContext<Model>,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
props: {
|
|
120
|
+
function: IAutoBeTestFunction;
|
|
121
|
+
failures: IAutoBeTestFunctionFailure[];
|
|
122
|
+
validate: AutoBeTestValidateEvent;
|
|
123
|
+
promptCacheKey: string;
|
|
124
|
+
instruction: string;
|
|
125
|
+
},
|
|
117
126
|
life: number,
|
|
118
127
|
): Promise<AutoBeTestValidateEvent> => {
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
121
|
-
? await correct(ctx,
|
|
122
|
-
:
|
|
128
|
+
if (props.validate.result.type === "failure") ctx.dispatch(props.validate);
|
|
129
|
+
return props.validate.result.type === "failure"
|
|
130
|
+
? await correct(ctx, props, life - 1)
|
|
131
|
+
: props.validate;
|
|
123
132
|
};
|
|
124
133
|
|
|
125
134
|
const correct = async <Model extends ILlmSchema.Model>(
|
|
126
135
|
ctx: AutoBeContext<Model>,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
props: {
|
|
137
|
+
function: IAutoBeTestFunction;
|
|
138
|
+
failures: IAutoBeTestFunctionFailure[];
|
|
139
|
+
validate: AutoBeTestValidateEvent;
|
|
140
|
+
promptCacheKey: string;
|
|
141
|
+
instruction: string;
|
|
142
|
+
},
|
|
131
143
|
life: number,
|
|
132
144
|
): Promise<AutoBeTestValidateEvent> => {
|
|
133
|
-
if (validate.result.type !== "failure") return validate;
|
|
134
|
-
else if (life < 0) return validate;
|
|
145
|
+
if (props.validate.result.type !== "failure") return props.validate;
|
|
146
|
+
else if (life < 0) return props.validate;
|
|
135
147
|
|
|
136
148
|
const pointer: IPointer<IAutoBeTestCorrectApplication.IProps | null> = {
|
|
137
149
|
value: null,
|
|
138
150
|
};
|
|
139
151
|
const { tokenUsage } = await ctx.conversate({
|
|
140
152
|
source: "testCorrect",
|
|
141
|
-
histories: await transformTestCorrectHistories(ctx,
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
153
|
+
histories: await transformTestCorrectHistories(ctx, {
|
|
154
|
+
instruction: props.instruction,
|
|
155
|
+
function: props.function,
|
|
156
|
+
failures: [
|
|
157
|
+
...props.failures,
|
|
158
|
+
{
|
|
159
|
+
function: props.function,
|
|
160
|
+
failure: props.validate.result,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
}),
|
|
148
164
|
controller: createController({
|
|
149
165
|
model: ctx.model,
|
|
150
|
-
failure: validate.result,
|
|
166
|
+
failure: props.validate.result,
|
|
151
167
|
build: (next) => {
|
|
152
168
|
pointer.value = next;
|
|
153
169
|
},
|
|
@@ -159,18 +175,18 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
159
175
|
You don't need to explain me anything, but just fix it immediately
|
|
160
176
|
without any hesitation, explanation, and questions.
|
|
161
177
|
`,
|
|
162
|
-
promptCacheKey,
|
|
178
|
+
promptCacheKey: props.promptCacheKey,
|
|
163
179
|
});
|
|
164
180
|
if (pointer.value === null) throw new Error("Failed to correct test code.");
|
|
165
181
|
|
|
166
182
|
pointer.value.revise.final = await completeTestCode(
|
|
167
183
|
ctx,
|
|
168
|
-
|
|
184
|
+
props.function.artifacts,
|
|
169
185
|
pointer.value.revise.final,
|
|
170
186
|
);
|
|
171
187
|
pointer.value.draft = await completeTestCode(
|
|
172
188
|
ctx,
|
|
173
|
-
|
|
189
|
+
props.function.artifacts,
|
|
174
190
|
pointer.value.draft,
|
|
175
191
|
);
|
|
176
192
|
|
|
@@ -178,8 +194,8 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
178
194
|
type: "testCorrect",
|
|
179
195
|
id: v7(),
|
|
180
196
|
created_at: new Date().toISOString(),
|
|
181
|
-
file: validate.file,
|
|
182
|
-
result: validate.result,
|
|
197
|
+
file: props.validate.file,
|
|
198
|
+
result: props.validate.result,
|
|
183
199
|
tokenUsage,
|
|
184
200
|
step: ctx.state().analyze?.step ?? 0,
|
|
185
201
|
think: pointer.value.think,
|
|
@@ -187,26 +203,29 @@ const correct = async <Model extends ILlmSchema.Model>(
|
|
|
187
203
|
review: pointer.value.revise?.review,
|
|
188
204
|
final: pointer.value.revise?.final,
|
|
189
205
|
} satisfies AutoBeTestCorrectEvent);
|
|
190
|
-
const
|
|
191
|
-
...
|
|
206
|
+
const newFunction: IAutoBeTestFunction = {
|
|
207
|
+
...props.function,
|
|
192
208
|
script: pointer.value.revise?.final ?? pointer.value.draft,
|
|
193
209
|
};
|
|
194
210
|
const newValidate: AutoBeTestValidateEvent = await compileTestFile(
|
|
195
211
|
ctx,
|
|
196
|
-
|
|
212
|
+
newFunction,
|
|
197
213
|
);
|
|
198
214
|
return predicate(
|
|
199
215
|
ctx,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
{
|
|
217
|
+
function: newFunction,
|
|
218
|
+
failures: [
|
|
219
|
+
...props.failures,
|
|
220
|
+
{
|
|
221
|
+
function: props.function,
|
|
222
|
+
failure: props.validate.result,
|
|
223
|
+
},
|
|
224
|
+
],
|
|
225
|
+
validate: newValidate,
|
|
226
|
+
promptCacheKey: props.promptCacheKey,
|
|
227
|
+
instruction: props.instruction,
|
|
228
|
+
},
|
|
210
229
|
life,
|
|
211
230
|
);
|
|
212
231
|
};
|
|
@@ -23,6 +23,7 @@ import { IAutoBeTestScenarioAuthorizationRole } from "./structures/IAutoBeTestSc
|
|
|
23
23
|
|
|
24
24
|
export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
|
|
25
25
|
ctx: AutoBeContext<Model>,
|
|
26
|
+
instruction: string,
|
|
26
27
|
): Promise<AutoBeTestScenario[]> {
|
|
27
28
|
const document: AutoBeOpenApi.IDocument | undefined =
|
|
28
29
|
ctx.state().interface?.document;
|
|
@@ -87,6 +88,7 @@ export async function orchestrateTestScenario<Model extends ILlmSchema.Model>(
|
|
|
87
88
|
progress,
|
|
88
89
|
reviewProgress,
|
|
89
90
|
promptCacheKey,
|
|
91
|
+
instruction,
|
|
90
92
|
})),
|
|
91
93
|
);
|
|
92
94
|
}),
|
|
@@ -129,6 +131,7 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
|
|
|
129
131
|
progress: AutoBeProgressEventBase;
|
|
130
132
|
reviewProgress: AutoBeProgressEventBase;
|
|
131
133
|
promptCacheKey: string;
|
|
134
|
+
instruction: string;
|
|
132
135
|
},
|
|
133
136
|
): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> => {
|
|
134
137
|
const pointer: IPointer<IAutoBeTestScenarioApplication.IScenarioGroup[]> = {
|
|
@@ -140,12 +143,13 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
|
|
|
140
143
|
try {
|
|
141
144
|
const { tokenUsage } = await ctx.conversate({
|
|
142
145
|
source: "testScenarios",
|
|
143
|
-
histories: transformTestScenarioHistories(
|
|
144
|
-
ctx.state(),
|
|
145
|
-
props.document,
|
|
146
|
-
props.include,
|
|
147
|
-
props.exclude,
|
|
148
|
-
|
|
146
|
+
histories: transformTestScenarioHistories({
|
|
147
|
+
state: ctx.state(),
|
|
148
|
+
document: props.document,
|
|
149
|
+
include: props.include,
|
|
150
|
+
exclude: props.exclude,
|
|
151
|
+
instruction: props.instruction,
|
|
152
|
+
}),
|
|
149
153
|
controller: createController({
|
|
150
154
|
model: ctx.model,
|
|
151
155
|
endpointNotFound: props.endpointNotFound,
|
|
@@ -193,11 +197,11 @@ const divideAndConquer = async <Model extends ILlmSchema.Model>(
|
|
|
193
197
|
step: ctx.state().interface?.step ?? 0,
|
|
194
198
|
created_at: new Date().toISOString(),
|
|
195
199
|
});
|
|
196
|
-
return await orchestrateTestScenarioReview(
|
|
197
|
-
|
|
198
|
-
pointer.value,
|
|
199
|
-
props.reviewProgress,
|
|
200
|
-
);
|
|
200
|
+
return await orchestrateTestScenarioReview(ctx, {
|
|
201
|
+
instruction: props.instruction,
|
|
202
|
+
groups: pointer.value,
|
|
203
|
+
progress: props.reviewProgress,
|
|
204
|
+
});
|
|
201
205
|
} catch {
|
|
202
206
|
return [];
|
|
203
207
|
}
|
|
@@ -16,21 +16,26 @@ export async function orchestrateTestScenarioReview<
|
|
|
16
16
|
Model extends ILlmSchema.Model,
|
|
17
17
|
>(
|
|
18
18
|
ctx: AutoBeContext<Model>,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
props: {
|
|
20
|
+
instruction: string;
|
|
21
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[];
|
|
22
|
+
progress: AutoBeProgressEventBase;
|
|
23
|
+
},
|
|
21
24
|
): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> {
|
|
22
25
|
const res: IAutoBeTestScenarioApplication.IScenarioGroup[] = await review(
|
|
23
26
|
ctx,
|
|
24
|
-
|
|
25
|
-
progress,
|
|
27
|
+
props,
|
|
26
28
|
);
|
|
27
29
|
return res;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
async function review<Model extends ILlmSchema.Model>(
|
|
31
33
|
ctx: AutoBeContext<Model>,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
props: {
|
|
35
|
+
instruction: string;
|
|
36
|
+
groups: IAutoBeTestScenarioApplication.IScenarioGroup[];
|
|
37
|
+
progress: AutoBeProgressEventBase;
|
|
38
|
+
},
|
|
34
39
|
): Promise<IAutoBeTestScenarioApplication.IScenarioGroup[]> {
|
|
35
40
|
try {
|
|
36
41
|
const pointer: IPointer<IAutoBeTestScenarioReviewApplication.IProps | null> =
|
|
@@ -42,9 +47,13 @@ async function review<Model extends ILlmSchema.Model>(
|
|
|
42
47
|
controller: createController({
|
|
43
48
|
model: ctx.model,
|
|
44
49
|
pointer,
|
|
45
|
-
originalGroups: groups,
|
|
50
|
+
originalGroups: props.groups,
|
|
51
|
+
}),
|
|
52
|
+
histories: transformTestScenarioReviewHistories({
|
|
53
|
+
state: ctx.state(),
|
|
54
|
+
groups: props.groups,
|
|
55
|
+
instruction: props.instruction,
|
|
46
56
|
}),
|
|
47
|
-
histories: transformTestScenarioReviewHistories(ctx, groups),
|
|
48
57
|
enforceFunctionCall: true,
|
|
49
58
|
message: "Review the Test Scenario.",
|
|
50
59
|
});
|
|
@@ -53,17 +62,17 @@ async function review<Model extends ILlmSchema.Model>(
|
|
|
53
62
|
throw new Error("Failed to get review result.");
|
|
54
63
|
}
|
|
55
64
|
|
|
56
|
-
progress.total = Math.max(
|
|
57
|
-
progress.total,
|
|
58
|
-
(progress.completed += pointer.value.scenarioGroups.length),
|
|
65
|
+
props.progress.total = Math.max(
|
|
66
|
+
props.progress.total,
|
|
67
|
+
(props.progress.completed += pointer.value.scenarioGroups.length),
|
|
59
68
|
);
|
|
60
69
|
|
|
61
70
|
ctx.dispatch({
|
|
62
71
|
type: "testScenariosReview",
|
|
63
72
|
id: v7(),
|
|
64
73
|
tokenUsage,
|
|
65
|
-
total: progress.total,
|
|
66
|
-
completed: progress.completed,
|
|
74
|
+
total: props.progress.total,
|
|
75
|
+
completed: props.progress.completed,
|
|
67
76
|
scenarios: pointer.value.scenarioGroups
|
|
68
77
|
.map((group) => {
|
|
69
78
|
return group.scenarios.map((s) => {
|
|
@@ -77,10 +86,14 @@ async function review<Model extends ILlmSchema.Model>(
|
|
|
77
86
|
step: ctx.state().interface?.step ?? 0,
|
|
78
87
|
created_at: new Date().toISOString(),
|
|
79
88
|
});
|
|
80
|
-
|
|
89
|
+
// @todo michael: need to investigate scenario removal more gracefully
|
|
90
|
+
return pointer.value.pass
|
|
91
|
+
? // || pointer.value.scenarioGroups.length < props.groups.length
|
|
92
|
+
props.groups
|
|
93
|
+
: pointer.value.scenarioGroups;
|
|
81
94
|
} catch {
|
|
82
|
-
progress.completed += groups.length;
|
|
83
|
-
return groups;
|
|
95
|
+
props.progress.completed += props.groups.length;
|
|
96
|
+
return props.groups;
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
|
|
@@ -22,10 +22,13 @@ import { IAutoBeTestWriteResult } from "./structures/IAutoBeTestWriteResult";
|
|
|
22
22
|
|
|
23
23
|
export async function orchestrateTestWrite<Model extends ILlmSchema.Model>(
|
|
24
24
|
ctx: AutoBeContext<Model>,
|
|
25
|
-
|
|
25
|
+
props: {
|
|
26
|
+
instruction: string;
|
|
27
|
+
scenarios: AutoBeTestScenario[];
|
|
28
|
+
},
|
|
26
29
|
): Promise<IAutoBeTestWriteResult[]> {
|
|
27
30
|
const progress: AutoBeProgressEventBase = {
|
|
28
|
-
total: scenarios.length,
|
|
31
|
+
total: props.scenarios.length,
|
|
29
32
|
completed: 0,
|
|
30
33
|
};
|
|
31
34
|
const result: Array<IAutoBeTestWriteResult | null> = await executeCachedBatch(
|
|
@@ -34,7 +37,7 @@ export async function orchestrateTestWrite<Model extends ILlmSchema.Model>(
|
|
|
34
37
|
* individual test code implementations. Each scenario is processed to
|
|
35
38
|
* generate corresponding test code and progress events.
|
|
36
39
|
*/
|
|
37
|
-
scenarios.map((scenario) => async (promptCacheKey) => {
|
|
40
|
+
props.scenarios.map((scenario) => async (promptCacheKey) => {
|
|
38
41
|
try {
|
|
39
42
|
const artifacts: IAutoBeTestScenarioArtifacts =
|
|
40
43
|
await getTestScenarioArtifacts(ctx, scenario);
|
|
@@ -43,6 +46,7 @@ export async function orchestrateTestWrite<Model extends ILlmSchema.Model>(
|
|
|
43
46
|
artifacts,
|
|
44
47
|
progress,
|
|
45
48
|
promptCacheKey,
|
|
49
|
+
instruction: props.instruction,
|
|
46
50
|
});
|
|
47
51
|
ctx.dispatch(event);
|
|
48
52
|
return {
|
|
@@ -65,6 +69,7 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
65
69
|
artifacts: IAutoBeTestScenarioArtifacts;
|
|
66
70
|
progress: AutoBeProgressEventBase;
|
|
67
71
|
promptCacheKey: string;
|
|
72
|
+
instruction: string;
|
|
68
73
|
},
|
|
69
74
|
): Promise<AutoBeTestWriteEvent> {
|
|
70
75
|
const { scenario, artifacts, progress, promptCacheKey } = props;
|
|
@@ -73,7 +78,11 @@ async function process<Model extends ILlmSchema.Model>(
|
|
|
73
78
|
};
|
|
74
79
|
const { tokenUsage } = await ctx.conversate({
|
|
75
80
|
source: "testWrite",
|
|
76
|
-
histories: await transformTestWriteHistories(ctx,
|
|
81
|
+
histories: await transformTestWriteHistories(ctx, {
|
|
82
|
+
scenario,
|
|
83
|
+
artifacts,
|
|
84
|
+
instruction: props.instruction,
|
|
85
|
+
}),
|
|
77
86
|
controller: createController({
|
|
78
87
|
model: ctx.model,
|
|
79
88
|
build: (next) => {
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformCommonCorrectDateHistories = void 0;
|
|
4
|
-
const utils_1 = require("@autobe/utils");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
/** Transform date correction histories for AI conversation */
|
|
7
|
-
const transformCommonCorrectDateHistories = (failures) => [
|
|
8
|
-
{
|
|
9
|
-
id: (0, uuid_1.v7)(),
|
|
10
|
-
created_at: new Date().toISOString(),
|
|
11
|
-
type: "systemMessage",
|
|
12
|
-
text: "<!--\nfilename: REALIZE_DATE.md\n-->\n# \uD83D\uDCC5 Date Type Handling Guide for Realize Agent\n\n## \uD83D\uDEA8 CRITICAL: Date Type is ABSOLUTELY FORBIDDEN in TypeScript Declarations\n\nThis document provides comprehensive guidelines for handling date-related types in the Realize Agent system. Violations of these rules will cause compilation failures.\n\n## \uD83D\uDD34 The Golden Rule: NEVER Use Native Date Type\n\n### \u274C ABSOLUTELY FORBIDDEN\n```typescript\n// NEVER declare variables with Date type\nconst now: Date = new Date(); // \u274C FORBIDDEN\nconst processDate = (date: Date) => { ... }; // \u274C FORBIDDEN\nfunction getDate(): Date { ... } // \u274C FORBIDDEN\ninterface IUser { created_at: Date; } // \u274C FORBIDDEN\ntype TimeStamp = Date; // \u274C FORBIDDEN\n```\n\n### \u2705 REQUIRED: Always Use String with Tags\n```typescript\n// ALWAYS use string with tags.Format<'date-time'>\nconst now: string & tags.Format<'date-time'> = toISOStringSafe(new Date());\nconst processDate = (date: string & tags.Format<'date-time'>) => { ... };\nfunction getDate(): string & tags.Format<'date-time'> { ... }\ninterface IUser { created_at: string & tags.Format<'date-time'>; }\ntype TimeStamp = string & tags.Format<'date-time'>;\n```\n\n## \uD83D\uDEE0\uFE0F The toISOStringSafe() Function\n\n### Function Signature\n```typescript\nfunction toISOStringSafe(\n value: Date | (string & tags.Format<\"date-time\">)\n): string & tags.Format<\"date-time\">\n```\n\n### Purpose\n`toISOStringSafe()` is the ONLY approved method for converting Date objects or date strings to ISO strings with proper type branding.\n\n### \u26A0\uFE0F CRITICAL: Parameter Requirements\n\n**toISOStringSafe REQUIRES a non-null parameter!**\n- The function accepts `Date` or ISO string format\n- It does NOT accept `null` or `undefined`\n- Always check for null/undefined BEFORE calling\n\n```typescript\n// \u274C WRONG: Function doesn't accept null\ntoISOStringSafe(nullableValue) // Type error if nullable!\n\n// \u2705 CORRECT: Check null first, then call\nvalue ? toISOStringSafe(value) : null // Safe null handling\n```\n\n### Common Usage Patterns\n\n#### 1. Creating New Timestamps\n```typescript\n// \u2705 For new timestamps\nconst created_at = toISOStringSafe(new Date());\nconst updated_at = toISOStringSafe(new Date());\n\n// \u2705 Converting existing date strings\nconst formatted_date = toISOStringSafe(dateString);\n```\n\n#### 2. Converting Prisma DateTime Fields\n```typescript\n// \u2705 Converting from Prisma (which returns Date objects)\nreturn {\n created_at: toISOStringSafe(created.created_at),\n updated_at: toISOStringSafe(created.updated_at),\n expires_at: created.expires_at ? toISOStringSafe(created.expires_at) : null,\n};\n```\n\n#### 3. Processing API Input Dates\n```typescript\n// \u2705 Converting date strings from API input\nawait MyGlobal.prisma.posts.create({\n data: {\n title: body.title,\n content: body.content,\n published_at: body.published_at ? toISOStringSafe(body.published_at) : null,\n scheduled_at: body.scheduled_at ? toISOStringSafe(body.scheduled_at) : null,\n },\n});\n```\n\n## \uD83D\uDCCA Date Field Patterns in Different Contexts\n\n### 1. Prisma Operations\n\n#### CREATE Operations\n```typescript\nawait MyGlobal.prisma.articles.create({\n data: {\n id: v4() as string & tags.Format<'uuid'>,\n title: body.title,\n content: body.content,\n // Required date fields\n created_at: toISOStringSafe(new Date()),\n updated_at: toISOStringSafe(new Date()),\n // Optional/nullable date fields\n published_at: body.published_at ? toISOStringSafe(body.published_at) : null,\n deleted_at: null, // If soft delete field exists\n },\n});\n```\n\n#### UPDATE Operations\n```typescript\nawait MyGlobal.prisma.articles.update({\n where: { id: parameters.id },\n data: {\n title: body.title,\n content: body.content,\n // Always update the updated_at field\n updated_at: toISOStringSafe(new Date()),\n // Conditional date updates\n ...(body.published_at !== undefined && {\n published_at: body.published_at ? toISOStringSafe(body.published_at) : null\n }),\n },\n});\n```\n\n#### WHERE Clauses with Date Ranges\n```typescript\nawait MyGlobal.prisma.events.findMany({\n where: {\n // Date range queries\n created_at: {\n gte: body.start_date ? toISOStringSafe(body.start_date) : undefined,\n lte: body.end_date ? toISOStringSafe(body.end_date) : undefined,\n },\n // Specific date comparisons\n expires_at: {\n gt: toISOStringSafe(new Date()), // Events not yet expired\n },\n },\n});\n```\n\n### 2. Return Object Transformations\n\n#### From Prisma to API Response\n```typescript\n// Prisma returns Date objects, API expects ISO strings\nconst users = await MyGlobal.prisma.users.findMany();\n\nreturn users.map(user => ({\n id: user.id,\n name: user.name,\n email: user.email,\n // Convert all Date fields to ISO strings\n created_at: toISOStringSafe(user.created_at),\n updated_at: toISOStringSafe(user.updated_at),\n last_login_at: user.last_login_at ? toISOStringSafe(user.last_login_at) : null,\n email_verified_at: user.email_verified_at ? toISOStringSafe(user.email_verified_at) : null,\n}));\n```\n\n### 3. Complex Date Operations\n\n#### Soft Delete Implementation\n```typescript\n// If schema has deleted_at field (always check first!)\nawait MyGlobal.prisma.posts.update({\n where: { id: parameters.id },\n data: {\n deleted_at: toISOStringSafe(new Date()), // Mark as deleted\n updated_at: toISOStringSafe(new Date()),\n },\n});\n\n// Querying non-deleted items\nawait MyGlobal.prisma.posts.findMany({\n where: {\n deleted_at: null, // Only get non-deleted posts\n },\n});\n```\n\n#### Date Calculations\n```typescript\n// Calculate expiry date (30 days from now)\nconst now = new Date();\nconst expiryDate = new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000);\n\nawait MyGlobal.prisma.subscriptions.create({\n data: {\n user_id: user.id,\n started_at: toISOStringSafe(now),\n expires_at: toISOStringSafe(expiryDate),\n },\n});\n```\n\n## \uD83D\uDEAB Common Date Type Errors and Solutions\n\n### Error: \"Type 'Date' is not assignable to type 'string & tags.Format<'date-time'>'\"\n\n**Cause**: Trying to assign a Date object directly without conversion\n\n```typescript\n// \u274C WRONG\nreturn {\n created_at: new Date(), // ERROR!\n};\n\n// \u2705 CORRECT\nreturn {\n created_at: toISOStringSafe(new Date()),\n};\n```\n\n### Error: \"Argument of type 'null' is not assignable to parameter\"\n\n**Cause**: Trying to pass null or undefined to toISOStringSafe\n\n```typescript\n// \u274C WRONG\nconst date = toISOStringSafe(nullableDate); // Type error if nullable!\n\n// \u2705 CORRECT\nconst date = nullableDate ? toISOStringSafe(nullableDate) : null;\n```\n\n### Error: \"Type 'string | null' is not assignable to type 'string & tags.Format<'date-time'>'\"\n\n**Cause**: Nullable date field being assigned to required date field\n\n```typescript\n// \u274C WRONG (if API expects non-nullable)\nreturn {\n created_at: user.created_at ? toISOStringSafe(user.created_at) : null, // ERROR!\n};\n\n// \u2705 CORRECT (provide default for required fields)\nreturn {\n created_at: user.created_at \n ? toISOStringSafe(user.created_at) \n : toISOStringSafe(new Date()), // Default to current time\n};\n```\n\n## \uD83D\uDCCB Date Type Checklist\n\nBefore implementing any date-related functionality, verify:\n\n1. \u2705 **NO Date type declarations** - Search for `: Date` in your code\n2. \u2705 **All Date objects wrapped in toISOStringSafe()** - Never use .toISOString() directly\n3. \u2705 **Null checks before toISOStringSafe()** - Function cannot handle null\n4. \u2705 **Proper type annotations** - Use `string & tags.Format<'date-time'>`\n5. \u2705 **Schema verification** - Check if date fields actually exist in Prisma schema\n6. \u2705 **API contract alignment** - Verify if fields are nullable or required in DTOs\n\n## \uD83C\uDFAF Quick Reference\n\n### DO \u2705\n- `toISOStringSafe(new Date())`\n- `toISOStringSafe(dateString)` for existing strings\n- `value ? toISOStringSafe(value) : null` for nullable values\n- `string & tags.Format<'date-time'>` for type declarations\n- Check null/undefined BEFORE calling toISOStringSafe\n- Check Prisma schema for date field existence\n\n### DON'T \u274C\n- `const date: Date = new Date()` - storing Date in variables\n- `new Date().toISOString()` - use toISOStringSafe instead\n- `toISOStringSafe(nullableValue)` - function doesn't accept null\n- `toISOStringSafe()` - function requires a parameter\n- Assume date fields exist (like deleted_at)\n- Use Date type in function signatures\n\n## \uD83D\uDD0D Exception: new Date() Usage\n\nThe ONLY acceptable use of `new Date()` is as an immediate argument to `toISOStringSafe()`:\n\n```typescript\n// \u2705 ONLY ALLOWED PATTERN\nconst timestamp = toISOStringSafe(new Date());\n\n// \u274C NEVER STORE Date IN VARIABLE\nconst now = new Date(); // FORBIDDEN!\nconst timestamp = toISOStringSafe(now); // VIOLATION!\n```\n\n## \uD83D\uDCDD Summary\n\nThe Date type handling in Realize Agent follows a strict pattern:\n1. **Never** declare Date types in TypeScript\n2. **Always** use `string & tags.Format<'date-time'>` for type declarations\n3. **Always** use `toISOStringSafe()` for Date/string to ISO conversions\n4. **Always** check null/undefined before calling `toISOStringSafe()` - it doesn't accept null\n5. **Always** pass a parameter to `toISOStringSafe()` - it's not optional\n6. **Always** verify schema before using date fields\n\nFollowing these rules ensures type safety, prevents runtime errors, and maintains consistency across the entire codebase." /* AutoBeSystemPromptConstant.REALIZE_DATE */,
|
|
13
|
-
},
|
|
14
|
-
...failures.map((f, i, array) => ({
|
|
15
|
-
id: (0, uuid_1.v7)(),
|
|
16
|
-
created_at: new Date().toISOString(),
|
|
17
|
-
type: "assistantMessage",
|
|
18
|
-
text: utils_1.StringUtil.trim `
|
|
19
|
-
# ${i === array.length - 1 ? "Latest Date Type Failure" : "Previous Date Type Failure"}
|
|
20
|
-
|
|
21
|
-
## Generated TypeScript Code
|
|
22
|
-
\`\`\`typescript
|
|
23
|
-
${f.script}
|
|
24
|
-
\`\`\`
|
|
25
|
-
|
|
26
|
-
## Date-Related Compile Errors
|
|
27
|
-
${f.diagnostics
|
|
28
|
-
.map((d) => {
|
|
29
|
-
const location = d.file
|
|
30
|
-
? `[${d.file}${d.start ? `:${d.start}` : ""}]`
|
|
31
|
-
: "[Unknown location]";
|
|
32
|
-
const code = d.code ? `TS${d.code}` : "";
|
|
33
|
-
const messageText = d.messageText || "Date type error";
|
|
34
|
-
return `- ${location} ${code}: ${messageText}`;
|
|
35
|
-
})
|
|
36
|
-
.join("\n")}
|
|
37
|
-
|
|
38
|
-
## Required Fixes:
|
|
39
|
-
- Replace all Date type declarations with string & tags.Format<"date-time">
|
|
40
|
-
- Wrap Date objects with toISOStringSafe(value)
|
|
41
|
-
- Check null/undefined BEFORE calling toISOStringSafe (it doesn't accept null)
|
|
42
|
-
- Remove Date variable declarations (const now = new Date() is forbidden)
|
|
43
|
-
- toISOStringSafe requires a parameter - it's not optional
|
|
44
|
-
`,
|
|
45
|
-
})),
|
|
46
|
-
];
|
|
47
|
-
exports.transformCommonCorrectDateHistories = transformCommonCorrectDateHistories;
|
|
48
|
-
//# sourceMappingURL=transformCommonCorrectDateHistories.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transformCommonCorrectDateHistories.js","sourceRoot":"","sources":["../../../../src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAS1B,8DAA8D;AACvD,MAAM,mCAAmC,GAAG,CACjD,QAAoB,EAGpB,EAAE,CAAC;IACH;QACE,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,eAAe;QACrB,IAAI,+wTAAyC;KAC9C;IACD,GAAG,QAAQ,CAAC,GAAG,CACb,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,CACd,CAAC;QACC,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;cACf,CAAC,KAAK,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,4BAA4B;;;;YAIpF,CAAC,CAAC,MAAM;;;;YAIR,CAAC,CAAC,WAAW;aACZ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI;gBACrB,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;gBAC9C,CAAC,CAAC,oBAAoB,CAAC;YACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI,iBAAiB,CAAC;YACvD,OAAO,KAAK,QAAQ,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACjD,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC;;;;;;;;SAQd;KACF,CAAkD,CACtD;CACF,CAAC;AA9CW,QAAA,mCAAmC,uCA8C9C"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import typia from "typia";
|
|
2
|
-
/** Application interface for Date type correction in generated code */
|
|
3
|
-
export interface IAutoBeCommonCorrectDateApplication {
|
|
4
|
-
/**
|
|
5
|
-
* Rewrite the function to fix Date type issues
|
|
6
|
-
*
|
|
7
|
-
* @param props - Correction properties
|
|
8
|
-
*/
|
|
9
|
-
rewrite(props: IAutoBeCommonCorrectDateApplication.IProps): void;
|
|
10
|
-
/** Reject the correction task if Date issues cannot be fixed */
|
|
11
|
-
reject(): void;
|
|
12
|
-
}
|
|
13
|
-
export declare namespace IAutoBeCommonCorrectDateApplication {
|
|
14
|
-
/** Properties for Date type correction */
|
|
15
|
-
interface IProps {
|
|
16
|
-
/** The correction revision containing the fixed code */
|
|
17
|
-
revise: {
|
|
18
|
-
/** Optional: Analysis of Date type errors found */
|
|
19
|
-
analysis?: string & typia.tags.MaxLength<4000>;
|
|
20
|
-
/** Optional: Strategy for fixing Date issues */
|
|
21
|
-
strategy?: string & typia.tags.MaxLength<2000>;
|
|
22
|
-
/**
|
|
23
|
-
* Final corrected code with all Date type issues resolved
|
|
24
|
-
*
|
|
25
|
-
* Must follow these rules:
|
|
26
|
-
*
|
|
27
|
-
* - No ': Date' type declarations
|
|
28
|
-
* - All dates use 'string & tags.Format<"date-time">'
|
|
29
|
-
* - All Date objects wrapped with toISOStringSafe()
|
|
30
|
-
* - Null checks before toISOStringSafe()
|
|
31
|
-
*/
|
|
32
|
-
final: string;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IAutoBeCommonCorrectDateApplication.js","sourceRoot":"","sources":["../../../../src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { AutoBeProgressEventBase, AutoBeRealizeAuthorization, AutoBeRealizeFunction } from "@autobe/interface";
|
|
2
|
-
import { ILlmSchema } from "@samchon/openapi";
|
|
3
|
-
import { AutoBeContext } from "../../context/AutoBeContext";
|
|
4
|
-
export declare const orchestrateRealizeCorrectDate: <Model extends ILlmSchema.Model>(ctx: AutoBeContext<Model>, authorizations: AutoBeRealizeAuthorization[], functions: AutoBeRealizeFunction[], progress: AutoBeProgressEventBase, life?: number) => Promise<AutoBeRealizeFunction[]>;
|