@autobe/agent 0.23.1 → 0.24.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.
Files changed (103) hide show
  1. package/lib/constants/AutoBeSystemPromptConstant.d.ts +30 -29
  2. package/lib/constants/AutoBeSystemPromptConstant.js.map +1 -1
  3. package/lib/factory/consentFunctionCall.js +1 -1
  4. package/lib/factory/consentFunctionCall.js.map +1 -1
  5. package/lib/factory/createAutoBeContext.js +3 -3
  6. package/lib/factory/createAutoBeContext.js.map +1 -1
  7. package/lib/index.mjs +683 -260
  8. package/lib/index.mjs.map +1 -1
  9. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
  10. package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
  11. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
  12. package/lib/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
  13. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
  14. package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
  15. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js +1 -1
  16. package/lib/orchestrate/common/histories/transformCommonCorrectCastingHistories.js.map +1 -1
  17. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.d.ts +9 -0
  18. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js +48 -0
  19. package/lib/orchestrate/common/histories/transformCommonCorrectDateHistories.js.map +1 -0
  20. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.d.ts +35 -0
  21. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js +3 -0
  22. package/lib/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.js.map +1 -0
  23. package/lib/orchestrate/facade/transformFacadeStateMessage.js +1 -1
  24. package/lib/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
  25. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +1 -1
  26. package/lib/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
  27. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
  28. package/lib/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
  29. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
  30. package/lib/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
  31. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
  32. package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
  33. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
  34. package/lib/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
  35. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
  36. package/lib/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
  37. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
  38. package/lib/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
  39. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
  40. package/lib/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
  41. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
  42. package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
  43. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
  44. package/lib/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
  45. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
  46. package/lib/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
  47. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
  48. package/lib/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
  49. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
  50. package/lib/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
  51. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
  52. package/lib/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
  53. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
  54. package/lib/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
  55. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js +2 -2
  56. package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
  57. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js +2 -2
  58. package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
  59. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js +4 -3
  60. package/lib/orchestrate/realize/orchestRateRealizeCorrectCasting.js.map +1 -1
  61. package/lib/orchestrate/realize/orchestrateRealize.js +6 -10
  62. package/lib/orchestrate/realize/orchestrateRealize.js.map +1 -1
  63. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js +46 -61
  64. package/lib/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
  65. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.d.ts +4 -0
  66. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js +540 -0
  67. package/lib/orchestrate/realize/orchestrateRealizeCorrectDate.js.map +1 -0
  68. package/lib/orchestrate/realize/orchestrateRealizeWrite.js +37 -55
  69. package/lib/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
  70. package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +8 -8
  71. package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +20 -264
  72. package/lib/orchestrate/realize/utils/filterDiagnostics.d.ts +13 -0
  73. package/lib/orchestrate/realize/utils/filterDiagnostics.js +20 -0
  74. package/lib/orchestrate/realize/utils/filterDiagnostics.js.map +1 -0
  75. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js +1 -1
  76. package/lib/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
  77. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js +1 -1
  78. package/lib/orchestrate/test/histories/transformTestCorrectInvalidRequestHistories.js.map +1 -1
  79. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js +1 -1
  80. package/lib/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
  81. package/lib/orchestrate/test/histories/transformTestWriteHistories.js +1 -1
  82. package/lib/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
  83. package/lib/structures/IAutoBeConfig.d.ts +34 -1
  84. package/lib/utils/{TimeoutConversation.d.ts → TimedConversation.d.ts} +2 -2
  85. package/lib/utils/{TimeoutConversation.js → TimedConversation.js} +20 -6
  86. package/lib/utils/TimedConversation.js.map +1 -0
  87. package/package.json +6 -6
  88. package/src/constants/AutoBeSystemPromptConstant.ts +30 -29
  89. package/src/factory/createAutoBeContext.ts +5 -5
  90. package/src/orchestrate/common/histories/transformCommonCorrectDateHistories.ts +60 -0
  91. package/src/orchestrate/common/structures/IAutoBeCommonCorrectDateApplication.ts +40 -0
  92. package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +1 -1
  93. package/src/orchestrate/realize/orchestRateRealizeCorrectCasting.ts +4 -3
  94. package/src/orchestrate/realize/orchestrateRealize.ts +22 -16
  95. package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +44 -16
  96. package/src/orchestrate/realize/orchestrateRealizeCorrectDate.ts +372 -0
  97. package/src/orchestrate/realize/orchestrateRealizeWrite.ts +3 -3
  98. package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +8 -10
  99. package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +21 -267
  100. package/src/orchestrate/realize/utils/filterDiagnostics.ts +21 -0
  101. package/src/structures/IAutoBeConfig.ts +34 -1
  102. package/src/utils/{TimeoutConversation.ts → TimedConversation.ts} +18 -3
  103. package/lib/utils/TimeoutConversation.js.map +0 -1
