@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.
Files changed (187) hide show
  1. package/lib/constants/AutoBeSystemPromptConstant.d.ts +16 -16
  2. package/lib/context/IAutoBeApplication.d.ts +101 -6
  3. package/lib/context/IAutoBeApplicationProps.d.ts +6 -2
  4. package/lib/factory/createAgenticaHistory.js +1 -1
  5. package/lib/factory/createAgenticaHistory.js.map +1 -1
  6. package/lib/factory/createAutoBeApplication.js +80 -90
  7. package/lib/factory/createAutoBeApplication.js.map +1 -1
  8. package/lib/factory/createAutoBeContext.js +5 -5
  9. package/lib/factory/createAutoBeContext.js.map +1 -1
  10. package/lib/index.mjs +941 -1065
  11. package/lib/index.mjs.map +1 -1
  12. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +5 -1
  13. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  14. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.d.ts +1 -1
  15. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +18 -3
  16. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  17. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +5 -1
  18. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +19 -7
  19. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  20. package/lib/orchestrate/analyze/orchestrateAnalyze.js +3 -2
  21. package/lib/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
  22. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.d.ts +1 -1
  23. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js +2 -2
  24. package/lib/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
  25. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +1 -0
  26. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js +2 -2
  27. package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
  28. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  29. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  30. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js +2 -1
  31. package/lib/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
  32. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.d.ts +5 -1
  33. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +20 -7
  34. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  35. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.d.ts +6 -1
  36. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -23
  37. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  38. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.d.ts +6 -1
  39. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +22 -6
  40. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +1 -1
  42. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  43. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.d.ts +4 -1
  44. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +26 -5
  45. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  46. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.d.ts +5 -1
  47. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +21 -5
  48. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  49. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +1 -1
  50. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  51. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.d.ts +5 -1
  52. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +20 -4
  53. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  54. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +1 -1
  55. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  56. package/lib/orchestrate/interface/orchestrateInterface.js +25 -7
  57. package/lib/orchestrate/interface/orchestrateInterface.js.map +1 -1
  58. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +1 -1
  59. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js +17 -8
  60. package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
  61. package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +4 -1
  62. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js +18 -11
  63. package/lib/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
  64. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.d.ts +6 -1
  65. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js +25 -10
  66. package/lib/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
  67. package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +4 -1
  68. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js +9 -6
  69. package/lib/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
  70. package/lib/orchestrate/interface/orchestrateInterfaceOperations.d.ts +5 -1
  71. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js +33 -17
  72. package/lib/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
  73. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.d.ts +5 -1
  74. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js +36 -18
  75. package/lib/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
  76. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.d.ts +4 -1
  77. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +19 -8
  78. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  79. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +1 -1
  80. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  81. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.d.ts +6 -1
  82. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +20 -6
  83. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  84. package/lib/orchestrate/prisma/orchestratePrisma.js +3 -3
  85. package/lib/orchestrate/prisma/orchestratePrisma.js.map +1 -1
  86. package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -1
  87. package/lib/orchestrate/prisma/orchestratePrismaComponent.js +6 -3
  88. package/lib/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
  89. package/lib/orchestrate/prisma/orchestratePrismaSchemas.d.ts +1 -1
  90. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js +12 -6
  91. package/lib/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
  92. package/lib/orchestrate/{common/histories/transformCommonCorrectDateHistories.d.ts → realize/histories/transformRealizeCorrectCastingHistories.d.ts} +1 -2
  93. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js +33 -0
  94. package/lib/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.js.map +1 -0
  95. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +21 -7
  96. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  97. package/lib/orchestrate/realize/orchestrateRealize.js +3 -9
  98. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  99. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +12 -2
  100. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  101. package/lib/orchestrate/realize/utils/generateRealizeScenario.js +1 -5
  102. package/lib/orchestrate/realize/utils/generateRealizeScenario.js.map +1 -1
  103. package/lib/orchestrate/realize/utils/replaceImportStatements.js +3 -1
  104. package/lib/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
  105. package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +5 -1
  106. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +11 -7
  107. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  108. package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +7 -1
  109. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +39 -31
  110. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  111. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.d.ts +6 -3
  112. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js +32 -26
  113. package/lib/orchestrate/test/histories/transformTestScenarioReviewHistories.js.map +1 -1
  114. package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +5 -1
  115. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +111 -94
  116. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  117. package/lib/orchestrate/test/orchestrateTest.js +20 -14
  118. package/lib/orchestrate/test/orchestrateTest.js.map +1 -1
  119. package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +4 -1
  120. package/lib/orchestrate/test/orchestrateTestCorrect.js +51 -35
  121. package/lib/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
  122. package/lib/orchestrate/test/orchestrateTestScenario.d.ts +1 -1
  123. package/lib/orchestrate/test/orchestrateTestScenario.js +14 -3
  124. package/lib/orchestrate/test/orchestrateTestScenario.js.map +1 -1
  125. package/lib/orchestrate/test/orchestrateTestScenarioReview.d.ts +5 -1
  126. package/lib/orchestrate/test/orchestrateTestScenarioReview.js +19 -11
  127. package/lib/orchestrate/test/orchestrateTestScenarioReview.js.map +1 -1
  128. package/lib/orchestrate/test/orchestrateTestWrite.d.ts +4 -1
  129. package/lib/orchestrate/test/orchestrateTestWrite.js +9 -4
  130. package/lib/orchestrate/test/orchestrateTestWrite.js.map +1 -1
  131. package/package.json +5 -5
  132. package/src/constants/AutoBeSystemPromptConstant.ts +16 -16
  133. package/src/context/IAutoBeApplication.ts +101 -6
  134. package/src/context/IAutoBeApplicationProps.ts +6 -2
  135. package/src/factory/createAgenticaHistory.ts +11 -5
  136. package/src/factory/createAutoBeContext.ts +5 -5
  137. package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +5 -1
  138. package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +16 -0
  139. package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +22 -7
  140. package/src/orchestrate/analyze/orchestrateAnalyze.ts +3 -2
  141. package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +2 -1
  142. package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +3 -2
  143. package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +2 -1
  144. package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +23 -9
  145. package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +33 -24
  146. package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +26 -9
  147. package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +27 -5
  148. package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +24 -7
  149. package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +23 -6
  150. package/src/orchestrate/interface/orchestrateInterface.ts +29 -10
  151. package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +22 -12
  152. package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +25 -17
  153. package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +35 -23
  154. package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +9 -3
  155. package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +44 -29
  156. package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +51 -32
  157. package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +20 -6
  158. package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +24 -9
  159. package/src/orchestrate/prisma/orchestratePrisma.ts +7 -3
  160. package/src/orchestrate/prisma/orchestratePrismaComponent.ts +5 -1
  161. package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +15 -10
  162. package/src/orchestrate/realize/histories/transformRealizeCorrectCastingHistories.ts +45 -0
  163. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +26 -7
  164. package/src/orchestrate/realize/orchestrateRealize.ts +6 -17
  165. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +18 -2
  166. package/src/orchestrate/realize/utils/generateRealizeScenario.ts +1 -5
  167. package/src/orchestrate/realize/utils/replaceImportStatements.ts +5 -0
  168. package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +14 -7
  169. package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +44 -36
  170. package/src/orchestrate/test/histories/transformTestScenarioReviewHistories.ts +74 -71
  171. package/src/orchestrate/test/histories/transformTestWriteHistories.ts +35 -12
  172. package/src/orchestrate/test/orchestrateTest.ts +19 -13
  173. package/src/orchestrate/test/orchestrateTestCorrect.ts +65 -46
  174. package/src/orchestrate/test/orchestrateTestScenario.ts +15 -11
  175. package/src/orchestrate/test/orchestrateTestScenarioReview.ts +29 -16
  176. package/src/orchestrate/test/orchestrateTestWrite.ts +13 -4
  177. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +0 -48
  178. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +0 -1
  179. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +0 -35
  180. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js +0 -3
  181. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +0 -1
  182. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +0 -4
  183. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +0 -540
  184. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +0 -1
  185. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +0 -60
  186. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +0 -40
  187. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +0 -372
