@cloudwarriors-ai/rlm 0.1.5

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 (220) hide show
  1. package/README.md +208 -0
  2. package/dist/application/index.d.ts +4 -0
  3. package/dist/application/index.d.ts.map +1 -0
  4. package/dist/application/index.js +4 -0
  5. package/dist/application/index.js.map +1 -0
  6. package/dist/application/query-handler.d.ts +49 -0
  7. package/dist/application/query-handler.d.ts.map +1 -0
  8. package/dist/application/query-handler.js +311 -0
  9. package/dist/application/query-handler.js.map +1 -0
  10. package/dist/application/rlm-service.d.ts +68 -0
  11. package/dist/application/rlm-service.d.ts.map +1 -0
  12. package/dist/application/rlm-service.js +132 -0
  13. package/dist/application/rlm-service.js.map +1 -0
  14. package/dist/application/session-manager.d.ts +70 -0
  15. package/dist/application/session-manager.d.ts.map +1 -0
  16. package/dist/application/session-manager.js +237 -0
  17. package/dist/application/session-manager.js.map +1 -0
  18. package/dist/cli/commands/config.d.ts +34 -0
  19. package/dist/cli/commands/config.d.ts.map +1 -0
  20. package/dist/cli/commands/config.js +157 -0
  21. package/dist/cli/commands/config.js.map +1 -0
  22. package/dist/cli/commands/index.d.ts +4 -0
  23. package/dist/cli/commands/index.d.ts.map +1 -0
  24. package/dist/cli/commands/index.js +4 -0
  25. package/dist/cli/commands/index.js.map +1 -0
  26. package/dist/cli/commands/query.d.ts +26 -0
  27. package/dist/cli/commands/query.d.ts.map +1 -0
  28. package/dist/cli/commands/query.js +90 -0
  29. package/dist/cli/commands/query.js.map +1 -0
  30. package/dist/cli/commands/session.d.ts +40 -0
  31. package/dist/cli/commands/session.d.ts.map +1 -0
  32. package/dist/cli/commands/session.js +55 -0
  33. package/dist/cli/commands/session.js.map +1 -0
  34. package/dist/cli/config-loader.d.ts +63 -0
  35. package/dist/cli/config-loader.d.ts.map +1 -0
  36. package/dist/cli/config-loader.js +94 -0
  37. package/dist/cli/config-loader.js.map +1 -0
  38. package/dist/cli/index.d.ts +3 -0
  39. package/dist/cli/index.d.ts.map +1 -0
  40. package/dist/cli/index.js +120 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/cli/output/formatter.d.ts +24 -0
  43. package/dist/cli/output/formatter.d.ts.map +1 -0
  44. package/dist/cli/output/formatter.js +196 -0
  45. package/dist/cli/output/formatter.js.map +1 -0
  46. package/dist/cli/output/index.d.ts +3 -0
  47. package/dist/cli/output/index.d.ts.map +1 -0
  48. package/dist/cli/output/index.js +3 -0
  49. package/dist/cli/output/index.js.map +1 -0
  50. package/dist/cli/output/progress.d.ts +60 -0
  51. package/dist/cli/output/progress.d.ts.map +1 -0
  52. package/dist/cli/output/progress.js +142 -0
  53. package/dist/cli/output/progress.js.map +1 -0
  54. package/dist/domain/errors/base-error.d.ts +17 -0
  55. package/dist/domain/errors/base-error.d.ts.map +1 -0
  56. package/dist/domain/errors/base-error.js +29 -0
  57. package/dist/domain/errors/base-error.js.map +1 -0
  58. package/dist/domain/errors/execution-error.d.ts +61 -0
  59. package/dist/domain/errors/execution-error.d.ts.map +1 -0
  60. package/dist/domain/errors/execution-error.js +86 -0
  61. package/dist/domain/errors/execution-error.js.map +1 -0
  62. package/dist/domain/errors/index.d.ts +14 -0
  63. package/dist/domain/errors/index.d.ts.map +1 -0
  64. package/dist/domain/errors/index.js +26 -0
  65. package/dist/domain/errors/index.js.map +1 -0
  66. package/dist/domain/errors/limit-exceeded.d.ts +38 -0
  67. package/dist/domain/errors/limit-exceeded.d.ts.map +1 -0
  68. package/dist/domain/errors/limit-exceeded.js +71 -0
  69. package/dist/domain/errors/limit-exceeded.js.map +1 -0
  70. package/dist/domain/errors/llm-error.d.ts +60 -0
  71. package/dist/domain/errors/llm-error.d.ts.map +1 -0
  72. package/dist/domain/errors/llm-error.js +92 -0
  73. package/dist/domain/errors/llm-error.js.map +1 -0
  74. package/dist/domain/errors/validation-error.d.ts +58 -0
  75. package/dist/domain/errors/validation-error.d.ts.map +1 -0
  76. package/dist/domain/errors/validation-error.js +81 -0
  77. package/dist/domain/errors/validation-error.js.map +1 -0
  78. package/dist/domain/interfaces/code-executor.d.ts +98 -0
  79. package/dist/domain/interfaces/code-executor.d.ts.map +1 -0
  80. package/dist/domain/interfaces/code-executor.js +2 -0
  81. package/dist/domain/interfaces/code-executor.js.map +1 -0
  82. package/dist/domain/interfaces/event-emitter.d.ts +137 -0
  83. package/dist/domain/interfaces/event-emitter.d.ts.map +1 -0
  84. package/dist/domain/interfaces/event-emitter.js +2 -0
  85. package/dist/domain/interfaces/event-emitter.js.map +1 -0
  86. package/dist/domain/interfaces/index.d.ts +5 -0
  87. package/dist/domain/interfaces/index.d.ts.map +1 -0
  88. package/dist/domain/interfaces/index.js +2 -0
  89. package/dist/domain/interfaces/index.js.map +1 -0
  90. package/dist/domain/interfaces/llm-provider.d.ts +64 -0
  91. package/dist/domain/interfaces/llm-provider.d.ts.map +1 -0
  92. package/dist/domain/interfaces/llm-provider.js +2 -0
  93. package/dist/domain/interfaces/llm-provider.js.map +1 -0
  94. package/dist/domain/interfaces/session-store.d.ts +65 -0
  95. package/dist/domain/interfaces/session-store.d.ts.map +1 -0
  96. package/dist/domain/interfaces/session-store.js +2 -0
  97. package/dist/domain/interfaces/session-store.js.map +1 -0
  98. package/dist/domain/services/context-chunker.d.ts +43 -0
  99. package/dist/domain/services/context-chunker.d.ts.map +1 -0
  100. package/dist/domain/services/context-chunker.js +152 -0
  101. package/dist/domain/services/context-chunker.js.map +1 -0
  102. package/dist/domain/services/cost-calculator.d.ts +63 -0
  103. package/dist/domain/services/cost-calculator.d.ts.map +1 -0
  104. package/dist/domain/services/cost-calculator.js +121 -0
  105. package/dist/domain/services/cost-calculator.js.map +1 -0
  106. package/dist/domain/services/index.d.ts +5 -0
  107. package/dist/domain/services/index.d.ts.map +1 -0
  108. package/dist/domain/services/index.js +9 -0
  109. package/dist/domain/services/index.js.map +1 -0
  110. package/dist/domain/services/limit-checker.d.ts +54 -0
  111. package/dist/domain/services/limit-checker.d.ts.map +1 -0
  112. package/dist/domain/services/limit-checker.js +146 -0
  113. package/dist/domain/services/limit-checker.js.map +1 -0
  114. package/dist/domain/services/result-aggregator.d.ts +49 -0
  115. package/dist/domain/services/result-aggregator.d.ts.map +1 -0
  116. package/dist/domain/services/result-aggregator.js +131 -0
  117. package/dist/domain/services/result-aggregator.js.map +1 -0
  118. package/dist/domain/types/config.d.ts +41 -0
  119. package/dist/domain/types/config.d.ts.map +1 -0
  120. package/dist/domain/types/config.js +22 -0
  121. package/dist/domain/types/config.js.map +1 -0
  122. package/dist/domain/types/context.d.ts +64 -0
  123. package/dist/domain/types/context.d.ts.map +1 -0
  124. package/dist/domain/types/context.js +20 -0
  125. package/dist/domain/types/context.js.map +1 -0
  126. package/dist/domain/types/index.d.ts +5 -0
  127. package/dist/domain/types/index.d.ts.map +1 -0
  128. package/dist/domain/types/index.js +9 -0
  129. package/dist/domain/types/index.js.map +1 -0
  130. package/dist/domain/types/result.d.ts +137 -0
  131. package/dist/domain/types/result.d.ts.map +1 -0
  132. package/dist/domain/types/result.js +27 -0
  133. package/dist/domain/types/result.js.map +1 -0
  134. package/dist/domain/types/session.d.ts +74 -0
  135. package/dist/domain/types/session.d.ts.map +1 -0
  136. package/dist/domain/types/session.js +31 -0
  137. package/dist/domain/types/session.js.map +1 -0
  138. package/dist/factory/create-rlm.d.ts +77 -0
  139. package/dist/factory/create-rlm.d.ts.map +1 -0
  140. package/dist/factory/create-rlm.js +82 -0
  141. package/dist/factory/create-rlm.js.map +1 -0
  142. package/dist/factory/default-config.d.ts +27 -0
  143. package/dist/factory/default-config.d.ts.map +1 -0
  144. package/dist/factory/default-config.js +98 -0
  145. package/dist/factory/default-config.js.map +1 -0
  146. package/dist/factory/index.d.ts +3 -0
  147. package/dist/factory/index.d.ts.map +1 -0
  148. package/dist/factory/index.js +3 -0
  149. package/dist/factory/index.js.map +1 -0
  150. package/dist/index.d.ts +37 -0
  151. package/dist/index.d.ts.map +1 -0
  152. package/dist/index.js +40 -0
  153. package/dist/index.js.map +1 -0
  154. package/dist/infrastructure/events/event-types.d.ts +35 -0
  155. package/dist/infrastructure/events/event-types.d.ts.map +1 -0
  156. package/dist/infrastructure/events/event-types.js +44 -0
  157. package/dist/infrastructure/events/event-types.js.map +1 -0
  158. package/dist/infrastructure/events/index.d.ts +3 -0
  159. package/dist/infrastructure/events/index.d.ts.map +1 -0
  160. package/dist/infrastructure/events/index.js +3 -0
  161. package/dist/infrastructure/events/index.js.map +1 -0
  162. package/dist/infrastructure/events/node-emitter.d.ts +72 -0
  163. package/dist/infrastructure/events/node-emitter.d.ts.map +1 -0
  164. package/dist/infrastructure/events/node-emitter.js +125 -0
  165. package/dist/infrastructure/events/node-emitter.js.map +1 -0
  166. package/dist/infrastructure/llm/index.d.ts +3 -0
  167. package/dist/infrastructure/llm/index.d.ts.map +1 -0
  168. package/dist/infrastructure/llm/index.js +3 -0
  169. package/dist/infrastructure/llm/index.js.map +1 -0
  170. package/dist/infrastructure/llm/openrouter-provider.d.ts +35 -0
  171. package/dist/infrastructure/llm/openrouter-provider.d.ts.map +1 -0
  172. package/dist/infrastructure/llm/openrouter-provider.js +158 -0
  173. package/dist/infrastructure/llm/openrouter-provider.js.map +1 -0
  174. package/dist/infrastructure/llm/prompts/code-gen-prompt.d.ts +21 -0
  175. package/dist/infrastructure/llm/prompts/code-gen-prompt.d.ts.map +1 -0
  176. package/dist/infrastructure/llm/prompts/code-gen-prompt.js +78 -0
  177. package/dist/infrastructure/llm/prompts/code-gen-prompt.js.map +1 -0
  178. package/dist/infrastructure/llm/prompts/error-recovery-prompt.d.ts +24 -0
  179. package/dist/infrastructure/llm/prompts/error-recovery-prompt.d.ts.map +1 -0
  180. package/dist/infrastructure/llm/prompts/error-recovery-prompt.js +70 -0
  181. package/dist/infrastructure/llm/prompts/error-recovery-prompt.js.map +1 -0
  182. package/dist/infrastructure/llm/prompts/index.d.ts +4 -0
  183. package/dist/infrastructure/llm/prompts/index.d.ts.map +1 -0
  184. package/dist/infrastructure/llm/prompts/index.js +4 -0
  185. package/dist/infrastructure/llm/prompts/index.js.map +1 -0
  186. package/dist/infrastructure/llm/prompts/system-prompt.d.ts +12 -0
  187. package/dist/infrastructure/llm/prompts/system-prompt.d.ts.map +1 -0
  188. package/dist/infrastructure/llm/prompts/system-prompt.js +96 -0
  189. package/dist/infrastructure/llm/prompts/system-prompt.js.map +1 -0
  190. package/dist/infrastructure/persistence/index.d.ts +3 -0
  191. package/dist/infrastructure/persistence/index.d.ts.map +1 -0
  192. package/dist/infrastructure/persistence/index.js +3 -0
  193. package/dist/infrastructure/persistence/index.js.map +1 -0
  194. package/dist/infrastructure/persistence/memory-store.d.ts +24 -0
  195. package/dist/infrastructure/persistence/memory-store.d.ts.map +1 -0
  196. package/dist/infrastructure/persistence/memory-store.js +71 -0
  197. package/dist/infrastructure/persistence/memory-store.js.map +1 -0
  198. package/dist/infrastructure/persistence/schema.d.ts +120 -0
  199. package/dist/infrastructure/persistence/schema.d.ts.map +1 -0
  200. package/dist/infrastructure/persistence/schema.js +130 -0
  201. package/dist/infrastructure/persistence/schema.js.map +1 -0
  202. package/dist/infrastructure/sandbox/ast-validator.d.ts +23 -0
  203. package/dist/infrastructure/sandbox/ast-validator.d.ts.map +1 -0
  204. package/dist/infrastructure/sandbox/ast-validator.js +249 -0
  205. package/dist/infrastructure/sandbox/ast-validator.js.map +1 -0
  206. package/dist/infrastructure/sandbox/index.d.ts +4 -0
  207. package/dist/infrastructure/sandbox/index.d.ts.map +1 -0
  208. package/dist/infrastructure/sandbox/index.js +4 -0
  209. package/dist/infrastructure/sandbox/index.js.map +1 -0
  210. package/dist/infrastructure/sandbox/prelude/rlm_prelude.py +376 -0
  211. package/dist/infrastructure/sandbox/process-manager.d.ts +98 -0
  212. package/dist/infrastructure/sandbox/process-manager.d.ts.map +1 -0
  213. package/dist/infrastructure/sandbox/process-manager.js +186 -0
  214. package/dist/infrastructure/sandbox/process-manager.js.map +1 -0
  215. package/dist/infrastructure/sandbox/python-executor.d.ts +29 -0
  216. package/dist/infrastructure/sandbox/python-executor.d.ts.map +1 -0
  217. package/dist/infrastructure/sandbox/python-executor.js +182 -0
  218. package/dist/infrastructure/sandbox/python-executor.js.map +1 -0
  219. package/package.json +65 -0
  220. package/src/infrastructure/sandbox/prelude/rlm_prelude.py +376 -0