@@ -8,294 +8,48 @@ export interface IAutoBeRealizeWriteApplication {
8
8
  * error-free code generation.
9
9
  *
10
10
  * The generation process includes:
11
+ *
11
12
  * 1. Strategic planning based on Prisma schema analysis
12
- * 2. Initial draft without Date type usage
13
+ * 2. Schema definition for relevant models
13
14
  * 3. Review and refinement for completeness
14
- * 4. Compiler feedback integration if errors detected
15
- * 5. Final implementation with all validations and type safety
15
+ * 4. Final implementation with all validations and type safety
16
16
  *
17
- * @param next Properties containing the multi-phase implementation plan and code
17
+ * @param next Properties containing the multi-phase implementation plan and
18
+ * code
18
19
  */
19
20
  coding: (next: IAutoBeRealizeWriteApplication.IProps) => void;
20
21
  }
21
22
 
22
23
  export namespace IAutoBeRealizeWriteApplication {
23
24
  /**
24
- * Properties for the Realize Write Application following Chain of Thinking (CoT).
25
- *
26
- * Each field represents a distinct phase in the reasoning and implementation process,
27
- * building upon the previous step to create a complete, error-free implementation.
28
- * This structured approach ensures clarity, debuggability, and systematic thinking.
25
+ * Properties for the Realize Write Application following Chain of Thinking
26
+ * (CoT).
27
+ *
28
+ * Each field represents a distinct phase in the implementation process.
29
+ * Detailed guidelines are in REALIZE_WRITE.md.
29
30
  */
30
31
  export interface IProps {
31
32
  /**
32
33
  * Step 1 - Planning Phase (CoT: Initial Reasoning)
33
34
  *
34
- * 🧠 Provider Function Implementation Plan
35
- *
36
- * This field outlines the strategic plan for implementing the provider
37
- * function according to the Realize Coder Agent specification. Before
38
- * writing the actual code, think through the logic and structure.
39
- *
40
- * The plan follows a SCHEMA-FIRST APPROACH:
41
- *
42
- * 📋 STEP 1 - PRISMA SCHEMA VERIFICATION:
43
- *
44
- * DO:
45
- *
46
- * - Examine the actual Prisma schema model definition
47
- * - List EVERY field that exists in the model with exact types
48
- * - Explicitly note fields that DO NOT exist
49
- * - Verify database compatibility (PostgreSQL AND SQLite)
50
- *
51
- * DO NOT:
52
- *
53
- * - Assume common fields exist without verification
54
- * - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
55
- * without checking
56
- * - Use PostgreSQL-specific features like mode: "insensitive"
57
- *
58
- * 📋 STEP 2 - FIELD INVENTORY:
59
- *
60
- * - List ONLY fields confirmed to exist in schema
61
- * - Example: "Verified fields in user model: id (String), email (String),
62
- * created_at (DateTime), updated_at (DateTime)"
63
- * - Example: "Fields that DO NOT exist: deleted_at, is_active, created_by"
64
- *
65
- * 📋 STEP 3 - FIELD ACCESS STRATEGY:
66
- *
67
- * - Plan which verified fields will be used in select, update, create
68
- * operations
69
- * - For complex operations with type errors, plan to use separate queries
70
- * instead of nested operations
71
- *
72
- * 📋 STEP 4 - TYPE COMPATIBILITY:
73
- *
74
- * - Plan DateTime to ISO string conversions using toISOStringSafe()
75
- * - Plan handling of nullable vs required fields
76
- *
77
- * 📋 STEP 5 - IMPLEMENTATION APPROACH:
78
- *
79
- * - 🧩 Required business entities (e.g., users, posts, logs) and their
80
- * relationships
81
- * - 🛠 Operations needed to fulfill the business scenario (e.g., fetch,
82
- * create, update) using ONLY verified fields
83
- * - 🔄 Data dependencies between steps (e.g., use userId to fetch related
84
- * data)
85
- * - ✅ Validation points (based on business rules, not field presence)
86
- * - 🚧 Error and edge cases that must be handled explicitly (e.g., missing
87
- * records)
88
- * - 🏗 Structure: always a single `async function`, using only `parameters`
89
- * and `body`
35
+ * Strategic plan following SCHEMA-FIRST APPROACH:
90
36
  *
91
- * ⚠️ Important Constraints:
37
+ * 1. Verify Prisma schema fields (list existing and non-existing)
38
+ * 2. Plan field usage in operations
39
+ * 3. Plan type conversions and nullable handling
40
+ * 4. Define implementation approach with error handling
92
41
  *
93
- * - Do NOT perform input validation — assume `parameters` and `body` are
94
- * already valid
95
- * - Use `typia.random<T>()` with an explanatory comment if logic can't be
96
- * implemented
97
- * - Never use `any` or make assumptions without sufficient context
98
- * - Use only allowed imports — DTOs and Prisma types
99
- * - Use `MyGlobal.prisma` for DB access and respect Prisma typing rules
100
- *
101
- * ⚠️ TypeScript-specific considerations:
102
- *
103
- * - Do **not** use native `Date` objects directly; always convert all dates
104
- * using `toISOStringSafe()` and brand as `string &
105
- * tags.Format<'date-time'>`. This rule applies throughout all phases.
106
- * - Prefer `satisfies` for DTO conformance instead of unsafe `as` casts
107
- * - Avoid weak typing such as `any`, `as any`, or `satisfies any`
108
- * - Use branded types (e.g., `tags.Format<'uuid'>`) and literal unions where
109
- * applicable
110
- *
111
- * ✅ Example Structure:
112
- *
113
- * ```ts
114
- * export async function doSomething(
115
- * user: { id: string & tags.Format<"uuid">; type: string },
116
- * parameters: IParams,
117
- * body: IBody
118
- * ): Promise<IReturn> {
119
- * const { id } = parameters;
120
- * const { name } = body;
121
- * const user = await MyGlobal.prisma.users.findFirst({ where: { id } });
122
- * if (!user) throw new Error("User not found");
123
- * ...
124
- * return result;
125
- * }
126
- * ```
127
- *
128
- * 🔍 Feasibility Analysis Requirement:
129
- *
130
- * - Before generating any code, the agent **must analyze** whether the
131
- * requested implementation is **feasible based on the given Prisma schema
132
- * and DTO types**.
133
- * - If required fields or relationships are **missing or incompatible**, the
134
- * plan should explicitly state that the implementation is **not
135
- * possible** with the current schema/DTO, and no code should be generated
136
- * in later stages.
137
- * - In such cases, only a detailed **comment in the `implementationCode`**
138
- * should be returned explaining why the logic cannot be implemented.
139
- *
140
- * 🔥 Error Handling Plan:
141
- *
142
- * If an error is expected or encountered during implementation:
143
- *
144
- * - Clearly document the error message(s) and TypeScript error codes.
145
- * - Analyze the root cause (e.g., type mismatch, missing field, nullability
146
- * issue).
147
- * - Define concrete steps to resolve the issue, such as:
148
- *
149
- * - Adjusting type declarations or using Prisma-generated input types.
150
- * - Using `?? undefined` to normalize nullable fields.
151
- * - Applying correct relation handling (e.g., `connect` instead of direct
152
- * foreign key assignment).
153
- * - Ensuring all date fields use `.toISOString()` and proper branding.
154
- * - Include fallback or workaround plans if a direct fix is complex.
155
- * - If no error is present, simply omit this section.
156
- *
157
- * This plan ensures the function will:
158
- *
159
- * - Respect the global architecture and coding conventions
160
- * - Be safe, predictable, and aligned with upstream logic
42
+ * See REALIZE_WRITE.md for detailed requirements.
161
43
  */
162
44
  plan: string;
163
45
 
164
- /**
165
- * Step 2 - Schema Definition (CoT: Context Establishment)
166
- *
167
- * The Prisma schema string that will be used to validate the implementation
168
- * logic in this file.
169
- *
170
- * You must **explicitly specify only the relevant models and fields** from
171
- * your full schema that are used in this implementation. This ensures that
172
- * your logic is aligned with the expected database structure without
173
- * accidentally introducing unrelated fields or models.
174
- *
175
- * ⚠️ Important: The value of this field must be a valid Prisma schema
176
- * string containing only the models used in this code — not the entire
177
- * schema.
178
- *
179
- * This acts as a safeguard against:
180
- *
181
- * - Forgetting required fields used in this implementation
182
- * - Including fields or models that are not actually used
183
- */
184
- prisma_schemas: string;
46
+ /** Step 2 - Relevant Prisma schema models and fields */
47
+ prismaSchemas: string;
185
48
 
186
- /**
187
- * Step 3 - Initial Draft (CoT: First Implementation Attempt)
188
- *
189
- * Draft WITHOUT using native Date type.
190
- *
191
- * This is the initial drafting phase where you outline the basic skeleton
192
- * of the function.
193
- *
194
- * DO NOT: Use the native Date type.
195
- *
196
- * - The function signature must correctly include `user`, `parameters`, and
197
- * `body` arguments.
198
- * - Design the main flow of business logic, such as DB fetches and early
199
- * returns based on conditions.
200
- * - Mark any incomplete or missing parts clearly with placeholders (e.g.,
201
- * comments or temporary values).
202
- *
203
- * Import rules:
204
- *
205
- * DO NOT:
206
- *
207
- * - Add any new import statements manually
208
- * - Write import statements directly (this causes compile errors)
209
- *
210
- * Note: All necessary imports are provided globally or by the system
211
- * automatically.
212
- *
213
- * ✅ Requirements:
214
- *
215
- * - Avoid using the `any` type at all costs to ensure type safety.
216
- * - NEVER declare variables with `: Date` type
217
- * - ALWAYS use `string & tags.Format<'date-time'>` for date values
218
- * - Use `toISOStringSafe(new Date())` for current timestamps
219
- * - Maintain a single-function structure; avoid using classes.
220
- */
221
- draft_without_date_type: string;
222
-
223
- /**
224
- * Step 4 - Review and Refinement (CoT: Self-Reflection)
225
- *
226
- * A refined version of the draft with improved completeness.
227
- *
228
- * - Replace placeholder logic with real DTO-conformant operations.
229
- * - Add error handling (`throw new Error(...)`) where necessary.
230
- * - Begin resolving structural or type mismatches.
231
- *
232
- * ✅ Requirements:
233
- *
234
- * - Use `satisfies` to ensure DTO conformity.
235
- * - Avoid unsafe `as` casts unless only for branding or literal narrowing.
236
- * - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
237
- * - Ensure all object keys strictly conform to the expected type definitions.
238
- * - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
239
- */
49
+ /** Step 3 - Refined version with real operations */
240
50
  review: string;
241
51
 
242
-
243
- /**
244
- * Step 5 - Complete Implementation (CoT: Final Synthesis)
245
- *
246
- * The complete and fully correct TypeScript function implementation.
247
- *
248
- * - Passes strict type checking without errors.
249
- * - Uses only safe branding or literal type assertions.
250
- * - Converts all date values properly using `toISOStringSafe()`.
251
- * - Follows DTO structures using `satisfies`.
252
- * - Avoids any weak typing such as `any`, `as any`, or `satisfies any`.
253
- * - Uses only allowed imports (e.g., from `../api/structures` and
254
- * `MyGlobal.prisma`).
255
- * - NEVER creates intermediate variables for Prisma operations.
256
- * - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
257
- *
258
- * ⚠️ Fallback Behavior:
259
- *
260
- * - If the `plan` phase explicitly determines that the requested logic is
261
- * **not feasible** due to mismatches or limitations in the provided
262
- * Prisma schema and DTO types:
263
- *
264
- * - The implementation must still return a syntactically valid function.
265
- * - In such cases, return mock data using `typia.random<T>()` wrapped in the
266
- * correct structure, along with a comment explaining the limitation.
267
- *
268
- * Example fallback:
269
- *
270
- * ```ts
271
- * // ⚠️ Cannot implement logic due to missing relation between A and B
272
- * export async function someFunction(...) {
273
- * return typia.random<IReturn>(); // mocked output
274
- * }
275
- * ```
276
- *
277
- * ⚠️ Prohibited Practices:
278
- *
279
- * - Do NOT add or modify import statements manually. Imports are handled
280
- * automatically by the system.
281
- * - Do NOT use `any`, `as any`, or `satisfies any` to bypass type checking.
282
- * - Do NOT assign native `Date` objects directly; always convert them using
283
- * `toISOStringSafe()`.
284
- * - Do NOT use unsafe type assertions except for safe branding or literal
285
- * narrowing.
286
- * - Do NOT write code outside the single async function structure (e.g., no
287
- * classes or multiple functions).
288
- * - Do NOT perform any input validation — assume all inputs are already
289
- * validated.
290
- * - Do NOT use dynamic import expressions (`import()`); all imports must be
291
- * static.
292
- * - Do NOT use Prisma-generated input types; always use types from
293
- * `../api/structures`.
294
- * - Do NOT use `Object.prototype.hasOwnProperty.call()` for field checks.
295
- * - Do NOT escape newlines or quotes in the implementation string (e.g., no
296
- * `\\n` or `\"`); use a properly formatted template literal with actual
297
- * line breaks instead.
298
- */
299
- implementationCode: string;
52
+ /** Step 4 - Final implementation See REALIZE_WRITE.md for requirements */
53
+ final: string;
300
54
  }
301
55
  }
