@agtlantis/core 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -5
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/types.d.ts +69 -0
- package/dist/errors/types.d.ts.map +1 -0
- package/dist/errors/types.js +116 -0
- package/dist/errors/types.js.map +1 -0
- package/dist/errors/utils.d.ts +17 -0
- package/dist/errors/utils.d.ts.map +1 -0
- package/dist/errors/utils.js +16 -0
- package/dist/errors/utils.js.map +1 -0
- package/dist/execution/constants.d.ts +7 -0
- package/dist/execution/constants.d.ts.map +1 -0
- package/dist/execution/constants.js +7 -0
- package/dist/execution/constants.js.map +1 -0
- package/dist/execution/index.d.ts +8 -0
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +7 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/execution/mapping.d.ts +17 -0
- package/dist/execution/mapping.d.ts.map +1 -0
- package/dist/execution/mapping.js +197 -0
- package/dist/execution/mapping.js.map +1 -0
- package/dist/execution/shared.d.ts +86 -0
- package/dist/execution/shared.d.ts.map +1 -0
- package/dist/execution/shared.js +100 -0
- package/dist/execution/shared.js.map +1 -0
- package/dist/execution/simple-host.d.ts +56 -0
- package/dist/execution/simple-host.d.ts.map +1 -0
- package/dist/execution/simple-host.js +126 -0
- package/dist/execution/simple-host.js.map +1 -0
- package/dist/execution/streaming-host.d.ts +79 -0
- package/dist/execution/streaming-host.d.ts.map +1 -0
- package/dist/execution/streaming-host.js +276 -0
- package/dist/execution/streaming-host.js.map +1 -0
- package/dist/execution/testing/fixtures.d.ts +67 -0
- package/dist/execution/testing/fixtures.d.ts.map +1 -0
- package/dist/execution/testing/fixtures.js +145 -0
- package/dist/execution/testing/fixtures.js.map +1 -0
- package/dist/execution/testing/helpers.d.ts +218 -0
- package/dist/execution/testing/helpers.d.ts.map +1 -0
- package/dist/execution/testing/helpers.js +327 -0
- package/dist/execution/testing/helpers.js.map +1 -0
- package/dist/execution/testing/host-configs.d.ts +56 -0
- package/dist/execution/testing/host-configs.d.ts.map +1 -0
- package/dist/execution/testing/host-configs.js +154 -0
- package/dist/execution/testing/host-configs.js.map +1 -0
- package/dist/execution/testing/vitest-assertions.d.ts +102 -0
- package/dist/execution/testing/vitest-assertions.d.ts.map +1 -0
- package/dist/execution/testing/vitest-assertions.js +142 -0
- package/dist/execution/testing/vitest-assertions.js.map +1 -0
- package/dist/execution/types.d.ts +432 -0
- package/dist/execution/types.d.ts.map +1 -0
- package/dist/execution/types.js +2 -0
- package/dist/execution/types.js.map +1 -0
- package/dist/execution/utils.d.ts +68 -0
- package/dist/execution/utils.d.ts.map +1 -0
- package/dist/execution/utils.js +93 -0
- package/dist/execution/utils.js.map +1 -0
- package/dist/index.d.ts +10 -1506
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -2979
- package/dist/index.js.map +1 -1
- package/dist/observability/index.d.ts +4 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +2 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/logger.d.ts +161 -0
- package/dist/observability/logger.d.ts.map +1 -0
- package/dist/observability/logger.js +31 -0
- package/dist/observability/logger.js.map +1 -0
- package/dist/observability/types.d.ts +46 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +2 -0
- package/dist/observability/types.js.map +1 -0
- package/dist/patterns/index.d.ts +2 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +2 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/progressive/index.d.ts +2 -0
- package/dist/patterns/progressive/index.d.ts.map +1 -0
- package/dist/patterns/progressive/index.js +2 -0
- package/dist/patterns/progressive/index.js.map +1 -0
- package/dist/patterns/progressive/progressive-pattern.d.ts +174 -0
- package/dist/patterns/progressive/progressive-pattern.d.ts.map +1 -0
- package/dist/patterns/progressive/progressive-pattern.js +260 -0
- package/dist/patterns/progressive/progressive-pattern.js.map +1 -0
- package/dist/pricing/calculator.d.ts +71 -0
- package/dist/pricing/calculator.d.ts.map +1 -0
- package/dist/pricing/calculator.js +127 -0
- package/dist/pricing/calculator.js.map +1 -0
- package/dist/pricing/config.d.ts +61 -0
- package/dist/pricing/config.d.ts.map +1 -0
- package/dist/pricing/config.js +87 -0
- package/dist/pricing/config.js.map +1 -0
- package/dist/pricing/defaults.d.ts +29 -0
- package/dist/pricing/defaults.d.ts.map +1 -0
- package/dist/pricing/defaults.js +139 -0
- package/dist/pricing/defaults.js.map +1 -0
- package/dist/pricing/index.d.ts +40 -0
- package/dist/pricing/index.d.ts.map +1 -0
- package/dist/pricing/index.js +43 -0
- package/dist/pricing/index.js.map +1 -0
- package/dist/pricing/types.d.ts +96 -0
- package/dist/pricing/types.d.ts.map +1 -0
- package/dist/pricing/types.js +7 -0
- package/dist/pricing/types.js.map +1 -0
- package/dist/pricing/validator.d.ts +55 -0
- package/dist/pricing/validator.d.ts.map +1 -0
- package/dist/pricing/validator.js +84 -0
- package/dist/pricing/validator.js.map +1 -0
- package/dist/prompt/errors.d.ts +112 -0
- package/dist/prompt/errors.d.ts.map +1 -0
- package/dist/prompt/errors.js +174 -0
- package/dist/prompt/errors.js.map +1 -0
- package/dist/prompt/file-prompt-repository.d.ts +80 -0
- package/dist/prompt/file-prompt-repository.d.ts.map +1 -0
- package/dist/prompt/file-prompt-repository.js +287 -0
- package/dist/prompt/file-prompt-repository.js.map +1 -0
- package/dist/prompt/index.d.ts +34 -0
- package/dist/prompt/index.d.ts.map +1 -0
- package/dist/prompt/index.js +37 -0
- package/dist/prompt/index.js.map +1 -0
- package/dist/prompt/prompt-template.d.ts +64 -0
- package/dist/prompt/prompt-template.d.ts.map +1 -0
- package/dist/prompt/prompt-template.js +90 -0
- package/dist/prompt/prompt-template.js.map +1 -0
- package/dist/prompt/template.d.ts +23 -0
- package/dist/prompt/template.d.ts.map +1 -0
- package/dist/prompt/template.js +70 -0
- package/dist/prompt/template.js.map +1 -0
- package/dist/prompt/types.d.ts +148 -0
- package/dist/prompt/types.d.ts.map +1 -0
- package/dist/prompt/types.js +7 -0
- package/dist/prompt/types.js.map +1 -0
- package/dist/provider/base-file-manager.d.ts +14 -0
- package/dist/provider/base-file-manager.d.ts.map +1 -0
- package/dist/provider/base-file-manager.js +91 -0
- package/dist/provider/base-file-manager.js.map +1 -0
- package/dist/provider/base-provider.d.ts +41 -0
- package/dist/provider/base-provider.d.ts.map +1 -0
- package/dist/provider/base-provider.js +21 -0
- package/dist/provider/base-provider.js.map +1 -0
- package/dist/provider/file-cache.d.ts +14 -0
- package/dist/provider/file-cache.d.ts.map +1 -0
- package/dist/provider/file-cache.js +29 -0
- package/dist/provider/file-cache.js.map +1 -0
- package/dist/provider/file-source.d.ts +32 -0
- package/dist/provider/file-source.d.ts.map +1 -0
- package/dist/provider/file-source.js +180 -0
- package/dist/provider/file-source.js.map +1 -0
- package/dist/provider/file-utils.d.ts +5 -0
- package/dist/provider/file-utils.d.ts.map +1 -0
- package/dist/provider/file-utils.js +15 -0
- package/dist/provider/file-utils.js.map +1 -0
- package/dist/provider/google/factory.d.ts +107 -0
- package/dist/provider/google/factory.d.ts.map +1 -0
- package/dist/provider/google/factory.js +143 -0
- package/dist/provider/google/factory.js.map +1 -0
- package/dist/provider/google/file-manager.d.ts +10 -0
- package/dist/provider/google/file-manager.d.ts.map +1 -0
- package/dist/provider/google/file-manager.js +93 -0
- package/dist/provider/google/file-manager.js.map +1 -0
- package/dist/provider/google/index.d.ts +8 -0
- package/dist/provider/google/index.d.ts.map +1 -0
- package/dist/provider/google/index.js +10 -0
- package/dist/provider/google/index.js.map +1 -0
- package/dist/provider/hash.d.ts +3 -0
- package/dist/provider/hash.d.ts.map +1 -0
- package/dist/provider/hash.js +34 -0
- package/dist/provider/hash.js.map +1 -0
- package/dist/provider/index.d.ts +10 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +12 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/provider/noop-file-manager.d.ts +9 -0
- package/dist/provider/noop-file-manager.d.ts.map +1 -0
- package/dist/provider/noop-file-manager.js +28 -0
- package/dist/provider/noop-file-manager.js.map +1 -0
- package/dist/provider/openai/factory.d.ts +67 -0
- package/dist/provider/openai/factory.d.ts.map +1 -0
- package/dist/provider/openai/factory.js +100 -0
- package/dist/provider/openai/factory.js.map +1 -0
- package/dist/provider/openai/file-manager.d.ts +17 -0
- package/dist/provider/openai/file-manager.d.ts.map +1 -0
- package/dist/provider/openai/file-manager.js +108 -0
- package/dist/provider/openai/file-manager.js.map +1 -0
- package/dist/provider/openai/index.d.ts +8 -0
- package/dist/provider/openai/index.d.ts.map +1 -0
- package/dist/provider/openai/index.js +8 -0
- package/dist/provider/openai/index.js.map +1 -0
- package/dist/provider/types.d.ts +105 -0
- package/dist/provider/types.d.ts.map +1 -0
- package/dist/provider/types.js +19 -0
- package/dist/provider/types.js.map +1 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +5 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/simple-session.d.ts +98 -0
- package/dist/session/simple-session.d.ts.map +1 -0
- package/dist/session/simple-session.js +299 -0
- package/dist/session/simple-session.js.map +1 -0
- package/dist/session/streaming-session.d.ts +90 -0
- package/dist/session/streaming-session.d.ts.map +1 -0
- package/dist/session/streaming-session.js +151 -0
- package/dist/session/streaming-session.js.map +1 -0
- package/dist/session/test-utils.d.ts +19 -0
- package/dist/session/test-utils.d.ts.map +1 -0
- package/dist/session/test-utils.js +65 -0
- package/dist/session/test-utils.js.map +1 -0
- package/dist/session/types.d.ts +219 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +181 -0
- package/dist/session/types.js.map +1 -0
- package/dist/session/usage-extractors.d.ts +7 -0
- package/dist/session/usage-extractors.d.ts.map +1 -0
- package/dist/session/usage-extractors.js +71 -0
- package/dist/session/usage-extractors.js.map +1 -0
- package/dist/testing/fixtures.d.ts +34 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +65 -0
- package/dist/testing/fixtures.js.map +1 -0
- package/dist/testing/helpers.d.ts +20 -0
- package/dist/testing/helpers.d.ts.map +1 -0
- package/dist/testing/helpers.js +32 -0
- package/dist/testing/helpers.js.map +1 -0
- package/dist/testing/index.d.ts +7 -519
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +21 -2123
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock-provider.d.ts +79 -0
- package/dist/testing/mock-provider.d.ts.map +1 -0
- package/dist/testing/mock-provider.js +152 -0
- package/dist/testing/mock-provider.js.map +1 -0
- package/dist/testing/mock.d.ts +29 -0
- package/dist/testing/mock.d.ts.map +1 -0
- package/dist/testing/mock.js +154 -0
- package/dist/testing/mock.js.map +1 -0
- package/dist/testing/test-execution.d.ts +14 -0
- package/dist/testing/test-execution.d.ts.map +1 -0
- package/dist/testing/test-execution.js +108 -0
- package/dist/testing/test-execution.js.map +1 -0
- package/dist/utils/deep-merge.d.ts +6 -0
- package/dist/utils/deep-merge.d.ts.map +1 -0
- package/dist/utils/deep-merge.js +24 -0
- package/dist/utils/deep-merge.js.map +1 -0
- package/dist/validation/errors.d.ts +28 -0
- package/dist/validation/errors.d.ts.map +1 -0
- package/dist/validation/errors.js +38 -0
- package/dist/validation/errors.js.map +1 -0
- package/dist/validation/index.d.ts +5 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +4 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/types.d.ts +49 -0
- package/dist/validation/types.d.ts.map +1 -0
- package/dist/validation/types.js +2 -0
- package/dist/validation/types.js.map +1 -0
- package/dist/validation/validation-history.d.ts +12 -0
- package/dist/validation/validation-history.d.ts.map +1 -0
- package/dist/validation/validation-history.js +29 -0
- package/dist/validation/validation-history.js.map +1 -0
- package/dist/validation/with-validation.d.ts +38 -0
- package/dist/validation/with-validation.d.ts.map +1 -0
- package/dist/validation/with-validation.js +58 -0
- package/dist/validation/with-validation.js.map +1 -0
- package/package.json +71 -75
- package/dist/base-provider-2TTw5HAa.d.cts +0 -1254
- package/dist/base-provider-2TTw5HAa.d.ts +0 -1254
- package/dist/index.cjs +0 -3085
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -1506
- package/dist/testing/index.cjs +0 -2167
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -520
|
@@ -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"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for execution hosts.
|
|
3
|
+
*
|
|
4
|
+
* These functions extract common patterns from SimpleExecutionHost and
|
|
5
|
+
* StreamingExecutionHost to reduce code duplication and ensure consistent
|
|
6
|
+
* behavior across both implementations.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Checks if an error is an abort-related error.
|
|
10
|
+
*
|
|
11
|
+
* An error is considered abort-related if either:
|
|
12
|
+
* - The error has the name 'AbortError' (standard for AbortController)
|
|
13
|
+
* - The signal has been aborted (covers edge cases where error name differs)
|
|
14
|
+
*
|
|
15
|
+
* @param error - The error to check
|
|
16
|
+
* @param signal - The AbortSignal associated with the execution
|
|
17
|
+
* @returns true if this is an abort-related error
|
|
18
|
+
*/
|
|
19
|
+
export function isAbortError(error, signal) {
|
|
20
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return signal.aborted;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Normalizes an unknown error to an Error instance.
|
|
27
|
+
*
|
|
28
|
+
* If the error is already an Error instance, it's returned as-is.
|
|
29
|
+
* Otherwise, it's converted to a string and wrapped in a new Error.
|
|
30
|
+
*
|
|
31
|
+
* @param error - The unknown error to normalize
|
|
32
|
+
* @returns A proper Error instance
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeError(error) {
|
|
35
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Determines the execution status based on the execution state.
|
|
39
|
+
*
|
|
40
|
+
* Status determination priority:
|
|
41
|
+
* 1. If user called cancel() OR the operation was aborted → 'canceled'
|
|
42
|
+
* 2. If there's an error → 'failed'
|
|
43
|
+
* 3. Otherwise → 'succeeded'
|
|
44
|
+
*
|
|
45
|
+
* Note: The 'aborted' flag takes precedence over 'hasError' because
|
|
46
|
+
* AbortError is treated as a normal cancellation, not a failure.
|
|
47
|
+
*
|
|
48
|
+
* @param cancelRequested - Whether cancel() was explicitly called
|
|
49
|
+
* @param aborted - Whether the signal was aborted (includes external abort)
|
|
50
|
+
* @param hasError - Whether the execution ended with an error
|
|
51
|
+
* @returns The appropriate execution status
|
|
52
|
+
*/
|
|
53
|
+
export function determineResultStatus(cancelRequested, aborted, hasError) {
|
|
54
|
+
// Cancellation takes priority (abort errors are treated as cancellation)
|
|
55
|
+
if (cancelRequested || aborted) {
|
|
56
|
+
return 'canceled';
|
|
57
|
+
}
|
|
58
|
+
// Error state
|
|
59
|
+
if (hasError) {
|
|
60
|
+
return 'failed';
|
|
61
|
+
}
|
|
62
|
+
// Success
|
|
63
|
+
return 'succeeded';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a hook runner that ensures hooks run exactly once.
|
|
67
|
+
*
|
|
68
|
+
* This utility encapsulates the common pattern of running cleanup hooks
|
|
69
|
+
* with a guard flag to prevent double execution. Both SimpleExecutionHost
|
|
70
|
+
* and StreamingExecutionHost use this pattern for onDone hooks.
|
|
71
|
+
*
|
|
72
|
+
* @param runHooks - The async function to run hooks
|
|
73
|
+
* @returns Object with ensureRun() and hasRun() methods
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const hookRunner = createHookRunner(async () => {
|
|
78
|
+
* await session.runOnDoneHooks();
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* // In finally block or cleanup:
|
|
82
|
+
* await hookRunner.ensureRun();
|
|
83
|
+
*
|
|
84
|
+
* // Safe to call multiple times - only executes once
|
|
85
|
+
* await hookRunner.ensureRun(); // no-op
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function createHookRunner(runHooks) {
|
|
89
|
+
let ran = false;
|
|
90
|
+
return {
|
|
91
|
+
ensureRun: async () => {
|
|
92
|
+
if (!ran) {
|
|
93
|
+
ran = true;
|
|
94
|
+
await runHooks();
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
hasRun: () => ran,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -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
+
import type { SimpleSession } from '../session/simple-session.js';
|
|
2
|
+
import type { SimpleExecution, SimpleResult } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* SimpleExecutionHost implements the SimpleExecution interface for eager execution.
|
|
5
|
+
*
|
|
6
|
+
* Execution starts immediately on construction (eager evaluation).
|
|
7
|
+
* Use result() to get the execution outcome with status and summary.
|
|
8
|
+
*
|
|
9
|
+
* Signal combination:
|
|
10
|
+
* - If userSignal is provided, it's combined with internal AbortController
|
|
11
|
+
* - Both cancel() and userSignal abort will trigger cancellation
|
|
12
|
+
* - The combined signal is passed to SimpleSession for AI SDK calls
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const execution = new SimpleExecutionHost(createSession, async (session) => {
|
|
17
|
+
* return await session.generateText({ prompt: 'Hello' });
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const result = await execution.result();
|
|
21
|
+
*
|
|
22
|
+
* if (result.status === 'succeeded') {
|
|
23
|
+
* console.log(result.value);
|
|
24
|
+
* }
|
|
25
|
+
* console.log(`Cost: $${result.summary.totalCost}`);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class SimpleExecutionHost<TResult> implements SimpleExecution<TResult> {
|
|
29
|
+
private readonly abortController;
|
|
30
|
+
private readonly effectiveSignal;
|
|
31
|
+
private readonly consumerPromise;
|
|
32
|
+
private cachedSession?;
|
|
33
|
+
private readonly startTime;
|
|
34
|
+
private cancelRequested;
|
|
35
|
+
constructor(createSession: (signal?: AbortSignal) => SimpleSession, fn: (session: SimpleSession) => Promise<TResult>, userSignal?: AbortSignal);
|
|
36
|
+
private execute;
|
|
37
|
+
/**
|
|
38
|
+
* Request cancellation of the execution.
|
|
39
|
+
* Aborts the current LLM call if in progress.
|
|
40
|
+
* No-op if execution already completed.
|
|
41
|
+
*/
|
|
42
|
+
cancel(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the execution result with status and summary.
|
|
45
|
+
* Never throws - returns a discriminated union with status.
|
|
46
|
+
*/
|
|
47
|
+
result(): Promise<SimpleResult<TResult>>;
|
|
48
|
+
/**
|
|
49
|
+
* Cleanup resources.
|
|
50
|
+
* For SimpleExecution, hooks are already run during execution,
|
|
51
|
+
* so this is intentionally a no-op.
|
|
52
|
+
*/
|
|
53
|
+
cleanup(): Promise<void>;
|
|
54
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=simple-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-host.d.ts","sourceRoot":"","sources":["../../src/execution/simple-host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAYhE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,mBAAmB,CAAC,OAAO,CAAE,YAAW,eAAe,CAAC,OAAO,CAAC;IAC3E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAc;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IACnE,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,eAAe,CAAS;IAEhC,YACE,aAAa,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,aAAa,EACtD,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,EAChD,UAAU,CAAC,EAAE,WAAW,EASzB;YAEa,OAAO;IA0CrB;;;;OAIG;IACH,MAAM,IAAI,IAAI,CAGb;IAED;;;OAGG;IACG,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CA0B7C;IAED;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAE7B;IAEK,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3C;CACF"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { combineSignals } from './utils.js';
|
|
2
|
+
import { isAbortError, normalizeError, createHookRunner } from './shared.js';
|
|
3
|
+
/**
|
|
4
|
+
* SimpleExecutionHost implements the SimpleExecution interface for eager execution.
|
|
5
|
+
*
|
|
6
|
+
* Execution starts immediately on construction (eager evaluation).
|
|
7
|
+
* Use result() to get the execution outcome with status and summary.
|
|
8
|
+
*
|
|
9
|
+
* Signal combination:
|
|
10
|
+
* - If userSignal is provided, it's combined with internal AbortController
|
|
11
|
+
* - Both cancel() and userSignal abort will trigger cancellation
|
|
12
|
+
* - The combined signal is passed to SimpleSession for AI SDK calls
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const execution = new SimpleExecutionHost(createSession, async (session) => {
|
|
17
|
+
* return await session.generateText({ prompt: 'Hello' });
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* const result = await execution.result();
|
|
21
|
+
*
|
|
22
|
+
* if (result.status === 'succeeded') {
|
|
23
|
+
* console.log(result.value);
|
|
24
|
+
* }
|
|
25
|
+
* console.log(`Cost: $${result.summary.totalCost}`);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class SimpleExecutionHost {
|
|
29
|
+
abortController = new AbortController();
|
|
30
|
+
effectiveSignal;
|
|
31
|
+
consumerPromise;
|
|
32
|
+
cachedSession;
|
|
33
|
+
startTime = Date.now();
|
|
34
|
+
cancelRequested = false;
|
|
35
|
+
constructor(createSession, fn, userSignal) {
|
|
36
|
+
// Combine user signal with internal controller for dual cancellation support
|
|
37
|
+
this.effectiveSignal = userSignal
|
|
38
|
+
? combineSignals(userSignal, this.abortController.signal)
|
|
39
|
+
: this.abortController.signal;
|
|
40
|
+
// Start execution immediately (eager evaluation)
|
|
41
|
+
this.consumerPromise = this.execute(createSession, fn);
|
|
42
|
+
}
|
|
43
|
+
async execute(createSession, fn) {
|
|
44
|
+
const session = createSession(this.effectiveSignal);
|
|
45
|
+
this.cachedSession = session;
|
|
46
|
+
const hookRunner = createHookRunner(() => session.runOnDoneHooks());
|
|
47
|
+
// Notify execution start
|
|
48
|
+
session.notifyExecutionStart();
|
|
49
|
+
try {
|
|
50
|
+
const result = await fn(session);
|
|
51
|
+
// Notify execution done
|
|
52
|
+
await session.notifyExecutionDone(result, this.startTime);
|
|
53
|
+
return {
|
|
54
|
+
success: true,
|
|
55
|
+
result,
|
|
56
|
+
summary: await session.getSummary(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const errorObj = normalizeError(error);
|
|
61
|
+
const isCancellation = isAbortError(error, this.abortController.signal);
|
|
62
|
+
// Notify execution error (AbortError excluded - treated as normal cancellation)
|
|
63
|
+
if (!isCancellation) {
|
|
64
|
+
await session.notifyExecutionError(errorObj, this.startTime);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
error: errorObj,
|
|
69
|
+
aborted: isCancellation,
|
|
70
|
+
summary: await session.getSummary(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await hookRunner.ensureRun();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Request cancellation of the execution.
|
|
79
|
+
* Aborts the current LLM call if in progress.
|
|
80
|
+
* No-op if execution already completed.
|
|
81
|
+
*/
|
|
82
|
+
cancel() {
|
|
83
|
+
this.cancelRequested = true;
|
|
84
|
+
this.abortController.abort();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the execution result with status and summary.
|
|
88
|
+
* Never throws - returns a discriminated union with status.
|
|
89
|
+
*/
|
|
90
|
+
async result() {
|
|
91
|
+
const internal = await this.consumerPromise;
|
|
92
|
+
// Success state
|
|
93
|
+
if (internal.success) {
|
|
94
|
+
return {
|
|
95
|
+
status: 'succeeded',
|
|
96
|
+
value: internal.result,
|
|
97
|
+
summary: internal.summary,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// Canceled state (user called cancel() or external signal aborted)
|
|
101
|
+
if (this.cancelRequested || internal.aborted) {
|
|
102
|
+
return {
|
|
103
|
+
status: 'canceled',
|
|
104
|
+
summary: internal.summary,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
// Failed state
|
|
108
|
+
return {
|
|
109
|
+
status: 'failed',
|
|
110
|
+
error: internal.error,
|
|
111
|
+
summary: internal.summary,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Cleanup resources.
|
|
116
|
+
* For SimpleExecution, hooks are already run during execution,
|
|
117
|
+
* so this is intentionally a no-op.
|
|
118
|
+
*/
|
|
119
|
+
async cleanup() {
|
|
120
|
+
// SimpleExecution runs hooks in execute(), nothing to clean up
|
|
121
|
+
}
|
|
122
|
+
async [Symbol.asyncDispose]() {
|
|
123
|
+
await this.cleanup();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=simple-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-host.js","sourceRoot":"","sources":["../../src/execution/simple-host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAU7E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,mBAAmB;IACb,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,eAAe,CAAc;IAC7B,eAAe,CAAmC;IAC3D,aAAa,CAAiB;IACrB,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,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-0,0 +1,79 @@
|
|
|
1
|
+
import type { StreamingSession } from '../session/streaming-session.js';
|
|
2
|
+
import type { ErrorEvent, ExtractResult, SessionEvent, SessionStreamGeneratorFn, StreamingExecution, StreamingResult } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Streaming execution host that uses StreamingSession.
|
|
5
|
+
* Starts execution eagerly on construction - events are buffered automatically.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam TEvent - User's pure domain event type with required `type` field (metrics added automatically)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const execution = new StreamingExecutionHost(
|
|
12
|
+
* () => new StreamingSession({
|
|
13
|
+
* defaultLanguageModel: provider.model,
|
|
14
|
+
* fileManager: new GoogleFileManager(apiKey),
|
|
15
|
+
* }),
|
|
16
|
+
* async function* (session) {
|
|
17
|
+
* session.onDone(() => session.fileManager.clear());
|
|
18
|
+
* const result = await session.generateText({ prompt: 'Hello' });
|
|
19
|
+
* yield session.emit({ type: 'progress', message: 'Working...' });
|
|
20
|
+
* return session.done(result.text);
|
|
21
|
+
* }
|
|
22
|
+
* );
|
|
23
|
+
* // ↑ Execution already started, events being buffered
|
|
24
|
+
*
|
|
25
|
+
* // Option 1: Stream events (buffered + real-time)
|
|
26
|
+
* for await (const event of execution.stream()) {
|
|
27
|
+
* console.log(event.type, event.metrics.elapsedMs);
|
|
28
|
+
* }
|
|
29
|
+
* const result = await execution.result();
|
|
30
|
+
*
|
|
31
|
+
* // Option 2: Skip streaming, events available in result
|
|
32
|
+
* const result = await execution.result();
|
|
33
|
+
* console.log(`Received ${result.events.length} events`);
|
|
34
|
+
*
|
|
35
|
+
* if (result.status === 'succeeded') {
|
|
36
|
+
* console.log(result.value);
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class StreamingExecutionHost<TEvent extends {
|
|
41
|
+
type: string;
|
|
42
|
+
}> implements StreamingExecution<TEvent> {
|
|
43
|
+
private readonly createSession;
|
|
44
|
+
private readonly generator;
|
|
45
|
+
private readonly abortController;
|
|
46
|
+
private readonly effectiveSignal;
|
|
47
|
+
private readonly consumerPromise;
|
|
48
|
+
private readonly eventBuffer;
|
|
49
|
+
private readonly subscribers;
|
|
50
|
+
private completed;
|
|
51
|
+
private cleaned;
|
|
52
|
+
private hookRunner;
|
|
53
|
+
private cancelRequested;
|
|
54
|
+
private extractedOutcome;
|
|
55
|
+
private extractedSummary;
|
|
56
|
+
constructor(createSession: (signal?: AbortSignal) => StreamingSession<TEvent>, generator: SessionStreamGeneratorFn<TEvent>, userSignal?: AbortSignal);
|
|
57
|
+
private hasDataField;
|
|
58
|
+
private hasSummaryField;
|
|
59
|
+
private hasErrorField;
|
|
60
|
+
private extractResultAndMetadata;
|
|
61
|
+
private notifySubscribers;
|
|
62
|
+
private startConsuming;
|
|
63
|
+
private buildResult;
|
|
64
|
+
/**
|
|
65
|
+
* Get the event stream.
|
|
66
|
+
* Returns buffered events first, then real-time events.
|
|
67
|
+
* Can be called multiple times - replays buffer each time.
|
|
68
|
+
*/
|
|
69
|
+
stream(): AsyncIterable<SessionEvent<TEvent | ErrorEvent>>;
|
|
70
|
+
cancel(): void;
|
|
71
|
+
cleanup(): Promise<void>;
|
|
72
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the execution result with status, summary, and all events.
|
|
75
|
+
* Never throws - returns a discriminated union with status.
|
|
76
|
+
*/
|
|
77
|
+
result(): Promise<StreamingResult<SessionEvent<TEvent | ErrorEvent>, ExtractResult<TEvent>>>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=streaming-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-host.d.ts","sourceRoot":"","sources":["../../src/execution/streaming-host.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,E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