@agtlantis/core 0.4.1 → 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 -1502
  62. package/dist/index.d.ts.map +1 -0
  63. package/dist/index.js +9 -3081
  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 -515
  218. package/dist/testing/index.d.ts.map +1 -0
  219. package/dist/testing/index.js +21 -2096
  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 -78
  258. package/dist/base-provider-C3mFLNiN.d.cts +0 -1236
  259. package/dist/base-provider-C3mFLNiN.d.ts +0 -1236
  260. package/dist/index.cjs +0 -3188
  261. package/dist/index.cjs.map +0 -1
  262. package/dist/index.d.cts +0 -1502
  263. package/dist/testing/index.cjs +0 -2144
  264. package/dist/testing/index.cjs.map +0 -1
  265. package/dist/testing/index.d.cts +0 -516
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Vitest-specific assertion helpers for execution module tests.
3
+ * These helpers depend on vitest and should only be used in internal tests.
4
+ */
5
+ import { vi, expect } from 'vitest';
6
+ // ============================================================================
7
+ // Result Assertion Helpers
8
+ // ============================================================================
9
+ /**
10
+ * Assert that an execution result is successful and optionally check the value.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const result = await execution.result();
15
+ * expectSuccessResult(result, 'expected-value');
16
+ * // result is now narrowed to succeeded type
17
+ * console.log(result.value);
18
+ * ```
19
+ */
20
+ export function expectSuccessResult(result, expectedValue) {
21
+ expect(result.status).toBe('succeeded');
22
+ if (result.status !== 'succeeded') {
23
+ throw new Error('Result is not succeeded');
24
+ }
25
+ if (expectedValue !== undefined) {
26
+ expect(result.value).toBe(expectedValue);
27
+ }
28
+ }
29
+ /**
30
+ * Assert that an execution result is failed and optionally check the error.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const result = await execution.result();
35
+ * expectFailedResult(result, 'Expected error message');
36
+ * // or with regex
37
+ * expectFailedResult(result, /timeout/i);
38
+ * ```
39
+ */
40
+ export function expectFailedResult(result, errorMatcher) {
41
+ expect(result.status).toBe('failed');
42
+ if (result.status !== 'failed') {
43
+ throw new Error('Result is not failed');
44
+ }
45
+ if (errorMatcher !== undefined) {
46
+ if (typeof errorMatcher === 'string') {
47
+ expect(result.error.message).toBe(errorMatcher);
48
+ }
49
+ else if (errorMatcher instanceof RegExp) {
50
+ expect(result.error.message).toMatch(errorMatcher);
51
+ }
52
+ else {
53
+ expect(result.error).toBe(errorMatcher);
54
+ }
55
+ }
56
+ }
57
+ /**
58
+ * Assert that an execution result is canceled.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const result = await execution.result();
63
+ * expectCanceledResult(result);
64
+ * ```
65
+ */
66
+ export function expectCanceledResult(result) {
67
+ expect(result.status).toBe('canceled');
68
+ }
69
+ /**
70
+ * Assert streaming result status and optionally check events count.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const result = await execution.result();
75
+ * expectStreamingSuccessResult(result, 'value', 3);
76
+ * ```
77
+ */
78
+ export function expectStreamingSuccessResult(result, expectedValue, expectedEventCount) {
79
+ expectSuccessResult(result, expectedValue);
80
+ if (expectedEventCount !== undefined) {
81
+ expect(result.events).toHaveLength(expectedEventCount);
82
+ }
83
+ }
84
+ /**
85
+ * Verify that logger was called in the expected sequence.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * const logger = createMockLogger();
90
+ * // ... run execution ...
91
+ *
92
+ * verifyLoggerSequence(logger, ['start', 'emit', 'emit', 'done']);
93
+ * ```
94
+ */
95
+ export function verifyLoggerSequence(logger, expectedSequence) {
96
+ const eventMap = {
97
+ start: 'onExecutionStart',
98
+ emit: 'onExecutionEmit',
99
+ done: 'onExecutionDone',
100
+ error: 'onExecutionError',
101
+ };
102
+ // Count expected occurrences
103
+ const expectedCounts = expectedSequence.reduce((acc, event) => {
104
+ acc[event] = (acc[event] || 0) + 1;
105
+ return acc;
106
+ }, {});
107
+ // Verify each event type was called the expected number of times
108
+ for (const [event, count] of Object.entries(expectedCounts)) {
109
+ const methodName = eventMap[event];
110
+ expect(logger[methodName]).toHaveBeenCalledTimes(count);
111
+ }
112
+ }
113
+ /**
114
+ * Create a vitest mock logger.
115
+ */
116
+ export function createVitestMockLogger() {
117
+ return {
118
+ onLLMCallStart: vi.fn(),
119
+ onLLMCallEnd: vi.fn(),
120
+ onExecutionStart: vi.fn(),
121
+ onExecutionEmit: vi.fn(),
122
+ onExecutionDone: vi.fn(),
123
+ onExecutionError: vi.fn(),
124
+ };
125
+ }
126
+ /**
127
+ * @deprecated Use createVitestMockLogger instead
128
+ */
129
+ export const createMockLogger = createVitestMockLogger;
130
+ /**
131
+ * Get vitest's vi.fn for use with framework-agnostic fixtures.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * import { vitestMockFn } from './vitest-assertions';
136
+ * import { createStreamingSessionFactory } from './fixtures';
137
+ *
138
+ * const factory = createStreamingSessionFactory({ mockFn: vitestMockFn });
139
+ * ```
140
+ */
141
+ export const vitestMockFn = () => vi.fn();
142
+ //# sourceMappingURL=vitest-assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitest-assertions.js","sourceRoot":"","sources":["../../../src/execution/testing/vitest-assertions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAiBpC,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA0B,EAC1B,aAAiB,EACuD;IACxE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,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AAA,CACjB;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAA0C,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC"}
@@ -0,0 +1,432 @@
1
+ /**
2
+ * Agent execution types for @agtlantis/core.
3
+ * Provides abstractions for streaming and non-streaming agent execution.
4
+ */
5
+ import type { EventMetrics } from '../observability/index.js';
6
+ import type { SessionSummary, StreamingSession } from '../session/index.js';
7
+ /**
8
+ * Distributive version of Omit that properly handles union types.
9
+ *
10
+ * Standard `Omit<A | B, K>` loses unique properties from union members.
11
+ * `DistributiveOmit<A | B, K>` preserves them by distributing over the union.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * type A = { type: 'a'; foo: string; metrics: EventMetrics };
16
+ * type B = { type: 'b'; bar: number; metrics: EventMetrics };
17
+ * type Union = A | B;
18
+ *
19
+ * // ❌ Standard Omit - loses foo and bar
20
+ * type Bad = Omit<Union, 'metrics'>;
21
+ * // Result: { type: 'a' | 'b' }
22
+ *
23
+ * // ✅ DistributiveOmit - preserves unique properties
24
+ * type Good = DistributiveOmit<Union, 'metrics'>;
25
+ * // Result: { type: 'a'; foo: string } | { type: 'b'; bar: number }
26
+ * ```
27
+ */
28
+ export type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never;
29
+ /**
30
+ * Adds `metrics: EventMetrics` to event types.
31
+ * The framework uses this internally to wrap user-defined events with timing info.
32
+ *
33
+ * **For most use cases, you don't need this type.** Simply define your events
34
+ * without metrics, and the framework handles the wrapping automatically.
35
+ *
36
+ * **When you need SessionEvent:**
37
+ * - Creating mock/stub streaming executions for testing
38
+ * - Explicitly typing `StreamingResult.events` arrays
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // User defines pure event types (recommended)
43
+ * type MyEvent =
44
+ * | { type: 'progress'; step: string }
45
+ * | { type: 'complete'; data: string };
46
+ *
47
+ * // Framework internally wraps as SessionEvent<MyEvent>
48
+ * // StreamingResult.events returns SessionEvent<MyEvent>[]
49
+ *
50
+ * // Testing: Create mock events with explicit metrics
51
+ * const mockEvents: SessionEvent<MyEvent>[] = [
52
+ * { type: 'progress', step: 'loading', metrics: { timestamp: Date.now(), elapsedMs: 0, deltaMs: 0 } },
53
+ * ];
54
+ * ```
55
+ */
56
+ export type SessionEvent<T extends {
57
+ type: string;
58
+ }> = T & {
59
+ metrics: EventMetrics;
60
+ };
61
+ /**
62
+ * Input type for session.emit() - removes metrics from event types.
63
+ * Uses DistributiveOmit to properly handle union types.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * type MyAgentEvent = SessionEvent<ProgressEvent | CompleteEvent | ErrorEvent>;
68
+ *
69
+ * // For emit input, metrics is not required
70
+ * type EmitInput = SessionEventInput<MyAgentEvent>;
71
+ *
72
+ * // Usage in session.emit()
73
+ * session.emit({ type: 'progress', step: 'reading', message: 'Loading...' });
74
+ * // No casting needed!
75
+ * ```
76
+ */
77
+ /**
78
+ * @deprecated TEvent no longer requires metrics constraint - use TEvent directly
79
+ * This type is kept for backwards compatibility during migration
80
+ */
81
+ export type SessionEventInput<T extends {
82
+ type: string;
83
+ }> = T;
84
+ /**
85
+ * Reserved event types that cannot be emitted directly via session.emit().
86
+ * These types are controlled internally by session.done() and session.fail().
87
+ */
88
+ export type ReservedEventType = 'complete' | 'error';
89
+ /**
90
+ * Input type for emit() - excludes reserved event types.
91
+ * Users define pure domain events; framework adds metrics wrapper.
92
+ */
93
+ export type EmittableEventInput<T extends {
94
+ type: string;
95
+ }> = T extends {
96
+ type: ReservedEventType;
97
+ } ? never : T;
98
+ /**
99
+ * Completion event emitted by session.done().
100
+ * Include this in your event union to define the result type.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * type MyEvent =
105
+ * | { type: 'progress'; step: string }
106
+ * | CompletionEvent<MyResult>;
107
+ *
108
+ * // session.done(result) emits { type: 'complete', data: result, summary }
109
+ * ```
110
+ */
111
+ export type CompletionEvent<TResult> = {
112
+ type: 'complete';
113
+ data: TResult;
114
+ summary: SessionSummary;
115
+ };
116
+ /**
117
+ * Error event emitted by session.fail().
118
+ * Auto-added to stream() return type — users don't need to include this in their event union.
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * for await (const event of execution.stream()) {
123
+ * if (event.type === 'error') {
124
+ * console.error(event.error.message);
125
+ * }
126
+ * }
127
+ * ```
128
+ */
129
+ export type ErrorEvent = {
130
+ type: 'error';
131
+ error: Error;
132
+ summary?: SessionSummary;
133
+ data?: unknown;
134
+ };
135
+ /**
136
+ * Extract the result type from an event union containing CompletionEvent<T>.
137
+ * Returns `never` if no CompletionEvent member exists (making session.done() uncallable).
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * type MyEvent =
142
+ * | { type: 'progress'; step: string }
143
+ * | CompletionEvent<{ answer: string }>;
144
+ *
145
+ * type Result = ExtractResult<MyEvent>;
146
+ * // Result = { answer: string }
147
+ * ```
148
+ */
149
+ export type ExtractResult<TEvent extends {
150
+ type: string;
151
+ }> = Extract<TEvent, {
152
+ type: 'complete';
153
+ }> extends {
154
+ data: infer R;
155
+ } ? R : never;
156
+ /**
157
+ * Options for execution.
158
+ * Used by both simpleExecution and streamingExecution.
159
+ */
160
+ export interface ExecutionOptions {
161
+ /**
162
+ * AbortSignal for cancellation.
163
+ * Combined with internal AbortController - both can trigger cancellation.
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * const controller = new AbortController();
168
+ *
169
+ * // Pass signal to execution
170
+ * const execution = provider.simpleExecution(fn, { signal: controller.signal });
171
+ *
172
+ * // Cancel externally
173
+ * setTimeout(() => controller.abort(), 5000);
174
+ *
175
+ * // Or use execution.cancel() directly
176
+ * execution.cancel();
177
+ * ```
178
+ */
179
+ signal?: AbortSignal;
180
+ }
181
+ /**
182
+ * Status of an execution after completion.
183
+ * - `succeeded`: Execution completed normally with a result
184
+ * - `failed`: Execution threw an error
185
+ * - `canceled`: Execution was canceled via cancel() or AbortSignal
186
+ */
187
+ export type ExecutionStatus = 'succeeded' | 'failed' | 'canceled';
188
+ /**
189
+ * Discriminated union representing the outcome of an execution.
190
+ * Summary is always available, regardless of execution status.
191
+ *
192
+ * @typeParam T - The result type on success
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const result = await execution.result();
197
+ *
198
+ * if (result.status === 'succeeded') {
199
+ * console.log(result.value);
200
+ * } else if (result.status === 'failed') {
201
+ * console.error(result.error);
202
+ * }
203
+ *
204
+ * // Summary always available
205
+ * console.log(`Cost: $${result.summary.totalCost}`);
206
+ * ```
207
+ */
208
+ export type ExecutionResult<T> = {
209
+ status: 'succeeded';
210
+ value: T;
211
+ summary: SessionSummary;
212
+ } | {
213
+ status: 'failed';
214
+ error: Error;
215
+ summary: SessionSummary;
216
+ } | {
217
+ status: 'canceled';
218
+ summary: SessionSummary;
219
+ };
220
+ /**
221
+ * Result type for SimpleExecution.
222
+ * Alias for ExecutionResult for clarity in type annotations.
223
+ */
224
+ export type SimpleResult<T> = ExecutionResult<T>;
225
+ /**
226
+ * Result type for StreamingExecution.
227
+ * Extends ExecutionResult with readonly events array.
228
+ * Events are always available, even on failure or cancellation.
229
+ *
230
+ * @typeParam TEvent - Event type
231
+ * @typeParam T - Result type on success
232
+ *
233
+ * @example
234
+ * ```typescript
235
+ * const result = await execution.result();
236
+ *
237
+ * // Events always available, regardless of status
238
+ * console.log(`Received ${result.events.length} events`);
239
+ *
240
+ * if (result.status === 'succeeded') {
241
+ * console.log(result.value);
242
+ * }
243
+ * ```
244
+ */
245
+ export type StreamingResult<TEvent, T> = ExecutionResult<T> & {
246
+ readonly events: readonly TEvent[];
247
+ };
248
+ /**
249
+ * Base interface for all execution types.
250
+ * Both streaming and non-streaming executions implement this interface,
251
+ * enabling unified handling at outer layers.
252
+ *
253
+ * @typeParam TResult - The final result type
254
+ *
255
+ * @example
256
+ * ```typescript
257
+ * // Option 1: Automatic cleanup with await using (recommended)
258
+ * await using execution = agent.execute(input);
259
+ * const result = await execution.result();
260
+ * if (result.status === 'succeeded') {
261
+ * console.log(result.value, result.summary.totalCost);
262
+ * }
263
+ * // cleanup() called automatically on scope exit
264
+ *
265
+ * // Option 2: Manual cleanup with try/finally
266
+ * const execution = agent.execute(input);
267
+ * try {
268
+ * const result = await execution.result();
269
+ * } finally {
270
+ * await execution.cleanup();
271
+ * }
272
+ * ```
273
+ */
274
+ export interface Execution<TResult> extends AsyncDisposable {
275
+ /**
276
+ * Get the execution result with status and summary.
277
+ * Returns a discriminated union that always includes the summary,
278
+ * regardless of whether execution succeeded, failed, or was canceled.
279
+ *
280
+ * For streaming executions, this waits for all events to complete.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const result = await execution.result();
285
+ *
286
+ * if (result.status === 'succeeded') {
287
+ * console.log(result.value);
288
+ * } else if (result.status === 'failed') {
289
+ * console.error(result.error);
290
+ * }
291
+ *
292
+ * // Summary always available
293
+ * console.log(`Cost: $${result.summary.totalCost}`);
294
+ * ```
295
+ */
296
+ result(): Promise<ExecutionResult<TResult>>;
297
+ /**
298
+ * Request cancellation of the execution.
299
+ * Aborts the current operation if in progress.
300
+ * Works even if custom signal was provided (signals are combined).
301
+ *
302
+ * No-op if execution already completed.
303
+ */
304
+ cancel(): void;
305
+ /**
306
+ * Cleanup resources (uploaded files, connections, etc.).
307
+ * Should always be called after execution, even on error.
308
+ * Safe to call multiple times.
309
+ */
310
+ cleanup(): Promise<void>;
311
+ /**
312
+ * Async disposal for `await using` syntax (TS 5.2+).
313
+ * Delegates to cleanup().
314
+ */
315
+ [Symbol.asyncDispose](): Promise<void>;
316
+ }
317
+ /**
318
+ * Simple (non-streaming) execution.
319
+ * Starts eagerly on construction - execution begins immediately.
320
+ *
321
+ * @typeParam TResult - The final result type
322
+ *
323
+ * @example
324
+ * ```typescript
325
+ * // Start execution (sync - no await, starts immediately)
326
+ * const execution = provider.simpleExecution(async (session) => {
327
+ * const response = await session.generateText({ prompt: 'Hello' });
328
+ * return response.text;
329
+ * });
330
+ *
331
+ * // Cancel if needed
332
+ * setTimeout(() => execution.cancel(), 5000);
333
+ *
334
+ * // Get result (status-based, never throws)
335
+ * const result = await execution.result();
336
+ *
337
+ * if (result.status === 'succeeded') {
338
+ * console.log(result.value);
339
+ * } else if (result.status === 'canceled') {
340
+ * console.log('Execution was canceled');
341
+ * }
342
+ *
343
+ * // Summary always available
344
+ * console.log(`Cost: $${result.summary.totalCost}`);
345
+ * ```
346
+ */
347
+ export interface SimpleExecution<TResult> extends Execution<TResult> {
348
+ /**
349
+ * Get the execution result with status and summary.
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * const execution = provider.simpleExecution(async (session) => {
354
+ * const response = await session.generateText({ prompt: 'Hello' });
355
+ * return response.text;
356
+ * });
357
+ *
358
+ * const result = await execution.result();
359
+ *
360
+ * if (result.status === 'succeeded') {
361
+ * console.log(result.value);
362
+ * } else if (result.status === 'failed') {
363
+ * console.error(result.error);
364
+ * }
365
+ *
366
+ * // Summary always available
367
+ * console.log(`Cost: $${result.summary.totalCost}`);
368
+ * ```
369
+ */
370
+ result(): Promise<SimpleResult<TResult>>;
371
+ }
372
+ /**
373
+ * Represents a streaming execution that emits events as they occur.
374
+ * TEvent is the user's pure domain event type (without metrics).
375
+ * stream() and result() return SessionEvent<TEvent> which includes metrics.
376
+ */
377
+ export interface StreamingExecution<TEvent extends {
378
+ type: string;
379
+ }> extends Execution<ExtractResult<TEvent>> {
380
+ /**
381
+ * Get the event stream.
382
+ * Returns an AsyncIterable that yields all events with metrics:
383
+ * - Events already in the buffer (from eager execution)
384
+ * - Real-time events as they occur
385
+ * - ErrorEvent is auto-included — no need to add it to your event union
386
+ *
387
+ * Can be called multiple times - each call replays buffered events.
388
+ * After execution completes, replays all events from buffer.
389
+ *
390
+ * @example
391
+ * ```typescript
392
+ * type MyEvent =
393
+ * | { type: 'progress'; step: number }
394
+ * | CompletionEvent<MyResult>;
395
+ *
396
+ * const execution = provider.streamingExecution<MyEvent>(...);
397
+ *
398
+ * for await (const event of execution.stream()) {
399
+ * // event is SessionEvent<MyEvent | ErrorEvent>
400
+ * console.log(`[${event.metrics.elapsedMs}ms] ${event.type}`);
401
+ * }
402
+ * ```
403
+ */
404
+ stream(): AsyncIterable<SessionEvent<TEvent | ErrorEvent>>;
405
+ /**
406
+ * Get the execution result with status, summary, and all events.
407
+ *
408
+ * @example
409
+ * ```typescript
410
+ * const result = await execution.result();
411
+ *
412
+ * // Events always available
413
+ * console.log(`Received ${result.events.length} events`);
414
+ *
415
+ * if (result.status === 'succeeded') {
416
+ * console.log(result.value);
417
+ * }
418
+ *
419
+ * console.log(`Cost: $${result.summary.totalCost}`);
420
+ * ```
421
+ */
422
+ result(): Promise<StreamingResult<SessionEvent<TEvent | ErrorEvent>, ExtractResult<TEvent>>>;
423
+ }
424
+ /**
425
+ * Generator function type for streaming executions.
426
+ * TEvent is the user's pure domain event type (without metrics).
427
+ * The generator yields SessionEvent<TEvent> which includes metrics.
428
+ */
429
+ export type SessionStreamGeneratorFn<TEvent extends {
430
+ type: string;
431
+ }> = (session: StreamingSession<TEvent>) => AsyncGenerator<SessionEvent<TEvent>, SessionEvent<TEvent> | Promise<SessionEvent<TEvent>> | undefined, unknown>;
432
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/execution/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAM5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,CAAC,SAAS,GAAG,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC;AAE1F;;;;;;;;;;;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W,eAAe,CAAC,OAAO,CAAE,SAAQ,SAAS,CAAC,OAAO,CAAC;IAChE;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;CAC5C;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CAAC,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAE,SAAQ,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzG;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,IAAI,aAAa,CAAC,YAAY,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;IAE3D;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAChG;AAED;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,CAChC,MAAM,SAAS;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,IAC/B,CACA,OAAO,EAAE,gBAAgB,CAAC,MAAM,CAAC,KAChC,cAAc,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/execution/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Calculate duration from start time in milliseconds.
3
+ *
4
+ * @param startTime - The start timestamp from Date.now()
5
+ * @returns Duration in milliseconds
6
+ */
7
+ export declare function getDuration(startTime: number): number;
8
+ /**
9
+ * Combine multiple AbortSignals into a single signal.
10
+ * The combined signal aborts when ANY of the source signals abort.
11
+ *
12
+ * Node 18 compatible - doesn't use AbortSignal.any() which is Node 20+.
13
+ *
14
+ * @param signals - AbortSignals to combine
15
+ * @returns A new AbortSignal that aborts when any input signal aborts
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const userController = new AbortController();
20
+ * const timeoutController = new AbortController();
21
+ *
22
+ * const combined = combineSignals(userController.signal, timeoutController.signal);
23
+ *
24
+ * // Either abort triggers the combined signal
25
+ * userController.abort(); // combined.aborted === true
26
+ * ```
27
+ */
28
+ export declare function combineSignals(...signals: AbortSignal[]): AbortSignal;
29
+ /**
30
+ * A Promise that can be resolved or rejected externally.
31
+ *
32
+ * Useful for bridging callback-based APIs to async/await patterns.
33
+ * The resolve/reject functions are exposed as instance properties,
34
+ * allowing external code to control when the promise settles.
35
+ *
36
+ * @typeParam T - The type of the resolved value (defaults to void)
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const deferred = new Deferred<string>();
41
+ *
42
+ * // Later, in a callback:
43
+ * someApi.onData((data) => deferred.resolve(data));
44
+ * someApi.onError((err) => deferred.reject(err));
45
+ *
46
+ * // Await the result:
47
+ * const result = await deferred.promise;
48
+ * ```
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // In async generator for event notification:
53
+ * let pending = new Deferred<void>();
54
+ * const subscriber = () => pending.resolve();
55
+ *
56
+ * while (!done) {
57
+ * await pending.promise;
58
+ * pending = new Deferred<void>(); // Reset for next wait
59
+ * }
60
+ * ```
61
+ */
62
+ export declare class Deferred<T = void> {
63
+ readonly promise: Promise<T>;
64
+ readonly resolve: (value: T) => void;
65
+ readonly reject: (error: Error) => void;
66
+ constructor();
67
+ }
68
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/execution/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAErD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,GAAG,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,CAiBrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,IAAI;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAExC,cASC;CACF"}