@@ -0,0 +1,21 @@
1
+ import { IAutoBeRealizeFunctionFailure } from "../structures/IAutoBeRealizeFunctionFailure";
2
+
3
+ /**
4
+ * Filter diagnostic failures to only include those matching the given
5
+ * locations.
6
+ *
7
+ * @param failures - Array of function failures with diagnostic information
8
+ * @param locations - Array of file locations to filter by
9
+ * @returns Filtered array of failures matching the specified locations
10
+ * @warning This function assumes f.function and f.function.location are always defined.
11
+ * If f.function is undefined, this will throw a runtime error.
12
+ * Consider using optional chaining: f.function?.location
13
+ */
14
+ export function filterDiagnostics(
15
+ failures: IAutoBeRealizeFunctionFailure[],
16
+ locations: string[],
17
+ ): IAutoBeRealizeFunctionFailure[] {
18
+ return failures
19
+ .filter((f) => f.function.location.startsWith("src/providers"))
20
+ .filter((f) => locations.includes(f.function.location));
21
+ }
@@ -64,7 +64,40 @@ export interface IAutoBeConfig {
64
64
  */
65
65
  timezone?: string;
66
66
 
67
- timeout?: number;
67
+ /**
68
+ * Maximum execution time limit for agent conversations in milliseconds.
69
+ *
70
+ * Controls the maximum duration allowed for each agent's conversation and
71
+ * code generation process. When set to a numeric value, the agent will
72
+ * automatically abort the conversation if it exceeds the specified time
73
+ * limit, preventing infinite loops or excessively long running operations
74
+ * that could consume excessive resources.
75
+ *
76
+ * Setting this value to `null` disables the timeout, allowing the agent to
77
+ * run indefinitely until the conversation naturally completes or encounters
78
+ * an error. This unlimited mode should be used with caution, particularly in
79
+ * production environments where resource management is critical.
80
+ *
81
+ * The timeout applies to each individual agent conversation phase (analyze,
82
+ * prisma, interface, test, realize) separately, not to the entire AutoBE
83
+ * pipeline execution. This ensures that a single slow phase doesn't prevent
84
+ * completion of other phases while still protecting against runaway
85
+ * processes.
86
+ *
87
+ * @example
88
+ * // 10 minute timeout
89
+ * {
90
+ * timeout: 10 * 60 * 1_000;
91
+ * }
92
+ *
93
+ * // No timeout (unlimited)
94
+ * {
95
+ * timeout: null;
96
+ * }
97
+ *
98
+ * @default null
99
+ */
100
+ timeout?: number | null;
68
101
 
69
102
  /**
70
103
  * Backoff strategy for retrying failed operations.
@@ -4,11 +4,11 @@ import { ConditionVariable, IPointer, Singleton, sleep_for } from "tstl";
4
4
 
5
5
  import { AutoBeTimeoutError } from "./AutoBeTimeoutError";
6
6
 
7
- export namespace TimeoutConversation {
7
+ export namespace TimedConversation {
8
8
  export interface IProps<Model extends ILlmSchema.Model> {
9
9
  agent: MicroAgentica<Model>;
10
- timeout: number;
11
10
  message: string;
11
+ timeout: number | null;
12
12
  }
13
13
  export type IResult<Model extends ILlmSchema.Model> =
14
14
  | ISuccessResult<Model>
@@ -30,6 +30,21 @@ export namespace TimeoutConversation {
30
30
  export const process = async <Model extends ILlmSchema.Model>(
31
31
  props: IProps<Model>,
32
32
  ): Promise<IResult<Model>> => {
33
+ if (props.timeout === null)
34
+ try {
35
+ const histories: MicroAgenticaHistory<Model>[] =
36
+ await props.agent.conversate(props.message);
37
+ return {
38
+ type: "success",
39
+ histories,
40
+ };
41
+ } catch (error) {
42
+ return {
43
+ type: "error",
44
+ error: error as Error,
45
+ };
46
+ }
47
+
33
48
  // PREPARE TIMEOUT HANDLERS
34
49
  const result: IPointer<IResult<Model> | null> = {
35
50
  value: null,
@@ -45,7 +60,7 @@ export namespace TimeoutConversation {
45
60
  };
46
61
  abort.abort(`Timeout, over ${props.timeout} ms`);
47
62
  void holder.notify_all().catch(() => {});
48
- }, props.timeout),
63
+ }, props.timeout!),
49
64
  );
50
65
 
51
66
  // DO CONVERSATE
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeoutConversation.js","sourceRoot":"","sources":["../../src/utils/TimeoutConversation.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,+BAAyE;AAEzE,6DAA0D;AAE1D,IAAiB,mBAAmB,CA2EnC;AA3ED,WAAiB,mBAAmB;IAuBrB,2BAAO,GAAG,CACrB,KAAoB,EACK,EAAE;QAC3B,2BAA2B;QAC3B,MAAM,MAAM,GAAoC;YAC9C,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,MAAM,MAAM,GAAsB,IAAI,wBAAiB,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAoB,IAAI,eAAe,EAAE,CAAC;QACrD,MAAM,OAAO,GAA8B,IAAI,gBAAS,CAAC,GAAG,EAAE,CAC5D,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,MAAM,CAAC,KAAK,KAAK,IAAI;gBAAE,OAAO;YAClC,MAAM,CAAC,KAAK,GAAG;gBACb,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,IAAI,uCAAkB,CAAC,iBAAiB,KAAK,CAAC,OAAO,MAAM,CAAC;aACpE,CAAC;YACF,KAAK,CAAC,KAAK,CAAC,iBAAiB,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC;YACjD,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAClB,CAAC;QAEF,gBAAgB;QAChB,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7B,OAAO,CAAC,GAAG,EAAE,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,KAAK;aACR,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE;YACzB,WAAW,EAAE,KAAK,CAAC,MAAM;SAC1B,CAAC;aACD,IAAI,CACH,CAAC,CAAC,EAAE,EAAE;;YACJ,OAAA,OAAC,MAAM,CAAC,KAAK,oCAAZ,MAAM,CAAC,KAAK,GAAK;gBAChB,IAAI,EAAE,SAAS;gBACf,SAAS,EAAE,CAAC;aACb,EAAC,CAAA;SAAA,CACL;aACA,KAAK,CACJ,CAAC,CAAC,EAAE,EAAE;;YACJ,OAAA,OAAC,MAAM,CAAC,KAAK,oCAAZ,MAAM,CAAC,KAAK,GAAK;gBAChB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,CAAU;aAClB,EAAC,CAAA;SAAA,CACL;aACA,OAAO,CAAC,GAAG,EAAE;YACZ,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACzC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEL,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,MAAM,IAAA,gBAAS,EAAC,CAAC,CAAC,CAAC;QACnB,OAAO,MAAM,CAAC,KAAM,CAAC;IACvB,CAAC,CAAA,CAAC;AACJ,CAAC,EA3EgB,mBAAmB,mCAAnB,mBAAmB,QA2EnC"}