@agtlantis/core 0.5.0 → 0.5.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 (265) hide show
  1. package/dist/errors/index.d.ts +4 -0
  2. package/dist/errors/index.d.ts.map +1 -0
  3. package/dist/errors/index.js +3 -0
  4. package/dist/errors/index.js.map +1 -0
  5. package/dist/errors/types.d.ts +69 -0
  6. package/dist/errors/types.d.ts.map +1 -0
  7. package/dist/errors/types.js +119 -0
  8. package/dist/errors/types.js.map +1 -0
  9. package/dist/errors/utils.d.ts +17 -0
  10. package/dist/errors/utils.d.ts.map +1 -0
  11. package/dist/errors/utils.js +16 -0
  12. package/dist/errors/utils.js.map +1 -0
  13. package/dist/execution/constants.d.ts +7 -0
  14. package/dist/execution/constants.d.ts.map +1 -0
  15. package/dist/execution/constants.js +7 -0
  16. package/dist/execution/constants.js.map +1 -0
  17. package/dist/execution/index.d.ts +8 -0
  18. package/dist/execution/index.d.ts.map +1 -0
  19. package/dist/execution/index.js +7 -0
  20. package/dist/execution/index.js.map +1 -0
  21. package/dist/execution/mapping.d.ts +17 -0
  22. package/dist/execution/mapping.d.ts.map +1 -0
  23. package/dist/execution/mapping.js +197 -0
  24. package/dist/execution/mapping.js.map +1 -0
  25. package/dist/execution/shared.d.ts +86 -0
  26. package/dist/execution/shared.d.ts.map +1 -0
  27. package/dist/execution/shared.js +100 -0
  28. package/dist/execution/shared.js.map +1 -0
  29. package/dist/execution/simple-host.d.ts +56 -0
  30. package/dist/execution/simple-host.d.ts.map +1 -0
  31. package/dist/execution/simple-host.js +126 -0
  32. package/dist/execution/simple-host.js.map +1 -0
  33. package/dist/execution/streaming-host.d.ts +79 -0
  34. package/dist/execution/streaming-host.d.ts.map +1 -0
  35. package/dist/execution/streaming-host.js +276 -0
  36. package/dist/execution/streaming-host.js.map +1 -0
  37. package/dist/execution/testing/fixtures.d.ts +67 -0
  38. package/dist/execution/testing/fixtures.d.ts.map +1 -0
  39. package/dist/execution/testing/fixtures.js +145 -0
  40. package/dist/execution/testing/fixtures.js.map +1 -0
  41. package/dist/execution/testing/helpers.d.ts +218 -0
  42. package/dist/execution/testing/helpers.d.ts.map +1 -0
  43. package/dist/execution/testing/helpers.js +327 -0
  44. package/dist/execution/testing/helpers.js.map +1 -0
  45. package/dist/execution/testing/host-configs.d.ts +56 -0
  46. package/dist/execution/testing/host-configs.d.ts.map +1 -0
  47. package/dist/execution/testing/host-configs.js +154 -0
  48. package/dist/execution/testing/host-configs.js.map +1 -0
  49. package/dist/execution/testing/vitest-assertions.d.ts +102 -0
  50. package/dist/execution/testing/vitest-assertions.d.ts.map +1 -0
  51. package/dist/execution/testing/vitest-assertions.js +142 -0
  52. package/dist/execution/testing/vitest-assertions.js.map +1 -0
  53. package/dist/execution/types.d.ts +432 -0
  54. package/dist/execution/types.d.ts.map +1 -0
  55. package/dist/execution/types.js +2 -0
  56. package/dist/execution/types.js.map +1 -0
  57. package/dist/execution/utils.d.ts +68 -0
  58. package/dist/execution/utils.d.ts.map +1 -0
  59. package/dist/execution/utils.js +93 -0
  60. package/dist/execution/utils.js.map +1 -0
  61. package/dist/index.d.ts +10 -1506
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +9 -2979
  64. package/dist/index.js.map +1 -1
  65. package/dist/observability/index.d.ts +4 -0
  66. package/dist/observability/index.d.ts.map +1 -0
  67. package/dist/observability/index.js +2 -0
  68. package/dist/observability/index.js.map +1 -0
  69. package/dist/observability/logger.d.ts +161 -0
  70. package/dist/observability/logger.d.ts.map +1 -0
  71. package/dist/observability/logger.js +31 -0
  72. package/dist/observability/logger.js.map +1 -0
  73. package/dist/observability/types.d.ts +46 -0
  74. package/dist/observability/types.d.ts.map +1 -0
  75. package/dist/observability/types.js +2 -0
  76. package/dist/observability/types.js.map +1 -0
  77. package/dist/patterns/index.d.ts +2 -0
  78. package/dist/patterns/index.d.ts.map +1 -0
  79. package/dist/patterns/index.js +2 -0
  80. package/dist/patterns/index.js.map +1 -0
  81. package/dist/patterns/progressive/index.d.ts +2 -0
  82. package/dist/patterns/progressive/index.d.ts.map +1 -0
  83. package/dist/patterns/progressive/index.js +2 -0
  84. package/dist/patterns/progressive/index.js.map +1 -0
  85. package/dist/patterns/progressive/progressive-pattern.d.ts +174 -0
  86. package/dist/patterns/progressive/progressive-pattern.d.ts.map +1 -0
  87. package/dist/patterns/progressive/progressive-pattern.js +260 -0
  88. package/dist/patterns/progressive/progressive-pattern.js.map +1 -0
  89. package/dist/pricing/calculator.d.ts +71 -0
  90. package/dist/pricing/calculator.d.ts.map +1 -0
  91. package/dist/pricing/calculator.js +127 -0
  92. package/dist/pricing/calculator.js.map +1 -0
  93. package/dist/pricing/config.d.ts +61 -0
  94. package/dist/pricing/config.d.ts.map +1 -0
  95. package/dist/pricing/config.js +87 -0
  96. package/dist/pricing/config.js.map +1 -0
  97. package/dist/pricing/defaults.d.ts +29 -0
  98. package/dist/pricing/defaults.d.ts.map +1 -0
  99. package/dist/pricing/defaults.js +139 -0
  100. package/dist/pricing/defaults.js.map +1 -0
  101. package/dist/pricing/index.d.ts +40 -0
  102. package/dist/pricing/index.d.ts.map +1 -0
  103. package/dist/pricing/index.js +43 -0
  104. package/dist/pricing/index.js.map +1 -0
  105. package/dist/pricing/types.d.ts +96 -0
  106. package/dist/pricing/types.d.ts.map +1 -0
  107. package/dist/pricing/types.js +7 -0
  108. package/dist/pricing/types.js.map +1 -0
  109. package/dist/pricing/validator.d.ts +55 -0
  110. package/dist/pricing/validator.d.ts.map +1 -0
  111. package/dist/pricing/validator.js +84 -0
  112. package/dist/pricing/validator.js.map +1 -0
  113. package/dist/prompt/errors.d.ts +112 -0
  114. package/dist/prompt/errors.d.ts.map +1 -0
  115. package/dist/prompt/errors.js +175 -0
  116. package/dist/prompt/errors.js.map +1 -0
  117. package/dist/prompt/file-prompt-repository.d.ts +80 -0
  118. package/dist/prompt/file-prompt-repository.d.ts.map +1 -0
  119. package/dist/prompt/file-prompt-repository.js +287 -0
  120. package/dist/prompt/file-prompt-repository.js.map +1 -0
  121. package/dist/prompt/index.d.ts +34 -0
  122. package/dist/prompt/index.d.ts.map +1 -0
  123. package/dist/prompt/index.js +37 -0
  124. package/dist/prompt/index.js.map +1 -0
  125. package/dist/prompt/prompt-template.d.ts +64 -0
  126. package/dist/prompt/prompt-template.d.ts.map +1 -0
  127. package/dist/prompt/prompt-template.js +90 -0
  128. package/dist/prompt/prompt-template.js.map +1 -0
  129. package/dist/prompt/template.d.ts +23 -0
  130. package/dist/prompt/template.d.ts.map +1 -0
  131. package/dist/prompt/template.js +70 -0
  132. package/dist/prompt/template.js.map +1 -0
  133. package/dist/prompt/types.d.ts +148 -0
  134. package/dist/prompt/types.d.ts.map +1 -0
  135. package/dist/prompt/types.js +7 -0
  136. package/dist/prompt/types.js.map +1 -0
  137. package/dist/provider/base-provider.d.ts +41 -0
  138. package/dist/provider/base-provider.d.ts.map +1 -0
  139. package/dist/provider/base-provider.js +21 -0
  140. package/dist/provider/base-provider.js.map +1 -0
  141. package/dist/provider/file-cache.d.ts +14 -0
  142. package/dist/provider/file-cache.d.ts.map +1 -0
  143. package/dist/provider/file-cache.js +29 -0
  144. package/dist/provider/file-cache.js.map +1 -0
  145. package/dist/provider/file-source.d.ts +32 -0
  146. package/dist/provider/file-source.d.ts.map +1 -0
  147. package/dist/provider/file-source.js +180 -0
  148. package/dist/provider/file-source.js.map +1 -0
  149. package/dist/provider/google/factory.d.ts +107 -0
  150. package/dist/provider/google/factory.d.ts.map +1 -0
  151. package/dist/provider/google/factory.js +143 -0
  152. package/dist/provider/google/factory.js.map +1 -0
  153. package/dist/provider/google/file-manager.d.ts +14 -0
  154. package/dist/provider/google/file-manager.d.ts.map +1 -0
  155. package/dist/provider/google/file-manager.js +183 -0
  156. package/dist/provider/google/file-manager.js.map +1 -0
  157. package/dist/provider/google/index.d.ts +8 -0
  158. package/dist/provider/google/index.d.ts.map +1 -0
  159. package/dist/provider/google/index.js +10 -0
  160. package/dist/provider/google/index.js.map +1 -0
  161. package/dist/provider/hash.d.ts +3 -0
  162. package/dist/provider/hash.d.ts.map +1 -0
  163. package/dist/provider/hash.js +34 -0
  164. package/dist/provider/hash.js.map +1 -0
  165. package/dist/provider/index.d.ts +9 -0
  166. package/dist/provider/index.d.ts.map +1 -0
  167. package/dist/provider/index.js +11 -0
  168. package/dist/provider/index.js.map +1 -0
  169. package/dist/provider/noop-file-manager.d.ts +9 -0
  170. package/dist/provider/noop-file-manager.d.ts.map +1 -0
  171. package/dist/provider/noop-file-manager.js +28 -0
  172. package/dist/provider/noop-file-manager.js.map +1 -0
  173. package/dist/provider/openai/factory.d.ts +67 -0
  174. package/dist/provider/openai/factory.d.ts.map +1 -0
  175. package/dist/provider/openai/factory.js +95 -0
  176. package/dist/provider/openai/factory.js.map +1 -0
  177. package/dist/provider/openai/index.d.ts +7 -0
  178. package/dist/provider/openai/index.d.ts.map +1 -0
  179. package/dist/provider/openai/index.js +7 -0
  180. package/dist/provider/openai/index.js.map +1 -0
  181. package/dist/provider/types.d.ts +105 -0
  182. package/dist/provider/types.d.ts.map +1 -0
  183. package/dist/provider/types.js +19 -0
  184. package/dist/provider/types.js.map +1 -0
  185. package/dist/session/index.d.ts +7 -0
  186. package/dist/session/index.d.ts.map +1 -0
  187. package/dist/session/index.js +5 -0
  188. package/dist/session/index.js.map +1 -0
  189. package/dist/session/simple-session.d.ts +98 -0
  190. package/dist/session/simple-session.d.ts.map +1 -0
  191. package/dist/session/simple-session.js +299 -0
  192. package/dist/session/simple-session.js.map +1 -0
  193. package/dist/session/streaming-session.d.ts +90 -0
  194. package/dist/session/streaming-session.d.ts.map +1 -0
  195. package/dist/session/streaming-session.js +151 -0
  196. package/dist/session/streaming-session.js.map +1 -0
  197. package/dist/session/test-utils.d.ts +19 -0
  198. package/dist/session/test-utils.d.ts.map +1 -0
  199. package/dist/session/test-utils.js +65 -0
  200. package/dist/session/test-utils.js.map +1 -0
  201. package/dist/session/types.d.ts +219 -0
  202. package/dist/session/types.d.ts.map +1 -0
  203. package/dist/session/types.js +181 -0
  204. package/dist/session/types.js.map +1 -0
  205. package/dist/session/usage-extractors.d.ts +7 -0
  206. package/dist/session/usage-extractors.d.ts.map +1 -0
  207. package/dist/session/usage-extractors.js +71 -0
  208. package/dist/session/usage-extractors.js.map +1 -0
  209. package/dist/testing/fixtures.d.ts +34 -0
  210. package/dist/testing/fixtures.d.ts.map +1 -0
  211. package/dist/testing/fixtures.js +65 -0
  212. package/dist/testing/fixtures.js.map +1 -0
  213. package/dist/testing/helpers.d.ts +20 -0
  214. package/dist/testing/helpers.d.ts.map +1 -0
  215. package/dist/testing/helpers.js +32 -0
  216. package/dist/testing/helpers.js.map +1 -0
  217. package/dist/testing/index.d.ts +7 -519
  218. package/dist/testing/index.d.ts.map +1 -0
  219. package/dist/testing/index.js +21 -2123
  220. package/dist/testing/index.js.map +1 -1
  221. package/dist/testing/mock-provider.d.ts +79 -0
  222. package/dist/testing/mock-provider.d.ts.map +1 -0
  223. package/dist/testing/mock-provider.js +152 -0
  224. package/dist/testing/mock-provider.js.map +1 -0
  225. package/dist/testing/mock.d.ts +29 -0
  226. package/dist/testing/mock.d.ts.map +1 -0
  227. package/dist/testing/mock.js +154 -0
  228. package/dist/testing/mock.js.map +1 -0
  229. package/dist/testing/test-execution.d.ts +14 -0
  230. package/dist/testing/test-execution.d.ts.map +1 -0
  231. package/dist/testing/test-execution.js +108 -0
  232. package/dist/testing/test-execution.js.map +1 -0
  233. package/dist/utils/deep-merge.d.ts +6 -0
  234. package/dist/utils/deep-merge.d.ts.map +1 -0
  235. package/dist/utils/deep-merge.js +24 -0
  236. package/dist/utils/deep-merge.js.map +1 -0
  237. package/dist/validation/errors.d.ts +28 -0
  238. package/dist/validation/errors.d.ts.map +1 -0
  239. package/dist/validation/errors.js +39 -0
  240. package/dist/validation/errors.js.map +1 -0
  241. package/dist/validation/index.d.ts +5 -0
  242. package/dist/validation/index.d.ts.map +1 -0
  243. package/dist/validation/index.js +4 -0
  244. package/dist/validation/index.js.map +1 -0
  245. package/dist/validation/types.d.ts +49 -0
  246. package/dist/validation/types.d.ts.map +1 -0
  247. package/dist/validation/types.js +2 -0
  248. package/dist/validation/types.js.map +1 -0
  249. package/dist/validation/validation-history.d.ts +12 -0
  250. package/dist/validation/validation-history.d.ts.map +1 -0
  251. package/dist/validation/validation-history.js +29 -0
  252. package/dist/validation/validation-history.js.map +1 -0
  253. package/dist/validation/with-validation.d.ts +38 -0
  254. package/dist/validation/with-validation.d.ts.map +1 -0
  255. package/dist/validation/with-validation.js +58 -0
  256. package/dist/validation/with-validation.js.map +1 -0
  257. package/package.json +72 -76
  258. package/dist/base-provider-2TTw5HAa.d.cts +0 -1254
  259. package/dist/base-provider-2TTw5HAa.d.ts +0 -1254
  260. package/dist/index.cjs +0 -3085
  261. package/dist/index.cjs.map +0 -1
  262. package/dist/index.d.cts +0 -1506
  263. package/dist/testing/index.cjs +0 -2167
  264. package/dist/testing/index.cjs.map +0 -1
  265. package/dist/testing/index.d.cts +0 -520