@@ -1,372 +0,0 @@
1
- import {
2
- AutoBeProgressEventBase,
3
- AutoBeRealizeAuthorization,
4
- AutoBeRealizeFunction,
5
- AutoBeRealizeValidateEvent,
6
- IAutoBeTypeScriptCompileResult,
7
- } from "@autobe/interface";
8
- import { StringUtil } from "@autobe/utils";
9
- import { ILlmApplication, ILlmController, ILlmSchema } from "@samchon/openapi";
10
- import { IPointer } from "tstl";
11
- import typia from "typia";
12
- import { v7 } from "uuid";
13
-
14
- import { AutoBeContext } from "../../context/AutoBeContext";
15
- import { assertSchemaModel } from "../../context/assertSchemaModel";
16
- import { executeCachedBatch } from "../../utils/executeCachedBatch";
17
- import { transformCommonCorrectDateHistories } from "../common/histories/transformCommonCorrectDateHistories";
18
- import { IAutoBeCommonCorrectDateApplication } from "../common/structures/IAutoBeCommonCorrectDateApplication";
19
- import { compileRealizeFiles } from "./internal/compileRealizeFiles";
20
-
21
- /** Result of attempting to correct a single function */
22
- type CorrectionResult = {
23
- result: "success" | "ignore" | "exception";
24
- func: AutoBeRealizeFunction;
25
- };
26
-
27
- export const orchestrateRealizeCorrectDate = async <
28
- Model extends ILlmSchema.Model,
29
- >(
30
- ctx: AutoBeContext<Model>,
31
- authorizations: AutoBeRealizeAuthorization[],
32
- functions: AutoBeRealizeFunction[],
33
- progress: AutoBeProgressEventBase,
34
- life: number = ctx.retry,
35
- ): Promise<AutoBeRealizeFunction[]> => {
36
- const validateEvent: AutoBeRealizeValidateEvent = await compileRealizeFiles(
37
- ctx,
38
- {
39
- authorizations,
40
- functions,
41
- },
42
- );
43
-
44
- return predicate(
45
- ctx,
46
- authorizations,
47
- functions,
48
- [],
49
- progress,
50
- validateEvent,
51
- life,
52
- );
53
- };
54
-
55
- const predicate = async <Model extends ILlmSchema.Model>(
56
- ctx: AutoBeContext<Model>,
57
- authorizations: AutoBeRealizeAuthorization[],
58
- functions: AutoBeRealizeFunction[],
59
- failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
60
- progress: AutoBeProgressEventBase,
61
- event: AutoBeRealizeValidateEvent,
62
- life: number,
63
- ): Promise<AutoBeRealizeFunction[]> => {
64
- if (event.result.type === "failure") {
65
- ctx.dispatch(event);
66
-
67
- return await correct(
68
- ctx,
69
- authorizations,
70
- functions,
71
- [...failures, ...event.result.diagnostics],
72
- progress,
73
- event,
74
- life,
75
- );
76
- }
77
- return functions;
78
- };
79
-
80
- const correct = async <Model extends ILlmSchema.Model>(
81
- ctx: AutoBeContext<Model>,
82
- authorizations: AutoBeRealizeAuthorization[],
83
- functions: AutoBeRealizeFunction[],
84
- failures: IAutoBeTypeScriptCompileResult.IDiagnostic[],
85
- progress: AutoBeProgressEventBase,
86
- event: AutoBeRealizeValidateEvent,
87
- life: number,
88
- ): Promise<AutoBeRealizeFunction[]> => {
89
- // Early returns for non-correctable cases
90
- if (event.result.type !== "failure" || life < 0) {
91
- return functions;
92
- }
93
-
94
- // Filter only Date-related errors
95
- const dateErrors = filterDateErrors(failures);
96
- const locations: string[] = diagnose(event).filter(
97
- (l) =>
98
- functions.map((f) => f.location).includes(l) &&
99
- dateErrors.some((e) => e.file === l),
100
- );
101
-
102
- // If no date errors found, return original functions
103
- if (locations.length === 0) {
104
- return functions;
105
- }
106
-
107
- progress.total += locations.length;
108
-
109
- const converted: CorrectionResult[] = await executeCachedBatch(
110
- locations.map((location) => async (): Promise<CorrectionResult> => {
111
- const func: AutoBeRealizeFunction = functions.find(
112
- (f) => f.location === location,
113
- )!;
114
-
115
- const pointer: IPointer<
116
- IAutoBeCommonCorrectDateApplication.IProps | false | null
117
- > = {
118
- value: null,
119
- };
120
-
121
- const { tokenUsage } = await ctx.conversate({
122
- source: "realizeCorrect",
123
- histories: transformCommonCorrectDateHistories([
124
- {
125
- script: func.content,
126
- diagnostics: dateErrors.filter((d) => d.file === location),
127
- },
128
- ]),
129
- controller: createController({
130
- model: ctx.model,
131
- then: (next) => {
132
- pointer.value = next;
133
- },
134
- reject: () => {
135
- pointer.value = false;
136
- },
137
- }),
138
- enforceFunctionCall: true,
139
- message: StringUtil.trim`
140
- Fix ALL Date type problems in this code following these ABSOLUTE RULES:
141
-
142
- 🔴 CRITICAL DATE TYPE RULES:
143
- 1. NEVER declare variables with ': Date' type
144
- 2. NEVER use 'Date' as return type or parameter type
145
- 3. ALWAYS use 'string & tags.Format<"date-time">' for date type declarations
146
- 4. Use toISOStringSafe() to convert Date or string to ISO format
147
- 5. toISOStringSafe() REQUIRES a parameter - it's NOT optional
148
-
149
- 📅 toISOStringSafe FUNCTION SIGNATURE:
150
- function toISOStringSafe(
151
- value: Date | (string & tags.Format<"date-time">)
152
- ): string & tags.Format<"date-time">
153
-
154
- Note: This function CANNOT accept null or undefined!
155
-
156
- 📅 CORRECT PATTERNS:
157
- - Creating timestamps: toISOStringSafe(new Date())
158
- - Converting nullable dates: value ? toISOStringSafe(value) : null
159
- - Converting strings: toISOStringSafe(dateString)
160
- - Type declarations: string & tags.Format<'date-time'>
161
- - Never store Date in variables: const now = new Date() is FORBIDDEN
162
-
163
- 🚨 COMMON ERRORS TO FIX:
164
- - Type 'Date' is not assignable → Use toISOStringSafe()
165
- - Direct Date assignment → Wrap with toISOStringSafe()
166
- - Date type in function signature → Change to string & tags.Format<'date-time'>
167
- - For nullable values → Check null BEFORE calling toISOStringSafe()
168
-
169
- Fix these Date type issues immediately. If you cannot fix them, reject the task.
170
- Do not explain, just fix the code or give up.
171
- `,
172
- });
173
- ++progress.completed;
174
- if (pointer.value === null)
175
- return { result: "exception" as const, func: func };
176
- else if (pointer.value === false)
177
- return { result: "ignore" as const, func: func };
178
-
179
- ctx.dispatch({
180
- id: v7(),
181
- type: "realizeCorrect",
182
- content: pointer.value.revise.final,
183
- created_at: new Date().toISOString(),
184
- location: func.location,
185
- step: ctx.state().analyze?.step ?? 0,
186
- tokenUsage,
187
- completed: progress.completed,
188
- total: progress.total,
189
- });
190
-
191
- return {
192
- result: "success" as const,
193
- func: { ...func, content: pointer.value.revise.final },
194
- };
195
- }),
196
- );
197
-
198
- const newValidate: AutoBeRealizeValidateEvent = await compileRealizeFiles(
199
- ctx,
200
- { authorizations, functions: converted.map((c) => c.func) },
201
- );
202
-
203
- if (newValidate.result.type === "success") {
204
- return converted.map((c) => c.func);
205
- }
206
-
207
- const newLocations: string[] = diagnose(newValidate);
208
-
209
- // Separate successful, failed, and ignored corrections
210
- const { success, failed, ignored } = separateCorrectionResults(
211
- converted,
212
- newLocations,
213
- );
214
-
215
- // If no failures to retry, return success and ignored functions
216
- if (failed.length === 0) {
217
- return [...success, ...ignored];
218
- }
219
-
220
- // Collect diagnostics relevant to failed functions
221
- const failedLocations: string[] = failed.map((f) => f.location);
222
- const allDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] = [
223
- ...failures,
224
- ...(newValidate.result.type === "failure"
225
- ? newValidate.result.diagnostics
226
- : []),
227
- ];
228
- const relevantDiagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[] =
229
- filterRelevantDiagnostics(allDiagnostics, failedLocations);
230
-
231
- // Recursively retry failed functions
232
- const retriedFunctions: AutoBeRealizeFunction[] = await predicate(
233
- ctx,
234
- authorizations,
235
- failed,
236
- relevantDiagnostics,
237
- progress,
238
- newValidate,
239
- life - 1,
240
- );
241
-
242
- return [...success, ...ignored, ...retriedFunctions];
243
- };
244
-
245
- /**
246
- * Extract unique file locations from validation event diagnostics
247
- *
248
- * @param event - Validation event containing compilation results
249
- * @returns Array of unique file paths that have errors
250
- */
251
- const diagnose = (event: AutoBeRealizeValidateEvent): string[] => {
252
- if (event.result.type !== "failure") {
253
- return [];
254
- }
255
-
256
- const diagnostics = event.result.diagnostics;
257
- const locations = diagnostics
258
- .map((d) => d.file)
259
- .filter((f): f is string => f !== null)
260
- .filter((f) => f.startsWith("src/providers"));
261
-
262
- return Array.from(new Set(locations));
263
- };
264
-
265
- /**
266
- * Filter diagnostics to only include Date-related errors
267
- *
268
- * @param diagnostics - All diagnostics
269
- * @returns Date-related diagnostics only
270
- */
271
- const filterDateErrors = (
272
- diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
273
- ): IAutoBeTypeScriptCompileResult.IDiagnostic[] => {
274
- return diagnostics.filter((d) => {
275
- const messageText = d.messageText?.toLowerCase() || "";
276
- return (
277
- messageText.includes("date") ||
278
- messageText.includes("date-time") ||
279
- messageText.includes("toisostring") ||
280
- messageText.includes("cannot read property") ||
281
- messageText.includes("type 'date'") ||
282
- messageText.includes("tags.format<'date-time'>") ||
283
- messageText.includes('tags.format<"date-time">')
284
- );
285
- });
286
- };
287
-
288
- /**
289
- * Separate correction results into successful, failed, and ignored functions
290
- *
291
- * @param corrections - Array of correction results
292
- * @param errorLocations - File paths that still have errors
293
- * @returns Object with success, failed, and ignored function arrays
294
- */
295
- const separateCorrectionResults = (
296
- corrections: CorrectionResult[],
297
- errorLocations: string[],
298
- ): {
299
- success: AutoBeRealizeFunction[];
300
- failed: AutoBeRealizeFunction[];
301
- ignored: AutoBeRealizeFunction[];
302
- } => {
303
- const success = corrections
304
- .filter(
305
- (c) =>
306
- c.result === "success" && !errorLocations.includes(c.func.location),
307
- )
308
- .map((c) => c.func);
309
-
310
- const failed = corrections
311
- .filter(
312
- (c) => c.result === "success" && errorLocations.includes(c.func.location),
313
- )
314
- .map((c) => c.func);
315
-
316
- const ignored = corrections
317
- .filter((c) => c.result === "ignore" || c.result === "exception")
318
- .map((c) => c.func);
319
-
320
- return { success, failed, ignored };
321
- };
322
-
323
- /**
324
- * Filter diagnostics to only include those relevant to specific functions
325
- *
326
- * @param diagnostics - All diagnostics
327
- * @param functionLocations - Locations of functions to filter for
328
- * @returns Filtered diagnostics
329
- */
330
- const filterRelevantDiagnostics = (
331
- diagnostics: IAutoBeTypeScriptCompileResult.IDiagnostic[],
332
- functionLocations: string[],
333
- ): IAutoBeTypeScriptCompileResult.IDiagnostic[] => {
334
- return diagnostics.filter(
335
- (d) => d.file && functionLocations.includes(d.file),
336
- );
337
- };
338
-
339
- const createController = <Model extends ILlmSchema.Model>(props: {
340
- model: Model;
341
- then: (next: IAutoBeCommonCorrectDateApplication.IProps) => void;
342
- reject: () => void;
343
- }): ILlmController<Model> => {
344
- assertSchemaModel(props.model);
345
- const application = collection[
346
- props.model === "chatgpt" ? "chatgpt" : "claude"
347
- ] satisfies ILlmApplication<any> as any as ILlmApplication<Model>;
348
- return {
349
- protocol: "class",
350
- name: "correctDateInvalidRequest",
351
- application,
352
- execute: {
353
- rewrite: (next) => {
354
- props.then(next);
355
- },
356
- reject: () => {
357
- props.reject();
358
- },
359
- } satisfies IAutoBeCommonCorrectDateApplication,
360
- };
361
- };
362
-
363
- const collection = {
364
- chatgpt: typia.llm.application<
365
- IAutoBeCommonCorrectDateApplication,
366
- "chatgpt"
367
- >(),
368
- claude: typia.llm.application<
369
- IAutoBeCommonCorrectDateApplication,
370
- "claude"
371
- >(),
372
- };