@@ -0,0 +1,14 @@
1
+ export { RLMError } from './base-error.js';
2
+ export { ExecutionError, CodeValidationError, ExecutionTimeoutError, SandboxViolationError, type ValidationErrorInfo, } from './execution-error.js';
3
+ export { LimitExceededError, SessionCancelledError, SessionTimeoutError, } from './limit-exceeded.js';
4
+ export { ValidationError, ConfigurationError, ContextError, QueryError, } from './validation-error.js';
5
+ export { LLMError, RateLimitError, AuthenticationError, ContentFilterError, MalformedResponseError, } from './llm-error.js';
6
+ /**
7
+ * Check if an error is an RLM error
8
+ */
9
+ export declare function isRLMError(error: unknown): error is import('./base-error.js').RLMError;
10
+ /**
11
+ * Check if an error is recoverable
12
+ */
13
+ export declare function isRecoverableError(error: unknown): boolean;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,UAAU,GACX,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,iBAAiB,EAAE,QAAQ,CAEtF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK1D"}
@@ -0,0 +1,26 @@
1
+ // Base error
2
+ export { RLMError } from './base-error.js';
3
+ // Execution errors
4
+ export { ExecutionError, CodeValidationError, ExecutionTimeoutError, SandboxViolationError, } from './execution-error.js';
5
+ // Limit errors
6
+ export { LimitExceededError, SessionCancelledError, SessionTimeoutError, } from './limit-exceeded.js';
7
+ // Validation errors
8
+ export { ValidationError, ConfigurationError, ContextError, QueryError, } from './validation-error.js';
9
+ // LLM errors
10
+ export { LLMError, RateLimitError, AuthenticationError, ContentFilterError, MalformedResponseError, } from './llm-error.js';
11
+ /**
12
+ * Check if an error is an RLM error
13
+ */
14
+ export function isRLMError(error) {
15
+ return error instanceof Error && 'code' in error && 'recoverable' in error;
16
+ }
17
+ /**
18
+ * Check if an error is recoverable
19
+ */
20
+ export function isRecoverableError(error) {
21
+ if (isRLMError(error)) {
22
+ return error.recoverable;
23
+ }
24
+ return false;
25
+ }
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/errors/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GAEtB,MAAM,sBAAsB,CAAC;AAE9B,eAAe;AACf,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAE7B,oBAAoB;AACpB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,UAAU,GACX,MAAM,uBAAuB,CAAC;AAE/B,aAAa;AACb,OAAO,EACL,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,aAAa,IAAI,KAAK,CAAC;AAC7E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,KAAK,CAAC,WAAW,CAAC;IAC3B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { RLMError } from './base-error.js';
2
+ import type { LimitType } from '../services/limit-checker.js';
3
+ /**
4
+ * Error when a limit is exceeded
5
+ */
6
+ export declare class LimitExceededError extends RLMError {
7
+ readonly code = "LIMIT_EXCEEDED";
8
+ readonly recoverable = false;
9
+ /** Type of limit that was exceeded */
10
+ readonly limitType: LimitType;
11
+ /** Current value */
12
+ readonly currentValue: number;
13
+ /** Maximum allowed value */
14
+ readonly maxValue: number;
15
+ constructor(limitType: LimitType, currentValue: number, maxValue: number, sessionId?: string);
16
+ private static formatMessage;
17
+ toJSON(): Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Error when session is cancelled
21
+ */
22
+ export declare class SessionCancelledError extends RLMError {
23
+ readonly code = "SESSION_CANCELLED";
24
+ readonly recoverable = false;
25
+ constructor(sessionId: string);
26
+ }
27
+ /**
28
+ * Error when session times out
29
+ */
30
+ export declare class SessionTimeoutError extends RLMError {
31
+ readonly code = "SESSION_TIMEOUT";
32
+ readonly recoverable = false;
33
+ /** Timeout duration in milliseconds */
34
+ readonly timeoutMs: number;
35
+ constructor(timeoutMs: number, sessionId?: string);
36
+ toJSON(): Record<string, unknown>;
37
+ }
38
+ //# sourceMappingURL=limit-exceeded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limit-exceeded.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/limit-exceeded.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,QAAQ;IAC9C,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,WAAW,SAAS;IAE7B,sCAAsC;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B,oBAAoB;IACpB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,4BAA4B;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGxB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM;IASpB,OAAO,CAAC,MAAM,CAAC,aAAa;IAiBnB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAQ3C;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;IACjD,QAAQ,CAAC,IAAI,uBAAuB;IACpC,QAAQ,CAAC,WAAW,SAAS;gBAEjB,SAAS,EAAE,MAAM;CAG9B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;IAC/C,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,WAAW,SAAS;IAE7B,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAKxC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAM3C"}
@@ -0,0 +1,71 @@
1
+ import { RLMError } from './base-error.js';
2
+ /**
3
+ * Error when a limit is exceeded
4
+ */
5
+ export class LimitExceededError extends RLMError {
6
+ code = 'LIMIT_EXCEEDED';
7
+ recoverable = false;
8
+ /** Type of limit that was exceeded */
9
+ limitType;
10
+ /** Current value */
11
+ currentValue;
12
+ /** Maximum allowed value */
13
+ maxValue;
14
+ constructor(limitType, currentValue, maxValue, sessionId) {
15
+ const message = LimitExceededError.formatMessage(limitType, currentValue, maxValue);
16
+ super(message, sessionId);
17
+ this.limitType = limitType;
18
+ this.currentValue = currentValue;
19
+ this.maxValue = maxValue;
20
+ }
21
+ static formatMessage(limitType, currentValue, maxValue) {
22
+ switch (limitType) {
23
+ case 'depth':
24
+ return `Maximum recursion depth exceeded: ${currentValue}/${maxValue}`;
25
+ case 'tokens':
26
+ return `Maximum tokens exceeded: ${currentValue.toLocaleString()}/${maxValue.toLocaleString()}`;
27
+ case 'cost':
28
+ return `Maximum cost exceeded: $${currentValue.toFixed(4)}/$${maxValue.toFixed(2)}`;
29
+ case 'time':
30
+ return `Timeout exceeded: ${(currentValue / 1000).toFixed(1)}s/${(maxValue / 1000).toFixed(0)}s`;
31
+ }
32
+ }
33
+ toJSON() {
34
+ return {
35
+ ...super.toJSON(),
36
+ limitType: this.limitType,
37
+ currentValue: this.currentValue,
38
+ maxValue: this.maxValue,
39
+ };
40
+ }
41
+ }
42
+ /**
43
+ * Error when session is cancelled
44
+ */
45
+ export class SessionCancelledError extends RLMError {
46
+ code = 'SESSION_CANCELLED';
47
+ recoverable = false;
48
+ constructor(sessionId) {
49
+ super('Session was cancelled', sessionId);
50
+ }
51
+ }
52
+ /**
53
+ * Error when session times out
54
+ */
55
+ export class SessionTimeoutError extends RLMError {
56
+ code = 'SESSION_TIMEOUT';
57
+ recoverable = false;
58
+ /** Timeout duration in milliseconds */
59
+ timeoutMs;
60
+ constructor(timeoutMs, sessionId) {
61
+ super(`Session timed out after ${(timeoutMs / 1000).toFixed(0)} seconds`, sessionId);
62
+ this.timeoutMs = timeoutMs;
63
+ }
64
+ toJSON() {
65
+ return {
66
+ ...super.toJSON(),
67
+ timeoutMs: this.timeoutMs,
68
+ };
69
+ }
70
+ }
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AO,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QACrG,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IACxC,IAAI,GAAG,mBAAmB,CAAC;IAC3B,WAAW,GAAG,KAAK,CAAC;IAE7B,YAAY,SAAiB;QAC3B,KAAK,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IACtC,IAAI,GAAG,iBAAiB,CAAC;IACzB,WAAW,GAAG,KAAK,CAAC;IAE7B,uCAAuC;IAC9B,SAAS,CAAS;IAE3B,YAAY,SAAiB,EAAE,SAAkB;QAC/C,KAAK,CAAC,2BAA2B,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEQ,MAAM;QACb,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,60 @@
1
+ import { RLMError } from './base-error.js';
2
+ /**
3
+ * Error from LLM provider
4
+ */
5
+ export declare class LLMError extends RLMError {
6
+ readonly code = "LLM_ERROR";
7
+ readonly recoverable = true;
8
+ /** HTTP status code if applicable */
9
+ readonly statusCode?: number;
10
+ /** Provider-specific error code */
11
+ readonly providerCode?: string;
12
+ constructor(message: string, options?: {
13
+ sessionId?: string;
14
+ statusCode?: number;
15
+ providerCode?: string;
16
+ });
17
+ toJSON(): Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Error when LLM rate limit is exceeded
21
+ */
22
+ export declare class RateLimitError extends RLMError {
23
+ readonly code = "RATE_LIMIT_ERROR";
24
+ readonly recoverable = true;
25
+ /** Seconds to wait before retry */
26
+ readonly retryAfter?: number;
27
+ constructor(message: string, retryAfter?: number, sessionId?: string);
28
+ toJSON(): Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Error when LLM authentication fails
32
+ */
33
+ export declare class AuthenticationError extends RLMError {
34
+ readonly code = "AUTHENTICATION_ERROR";
35
+ readonly recoverable = false;
36
+ constructor(message: string, sessionId?: string);
37
+ }
38
+ /**
39
+ * Error when LLM content is filtered
40
+ */
41
+ export declare class ContentFilterError extends RLMError {
42
+ readonly code = "CONTENT_FILTER_ERROR";
43
+ readonly recoverable = false;
44
+ /** Reason for filtering */
45
+ readonly filterReason?: string;
46
+ constructor(message: string, filterReason?: string, sessionId?: string);
47
+ toJSON(): Record<string, unknown>;
48
+ }
49
+ /**
50
+ * Error when LLM response is malformed
51
+ */
52
+ export declare class MalformedResponseError extends RLMError {
53
+ readonly code = "MALFORMED_RESPONSE_ERROR";
54
+ readonly recoverable = true;
55
+ /** The malformed response */
56
+ readonly response?: string;
57
+ constructor(message: string, response?: string, sessionId?: string);
58
+ toJSON(): Record<string, unknown>;
59
+ }
60
+ //# sourceMappingURL=llm-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-error.d.ts","sourceRoot":"","sources":["../../../src/domain/errors/llm-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,qBAAa,QAAS,SAAQ,QAAQ;IACpC,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,WAAW,QAAQ;IAE5B,qCAAqC;IACrC,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AI,8BAA8B;IAC3C,QAAQ,CAAC,WAAW,QAAQ;IAE5B,6BAA6B;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAKzD,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAM3C"}
@@ -0,0 +1,92 @@
1
+ import { RLMError } from './base-error.js';
2
+ /**
3
+ * Error from LLM provider
4
+ */
5
+ export class LLMError extends RLMError {
6
+ code = 'LLM_ERROR';
7
+ recoverable = true;
8
+ /** HTTP status code if applicable */
9
+ statusCode;
10
+ /** Provider-specific error code */
11
+ providerCode;
12
+ constructor(message, options) {
13
+ super(message, options?.sessionId);
14
+ this.statusCode = options?.statusCode;
15
+ this.providerCode = options?.providerCode;
16
+ }
17
+ toJSON() {
18
+ return {
19
+ ...super.toJSON(),
20
+ statusCode: this.statusCode,
21
+ providerCode: this.providerCode,
22
+ };
23
+ }
24
+ }
25
+ /**
26
+ * Error when LLM rate limit is exceeded
27
+ */
28
+ export class RateLimitError extends RLMError {
29
+ code = 'RATE_LIMIT_ERROR';
30
+ recoverable = true;
31
+ /** Seconds to wait before retry */
32
+ retryAfter;
33
+ constructor(message, retryAfter, sessionId) {
34
+ super(message, sessionId);
35
+ this.retryAfter = retryAfter;
36
+ }
37
+ toJSON() {
38
+ return {
39
+ ...super.toJSON(),
40
+ retryAfter: this.retryAfter,
41
+ };
42
+ }
43
+ }
44
+ /**
45
+ * Error when LLM authentication fails
46
+ */
47
+ export class AuthenticationError extends RLMError {
48
+ code = 'AUTHENTICATION_ERROR';
49
+ recoverable = false;
50
+ constructor(message, sessionId) {
51
+ super(message, sessionId);
52
+ }
53
+ }
54
+ /**
55
+ * Error when LLM content is filtered
56
+ */
57
+ export class ContentFilterError extends RLMError {
58
+ code = 'CONTENT_FILTER_ERROR';
59
+ recoverable = false;
60
+ /** Reason for filtering */
61
+ filterReason;
62
+ constructor(message, filterReason, sessionId) {
63
+ super(message, sessionId);
64
+ this.filterReason = filterReason;
65
+ }
66
+ toJSON() {
67
+ return {
68
+ ...super.toJSON(),
69
+ filterReason: this.filterReason,
70
+ };
71
+ }
72
+ }
73
+ /**
74
+ * Error when LLM response is malformed
75
+ */
76
+ export class MalformedResponseError extends RLMError {
77
+ code = 'MALFORMED_RESPONSE_ERROR';
78
+ recoverable = true;
79
+ /** The malformed response */
80
+ response;
81
+ constructor(message, response, sessionId) {
82
+ super(message, sessionId);
83
+ this.response = response;
84
+ }
85
+ toJSON() {
86
+ return {
87
+ ...super.toJSON(),
88
+ response: this.response,
89
+ };
90
+ }
91
+ }
92
+ //# sourceMappingURL=llm-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-error.js","sourceRoot":"","sources":["../../../src/domain/errors/llm-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IAC3B,IAAI,GAAG,WAAW,CAAC;IACnB,WAAW,GAAG,IAAI,CAAC;IAE5B,qCAAqC;IAC5B,UAAU,CAAU;IAE7B,mCAAmC;IAC1B,YAAY,CAAU;IAE/B,YACE,OAAe,EACf,OAIC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,OAAO,EAAE,YAAY,CAAC;IAC5C,CAAC;IAEQ,MAAM;QACb,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACjC,IAAI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CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import { RLMError } from './base-error.js';
2
+ /**
3
+ * Error when input validation fails
4
+ */
5
+ export declare class ValidationError extends RLMError {
6
+ readonly code = "VALIDATION_ERROR";
7
+ readonly recoverable = true;
8
+ /** Field that failed validation */
9
+ readonly field?: string;
10
+ /** Expected value or format */
11
+ readonly expected?: string;
12
+ /** Actual value received */
13
+ readonly actual?: string;
14
+ constructor(message: string, options?: {
15
+ sessionId?: string;
16
+ field?: string;
17
+ expected?: string;
18
+ actual?: string;
19
+ });
20
+ toJSON(): Record<string, unknown>;
21
+ }
22
+ /**
23
+ * Error when configuration is invalid
24
+ */
25
+ export declare class ConfigurationError extends RLMError {
26
+ readonly code = "CONFIGURATION_ERROR";
27
+ readonly recoverable = false;
28
+ /** Configuration key that's invalid */
29
+ readonly configKey?: string;
30
+ constructor(message: string, configKey?: string);
31
+ toJSON(): Record<string, unknown>;
32
+ }
33
+ /**
34
+ * Error when context is invalid or too large
35
+ */
36
+ export declare class ContextError extends RLMError {
37
+ readonly code = "CONTEXT_ERROR";
38
+ readonly recoverable = false;
39
+ /** Size of context in bytes or tokens */
40
+ readonly contextSize?: number;
41
+ /** Maximum allowed size */
42
+ readonly maxSize?: number;
43
+ constructor(message: string, options?: {
44
+ sessionId?: string;
45
+ contextSize?: number;
46
+ maxSize?: number;
47
+ });
48
+ toJSON(): Record<string, unknown>;
49
+ }
50
+ /**
51
+ * Error when query is invalid
52
+ */
53
+ export declare class QueryError extends RLMError {
54
+ readonly code = "QUERY_ERROR";
55
+ readonly recoverable = true;
56
+ constructor(message: string, sessionId?: string);
57
+ }
58
+ //# sourceMappingURL=validation-error.d.ts.map
@@ -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,CAAC,EAAE,MAAM,CAAC;gBAGxB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;IAOM,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAO3C;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,QAAQ;IACtC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,QAAQ;gBAEhB,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAGhD"}
@@ -0,0 +1,81 @@
1
+ import { RLMError } from './base-error.js';
2
+ /**
3
+ * Error when input validation fails
4
+ */
5
+ export class ValidationError extends RLMError {
6
+ code = 'VALIDATION_ERROR';
7
+ recoverable = true;
8
+ /** Field that failed validation */
9
+ field;
10
+ /** Expected value or format */
11
+ expected;
12
+ /** Actual value received */
13
+ actual;
14
+ constructor(message, options) {
15
+ super(message, options?.sessionId);
16
+ this.field = options?.field;
17
+ this.expected = options?.expected;
18
+ this.actual = options?.actual;
19
+ }
20
+ toJSON() {
21
+ return {
22
+ ...super.toJSON(),
23
+ field: this.field,
24
+ expected: this.expected,
25
+ actual: this.actual,
26
+ };
27
+ }
28
+ }
29
+ /**
30
+ * Error when configuration is invalid
31
+ */
32
+ export class ConfigurationError extends RLMError {
33
+ code = 'CONFIGURATION_ERROR';
34
+ recoverable = false;
35
+ /** Configuration key that's invalid */
36
+ configKey;
37
+ constructor(message, configKey) {
38
+ super(message);
39
+ this.configKey = configKey;
40
+ }
41
+ toJSON() {
42
+ return {
43
+ ...super.toJSON(),
44
+ configKey: this.configKey,
45
+ };
46
+ }
47
+ }
48
+ /**
49
+ * Error when context is invalid or too large
50
+ */
51
+ export class ContextError extends RLMError {
52
+ code = 'CONTEXT_ERROR';
53
+ recoverable = false;
54
+ /** Size of context in bytes or tokens */
55
+ contextSize;
56
+ /** Maximum allowed size */
57
+ maxSize;
58
+ constructor(message, options) {
59
+ super(message, options?.sessionId);
60
+ this.contextSize = options?.contextSize;
61
+ this.maxSize = options?.maxSize;
62
+ }
63
+ toJSON() {
64
+ return {
65
+ ...super.toJSON(),
66
+ contextSize: this.contextSize,
67
+ maxSize: this.maxSize,
68
+ };
69
+ }
70
+ }
71
+ /**
72
+ * Error when query is invalid
73
+ */
74
+ export class QueryError extends RLMError {
75
+ code = 'QUERY_ERROR';
76
+ recoverable = true;
77
+ constructor(message, sessionId) {
78
+ super(message, sessionId);
79
+ }
80
+ }
81
+ //# sourceMappingURL=validation-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-error.js","sourceRoot":"","sources":["../../../src/domain/errors/validation-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAClC,IAAI,GAAG,kBAAkB,CAAC;IAC1B,WAAW,GAAG,IAAI,CAAC;IAE5B,mCAAmC;IAC1B,KAAK,CAAU;IAExB,+BAA+B;IACtB,QAAQ,CAAU;IAE3B,4BAA4B;IACnB,MAAM,CAAU;IAEzB,YACE,OAAe,EACf,OAKC;QAED,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;IAChC,CAAC;IAEQ,MAAM;QACb,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;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interface ExecutionContext {
5
+ /** Variables available in the Python environment */
6
+ readonly variables: ReadonlyMap<string, string>;
7
+ /** Session ID for tracking */
8
+ readonly sessionId: string;
9
+ /** Current recursion depth */
10
+ readonly depth: number;
11
+ /** Timeout in milliseconds */
12
+ readonly timeoutMs: number;
13
+ }
14
+ /**
15
+ * Result of code validation
16
+ */
17
+ export interface ValidationResult {
18
+ /** Whether the code is valid and safe */
19
+ readonly valid: boolean;
20
+ /** Validation errors if any */
21
+ readonly errors: readonly ValidationError[];
22
+ /** Warnings (code is valid but might have issues) */
23
+ readonly warnings: readonly string[];
24
+ }
25
+ export interface ValidationError {
26
+ /** Line number (1-indexed) */
27
+ readonly line: number;
28
+ /** Column number (1-indexed) */
29
+ readonly column: number;
30
+ /** Error message */
31
+ readonly message: string;
32
+ /** Error code for categorization */
33
+ readonly code: ValidationErrorCode;
34
+ }
35
+ export type ValidationErrorCode = 'SYNTAX_ERROR' | 'FORBIDDEN_IMPORT' | 'FORBIDDEN_BUILTIN' | 'FORBIDDEN_ATTRIBUTE' | 'INFINITE_LOOP_RISK' | 'FILE_SYSTEM_ACCESS' | 'NETWORK_ACCESS' | 'SHELL_EXECUTION';
36
+ /**
37
+ * Result of code execution
38
+ */
39
+ export interface ExecutionResult {
40
+ /** Whether execution completed successfully */
41
+ readonly success: boolean;
42
+ /** Output printed to stdout */
43
+ readonly stdout: string;
44
+ /** Output printed to stderr */
45
+ readonly stderr: string;
46
+ /** Final result value if any */
47
+ readonly result?: string;
48
+ /** Error message if execution failed */
49
+ readonly error?: string;
50
+ /** Execution time in milliseconds */
51
+ readonly executionTimeMs: number;
52
+ /** Commands from Python to Node (llm_query, set_result, etc.) */
53
+ readonly commands: readonly PythonCommand[];
54
+ }
55
+ /**
56
+ * Commands that Python code can issue to Node
57
+ */
58
+ export type PythonCommand = LLMQueryCommand | SetResultCommand | SetVariableCommand;
59
+ export interface LLMQueryCommand {
60
+ readonly type: 'llm_query';
61
+ readonly query: string;
62
+ readonly contextVariables: readonly string[];
63
+ }
64
+ export interface SetResultCommand {
65
+ readonly type: 'set_result';
66
+ readonly result: string;
67
+ }
68
+ export interface SetVariableCommand {
69
+ readonly type: 'set_variable';
70
+ readonly name: string;
71
+ readonly value: string;
72
+ }
73
+ /**
74
+ * Interface for code execution (Python sandbox)
75
+ */
76
+ export interface ICodeExecutor {
77
+ /**
78
+ * Validate code before execution
79
+ */
80
+ validate(code: string): ValidationResult;
81
+ /**
82
+ * Execute Python code in sandbox
83
+ */
84
+ execute(code: string, context: ExecutionContext): Promise<ExecutionResult>;
85
+ /**
86
+ * Send a response to a pending llm_query
87
+ */
88
+ respondToQuery(response: string): Promise<void>;
89
+ /**
90
+ * Kill any running execution
91
+ */
92
+ kill(): Promise<void>;
93
+ /**
94
+ * Check if executor is ready
95
+ */
96
+ isReady(): boolean;
97
+ }
98
+ //# sourceMappingURL=code-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-executor.d.ts","sourceRoot":"","sources":["../../../src/domain/interfaces/code-executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,8BAA8B;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAE5C,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,eA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AAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAEzC;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE3E;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhD;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC;CACpB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=code-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-executor.js","sourceRoot":"","sources":["../../../src/domain/interfaces/code-executor.ts"],"names":[],"mappings":""}