@@ -0,0 +1,4 @@
1
+ export { ExecutionErrorCode, ConfigurationErrorCode, FileErrorCode, type AgtlantisErrorCode, } from './types.js';
2
+ export type { AgtlantisErrorOptions, ExecutionErrorOptions, ConfigurationErrorOptions, FileErrorOptions, } from './types.js';
3
+ export { AgtlantisError, ExecutionError, ConfigurationError, FileError, } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,KAAK,kBAAkB,GACxB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { ExecutionErrorCode, ConfigurationErrorCode, FileErrorCode, } from './types.js';
2
+ export { AgtlantisError, ExecutionError, ConfigurationError, FileError, } from './types.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,GAEd,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAC"}
@@ -0,0 +1,69 @@
1
+ export declare enum ExecutionErrorCode {
2
+ EXECUTION_ERROR = "EXECUTION_ERROR",
3
+ STREAM_ERROR = "STREAM_ERROR",
4
+ RESULT_EXTRACTION_ERROR = "RESULT_EXTRACTION_ERROR",
5
+ CANCELLED = "CANCELLED",
6
+ VALIDATION_ERROR = "VALIDATION_ERROR"
7
+ }
8
+ export declare enum ConfigurationErrorCode {
9
+ CONFIG_ERROR = "CONFIG_ERROR",
10
+ MISSING_API_KEY = "MISSING_API_KEY",
11
+ INVALID_CONFIG = "INVALID_CONFIG",
12
+ MISSING_REQUIRED = "MISSING_REQUIRED"
13
+ }
14
+ export declare enum FileErrorCode {
15
+ FILE_ERROR = "FILE_ERROR",
16
+ UPLOAD_ERROR = "UPLOAD_ERROR",
17
+ DELETE_ERROR = "DELETE_ERROR",
18
+ NOT_FOUND = "NOT_FOUND",
19
+ TOO_LARGE = "TOO_LARGE",
20
+ UNSUPPORTED_TYPE = "UNSUPPORTED_TYPE"
21
+ }
22
+ export type AgtlantisErrorCode = ExecutionErrorCode | ConfigurationErrorCode | FileErrorCode;
23
+ export interface AgtlantisErrorOptions<TCode extends AgtlantisErrorCode = AgtlantisErrorCode> {
24
+ code: TCode;
25
+ cause?: Error;
26
+ context?: Record<string, unknown>;
27
+ }
28
+ export interface ErrorOptions<TCode extends AgtlantisErrorCode> {
29
+ code?: TCode;
30
+ cause?: Error;
31
+ context?: Record<string, unknown>;
32
+ }
33
+ export type ExecutionErrorOptions = ErrorOptions<ExecutionErrorCode>;
34
+ export type ConfigurationErrorOptions = ErrorOptions<ConfigurationErrorCode>;
35
+ export type FileErrorOptions = ErrorOptions<FileErrorCode>;
36
+ /**
37
+ * Base error class for all Agtlantis errors.
38
+ * Provides structured error information including error code and optional context.
39
+ */
40
+ export declare class AgtlantisError<TCode extends AgtlantisErrorCode = AgtlantisErrorCode> extends Error {
41
+ readonly code: TCode;
42
+ readonly cause?: Error;
43
+ readonly context?: Record<string, unknown>;
44
+ constructor(message: string, options: AgtlantisErrorOptions<TCode>);
45
+ get isRetryable(): boolean;
46
+ toJSON(): Record<string, unknown>;
47
+ }
48
+ /**
49
+ * Error thrown during agent execution (streaming failures, result extraction, cancellation).
50
+ */
51
+ export declare class ExecutionError extends AgtlantisError<ExecutionErrorCode> {
52
+ constructor(message: string, options?: ExecutionErrorOptions);
53
+ static from(error: unknown, code?: ExecutionErrorCode, context?: Record<string, unknown>): ExecutionError;
54
+ }
55
+ /**
56
+ * Error thrown when configuration is invalid or missing (API keys, model names).
57
+ */
58
+ export declare class ConfigurationError extends AgtlantisError<ConfigurationErrorCode> {
59
+ constructor(message: string, options?: ConfigurationErrorOptions);
60
+ static from(error: unknown, code?: ConfigurationErrorCode, context?: Record<string, unknown>): ConfigurationError;
61
+ }
62
+ /**
63
+ * Error thrown during file operations (upload, delete, not found, size limits).
64
+ */
65
+ export declare class FileError extends AgtlantisError<FileErrorCode> {
66
+ constructor(message: string, options?: FileErrorOptions);
67
+ static from(error: unknown, code?: FileErrorCode, context?: Record<string, unknown>): FileError;
68
+ }
69
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/errors/types.ts"],"names":[],"mappings":"AAEA,oBAAY,kBAAkB;IAC5B,eAAe,oBAAoB;IACnC,YAAY,iBA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,EAAE,OAAO,CAAC,CAAC;IAE3C,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,EAYjE;IAED,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUhC;CACF;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,cAAc,CAAC,kBAAkB,CAAC;IACpE,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,EAO/D;IAED,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,kBAAuD,EAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,cAAc,CAKhB;CACF;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,sBAAsB,CAAC;IAC5E,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,EAOnE;IAED,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,sBAA4D,EAClE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,kBAAkB,CAKpB;CACF;AAED;;GAEG;AACH,qBAAa,SAAU,SAAQ,cAAc,CAAC,aAAa,CAAC;IAC1D,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,EAO1D;IAED,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,aAAwC,EAC9C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,SAAS,CAKX;CACF"}
@@ -0,0 +1,119 @@
1
+ import { wrapAsError } from './utils.js';
2
+ export { ExecutionErrorCode };
3
+ var ExecutionErrorCode;
4
+ (function (ExecutionErrorCode) {
5
+ ExecutionErrorCode["EXECUTION_ERROR"] = "EXECUTION_ERROR";
6
+ ExecutionErrorCode["STREAM_ERROR"] = "STREAM_ERROR";
7
+ ExecutionErrorCode["RESULT_EXTRACTION_ERROR"] = "RESULT_EXTRACTION_ERROR";
8
+ ExecutionErrorCode["CANCELLED"] = "CANCELLED";
9
+ ExecutionErrorCode["VALIDATION_ERROR"] = "VALIDATION_ERROR";
10
+ })(ExecutionErrorCode || (ExecutionErrorCode = {}));
11
+ export { ConfigurationErrorCode };
12
+ var ConfigurationErrorCode;
13
+ (function (ConfigurationErrorCode) {
14
+ ConfigurationErrorCode["CONFIG_ERROR"] = "CONFIG_ERROR";
15
+ ConfigurationErrorCode["MISSING_API_KEY"] = "MISSING_API_KEY";
16
+ ConfigurationErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG";
17
+ ConfigurationErrorCode["MISSING_REQUIRED"] = "MISSING_REQUIRED";
18
+ })(ConfigurationErrorCode || (ConfigurationErrorCode = {}));
19
+ export { FileErrorCode };
20
+ var FileErrorCode;
21
+ (function (FileErrorCode) {
22
+ FileErrorCode["FILE_ERROR"] = "FILE_ERROR";
23
+ FileErrorCode["UPLOAD_ERROR"] = "UPLOAD_ERROR";
24
+ FileErrorCode["DELETE_ERROR"] = "DELETE_ERROR";
25
+ FileErrorCode["NOT_FOUND"] = "NOT_FOUND";
26
+ FileErrorCode["TOO_LARGE"] = "TOO_LARGE";
27
+ FileErrorCode["UNSUPPORTED_TYPE"] = "UNSUPPORTED_TYPE";
28
+ })(FileErrorCode || (FileErrorCode = {}));
29
+ /**
30
+ * Base error class for all Agtlantis errors.
31
+ * Provides structured error information including error code and optional context.
32
+ */
33
+ export class AgtlantisError extends Error {
34
+ code;
35
+ cause;
36
+ context;
37
+ constructor(message, options) {
38
+ super(message);
39
+ this.name = 'AgtlantisError';
40
+ this.code = options.code;
41
+ this.cause = options.cause;
42
+ this.context = options.context;
43
+ // V8-specific stack trace capture
44
+ const ErrorWithCapture = Error;
45
+ ErrorWithCapture.captureStackTrace?.(this, this.constructor);
46
+ }
47
+ get isRetryable() {
48
+ return false;
49
+ }
50
+ toJSON() {
51
+ return {
52
+ name: this.name,
53
+ message: this.message,
54
+ code: this.code,
55
+ isRetryable: this.isRetryable,
56
+ context: this.context,
57
+ cause: this.cause?.message,
58
+ stack: this.stack,
59
+ };
60
+ }
61
+ }
62
+ /**
63
+ * Error thrown during agent execution (streaming failures, result extraction, cancellation).
64
+ */
65
+ export class ExecutionError extends AgtlantisError {
66
+ constructor(message, options = {}) {
67
+ super(message, {
68
+ code: options.code ?? ExecutionErrorCode.EXECUTION_ERROR,
69
+ cause: options.cause,
70
+ context: options.context,
71
+ });
72
+ this.name = 'ExecutionError';
73
+ }
74
+ static from(error, code = ExecutionErrorCode.EXECUTION_ERROR, context) {
75
+ if (error instanceof ExecutionError) {
76
+ return error;
77
+ }
78
+ return wrapAsError(error, ExecutionError, { code, context });
79
+ }
80
+ }
81
+ /**
82
+ * Error thrown when configuration is invalid or missing (API keys, model names).
83
+ */
84
+ export class ConfigurationError extends AgtlantisError {
85
+ constructor(message, options = {}) {
86
+ super(message, {
87
+ code: options.code ?? ConfigurationErrorCode.CONFIG_ERROR,
88
+ cause: options.cause,
89
+ context: options.context,
90
+ });
91
+ this.name = 'ConfigurationError';
92
+ }
93
+ static from(error, code = ConfigurationErrorCode.CONFIG_ERROR, context) {
94
+ if (error instanceof ConfigurationError) {
95
+ return error;
96
+ }
97
+ return wrapAsError(error, ConfigurationError, { code, context });
98
+ }
99
+ }
100
+ /**
101
+ * Error thrown during file operations (upload, delete, not found, size limits).
102
+ */
103
+ export class FileError extends AgtlantisError {
104
+ constructor(message, options = {}) {
105
+ super(message, {
106
+ code: options.code ?? FileErrorCode.FILE_ERROR,
107
+ cause: options.cause,
108
+ context: options.context,
109
+ });
110
+ this.name = 'FileError';
111
+ }
112
+ static from(error, code = FileErrorCode.FILE_ERROR, context) {
113
+ if (error instanceof FileError) {
114
+ return error;
115
+ }
116
+ return wrapAsError(error, FileError, { code, context });
117
+ }
118
+ }
119
+ //# sourceMappingURL=types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AAC,YAAY;YACzD,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAAA,CAClC;IAED,MAAM,CAAC,IAAI,CACT,KAAc,EACd,IAAI,GAA2B,sBAAsB,CAAC,YAAY,EAClE,OAAiC,EACb;QACpB,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAAA,CAClE;CACF;AAED;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,cAA6B;IAC1D,YAAY,OAAe,EAAE,OAAO,GAAqB,EAAE,EAAE;QAC3D,KAAK,CAAC,OAAO,EAAE;YACb,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,aAAa,CAAC,UAAU;YAC9C,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAAA,CACzB;IAED,MAAM,CAAC,IAAI,CACT,KAAc,EACd,IAAI,GAAkB,aAAa,CAAC,UAAU,EAC9C,OAAiC,EACtB;QACX,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAAA,CACzD;CACF"}
@@ -0,0 +1,17 @@
1
+ import type { AgtlantisError, AgtlantisErrorCode, AgtlantisErrorOptions } from './types.js';
2
+ /**
3
+ * Wraps an unknown error as a specific AgtlantisError subclass.
4
+ * Internal utility - not part of public API.
5
+ *
6
+ * @param error - The unknown error to wrap
7
+ * @param ErrorClass - The error class constructor to use
8
+ * @param options - Error options including code and optional context
9
+ * @returns A new instance of the specified error class
10
+ *
11
+ * @internal
12
+ */
13
+ export declare function wrapAsError<T extends AgtlantisError<TCode>, TCode extends AgtlantisErrorCode>(error: unknown, ErrorClass: new (message: string, options: AgtlantisErrorOptions<TCode>) => T, options: {
14
+ code: TCode;
15
+ context?: Record<string, unknown>;
16
+ }): T;
17
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/errors/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE5F;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACzB,CAAC,SAAS,cAAc,CAAC,KAAK,CAAC,EAC/B,KAAK,SAAS,kBAAkB,EAEhC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,EAC7E,OAAO,EAAE;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC1D,CAAC,CAGH"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Wraps an unknown error as a specific AgtlantisError subclass.
3
+ * Internal utility - not part of public API.
4
+ *
5
+ * @param error - The unknown error to wrap
6
+ * @param ErrorClass - The error class constructor to use
7
+ * @param options - Error options including code and optional context
8
+ * @returns A new instance of the specified error class
9
+ *
10
+ * @internal
11
+ */
12
+ export function wrapAsError(error, ErrorClass, options) {
13
+ const cause = error instanceof Error ? error : new Error(String(error));
14
+ return new ErrorClass(cause.message, { ...options, cause });
15
+ }
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/errors/utils.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAIzB,KAAc,EACd,UAA6E,EAC7E,OAA2D,EACxD;IACH,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAAA,CAC7D"}
@@ -0,0 +1,7 @@
1
+ export declare const ERRORS: {
2
+ readonly ALREADY_CONSUMED: "Execution already consumed";
3
+ readonly METADATA_NOT_AVAILABLE: "Metadata not available yet. Consume the execution first.";
4
+ readonly NO_RESULT: "No result available";
5
+ readonly UNKNOWN_ERROR: "Execution failed with unknown error";
6
+ };
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/execution/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;CAMT,CAAC"}
@@ -0,0 +1,7 @@
1
+ export const ERRORS = {
2
+ ALREADY_CONSUMED: 'Execution already consumed',
3
+ METADATA_NOT_AVAILABLE: 'Metadata not available yet. Consume the execution first.',
4
+ NO_RESULT: 'No result available',
5
+ UNKNOWN_ERROR: 'Execution failed with unknown error',
6
+ };
7
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/execution/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,gBAAgB,EAAE,4BAA4B;IAC9C,sBAAsB,EACpB,0DAA0D;IAC5D,SAAS,EAAE,qBAAqB;IAChC,aAAa,EAAE,qCAAqC;CAC5C,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type { Execution, ExecutionOptions, SimpleExecution, StreamingExecution, SessionStreamGeneratorFn, ExecutionStatus, ExecutionResult, SimpleResult, StreamingResult, DistributiveOmit, SessionEvent, SessionEventInput, EmittableEventInput, ReservedEventType, CompletionEvent, ErrorEvent, ExtractResult, } from './types.js';
2
+ export { StreamingExecutionHost } from './streaming-host.js';
3
+ export { SimpleExecutionHost } from './simple-host.js';
4
+ export { ERRORS } from './constants.js';
5
+ export { getDuration, combineSignals } from './utils.js';
6
+ export { isAbortError, normalizeError, determineResultStatus, createHookRunner, type HookRunner } from './shared.js';
7
+ export { mapExecution, mapExecutionResult, type ReplaceResult } from './mapping.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EAExB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,eAAe,EAEf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EAEjB,eAAe,EACf,UAAU,EACV,aAAa,GACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAErH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { StreamingExecutionHost } from './streaming-host.js';
2
+ export { SimpleExecutionHost } from './simple-host.js';
3
+ export { ERRORS } from './constants.js';
4
+ export { getDuration, combineSignals } from './utils.js';
5
+ export { isAbortError, normalizeError, determineResultStatus, createHookRunner } from './shared.js';
6
+ export { mapExecution, mapExecutionResult } from './mapping.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAErH,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAsB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { StreamingExecution, SimpleExecution, CompletionEvent, ExtractResult } from './types.js';
2
+ export type ReplaceResult<TEvent extends {
3
+ type: string;
4
+ }, U> = Exclude<TEvent, {
5
+ type: 'complete';
6
+ }> | CompletionEvent<U>;
7
+ export declare function mapExecution<TEvent extends {
8
+ type: string;
9
+ }, UEvent extends {
10
+ type: string;
11
+ }>(execution: StreamingExecution<TEvent>, fn: (event: TEvent) => UEvent | Promise<UEvent>): StreamingExecution<UEvent>;
12
+ export declare function mapExecution<A, B>(execution: SimpleExecution<A>, fn: (result: A) => B | Promise<B>): SimpleExecution<B>;
13
+ export declare function mapExecutionResult<TEvent extends {
14
+ type: string;
15
+ }, U>(execution: StreamingExecution<TEvent>, fn: (result: ExtractResult<TEvent>) => U | Promise<U>): StreamingExecution<ReplaceResult<TEvent, U>>;
16
+ export declare function mapExecutionResult<A, B>(execution: SimpleExecution<A>, fn: (result: A) => B | Promise<B>): SimpleExecution<B>;
17
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/execution/mapping.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EAClB,eAAe,EAIf,eAAe,EAEf,aAAa,EAChB,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,IACtD,OAAO,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GACrC,eAAe,CAAC,CAAC,CAAC,CAAC;AAMzB,wBAAgB,YAAY,CAAC,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACzF,SAAS,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACrC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAChD,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAE9B,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAC7B,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,EAC7B,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAClC,eAAe,CAAC,CAAC,CAAC,CAAC;AAgBtB,wBAAgB,kBAAkB,CAAC,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EACjE,SAAS,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACrC,EAAE,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACtD,kBAAkB,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EACnC,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,EAC7B,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAClC,eAAe,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,197 @@
1
+ import { normalizeError } from './shared.js';
2
+ export function mapExecution(execution, fn) {
3
+ if ('stream' in execution) {
4
+ return mapStreamingExecution(execution, fn);
5
+ }
6
+ return mapSimpleExecution(execution, fn);
7
+ }
8
+ export function mapExecutionResult(execution, fn) {
9
+ if ('stream' in execution) {
10
+ return mapStreamingExecutionResult(execution, fn);
11
+ }
12
+ return mapSimpleExecution(execution, fn);
13
+ }
14
+ // ============================================================================
15
+ // Internal: Streaming — full event mapping
16
+ // ============================================================================
17
+ function mapStreamingExecution(execution, fn) {
18
+ return {
19
+ stream() {
20
+ const original = execution.stream();
21
+ return {
22
+ [Symbol.asyncIterator]() {
23
+ const iter = original[Symbol.asyncIterator]();
24
+ return {
25
+ async next() {
26
+ const { value, done } = await iter.next();
27
+ if (done)
28
+ return { value: undefined, done: true };
29
+ const event = value;
30
+ if (event.type === 'error') {
31
+ return { value: event, done: false };
32
+ }
33
+ const { metrics, ...pureEvent } = event;
34
+ try {
35
+ const mapped = await fn(pureEvent);
36
+ return {
37
+ value: { ...mapped, metrics },
38
+ done: false,
39
+ };
40
+ }
41
+ catch (err) {
42
+ const errorEvent = {
43
+ type: 'error',
44
+ error: normalizeError(err),
45
+ metrics,
46
+ };
47
+ return { value: errorEvent, done: false };
48
+ }
49
+ },
50
+ };
51
+ },
52
+ };
53
+ },
54
+ async result() {
55
+ const original = await execution.result();
56
+ if (original.status !== 'succeeded') {
57
+ return original;
58
+ }
59
+ try {
60
+ const mappedEvents = [];
61
+ for (const event of original.events) {
62
+ if (event.type === 'error') {
63
+ mappedEvents.push(event);
64
+ continue;
65
+ }
66
+ const { metrics, ...pureEvent } = event;
67
+ const mapped = await fn(pureEvent);
68
+ mappedEvents.push({ ...mapped, metrics });
69
+ }
70
+ const completionEvent = mappedEvents.find(e => e.type === 'complete');
71
+ return {
72
+ status: 'succeeded',
73
+ value: completionEvent.data,
74
+ events: mappedEvents,
75
+ summary: original.summary,
76
+ };
77
+ }
78
+ catch (err) {
79
+ return {
80
+ status: 'failed',
81
+ error: normalizeError(err),
82
+ events: original.events,
83
+ summary: original.summary,
84
+ };
85
+ }
86
+ },
87
+ cancel: () => execution.cancel(),
88
+ cleanup: () => execution.cleanup(),
89
+ [Symbol.asyncDispose]: () => execution[Symbol.asyncDispose](),
90
+ };
91
+ }
92
+ // ============================================================================
93
+ // Internal: Streaming — result-only mapping
94
+ // ============================================================================
95
+ function mapStreamingExecutionResult(execution, fn) {
96
+ return {
97
+ stream() {
98
+ const original = execution.stream();
99
+ return {
100
+ [Symbol.asyncIterator]() {
101
+ const iter = original[Symbol.asyncIterator]();
102
+ return {
103
+ async next() {
104
+ const { value, done } = await iter.next();
105
+ if (done)
106
+ return { value: undefined, done: true };
107
+ const event = value;
108
+ if (event.type === 'complete') {
109
+ const { metrics, ...rest } = event;
110
+ try {
111
+ const mapped = await fn(rest.data);
112
+ return {
113
+ value: { type: 'complete', data: mapped, summary: rest.summary, metrics },
114
+ done: false,
115
+ };
116
+ }
117
+ catch (err) {
118
+ const errorEvent = {
119
+ type: 'error',
120
+ error: normalizeError(err),
121
+ metrics,
122
+ };
123
+ return { value: errorEvent, done: false };
124
+ }
125
+ }
126
+ return { value: event, done: false };
127
+ },
128
+ };
129
+ },
130
+ };
131
+ },
132
+ async result() {
133
+ const original = await execution.result();
134
+ if (original.status !== 'succeeded') {
135
+ return original;
136
+ }
137
+ try {
138
+ const mapped = await fn(original.value);
139
+ const mappedEvents = original.events.map(event => {
140
+ if (event.type === 'complete') {
141
+ return { ...event, data: mapped };
142
+ }
143
+ return event;
144
+ });
145
+ return {
146
+ status: 'succeeded',
147
+ value: mapped,
148
+ events: mappedEvents,
149
+ summary: original.summary,
150
+ };
151
+ }
152
+ catch (err) {
153
+ return {
154
+ status: 'failed',
155
+ error: normalizeError(err),
156
+ events: original.events,
157
+ summary: original.summary,
158
+ };
159
+ }
160
+ },
161
+ cancel: () => execution.cancel(),
162
+ cleanup: () => execution.cleanup(),
163
+ [Symbol.asyncDispose]: () => execution[Symbol.asyncDispose](),
164
+ };
165
+ }
166
+ // ============================================================================
167
+ // Internal: Simple execution mapping (shared by both mapExecution and mapExecutionResult)
168
+ // ============================================================================
169
+ function mapSimpleExecution(execution, fn) {
170
+ return {
171
+ async result() {
172
+ const original = await execution.result();
173
+ if (original.status !== 'succeeded') {
174
+ return original;
175
+ }
176
+ try {
177
+ const mapped = await fn(original.value);
178
+ return {
179
+ status: 'succeeded',
180
+ value: mapped,
181
+ summary: original.summary,
182
+ };
183
+ }
184
+ catch (err) {
185
+ return {
186
+ status: 'failed',
187
+ error: normalizeError(err),
188
+ summary: original.summary,
189
+ };
190
+ }
191
+ },
192
+ cancel: () => execution.cancel(),
193
+ cleanup: () => execution.cleanup(),
194
+ [Symbol.asyncDispose]: () => execution[Symbol.asyncDispose](),
195
+ };
196
+ }
197
+ //# sourceMappingURL=mapping.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../src/execution/mapping.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAoB7C,MAAM,UAAU,YAAY,CACxB,SAAyD,EACzD,EAAuB,EACpB;IACH,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;QACxB,OAAO,qBAAqB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,kBAAkB,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AAAA,CAC5C;AAgBD,MAAM,UAAU,kBAAkB,CAC9B,SAAyD,EACzD,EAAuB,EACpB;IACH,IAAI,QAA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EAAE;QAChC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE;QAClC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;KAChE,CAAC;AAAA,CACL"}
@@ -0,0 +1,86 @@
1
+ import type { ExecutionStatus } from './types.js';
2
+ /**
3
+ * Shared utilities for execution hosts.
4
+ *
5
+ * These functions extract common patterns from SimpleExecutionHost and
6
+ * StreamingExecutionHost to reduce code duplication and ensure consistent
7
+ * behavior across both implementations.
8
+ */
9
+ /**
10
+ * Checks if an error is an abort-related error.
11
+ *
12
+ * An error is considered abort-related if either:
13
+ * - The error has the name 'AbortError' (standard for AbortController)
14
+ * - The signal has been aborted (covers edge cases where error name differs)
15
+ *
16
+ * @param error - The error to check
17
+ * @param signal - The AbortSignal associated with the execution
18
+ * @returns true if this is an abort-related error
19
+ */
20
+ export declare function isAbortError(error: unknown, signal: AbortSignal): boolean;
21
+ /**
22
+ * Normalizes an unknown error to an Error instance.
23
+ *
24
+ * If the error is already an Error instance, it's returned as-is.
25
+ * Otherwise, it's converted to a string and wrapped in a new Error.
26
+ *
27
+ * @param error - The unknown error to normalize
28
+ * @returns A proper Error instance
29
+ */
30
+ export declare function normalizeError(error: unknown): Error;
31
+ /**
32
+ * Determines the execution status based on the execution state.
33
+ *
34
+ * Status determination priority:
35
+ * 1. If user called cancel() OR the operation was aborted → 'canceled'
36
+ * 2. If there's an error → 'failed'
37
+ * 3. Otherwise → 'succeeded'
38
+ *
39
+ * Note: The 'aborted' flag takes precedence over 'hasError' because
40
+ * AbortError is treated as a normal cancellation, not a failure.
41
+ *
42
+ * @param cancelRequested - Whether cancel() was explicitly called
43
+ * @param aborted - Whether the signal was aborted (includes external abort)
44
+ * @param hasError - Whether the execution ended with an error
45
+ * @returns The appropriate execution status
46
+ */
47
+ export declare function determineResultStatus(cancelRequested: boolean, aborted: boolean, hasError: boolean): ExecutionStatus;
48
+ /**
49
+ * Return type for createHookRunner utility.
50
+ */
51
+ export type HookRunner = {
52
+ /**
53
+ * Ensures hooks run exactly once.
54
+ * Safe to call multiple times - only executes on first call.
55
+ */
56
+ ensureRun: () => Promise<void>;
57
+ /**
58
+ * Check if hooks have already been run.
59
+ */
60
+ hasRun: () => boolean;
61
+ };
62
+ /**
63
+ * Creates a hook runner that ensures hooks run exactly once.
64
+ *
65
+ * This utility encapsulates the common pattern of running cleanup hooks
66
+ * with a guard flag to prevent double execution. Both SimpleExecutionHost
67
+ * and StreamingExecutionHost use this pattern for onDone hooks.
68
+ *
69
+ * @param runHooks - The async function to run hooks
70
+ * @returns Object with ensureRun() and hasRun() methods
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const hookRunner = createHookRunner(async () => {
75
+ * await session.runOnDoneHooks();
76
+ * });
77
+ *
78
+ * // In finally block or cleanup:
79
+ * await hookRunner.ensureRun();
80
+ *
81
+ * // Safe to call multiple times - only executes once
82
+ * await hookRunner.ensureRun(); // no-op
83
+ * ```
84
+ */
85
+ export declare function createHookRunner(runHooks: () => Promise<void>): HookRunner;
86
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/execution/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAKzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,OAAO,EACxB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,OAAO,GAChB,eAAe,CAajB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B;;OAEG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAY1E"}