askui 0.20.8 → 0.20.9
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/dist/cjs/core/inference-response/model-type.d.ts +1 -1
- package/dist/cjs/core/model/custom-element.d.ts +5 -5
- package/dist/cjs/core/model/custom-element.js +2 -2
- package/dist/cjs/core/reporting/index.js +5 -1
- package/dist/cjs/core/reporting/snapshot-detail-level.d.ts +1 -1
- package/dist/cjs/core/reporting/snapshot-detail-level.js +1 -2
- package/dist/cjs/core/reporting/step-status-end.d.ts +1 -1
- package/dist/cjs/core/reporting/step-status.d.ts +1 -1
- package/dist/cjs/core/runner-protocol/index.js +5 -1
- package/dist/cjs/core/ui-control-commands/action.d.ts +1 -1
- package/dist/cjs/core/ui-control-commands/control-command-code.js +1 -1
- package/dist/cjs/core/ui-control-commands/input-event.js +1 -1
- package/dist/cjs/execution/dsl.d.ts +6 -6
- package/dist/cjs/execution/dsl.js +1 -1
- package/dist/cjs/execution/execution-runtime.d.ts +3 -2
- package/dist/cjs/execution/execution-runtime.js +8 -7
- package/dist/cjs/execution/index.d.ts +1 -0
- package/dist/cjs/execution/index.js +6 -1
- package/dist/cjs/execution/inference-client.js +8 -8
- package/dist/cjs/execution/misc.js +1 -2
- package/dist/cjs/execution/read-credentials.js +1 -2
- package/dist/cjs/execution/read-environment-credentials.js +1 -2
- package/dist/cjs/execution/retry-strategies/exponential-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/exponential-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/fixed-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/fixed-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/index.d.ts +4 -0
- package/dist/cjs/execution/retry-strategies/index.js +20 -0
- package/dist/cjs/execution/retry-strategies/linear-retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/linear-retry-strategy.js +25 -0
- package/dist/cjs/execution/retry-strategies/retry-strategy.d.ts +19 -0
- package/dist/cjs/execution/retry-strategies/retry-strategy.js +2 -0
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +6 -5
- package/dist/cjs/execution/ui-control-client.d.ts +3 -3
- package/dist/cjs/execution/ui-control-client.js +21 -15
- package/dist/cjs/execution/ui-controller-client-connection-state.js +1 -1
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +6 -0
- package/dist/cjs/execution/ui-controller-client.js +2 -1
- package/dist/cjs/lib/download-binaries.d.ts +0 -1
- package/dist/cjs/lib/download-binaries.js +3 -4
- package/dist/cjs/lib/interactive_cli/add-remove-script-package-json.js +2 -3
- package/dist/cjs/lib/interactive_cli/cli.js +1 -2
- package/dist/cjs/lib/logger.d.ts +1 -1
- package/dist/cjs/lib/ui-controller-args.js +2 -3
- package/dist/cjs/lib/ui-controller-facade.js +4 -4
- package/dist/cjs/main.js +5 -1
- package/dist/cjs/shared/log-levels.js +1 -1
- package/dist/cjs/shared/proxy-agent-args.d.ts +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +0 -1
- package/dist/cjs/utils/base_64_image/sharp.js +6 -3
- package/dist/cjs/utils/http/custom-errors/index.js +2 -2
- package/dist/cjs/utils/http/http-client-got.d.ts +0 -1
- package/dist/cjs/utils/http/http-client-got.js +2 -2
- package/dist/cjs/utils/path.js +1 -2
- package/dist/cjs/utils/proxy/proxy-builder.js +7 -3
- package/dist/cjs/utils/transformations.js +3 -4
- package/dist/esm/core/inference-response/model-type.d.ts +1 -1
- package/dist/esm/core/model/custom-element.d.ts +5 -5
- package/dist/esm/core/model/custom-element.js +2 -2
- package/dist/esm/core/reporting/snapshot-detail-level.d.ts +1 -1
- package/dist/esm/core/reporting/step-status-end.d.ts +1 -1
- package/dist/esm/core/reporting/step-status.d.ts +1 -1
- package/dist/esm/core/ui-control-commands/action.d.ts +1 -1
- package/dist/esm/execution/dsl.d.ts +6 -6
- package/dist/esm/execution/execution-runtime.d.ts +3 -2
- package/dist/esm/execution/execution-runtime.js +8 -7
- package/dist/esm/execution/index.d.ts +1 -0
- package/dist/esm/execution/index.js +1 -0
- package/dist/esm/execution/inference-client.js +8 -8
- package/dist/esm/execution/retry-strategies/exponential-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/exponential-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/fixed-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/fixed-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/index.d.ts +4 -0
- package/dist/esm/execution/retry-strategies/index.js +4 -0
- package/dist/esm/execution/retry-strategies/linear-retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/linear-retry-strategy.js +21 -0
- package/dist/esm/execution/retry-strategies/retry-strategy.d.ts +19 -0
- package/dist/esm/execution/retry-strategies/retry-strategy.js +1 -0
- package/dist/esm/execution/ui-control-client-dependency-builder.js +6 -5
- package/dist/esm/execution/ui-control-client.d.ts +3 -3
- package/dist/esm/execution/ui-control-client.js +21 -15
- package/dist/esm/execution/ui-controller-client-interface.d.ts +6 -0
- package/dist/esm/execution/ui-controller-client.js +2 -1
- package/dist/esm/lib/download-binaries.d.ts +0 -1
- package/dist/esm/lib/logger.d.ts +1 -1
- package/dist/esm/lib/ui-controller-facade.js +4 -4
- package/dist/esm/shared/proxy-agent-args.d.ts +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +0 -1
- package/dist/esm/utils/http/http-client-got.d.ts +0 -1
- package/dist/esm/utils/http/http-client-got.js +2 -2
- package/dist/esm/utils/transformations.js +2 -2
- package/package.json +28 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ModelType = 'DETECTED_ELEMENTS' | 'COMMANDS';
|
|
@@ -5,16 +5,16 @@ export declare class CustomElement implements CustomElementJson {
|
|
|
5
5
|
threshold?: number | undefined;
|
|
6
6
|
stopThreshold?: number | undefined;
|
|
7
7
|
rotationDegreePerStep?: number | undefined;
|
|
8
|
-
imageCompareFormat?: "RGB" | "grayscale" | "edges" | undefined;
|
|
9
|
-
mask?: {
|
|
8
|
+
imageCompareFormat?: ("RGB" | "grayscale" | "edges") | undefined;
|
|
9
|
+
mask?: ({
|
|
10
10
|
x: number;
|
|
11
11
|
y: number;
|
|
12
|
-
}[] | undefined;
|
|
12
|
+
})[] | undefined;
|
|
13
13
|
private static schema;
|
|
14
|
-
constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, stopThreshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "RGB" | "grayscale" | "edges" | undefined, mask?: {
|
|
14
|
+
constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, stopThreshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: ("RGB" | "grayscale" | "edges") | undefined, mask?: ({
|
|
15
15
|
x: number;
|
|
16
16
|
y: number;
|
|
17
|
-
}[] | undefined);
|
|
17
|
+
})[] | undefined);
|
|
18
18
|
static fromJsonListWithImagePathOrImage(ceJson?: CustomElementJson[]): Promise<CustomElement[]>;
|
|
19
19
|
static fromJsonWithImagePathOrImage(ceJson: CustomElementJson): Promise<CustomElement>;
|
|
20
20
|
static fromJson(ceJson: CustomElementJson): CustomElement;
|
|
@@ -22,8 +22,8 @@ class CustomElement {
|
|
|
22
22
|
this.imageCompareFormat = imageCompareFormat;
|
|
23
23
|
this.mask = mask;
|
|
24
24
|
}
|
|
25
|
-
static fromJsonListWithImagePathOrImage(
|
|
26
|
-
return __awaiter(this,
|
|
25
|
+
static fromJsonListWithImagePathOrImage() {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* (ceJson = []) {
|
|
27
27
|
return Promise.all(ceJson.map((customElement) => CustomElement.fromJsonWithImagePathOrImage(customElement)));
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxSnapshotDetailLevel =
|
|
3
|
+
exports.maxSnapshotDetailLevel = maxSnapshotDetailLevel;
|
|
4
4
|
const levelsOrdered = ['required', 'onFailure', 'begin', 'always'];
|
|
5
5
|
const levelValues = levelsOrdered.reduce((acc, level, index) => (Object.assign(Object.assign({}, acc), { [level]: index })), {});
|
|
6
6
|
function maxSnapshotDetailLevel(...levels) {
|
|
7
7
|
var _a;
|
|
8
8
|
return (_a = levelsOrdered[Math.max(...levels.map((level) => levelValues[level]))]) !== null && _a !== void 0 ? _a : 'required';
|
|
9
9
|
}
|
|
10
|
-
exports.maxSnapshotDetailLevel = maxSnapshotDetailLevel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type StepStatusEnd = 'passed' | 'failed' | 'erroneous';
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
* e.g., the user has no usage left, response of inference backend cannot be processed,
|
|
11
11
|
* e.g., because lib version is outdated, etc. (currently not supported, everything "failed")
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type StepStatus = 'passed' | 'failed' | 'pending' | 'running' | 'erroneous';
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -6,4 +6,4 @@ var ControlCommandCode;
|
|
|
6
6
|
ControlCommandCode["ERROR"] = "ERROR";
|
|
7
7
|
ControlCommandCode["WARNING"] = "WARNING";
|
|
8
8
|
ControlCommandCode["OK"] = "OK";
|
|
9
|
-
})(ControlCommandCode
|
|
9
|
+
})(ControlCommandCode || (exports.ControlCommandCode = ControlCommandCode = {}));
|
|
@@ -21,4 +21,4 @@ var InputEvent;
|
|
|
21
21
|
InputEvent["MOUSE_DOWN"] = "MOUSE_DOWN";
|
|
22
22
|
InputEvent["MOUSE_UP"] = "MOUSE_UP";
|
|
23
23
|
InputEvent["EXECUTE_COMMAND"] = "EXECUTE_COMMAND";
|
|
24
|
-
})(InputEvent
|
|
24
|
+
})(InputEvent || (exports.InputEvent = InputEvent = {}));
|
|
@@ -3,12 +3,12 @@ import { DetectedElement } from '../core/model/annotation-result/detected-elemen
|
|
|
3
3
|
export declare enum Separators {
|
|
4
4
|
STRING = "<|string|>"
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
6
|
+
export type INTERSECTION_AREA = 'element_center_line' | 'element_edge_area' | 'display_edge_area';
|
|
7
|
+
export type PC_KEY = 'backspace' | 'delete' | 'enter' | 'tab' | 'escape' | 'up' | 'down' | 'right' | 'left' | 'home' | 'end' | 'pageup' | 'pagedown' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'space' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '!' | '"' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~ ';
|
|
8
|
+
export type ANDROID_KEY = 'home' | 'back' | 'call' | 'endcall' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'star' | 'pound' | 'dpad_up' | 'dpad_down' | 'dpad_left' | 'dpad_right' | 'dpad_center' | 'volume_up' | 'volume_down' | 'power' | 'camera' | 'clear' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'comma' | 'period' | 'alt_left' | 'alt_right' | 'shift_left' | 'shift_right' | 'tab' | 'space' | 'sym' | 'explorer' | 'envelope' | 'enter' | 'del' | 'grave' | 'minus' | 'equals' | 'left_bracket' | 'right_bracket' | 'backslash' | 'semicolon' | 'apostrophe' | 'slash' | 'at' | 'num' | 'headsethook' | 'focus' | 'plus' | 'menu' | 'notification' | 'search' | 'media_play_pause' | 'media_stop' | 'media_next' | 'media_previous' | 'media_rewind' | 'media_fast_forward' | 'mute' | 'page_up' | 'page_down' | 'switch_charset' | 'escape' | 'forward_del' | 'ctrl_left' | 'ctrl_right' | 'caps_lock' | 'scroll_lock' | 'function' | 'break' | 'move_home' | 'move_end' | 'insert' | 'forward' | 'media_play' | 'media_pause' | 'media_close' | 'media_eject' | 'media_record' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'num_lock' | 'numpad_0' | 'numpad_1' | 'numpad_2' | 'numpad_3' | 'numpad_4' | 'numpad_5' | 'numpad_6' | 'numpad_7' | 'numpad_8' | 'numpad_9' | 'numpad_divide' | 'numpad_multiply' | 'numpad_subtract' | 'numpad_add' | 'numpad_dot' | 'numpad_comma' | 'numpad_enter' | 'numpad_equals' | 'numpad_left_paren' | 'numpad_right_paren' | 'volume_mute' | 'info' | 'channel_up' | 'channel_down' | 'zoom_in' | 'zoom_out' | 'window' | 'guide' | 'bookmark' | 'captions' | 'settings' | 'app_switch' | 'language_switch' | 'contacts' | 'calendar' | 'music' | 'calculator' | 'assist' | 'brightness_down' | 'brightness_up' | 'media_audio_track' | 'sleep' | 'wakeup' | 'pairing' | 'media_top_menu' | 'last_channel' | 'tv_data_service' | 'voice_assist' | 'help' | 'navigate_previous' | 'navigate_next' | 'navigate_in' | 'navigate_out' | 'dpad_up_left' | 'dpad_down_left' | 'dpad_up_right' | 'dpad_down_right' | 'media_skip_forward' | 'media_skip_backward' | 'media_step_forward' | 'media_step_backward' | 'soft_sleep' | 'cut' | 'copy' | 'paste' | 'all_apps' | 'refresh';
|
|
9
|
+
export type MODIFIER_KEY = 'command' | 'alt' | 'control' | 'shift' | 'right_shift';
|
|
10
|
+
export type COLOR = 'black' | 'white' | 'red' | 'green' | 'yellow green' | 'orange' | 'yellow' | 'purple' | 'pink' | 'gray' | 'lime green' | 'royal blue';
|
|
11
|
+
export type PC_AND_MODIFIER_KEY = 'command' | 'alt' | 'control' | 'shift' | 'right_shift' | 'backspace' | 'delete' | 'enter' | 'tab' | 'escape' | 'up' | 'down' | 'right' | 'left' | 'home' | 'end' | 'pageup' | 'pagedown' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'space' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '!' | '"' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~ ';
|
|
12
12
|
export interface CommandExecutorContext {
|
|
13
13
|
customElementsJson: CustomElementJson[];
|
|
14
14
|
aiElementNames: string[];
|
|
@@ -36,7 +36,7 @@ function rewriteStackTraceForError(error, newStackTrace) {
|
|
|
36
36
|
var Separators;
|
|
37
37
|
(function (Separators) {
|
|
38
38
|
Separators["STRING"] = "<|string|>";
|
|
39
|
-
})(Separators
|
|
39
|
+
})(Separators || (exports.Separators = Separators = {}));
|
|
40
40
|
class FluentBase {
|
|
41
41
|
constructor(prev) {
|
|
42
42
|
this.prev = prev;
|
|
@@ -5,11 +5,13 @@ import { CustomElementJson } from '../core/model/custom-element-json';
|
|
|
5
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
6
|
import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
|
|
7
7
|
import { Instruction, StepReporter } from '../core/reporting';
|
|
8
|
+
import { RetryStrategy } from './retry-strategies/retry-strategy';
|
|
8
9
|
export declare class ExecutionRuntime {
|
|
9
10
|
private uiControllerClient;
|
|
10
11
|
private inferenceClient;
|
|
11
12
|
private stepReporter;
|
|
12
|
-
|
|
13
|
+
private retryStrategy;
|
|
14
|
+
constructor(uiControllerClient: UiControllerClient, inferenceClient: InferenceClient, stepReporter: StepReporter, retryStrategy: RetryStrategy);
|
|
13
15
|
connect(): Promise<UiControllerClientConnectionState>;
|
|
14
16
|
disconnect(): void;
|
|
15
17
|
startVideoRecording(): Promise<void>;
|
|
@@ -19,7 +21,6 @@ export declare class ExecutionRuntime {
|
|
|
19
21
|
executeInstruction(instruction: Instruction): Promise<void>;
|
|
20
22
|
private readonly EXEC_REPETITION_COUNT;
|
|
21
23
|
private executeCommandRepeatedly;
|
|
22
|
-
private readonly PREDICT_COMMAND_RETRY_COUNT;
|
|
23
24
|
/**
|
|
24
25
|
* Command prediction may fail, e.g., due to application still loading
|
|
25
26
|
* --> retry with linear back-off
|
|
@@ -19,12 +19,12 @@ const annotation_1 = require("../core/annotation/annotation");
|
|
|
19
19
|
const logger_1 = require("../lib/logger");
|
|
20
20
|
const base_64_image_1 = require("../utils/base_64_image/base-64-image");
|
|
21
21
|
class ExecutionRuntime {
|
|
22
|
-
constructor(uiControllerClient, inferenceClient, stepReporter) {
|
|
22
|
+
constructor(uiControllerClient, inferenceClient, stepReporter, retryStrategy) {
|
|
23
23
|
this.uiControllerClient = uiControllerClient;
|
|
24
24
|
this.inferenceClient = inferenceClient;
|
|
25
25
|
this.stepReporter = stepReporter;
|
|
26
|
+
this.retryStrategy = retryStrategy;
|
|
26
27
|
this.EXEC_REPETITION_COUNT = 25;
|
|
27
|
-
this.PREDICT_COMMAND_RETRY_COUNT = 2;
|
|
28
28
|
}
|
|
29
29
|
connect() {
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,8 +56,8 @@ class ExecutionRuntime {
|
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
executeInstruction(instruction) {
|
|
59
|
-
var _a, _b, _c;
|
|
60
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
var _a, _b, _c;
|
|
61
61
|
const controlCommand = yield this.predictCommandWithRetry(instruction);
|
|
62
62
|
if (controlCommand.code === ui_control_commands_1.ControlCommandCode.OK) {
|
|
63
63
|
return this.requestControl(controlCommand);
|
|
@@ -70,8 +70,8 @@ class ExecutionRuntime {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
executeCommandRepeatedly(instruction) {
|
|
73
|
-
var _a, _b, _c;
|
|
74
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
var _a, _b, _c;
|
|
75
75
|
/* eslint-disable no-await-in-loop */
|
|
76
76
|
for (let repeatCount = this.EXEC_REPETITION_COUNT; repeatCount >= 0; repeatCount -= 1) {
|
|
77
77
|
if (repeatCount === 0) {
|
|
@@ -90,6 +90,7 @@ class ExecutionRuntime {
|
|
|
90
90
|
throw new control_command_error_1.ControlCommandError((_c = (_b = (_a = controlCommand.actions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : '');
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
/* eslint-enable no-await-in-loop */
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
@@ -98,15 +99,15 @@ class ExecutionRuntime {
|
|
|
98
99
|
*/
|
|
99
100
|
/* eslint-disable-next-line consistent-return */
|
|
100
101
|
predictCommandWithRetry(instruction) {
|
|
101
|
-
var _a, _b, _c;
|
|
102
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
var _a, _b, _c;
|
|
103
104
|
let command = yield this.predictCommand(instruction);
|
|
104
105
|
/* eslint-disable no-await-in-loop */
|
|
105
|
-
for (let k = 0; k < this.
|
|
106
|
+
for (let k = 0; k < this.retryStrategy.retryCount; k += 1) {
|
|
106
107
|
if (command.code === ui_control_commands_1.ControlCommandCode.OK) {
|
|
107
108
|
return command;
|
|
108
109
|
}
|
|
109
|
-
const msUntilRetry = k
|
|
110
|
+
const msUntilRetry = this.retryStrategy.getDelay(k + 1);
|
|
110
111
|
logger_1.logger.debug(`Wait ${msUntilRetry} and retry predicting command...`);
|
|
111
112
|
yield (0, misc_1.delay)(msUntilRetry);
|
|
112
113
|
command = yield this.predictCommand(instruction, new control_command_error_1.ControlCommandError((_c = (_b = (_a = command.actions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.text) !== null && _c !== void 0 ? _c : ''));
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -11,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./ui-control-client"), exports);
|
|
18
|
+
__exportStar(require("./retry-strategies"), exports);
|
|
@@ -60,8 +60,8 @@ class InferenceClient {
|
|
|
60
60
|
return (0, transformations_1.resizeBase64ImageWithSameRatio)(image, this.resize);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
inference(
|
|
64
|
-
return __awaiter(this,
|
|
63
|
+
inference() {
|
|
64
|
+
return __awaiter(this, arguments, void 0, function* (customElements = [], image, instruction) {
|
|
65
65
|
const resizedImage = yield this.resizeIfNeeded(customElements, image);
|
|
66
66
|
const response = yield this.httpClient.post(this.urls.inference, this.urls.inference.includes('v4-experimental') ? {
|
|
67
67
|
image: resizedImage.base64Image,
|
|
@@ -94,8 +94,8 @@ class InferenceClient {
|
|
|
94
94
|
logger_1.logger.warn(response.headers['askui-usage-warnings']);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
predictControlCommand(
|
|
98
|
-
return __awaiter(this,
|
|
97
|
+
predictControlCommand(instruction_1) {
|
|
98
|
+
return __awaiter(this, arguments, void 0, function* (instruction, customElements = [], image) {
|
|
99
99
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
100
100
|
if (!(inferenceResponse instanceof ui_control_commands_1.ControlCommand)) {
|
|
101
101
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Can not execute command');
|
|
@@ -103,8 +103,8 @@ class InferenceClient {
|
|
|
103
103
|
return inferenceResponse;
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
getDetectedElements(
|
|
107
|
-
return __awaiter(this,
|
|
106
|
+
getDetectedElements(instruction_1, image_1) {
|
|
107
|
+
return __awaiter(this, arguments, void 0, function* (instruction, image, customElements = []) {
|
|
108
108
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
109
109
|
if (!(inferenceResponse instanceof annotation_1.Annotation)) {
|
|
110
110
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Unable to get the detected elements');
|
|
@@ -112,8 +112,8 @@ class InferenceClient {
|
|
|
112
112
|
return inferenceResponse.detected_elements;
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
|
-
predictImageAnnotation(
|
|
116
|
-
return __awaiter(this,
|
|
115
|
+
predictImageAnnotation(image_1) {
|
|
116
|
+
return __awaiter(this, arguments, void 0, function* (image, customElements = []) {
|
|
117
117
|
const inferenceResponse = yield this.inference(customElements, image);
|
|
118
118
|
if (!(inferenceResponse instanceof annotation_1.Annotation)) {
|
|
119
119
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Can not execute annotation');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readCredentials =
|
|
3
|
+
exports.readCredentials = readCredentials;
|
|
4
4
|
const lib_1 = require("../lib");
|
|
5
5
|
const read_environment_credentials_1 = require("./read-environment-credentials");
|
|
6
6
|
function readCredentials(clientArgs) {
|
|
@@ -21,4 +21,3 @@ function readCredentials(clientArgs) {
|
|
|
21
21
|
}
|
|
22
22
|
return credentials;
|
|
23
23
|
}
|
|
24
|
-
exports.readCredentials = readCredentials;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.envCredentials =
|
|
3
|
+
exports.envCredentials = envCredentials;
|
|
4
4
|
const lib_1 = require("../lib");
|
|
5
5
|
function envCredentials() {
|
|
6
6
|
const envToken = process.env['ASKUI_TOKEN'];
|
|
@@ -14,4 +14,3 @@ function envCredentials() {
|
|
|
14
14
|
}
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
-
exports.envCredentials = envCredentials;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RetryStrategy } from './retry-strategy';
|
|
2
|
+
/**
|
|
3
|
+
* ExponentialRetryStrategy implements a retry strategy that uses an exponential backoff algorithm.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ExponentialRetryStrategy implements RetryStrategy {
|
|
6
|
+
baseDelayMs: number;
|
|
7
|
+
retryCount: number;
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs?: number, retryCount?: number);
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the delay for a given retry attempt using exponential backoff.
|
|
15
|
+
* @param attempt - The current retry attempt number (0-based)
|
|
16
|
+
* @returns The delay in milliseconds for the current attempt
|
|
17
|
+
*/
|
|
18
|
+
getDelay(attempt: number): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExponentialRetryStrategy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ExponentialRetryStrategy implements a retry strategy that uses an exponential backoff algorithm.
|
|
6
|
+
*/
|
|
7
|
+
class ExponentialRetryStrategy {
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
13
|
+
this.baseDelayMs = baseDelayMs;
|
|
14
|
+
this.retryCount = retryCount;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Calculates the delay for a given retry attempt using exponential backoff.
|
|
18
|
+
* @param attempt - The current retry attempt number (0-based)
|
|
19
|
+
* @returns The delay in milliseconds for the current attempt
|
|
20
|
+
*/
|
|
21
|
+
getDelay(attempt) {
|
|
22
|
+
return this.baseDelayMs * (Math.pow(2, attempt));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ExponentialRetryStrategy = ExponentialRetryStrategy;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RetryStrategy } from './retry-strategy';
|
|
2
|
+
/**
|
|
3
|
+
* FixedRetryStrategy implements a retry strategy that uses a constant delay for each retry attempt.
|
|
4
|
+
*/
|
|
5
|
+
export declare class FixedRetryStrategy implements RetryStrategy {
|
|
6
|
+
baseDelayMs: number;
|
|
7
|
+
retryCount: number;
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The constant delay before each retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs?: number, retryCount?: number);
|
|
13
|
+
/**
|
|
14
|
+
* Returns the fixed delay for each retry attempt.
|
|
15
|
+
* @param _attempt - The current retry attempt number (not used in this strategy)
|
|
16
|
+
* @returns The fixed delay in milliseconds for the current attempt
|
|
17
|
+
*/
|
|
18
|
+
getDelay(_attempt: number): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FixedRetryStrategy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* FixedRetryStrategy implements a retry strategy that uses a constant delay for each retry attempt.
|
|
6
|
+
*/
|
|
7
|
+
class FixedRetryStrategy {
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The constant delay before each retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
13
|
+
this.baseDelayMs = baseDelayMs;
|
|
14
|
+
this.retryCount = retryCount;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the fixed delay for each retry attempt.
|
|
18
|
+
* @param _attempt - The current retry attempt number (not used in this strategy)
|
|
19
|
+
* @returns The fixed delay in milliseconds for the current attempt
|
|
20
|
+
*/
|
|
21
|
+
getDelay(_attempt) {
|
|
22
|
+
return this.baseDelayMs;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.FixedRetryStrategy = FixedRetryStrategy;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./exponential-retry-strategy"), exports);
|
|
18
|
+
__exportStar(require("./linear-retry-strategy"), exports);
|
|
19
|
+
__exportStar(require("./fixed-retry-strategy"), exports);
|
|
20
|
+
__exportStar(require("./retry-strategy"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RetryStrategy } from './retry-strategy';
|
|
2
|
+
/**
|
|
3
|
+
* LinearRetryStrategy implements a retry strategy that uses a linear backoff algorithm.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LinearRetryStrategy implements RetryStrategy {
|
|
6
|
+
baseDelayMs: number;
|
|
7
|
+
retryCount: number;
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs?: number, retryCount?: number);
|
|
13
|
+
/**
|
|
14
|
+
* Calculates the delay for a given retry attempt using linear backoff.
|
|
15
|
+
* @param attempt - The current retry attempt number (1-based)
|
|
16
|
+
* @returns The delay in milliseconds for the current attempt
|
|
17
|
+
*/
|
|
18
|
+
getDelay(attempt: number): number;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LinearRetryStrategy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* LinearRetryStrategy implements a retry strategy that uses a linear backoff algorithm.
|
|
6
|
+
*/
|
|
7
|
+
class LinearRetryStrategy {
|
|
8
|
+
/**
|
|
9
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
10
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
11
|
+
*/
|
|
12
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
13
|
+
this.baseDelayMs = baseDelayMs;
|
|
14
|
+
this.retryCount = retryCount;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Calculates the delay for a given retry attempt using linear backoff.
|
|
18
|
+
* @param attempt - The current retry attempt number (1-based)
|
|
19
|
+
* @returns The delay in milliseconds for the current attempt
|
|
20
|
+
*/
|
|
21
|
+
getDelay(attempt) {
|
|
22
|
+
return this.baseDelayMs * attempt;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.LinearRetryStrategy = LinearRetryStrategy;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface representing a retry strategy for operations.
|
|
3
|
+
*/
|
|
4
|
+
export interface RetryStrategy {
|
|
5
|
+
/**
|
|
6
|
+
* The base delay in milliseconds before the first retry.
|
|
7
|
+
*/
|
|
8
|
+
baseDelayMs: number;
|
|
9
|
+
/**
|
|
10
|
+
* The maximum number of retry attempts.
|
|
11
|
+
*/
|
|
12
|
+
retryCount: number;
|
|
13
|
+
/**
|
|
14
|
+
* Function to calculate the delay before the next retry attempt.
|
|
15
|
+
* @param attempt - The current retry attempt number (0-based).
|
|
16
|
+
* @returns The delay in milliseconds for the next retry.
|
|
17
|
+
*/
|
|
18
|
+
getDelay(attempt: number): number;
|
|
19
|
+
}
|
|
@@ -22,10 +22,11 @@ const proxy_builder_1 = require("../utils/proxy/proxy-builder");
|
|
|
22
22
|
const execution_runtime_1 = require("./execution-runtime");
|
|
23
23
|
const reporting_1 = require("../core/reporting");
|
|
24
24
|
const read_credentials_1 = require("./read-credentials");
|
|
25
|
+
const linear_retry_strategy_1 = require("./retry-strategies/linear-retry-strategy");
|
|
25
26
|
class UiControlClientDependencyBuilder {
|
|
26
27
|
static buildHttpClient(clientArgs) {
|
|
27
|
-
var _a;
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a;
|
|
29
30
|
const analytics = new analytics_1.Analytics();
|
|
30
31
|
const analyticsHeaders = yield analytics.getAnalyticsHeaders(clientArgs.context);
|
|
31
32
|
const analyticsCookies = yield analytics.getAnalyticsCookies();
|
|
@@ -33,8 +34,8 @@ class UiControlClientDependencyBuilder {
|
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
static buildInferenceClient(clientArgs) {
|
|
36
|
-
var _a;
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a;
|
|
38
39
|
const httpClient = yield UiControlClientDependencyBuilder.buildHttpClient(clientArgs);
|
|
39
40
|
return new inference_client_1.InferenceClient(clientArgs.inferenceServerUrl, httpClient, clientArgs.resize, (_a = clientArgs.credentials) === null || _a === void 0 ? void 0 : _a.workspaceId, clientArgs.modelComposition, clientArgs.inferenceServerApiVersion);
|
|
40
41
|
});
|
|
@@ -43,22 +44,22 @@ class UiControlClientDependencyBuilder {
|
|
|
43
44
|
return new ui_controller_client_1.UiControllerClient(clientArgs.uiControllerUrl);
|
|
44
45
|
}
|
|
45
46
|
static build(clientArgs) {
|
|
46
|
-
var _a;
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
var _a, _b;
|
|
48
49
|
const uiControllerClient = UiControlClientDependencyBuilder.buildUiControllerClient(clientArgs);
|
|
49
50
|
const inferenceClient = yield UiControlClientDependencyBuilder.buildInferenceClient(clientArgs);
|
|
50
51
|
const stepReporter = new reporting_1.StepReporter(clientArgs.reporter);
|
|
51
52
|
const workspaceId = (_a = clientArgs.credentials) === null || _a === void 0 ? void 0 : _a.workspaceId;
|
|
52
53
|
return {
|
|
53
|
-
executionRuntime: new execution_runtime_1.ExecutionRuntime(uiControllerClient, inferenceClient, stepReporter),
|
|
54
|
+
executionRuntime: new execution_runtime_1.ExecutionRuntime(uiControllerClient, inferenceClient, stepReporter, (_b = clientArgs.retryStrategy) !== null && _b !== void 0 ? _b : new linear_retry_strategy_1.LinearRetryStrategy()),
|
|
54
55
|
stepReporter,
|
|
55
56
|
workspaceId,
|
|
56
57
|
};
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
static getClientArgsWithDefaults(clientArgs) {
|
|
60
|
-
var _a, _b, _c, _d, _e, _f;
|
|
61
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
62
63
|
return Object.assign(Object.assign({}, clientArgs), { context: {
|
|
63
64
|
isCi: (_b = (_a = clientArgs.context) === null || _a === void 0 ? void 0 : _a.isCi) !== null && _b !== void 0 ? _b : is_ci_1.default,
|
|
64
65
|
}, credentials: (0, read_credentials_1.readCredentials)(clientArgs), inferenceServerApiVersion: (_c = clientArgs.inferenceServerApiVersion) !== null && _c !== void 0 ? _c : 'v3', inferenceServerUrl: (_d = clientArgs.inferenceServerUrl) !== null && _d !== void 0 ? _d : 'https://inference.askui.com', proxyAgents: (_e = clientArgs.proxyAgents) !== null && _e !== void 0 ? _e : (yield (0, proxy_builder_1.envProxyAgents)()), uiControllerUrl: (_f = clientArgs.uiControllerUrl) !== null && _f !== void 0 ? _f : 'http://127.0.0.1:6769' });
|