@illalabs/sdk 0.0.0 → 0.1.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/LICENSE +17 -2
- package/dist/src/asyncToolChecker/AsyncToolChecker.d.ts +39 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.js +209 -0
- package/dist/src/asyncToolChecker/AsyncToolChecker.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.d.ts +23 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.js +30 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.d.ts +17 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.js +26 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.d.ts +17 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.js +21 -0
- package/dist/src/asyncToolChecker/errors/AsyncToolCheckerTimeout.js.map +1 -0
- package/dist/src/asyncToolChecker/errors/index.d.ts +4 -0
- package/dist/src/asyncToolChecker/errors/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/errors/index.js +4 -0
- package/dist/src/asyncToolChecker/errors/index.js.map +1 -0
- package/dist/src/asyncToolChecker/index.d.ts +6 -0
- package/dist/src/asyncToolChecker/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/index.js +5 -0
- package/dist/src/asyncToolChecker/index.js.map +1 -0
- package/dist/src/asyncToolChecker/types.d.ts +24 -0
- package/dist/src/asyncToolChecker/types.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/types.js +2 -0
- package/dist/src/asyncToolChecker/types.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/index.d.ts +3 -0
- package/dist/src/asyncToolChecker/utils/index.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/index.js +3 -0
- package/dist/src/asyncToolChecker/utils/index.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.d.ts +11 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.js +12 -0
- package/dist/src/asyncToolChecker/utils/isErrorResponse.js.map +1 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.d.ts +9 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.d.ts.map +1 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.js +14 -0
- package/dist/src/asyncToolChecker/utils/normalizeTimeout.js.map +1 -0
- package/dist/src/caching/InMemoryCache.d.ts +14 -0
- package/dist/src/caching/InMemoryCache.d.ts.map +1 -0
- package/dist/src/caching/InMemoryCache.js +31 -0
- package/dist/src/caching/InMemoryCache.js.map +1 -0
- package/dist/src/caching/index.d.ts +3 -0
- package/dist/src/caching/index.d.ts.map +1 -0
- package/dist/src/caching/index.js +2 -0
- package/dist/src/caching/index.js.map +1 -0
- package/dist/src/chat/Chat.d.ts +62 -0
- package/dist/src/chat/Chat.d.ts.map +1 -0
- package/dist/src/chat/Chat.js +126 -0
- package/dist/src/chat/Chat.js.map +1 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.d.ts +19 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.d.ts.map +1 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.js +28 -0
- package/dist/src/chat/errors/ChatAsyncToolCheckerUnavailable.js.map +1 -0
- package/dist/src/chat/errors/index.d.ts +2 -0
- package/dist/src/chat/errors/index.d.ts.map +1 -0
- package/dist/src/chat/errors/index.js +2 -0
- package/dist/src/chat/errors/index.js.map +1 -0
- package/dist/src/chat/index.d.ts +5 -0
- package/dist/src/chat/index.d.ts.map +1 -0
- package/dist/src/chat/index.js +3 -0
- package/dist/src/chat/index.js.map +1 -0
- package/dist/src/chat/types.d.ts +9 -0
- package/dist/src/chat/types.d.ts.map +1 -0
- package/dist/src/chat/types.js +2 -0
- package/dist/src/chat/types.js.map +1 -0
- package/dist/src/chat/utils/index.d.ts +2 -0
- package/dist/src/chat/utils/index.d.ts.map +1 -0
- package/dist/src/chat/utils/index.js +2 -0
- package/dist/src/chat/utils/index.js.map +1 -0
- package/dist/src/chat/utils/uuid.d.ts +12 -0
- package/dist/src/chat/utils/uuid.d.ts.map +1 -0
- package/dist/src/chat/utils/uuid.js +19 -0
- package/dist/src/chat/utils/uuid.js.map +1 -0
- package/dist/src/context/ContextManager.d.ts +26 -0
- package/dist/src/context/ContextManager.d.ts.map +1 -0
- package/dist/src/context/ContextManager.js +93 -0
- package/dist/src/context/ContextManager.js.map +1 -0
- package/dist/src/context/index.d.ts +2 -0
- package/dist/src/context/index.d.ts.map +1 -0
- package/dist/src/context/index.js +2 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/types.d.ts +17 -0
- package/dist/src/context/types.d.ts.map +1 -0
- package/dist/src/context/types.js +2 -0
- package/dist/src/context/types.js.map +1 -0
- package/dist/src/external.d.ts +14 -0
- package/dist/src/external.d.ts.map +1 -0
- package/dist/src/external.js +13 -0
- package/dist/src/external.js.map +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/asyncToolChecker.interface.d.ts +85 -0
- package/dist/src/interfaces/asyncToolChecker.interface.d.ts.map +1 -0
- package/dist/src/interfaces/asyncToolChecker.interface.js +2 -0
- package/dist/src/interfaces/asyncToolChecker.interface.js.map +1 -0
- package/dist/src/interfaces/cache.interface.d.ts +35 -0
- package/dist/src/interfaces/cache.interface.d.ts.map +1 -0
- package/dist/src/interfaces/cache.interface.js +2 -0
- package/dist/src/interfaces/cache.interface.js.map +1 -0
- package/dist/src/interfaces/chat.interface.d.ts +84 -0
- package/dist/src/interfaces/chat.interface.d.ts.map +1 -0
- package/dist/src/interfaces/chat.interface.js +2 -0
- package/dist/src/interfaces/chat.interface.js.map +1 -0
- package/dist/src/interfaces/contextManager.interface.d.ts +86 -0
- package/dist/src/interfaces/contextManager.interface.d.ts.map +1 -0
- package/dist/src/interfaces/contextManager.interface.js +2 -0
- package/dist/src/interfaces/contextManager.interface.js.map +1 -0
- package/dist/src/interfaces/coreApiProvider.interface.d.ts +26 -0
- package/dist/src/interfaces/coreApiProvider.interface.d.ts.map +1 -0
- package/dist/src/interfaces/coreApiProvider.interface.js +2 -0
- package/dist/src/interfaces/coreApiProvider.interface.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +7 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +2 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/internal.d.ts +14 -0
- package/dist/src/internal.d.ts.map +1 -0
- package/dist/src/internal.js +14 -0
- package/dist/src/internal.js.map +1 -0
- package/dist/src/prompt/Prompt.d.ts +61 -0
- package/dist/src/prompt/Prompt.d.ts.map +1 -0
- package/dist/src/prompt/Prompt.js +118 -0
- package/dist/src/prompt/Prompt.js.map +1 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.d.ts +10 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.d.ts.map +1 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.js +13 -0
- package/dist/src/prompt/errors/PromptConfigurationConflict.js.map +1 -0
- package/dist/src/prompt/errors/index.d.ts +2 -0
- package/dist/src/prompt/errors/index.d.ts.map +1 -0
- package/dist/src/prompt/errors/index.js +2 -0
- package/dist/src/prompt/errors/index.js.map +1 -0
- package/dist/src/prompt/index.d.ts +4 -0
- package/dist/src/prompt/index.d.ts.map +1 -0
- package/dist/src/prompt/index.js +3 -0
- package/dist/src/prompt/index.js.map +1 -0
- package/dist/src/prompt/types.d.ts +57 -0
- package/dist/src/prompt/types.d.ts.map +1 -0
- package/dist/src/prompt/types.js +2 -0
- package/dist/src/prompt/types.js.map +1 -0
- package/dist/src/prompt/utils/cloneToolResult.d.ts +12 -0
- package/dist/src/prompt/utils/cloneToolResult.d.ts.map +1 -0
- package/dist/src/prompt/utils/cloneToolResult.js +28 -0
- package/dist/src/prompt/utils/cloneToolResult.js.map +1 -0
- package/dist/src/prompt/utils/deepClone.d.ts +9 -0
- package/dist/src/prompt/utils/deepClone.d.ts.map +1 -0
- package/dist/src/prompt/utils/deepClone.js +15 -0
- package/dist/src/prompt/utils/deepClone.js.map +1 -0
- package/dist/src/prompt/utils/index.d.ts +5 -0
- package/dist/src/prompt/utils/index.d.ts.map +1 -0
- package/dist/src/prompt/utils/index.js +5 -0
- package/dist/src/prompt/utils/index.js.map +1 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts +14 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.d.ts.map +1 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.js +22 -0
- package/dist/src/prompt/utils/normalizeTextPrompt.js.map +1 -0
- package/dist/src/prompt/utils/normalizeToolResult.d.ts +14 -0
- package/dist/src/prompt/utils/normalizeToolResult.d.ts.map +1 -0
- package/dist/src/prompt/utils/normalizeToolResult.js +27 -0
- package/dist/src/prompt/utils/normalizeToolResult.js.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts +35 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js +93 -0
- package/dist/src/providers/coreApiProvider/CoreApiProvider.js.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.d.ts +24 -0
- package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.js +2 -0
- package/dist/src/providers/coreApiProvider/CoreApiProviderConfig.js.map +1 -0
- package/dist/src/providers/coreApiProvider/RequestOptions.d.ts +10 -0
- package/dist/src/providers/coreApiProvider/RequestOptions.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/RequestOptions.js +2 -0
- package/dist/src/providers/coreApiProvider/RequestOptions.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts +10 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js +14 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiAuthenticationMissing.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.d.ts +9 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.js +19 -0
- package/dist/src/providers/coreApiProvider/errors/CoreApiMethodNotImplemented.js.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/index.d.ts +3 -0
- package/dist/src/providers/coreApiProvider/errors/index.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/errors/index.js +3 -0
- package/dist/src/providers/coreApiProvider/errors/index.js.map +1 -0
- package/dist/src/providers/coreApiProvider/index.d.ts +7 -0
- package/dist/src/providers/coreApiProvider/index.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/index.js +3 -0
- package/dist/src/providers/coreApiProvider/index.js.map +1 -0
- package/dist/src/providers/coreApiProvider/types.d.ts +7 -0
- package/dist/src/providers/coreApiProvider/types.d.ts.map +1 -0
- package/dist/src/providers/coreApiProvider/types.js +2 -0
- package/dist/src/providers/coreApiProvider/types.js.map +1 -0
- package/dist/src/providers/index.d.ts +2 -0
- package/dist/src/providers/index.d.ts.map +1 -0
- package/dist/src/providers/index.js +2 -0
- package/dist/src/providers/index.js.map +1 -0
- package/package.json +36 -5
- package/README.md +0 -3
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Wonderland
|
|
4
|
+
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
-
in the Software without restriction
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AsyncToolCheckerOptions, EventSubscription, PollingConfig } from "../interfaces/index.js";
|
|
2
|
+
import type { AwaitActionResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Provides high level tooling to monitor asynchronous Core API executions.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AsyncToolChecker {
|
|
7
|
+
private readonly coreApiProvider;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link AsyncToolChecker} instance.
|
|
10
|
+
*
|
|
11
|
+
* @param options Dependencies required to perform asynchronous checks.
|
|
12
|
+
*/
|
|
13
|
+
constructor(options: AsyncToolCheckerOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves the latest status for a specific tool execution.
|
|
16
|
+
*
|
|
17
|
+
* The method delegates the long polling request to the injected {@link ICoreApiProvider}
|
|
18
|
+
* and normalizes the resulting payload into an {@link AwaitActionResult} discriminated union
|
|
19
|
+
* to simplify downstream handling.
|
|
20
|
+
*
|
|
21
|
+
* @param params Parameters describing the tool execution to inspect.
|
|
22
|
+
*
|
|
23
|
+
* @returns Latest status returned by the Core API.
|
|
24
|
+
*/
|
|
25
|
+
check(params: AsyncToolCheckerCheckParams): Promise<AwaitActionResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Subscribes to status updates for a tool execution using a polling strategy.
|
|
28
|
+
*
|
|
29
|
+
* TODO: Implement polling orchestration and event dispatch once the execution
|
|
30
|
+
* checker workflow is defined.
|
|
31
|
+
*
|
|
32
|
+
* @param events Callback handlers invoked during the subscription lifecycle.
|
|
33
|
+
* @param pollingConfig Configuration that controls polling cadence and retries.
|
|
34
|
+
*
|
|
35
|
+
* @returns Subscription handle that allows callers to cancel the polling loop.
|
|
36
|
+
*/
|
|
37
|
+
subscribe<TPayload, TError>(params: AsyncToolCheckerCheckParams, events: AsyncCheckerEvents<TPayload, TError>, pollingConfig: PollingConfig): EventSubscription;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=AsyncToolChecker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolChecker.d.ts","sourceRoot":"","sources":["../../../src/asyncToolChecker/AsyncToolChecker.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EAEjB,aAAa,EAEhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIpD;;GAEG;AACH,qBAAa,gBAAgB;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmB;IAEnD;;;;OAIG;gBACgB,OAAO,EAAE,uBAAuB;IAInD;;;;;;;;;;OAUG;IACU,KAAK,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoBnF;;;;;;;;;;OAUG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAC7B,MAAM,EAAE,2BAA2B,EACnC,MAAM,EAAE,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC5C,aAAa,EAAE,aAAa,GAC7B,iBAAiB;CAqMvB"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { AsyncToolCheckerMaxRetriesExceeded, AsyncToolCheckerTimeout } from "./errors/index.js";
|
|
2
|
+
import { isErrorResponse, normalizeTimeout } from "./utils/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Provides high level tooling to monitor asynchronous Core API executions.
|
|
5
|
+
*/
|
|
6
|
+
export class AsyncToolChecker {
|
|
7
|
+
coreApiProvider;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new {@link AsyncToolChecker} instance.
|
|
10
|
+
*
|
|
11
|
+
* @param options Dependencies required to perform asynchronous checks.
|
|
12
|
+
*/
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.coreApiProvider = options.coreApiProvider;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the latest status for a specific tool execution.
|
|
18
|
+
*
|
|
19
|
+
* The method delegates the long polling request to the injected {@link ICoreApiProvider}
|
|
20
|
+
* and normalizes the resulting payload into an {@link AwaitActionResult} discriminated union
|
|
21
|
+
* to simplify downstream handling.
|
|
22
|
+
*
|
|
23
|
+
* @param params Parameters describing the tool execution to inspect.
|
|
24
|
+
*
|
|
25
|
+
* @returns Latest status returned by the Core API.
|
|
26
|
+
*/
|
|
27
|
+
async check(params) {
|
|
28
|
+
const response = await this.coreApiProvider.awaitTransaction({
|
|
29
|
+
toolName: params.toolName,
|
|
30
|
+
protocol: params.protocol,
|
|
31
|
+
args: params.descriptor,
|
|
32
|
+
});
|
|
33
|
+
if (isErrorResponse(response)) {
|
|
34
|
+
return {
|
|
35
|
+
isError: true,
|
|
36
|
+
error: response,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
isError: false,
|
|
41
|
+
response,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Subscribes to status updates for a tool execution using a polling strategy.
|
|
46
|
+
*
|
|
47
|
+
* TODO: Implement polling orchestration and event dispatch once the execution
|
|
48
|
+
* checker workflow is defined.
|
|
49
|
+
*
|
|
50
|
+
* @param events Callback handlers invoked during the subscription lifecycle.
|
|
51
|
+
* @param pollingConfig Configuration that controls polling cadence and retries.
|
|
52
|
+
*
|
|
53
|
+
* @returns Subscription handle that allows callers to cancel the polling loop.
|
|
54
|
+
*/
|
|
55
|
+
subscribe(params, events, pollingConfig) {
|
|
56
|
+
const intervalMs = normalizeTimeout(pollingConfig.interval);
|
|
57
|
+
const retryThresholdMs = normalizeTimeout(pollingConfig.retryThreshold);
|
|
58
|
+
const maxRetries = Math.max(0, Math.floor(pollingConfig.maxRetries));
|
|
59
|
+
const maxDurationSeconds = Math.max(0, pollingConfig.maxDuration);
|
|
60
|
+
const maxDurationMs = maxDurationSeconds > 0 ? normalizeTimeout(maxDurationSeconds) : undefined;
|
|
61
|
+
let retries = 0;
|
|
62
|
+
let isActive = true;
|
|
63
|
+
let previous = null;
|
|
64
|
+
let pollingTimer;
|
|
65
|
+
let maxDurationTimer;
|
|
66
|
+
let inFlightController = null;
|
|
67
|
+
const clearTimer = (timer) => {
|
|
68
|
+
if (timer !== undefined) {
|
|
69
|
+
clearTimeout(timer);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const finalize = (error, notifyError = error !== undefined) => {
|
|
73
|
+
if (!isActive) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
isActive = false;
|
|
77
|
+
clearTimer(pollingTimer);
|
|
78
|
+
pollingTimer = undefined;
|
|
79
|
+
clearTimer(maxDurationTimer);
|
|
80
|
+
maxDurationTimer = undefined;
|
|
81
|
+
if (inFlightController !== null) {
|
|
82
|
+
inFlightController.abort();
|
|
83
|
+
inFlightController = null;
|
|
84
|
+
}
|
|
85
|
+
if (notifyError && error !== undefined) {
|
|
86
|
+
events.onError?.(error);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
if (maxDurationMs !== undefined) {
|
|
90
|
+
maxDurationTimer = setTimeout(() => {
|
|
91
|
+
finalize(new AsyncToolCheckerTimeout(maxDurationSeconds));
|
|
92
|
+
}, maxDurationMs);
|
|
93
|
+
}
|
|
94
|
+
const emitStatus = (current) => {
|
|
95
|
+
if (!isActive) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
// Avoids duplicate notifications when no state transition occurred.
|
|
99
|
+
if (previous === current) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const event = {
|
|
103
|
+
previous,
|
|
104
|
+
current,
|
|
105
|
+
};
|
|
106
|
+
try {
|
|
107
|
+
events.onStatusChange(event);
|
|
108
|
+
}
|
|
109
|
+
catch (handlerError) {
|
|
110
|
+
finalize(handlerError);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
previous = current;
|
|
114
|
+
return true;
|
|
115
|
+
};
|
|
116
|
+
const scheduleNext = (delayMs) => {
|
|
117
|
+
if (!isActive) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
clearTimer(pollingTimer);
|
|
121
|
+
pollingTimer = setTimeout(() => {
|
|
122
|
+
pollingTimer = undefined;
|
|
123
|
+
void tick();
|
|
124
|
+
}, delayMs);
|
|
125
|
+
};
|
|
126
|
+
const handleRetryableError = (error) => {
|
|
127
|
+
retries += 1;
|
|
128
|
+
if (retries > maxRetries) {
|
|
129
|
+
finalize(new AsyncToolCheckerMaxRetriesExceeded(maxRetries, error));
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
scheduleNext(retryThresholdMs);
|
|
133
|
+
};
|
|
134
|
+
const handleSuccessResponse = (response) => {
|
|
135
|
+
retries = 0;
|
|
136
|
+
if (!emitStatus(response)) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (response.pollStatus === "pending") {
|
|
140
|
+
scheduleNext(intervalMs);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
finalize();
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Normalizes successful polling responses by preserving pending and completed states.
|
|
147
|
+
*/
|
|
148
|
+
const normalizeSuccessResponse = (response) => {
|
|
149
|
+
if (response.pollStatus !== "failed") {
|
|
150
|
+
return response;
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
...response,
|
|
154
|
+
error: response.error,
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
const tick = async () => {
|
|
158
|
+
if (!isActive) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const controller = new AbortController();
|
|
162
|
+
inFlightController = controller;
|
|
163
|
+
let response;
|
|
164
|
+
try {
|
|
165
|
+
response = await this.coreApiProvider.awaitTransaction({
|
|
166
|
+
toolName: params.toolName,
|
|
167
|
+
protocol: params.protocol,
|
|
168
|
+
args: params.descriptor,
|
|
169
|
+
}, { signal: controller.signal });
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
if (!isActive) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (controller.signal.aborted) {
|
|
176
|
+
finalize(undefined, false);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
finalize(error);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
if (inFlightController === controller) {
|
|
184
|
+
inFlightController = null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (!isActive) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (isErrorResponse(response)) {
|
|
191
|
+
const statusCode = response.statusCode;
|
|
192
|
+
if (statusCode === 400 || statusCode === 429) {
|
|
193
|
+
handleRetryableError(response);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
finalize(response);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
handleSuccessResponse(normalizeSuccessResponse(response));
|
|
200
|
+
};
|
|
201
|
+
void tick();
|
|
202
|
+
return {
|
|
203
|
+
unsubscribe: () => {
|
|
204
|
+
finalize(undefined, false);
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=AsyncToolChecker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolChecker.js","sourceRoot":"","sources":["../../../src/asyncToolChecker/AsyncToolChecker.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,kCAAkC,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErE;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACR,eAAe,CAAmB;IAEnD;;;;OAIG;IACH,YAAmB,OAAgC;QAC/C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IACnD,CAAC;IAED;;;;;;;;;;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UAAU,KAAK,GAAG,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;oBAC3C,oBAAoB,CAAC,QAAQ,CAAC,CAAC;oBAC/B,OAAO;gBACX,CAAC;gBAED,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACnB,OAAO;YACX,CAAC;YAED,qBAAqB,CACjB,wBAAwB,CAAC,QAAsD,CAAC,CACnF,CAAC;QACN,CAAC,CAAC;QAEF,KAAK,IAAI,EAAE,CAAC;QAEZ,OAAO;YACH,WAAW,EAAE,GAAS,EAAE;gBACpB,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LongPollingActionErrorResponse } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Error emitted when the async tool checker exhausts the configured retry attempts for recoverable errors.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AsyncToolCheckerMaxRetriesExceeded extends Error {
|
|
6
|
+
/**
|
|
7
|
+
* Number of retry attempts that were configured.
|
|
8
|
+
*/
|
|
9
|
+
readonly maxRetries: number;
|
|
10
|
+
/**
|
|
11
|
+
* Last error response received from the Core API.
|
|
12
|
+
*/
|
|
13
|
+
readonly lastError: LongPollingActionErrorResponse;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new {@link AsyncToolCheckerMaxRetriesExceeded} instance.
|
|
16
|
+
*
|
|
17
|
+
* @param maxRetries Maximum number of retries allowed before failing.
|
|
18
|
+
* @param lastError Last error emitted by the Core API.
|
|
19
|
+
* @param options Error options.
|
|
20
|
+
*/
|
|
21
|
+
constructor(maxRetries: number, lastError: LongPollingActionErrorResponse, options?: ErrorOptions);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=AsyncToolCheckerMaxRetriesExceeded.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerMaxRetriesExceeded.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;GAEG;AACH,qBAAa,kCAAmC,SAAQ,KAAK;IACzD;;OAEG;IACH,SAAgB,UAAU,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,SAAgB,SAAS,EAAE,8BAA8B,CAAC;IAE1D;;;;;;OAMG;gBAEC,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,8BAA8B,EACzC,OAAO,CAAC,EAAE,YAAY;CAU7B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when the async tool checker exhausts the configured retry attempts for recoverable errors.
|
|
3
|
+
*/
|
|
4
|
+
export class AsyncToolCheckerMaxRetriesExceeded extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Number of retry attempts that were configured.
|
|
7
|
+
*/
|
|
8
|
+
maxRetries;
|
|
9
|
+
/**
|
|
10
|
+
* Last error response received from the Core API.
|
|
11
|
+
*/
|
|
12
|
+
lastError;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new {@link AsyncToolCheckerMaxRetriesExceeded} instance.
|
|
15
|
+
*
|
|
16
|
+
* @param maxRetries Maximum number of retries allowed before failing.
|
|
17
|
+
* @param lastError Last error emitted by the Core API.
|
|
18
|
+
* @param options Error options.
|
|
19
|
+
*/
|
|
20
|
+
constructor(maxRetries, lastError, options) {
|
|
21
|
+
super(`Async tool checker exceeded maximum retry attempts (${maxRetries}).`, {
|
|
22
|
+
cause: lastError,
|
|
23
|
+
...options,
|
|
24
|
+
});
|
|
25
|
+
this.name = "AsyncToolCheckerMaxRetriesExceeded";
|
|
26
|
+
this.maxRetries = maxRetries;
|
|
27
|
+
this.lastError = lastError;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=AsyncToolCheckerMaxRetriesExceeded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerMaxRetriesExceeded.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerMaxRetriesExceeded.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,KAAK;IACzD;;OAEG;IACa,UAAU,CAAS;IAEnC;;OAEG;IACa,SAAS,CAAiC;IAE1D;;;;;;OAMG;IACH,YACI,UAAkB,EAClB,SAAyC,EACzC,OAAsB;QAEtB,KAAK,CAAC,uDAAuD,UAAU,IAAI,EAAE;YACzE,KAAK,EAAE,SAAS;YAChB,GAAG,OAAO;SACb,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,oCAAoC,CAAC;QACjD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when an {@link AsyncToolChecker} method is invoked prior to its implementation.
|
|
3
|
+
*/
|
|
4
|
+
export declare class AsyncToolCheckerMethodNotImplemented extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Additional context useful for debugging the method invocation.
|
|
7
|
+
*/
|
|
8
|
+
readonly context?: unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new {@link AsyncToolCheckerMethodNotImplemented} instance.
|
|
11
|
+
*
|
|
12
|
+
* @param methodName Name of the method that is not implemented.
|
|
13
|
+
* @param context Optional contextual information describing the invocation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(methodName: string, context?: unknown);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AsyncToolCheckerMethodNotImplemented.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerMethodNotImplemented.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,oCAAqC,SAAQ,KAAK;IAC3D;;OAEG;IACH,SAAgB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElC;;;;;OAKG;gBACgB,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;CAU3D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when an {@link AsyncToolChecker} method is invoked prior to its implementation.
|
|
3
|
+
*/
|
|
4
|
+
export class AsyncToolCheckerMethodNotImplemented extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Additional context useful for debugging the method invocation.
|
|
7
|
+
*/
|
|
8
|
+
context;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new {@link AsyncToolCheckerMethodNotImplemented} instance.
|
|
11
|
+
*
|
|
12
|
+
* @param methodName Name of the method that is not implemented.
|
|
13
|
+
* @param context Optional contextual information describing the invocation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(methodName, context) {
|
|
16
|
+
super(`AsyncToolChecker method "${methodName}" is not implemented.`);
|
|
17
|
+
this.name = "AsyncToolCheckerMethodNotImplemented";
|
|
18
|
+
if (context !== undefined) {
|
|
19
|
+
Object.defineProperty(this, "context", {
|
|
20
|
+
value: context,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=AsyncToolCheckerMethodNotImplemented.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerMethodNotImplemented.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerMethodNotImplemented.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,oCAAqC,SAAQ,KAAK;IAC3D;;OAEG;IACa,OAAO,CAAW;IAElC;;;;;OAKG;IACH,YAAmB,UAAkB,EAAE,OAAiB;QACpD,KAAK,CAAC,4BAA4B,UAAU,uBAAuB,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,sCAAsC,CAAC;QACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;gBACnC,KAAK,EAAE,OAAO;gBACd,UAAU,EAAE,IAAI;aACnB,CAAC,CAAC;QACP,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when an asynchronous polling operation exceeds the configured maximum duration.
|
|
3
|
+
*/
|
|
4
|
+
export declare class AsyncToolCheckerTimeout extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum duration, expressed in seconds, that was exceeded.
|
|
7
|
+
*/
|
|
8
|
+
readonly maxDuration: number;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new {@link AsyncToolCheckerTimeout} instance.
|
|
11
|
+
*
|
|
12
|
+
* @param maxDuration Maximum duration, in seconds, permitted for the polling loop.
|
|
13
|
+
* @param options Error options.
|
|
14
|
+
*/
|
|
15
|
+
constructor(maxDuration: number, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AsyncToolCheckerTimeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerTimeout.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerTimeout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAC9C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC;;;;;OAKG;gBACgB,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKjE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error emitted when an asynchronous polling operation exceeds the configured maximum duration.
|
|
3
|
+
*/
|
|
4
|
+
export class AsyncToolCheckerTimeout extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Maximum duration, expressed in seconds, that was exceeded.
|
|
7
|
+
*/
|
|
8
|
+
maxDuration;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new {@link AsyncToolCheckerTimeout} instance.
|
|
11
|
+
*
|
|
12
|
+
* @param maxDuration Maximum duration, in seconds, permitted for the polling loop.
|
|
13
|
+
* @param options Error options.
|
|
14
|
+
*/
|
|
15
|
+
constructor(maxDuration, options) {
|
|
16
|
+
super(`Async tool checker exceeded maximum duration of ${maxDuration} seconds.`, options);
|
|
17
|
+
this.name = "AsyncToolCheckerTimeout";
|
|
18
|
+
this.maxDuration = maxDuration;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=AsyncToolCheckerTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncToolCheckerTimeout.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/AsyncToolCheckerTimeout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC9C;;OAEG;IACa,WAAW,CAAS;IAEpC;;;;;OAKG;IACH,YAAmB,WAAmB,EAAE,OAAsB;QAC1D,KAAK,CAAC,mDAAmD,WAAW,WAAW,EAAE,OAAO,CAAC,CAAC;QAC1F,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AsyncToolCheckerMethodNotImplemented } from "./AsyncToolCheckerMethodNotImplemented.js";
|
|
2
|
+
export { AsyncToolCheckerTimeout } from "./AsyncToolCheckerTimeout.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded } from "./AsyncToolCheckerMaxRetriesExceeded.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AsyncToolCheckerMethodNotImplemented } from "./AsyncToolCheckerMethodNotImplemented.js";
|
|
2
|
+
export { AsyncToolCheckerTimeout } from "./AsyncToolCheckerTimeout.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded } from "./AsyncToolCheckerMaxRetriesExceeded.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,2CAA2C,CAAC;AACjG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,kCAAkC,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AsyncToolChecker } from "./AsyncToolChecker.js";
|
|
2
|
+
export type { AsyncCheckerEvents, AsyncToolCheckerCheckParams, AsyncToolCheckerOptions, EventSubscription, PollingConfig, StatusChangedEvent, } from "../interfaces/index.js";
|
|
3
|
+
export { AsyncToolCheckerMaxRetriesExceeded, AsyncToolCheckerMethodNotImplemented, AsyncToolCheckerTimeout, } from "./errors/index.js";
|
|
4
|
+
export * from "./types.js";
|
|
5
|
+
export * from "./utils/index.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/asyncToolChecker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EACR,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AsyncToolChecker } from "./AsyncToolChecker.js";
|
|
2
|
+
export { AsyncToolCheckerMaxRetriesExceeded, AsyncToolCheckerMethodNotImplemented, AsyncToolCheckerTimeout, } from "./errors/index.js";
|
|
3
|
+
export * from "./types.js";
|
|
4
|
+
export * from "./utils/index.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/asyncToolChecker/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AASzD,OAAO,EACH,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ActionStatus, BaseLongPollingArgs, LongPollingActionErrorResponse, LongPollingActionParams } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Descriptor containing parameters for an action whose execution can be awaited.
|
|
4
|
+
*/
|
|
5
|
+
export type AwaitableActionDescriptor<T extends BaseLongPollingArgs = BaseLongPollingArgs> = LongPollingActionParams<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Successful result emitted after awaiting a long running tool execution.
|
|
8
|
+
*/
|
|
9
|
+
export type AwaitActionSuccess<TPayload = unknown, TError = unknown> = {
|
|
10
|
+
readonly isError: false;
|
|
11
|
+
readonly response: ActionStatus<TPayload, TError>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Error result emitted when awaiting a long running tool execution fails.
|
|
15
|
+
*/
|
|
16
|
+
export type AwaitActionFailure = {
|
|
17
|
+
readonly isError: true;
|
|
18
|
+
readonly error: LongPollingActionErrorResponse;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Discriminated union representing the result of awaiting a long running tool execution.
|
|
22
|
+
*/
|
|
23
|
+
export type AwaitActionResult<TPayload = unknown, TError = unknown> = AwaitActionSuccess<TPayload, TError> | AwaitActionFailure;
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/asyncToolChecker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,YAAY,EACZ,mBAAmB,EACnB,8BAA8B,EAC9B,uBAAuB,EAC1B,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,IACrF,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI;IACnE,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CACrD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,8BAA8B,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,IAC5D,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,GACpC,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/asyncToolChecker/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LongPollingActionErrorResponse, LongPollingActionResponse } from "@illalabs/interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to determine if a long polling response represents an error state.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam TPayload - Payload type associated with successful responses.
|
|
6
|
+
* @param response Response from the Core API long polling endpoint.
|
|
7
|
+
*
|
|
8
|
+
* @returns True if the response contains an error, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isErrorResponse<TPayload = unknown>(response: LongPollingActionResponse<TPayload>): response is LongPollingActionErrorResponse;
|
|
11
|
+
//# sourceMappingURL=isErrorResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrorResponse.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/isErrorResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,8BAA8B,EAC9B,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAE9B;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,GAAG,OAAO,EAC9C,QAAQ,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAC9C,QAAQ,IAAI,8BAA8B,CAE5C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard to determine if a long polling response represents an error state.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam TPayload - Payload type associated with successful responses.
|
|
5
|
+
* @param response Response from the Core API long polling endpoint.
|
|
6
|
+
*
|
|
7
|
+
* @returns True if the response contains an error, false otherwise.
|
|
8
|
+
*/
|
|
9
|
+
export function isErrorResponse(response) {
|
|
10
|
+
return response.statusCode !== undefined;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=isErrorResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isErrorResponse.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/isErrorResponse.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC3B,QAA6C;IAE7C,OAAQ,QAA2C,CAAC,UAAU,KAAK,SAAS,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a timeout value expressed in seconds.
|
|
3
|
+
*
|
|
4
|
+
* @param value Timeout expressed in seconds.
|
|
5
|
+
*
|
|
6
|
+
* @returns Timeout converted to milliseconds. Values less than zero are coerced to zero.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeTimeout(value: number): number;
|
|
9
|
+
//# sourceMappingURL=normalizeTimeout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeTimeout.d.ts","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/normalizeTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMtD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes a timeout value expressed in seconds.
|
|
3
|
+
*
|
|
4
|
+
* @param value Timeout expressed in seconds.
|
|
5
|
+
*
|
|
6
|
+
* @returns Timeout converted to milliseconds. Values less than zero are coerced to zero.
|
|
7
|
+
*/
|
|
8
|
+
export function normalizeTimeout(value) {
|
|
9
|
+
if (!Number.isFinite(value)) {
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
return Math.max(0, value) * 1000;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=normalizeTimeout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeTimeout.js","sourceRoot":"","sources":["../../../../src/asyncToolChecker/utils/normalizeTimeout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC1C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,CAAC;IACb,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CacheEntryOptions, ICache } from "../interfaces/cache.interface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default cache implementation that keeps values in memory.
|
|
4
|
+
*/
|
|
5
|
+
export declare class InMemoryCache implements ICache {
|
|
6
|
+
private readonly store;
|
|
7
|
+
/** @inheritdoc */
|
|
8
|
+
get<TValue>(key: string): Promise<TValue | undefined>;
|
|
9
|
+
/** @inheritdoc */
|
|
10
|
+
set(key: string, value: unknown, options?: CacheEntryOptions): Promise<void>;
|
|
11
|
+
/** @inheritdoc */
|
|
12
|
+
del(key: string): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=InMemoryCache.d.ts.map
|