askui 0.20.7 → 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/inference-response.d.ts +5 -0
- 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 +4 -2
- package/dist/cjs/execution/execution-runtime.js +14 -7
- package/dist/cjs/execution/index.d.ts +1 -0
- package/dist/cjs/execution/index.js +6 -1
- package/dist/cjs/execution/inference-client.d.ts +3 -0
- package/dist/cjs/execution/inference-client.js +33 -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 +92 -3
- package/dist/cjs/execution/ui-control-client.js +115 -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/inference-response.d.ts +5 -0
- 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 +4 -2
- package/dist/esm/execution/execution-runtime.js +14 -7
- package/dist/esm/execution/index.d.ts +1 -0
- package/dist/esm/execution/index.js +1 -0
- package/dist/esm/execution/inference-client.d.ts +3 -0
- package/dist/esm/execution/inference-client.js +33 -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 +92 -3
- package/dist/esm/execution/ui-control-client.js +115 -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
|
@@ -5,6 +5,11 @@ export interface InferenceResponseBody {
|
|
|
5
5
|
type: ModelType;
|
|
6
6
|
data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation;
|
|
7
7
|
}
|
|
8
|
+
export interface VQAInferenceResponseBody {
|
|
9
|
+
data: {
|
|
10
|
+
response: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
8
13
|
export declare class InferenceResponse {
|
|
9
14
|
static fromJson(json: InferenceResponseBody, resizeRatio?: number, image?: string): ControlCommand | Annotation;
|
|
10
15
|
static createModels(type: ModelType, data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation, resizeRatio: number, image?: string): ControlCommand | Annotation;
|
|
@@ -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
|
|
@@ -35,4 +36,5 @@ export declare class ExecutionRuntime {
|
|
|
35
36
|
takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
|
|
36
37
|
getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
|
|
37
38
|
annotateImage(imagePath?: string, customElementJson?: CustomElementJson[], elements?: DetectedElement[]): Promise<Annotation>;
|
|
39
|
+
predictVQA(prompt: string, config?: object): Promise<any>;
|
|
38
40
|
}
|
|
@@ -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 : ''));
|
|
@@ -208,5 +209,11 @@ class ExecutionRuntime {
|
|
|
208
209
|
return this.inferenceClient.predictImageAnnotation(base64Image, customElements);
|
|
209
210
|
});
|
|
210
211
|
}
|
|
212
|
+
predictVQA(prompt, config) {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
const base64Image = yield this.takeScreenshotIfImageisNotProvided();
|
|
215
|
+
return this.inferenceClient.predictVQAAnswer(prompt, base64Image, config);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
211
218
|
}
|
|
212
219
|
exports.ExecutionRuntime = ExecutionRuntime;
|
|
@@ -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);
|
|
@@ -3,6 +3,7 @@ import { ControlCommand } from '../core/ui-control-commands';
|
|
|
3
3
|
import { CustomElement } from '../core/model/custom-element';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
|
+
import { VQAInferenceResponseBody } from '../core/inference-response/inference-response';
|
|
6
7
|
import { ModelCompositionBranch } from './model-composition-branch';
|
|
7
8
|
export declare class InferenceClient {
|
|
8
9
|
private readonly baseUrl;
|
|
@@ -16,8 +17,10 @@ export declare class InferenceClient {
|
|
|
16
17
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
17
18
|
private resizeIfNeeded;
|
|
18
19
|
inference(customElements?: CustomElement[], image?: string, instruction?: string): Promise<ControlCommand | Annotation>;
|
|
20
|
+
vqaInference(image: string, prompt: string, config?: object): Promise<VQAInferenceResponseBody>;
|
|
19
21
|
private static logMetaInformation;
|
|
20
22
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
21
23
|
getDetectedElements(instruction: string, image: string, customElements?: CustomElement[]): Promise<DetectedElement[]>;
|
|
22
24
|
predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
|
|
25
|
+
predictVQAAnswer(prompt: string, image: string, config?: object): Promise<any>;
|
|
23
26
|
}
|
|
@@ -35,6 +35,7 @@ class InferenceClient {
|
|
|
35
35
|
this.urls = {
|
|
36
36
|
inference: (0, url_join_1.default)(url, 'inference'),
|
|
37
37
|
isImageRequired: (0, url_join_1.default)(url, 'instruction', 'is-image-required'),
|
|
38
|
+
vqaInference: (0, url_join_1.default)(url, 'vqa', 'inference'),
|
|
38
39
|
};
|
|
39
40
|
this.httpClient.urlsToRetry = Object.values(this.urls);
|
|
40
41
|
if (this.resize !== undefined && this.resize <= 0) {
|
|
@@ -59,8 +60,8 @@ class InferenceClient {
|
|
|
59
60
|
return (0, transformations_1.resizeBase64ImageWithSameRatio)(image, this.resize);
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
inference(
|
|
63
|
-
return __awaiter(this,
|
|
63
|
+
inference() {
|
|
64
|
+
return __awaiter(this, arguments, void 0, function* (customElements = [], image, instruction) {
|
|
64
65
|
const resizedImage = yield this.resizeIfNeeded(customElements, image);
|
|
65
66
|
const response = yield this.httpClient.post(this.urls.inference, this.urls.inference.includes('v4-experimental') ? {
|
|
66
67
|
image: resizedImage.base64Image,
|
|
@@ -77,13 +78,24 @@ class InferenceClient {
|
|
|
77
78
|
return ui_control_commands_1.InferenceResponse.fromJson(response.body, resizedImage.resizeRatio, image);
|
|
78
79
|
});
|
|
79
80
|
}
|
|
81
|
+
vqaInference(image, prompt, config) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const response = yield this.httpClient.post(this.urls.vqaInference, {
|
|
84
|
+
config,
|
|
85
|
+
image,
|
|
86
|
+
prompt,
|
|
87
|
+
});
|
|
88
|
+
InferenceClient.logMetaInformation(response);
|
|
89
|
+
return response.body;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
80
92
|
static logMetaInformation(response) {
|
|
81
93
|
if (response.headers['askui-usage-warnings'] !== undefined) {
|
|
82
94
|
logger_1.logger.warn(response.headers['askui-usage-warnings']);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
|
-
predictControlCommand(
|
|
86
|
-
return __awaiter(this,
|
|
97
|
+
predictControlCommand(instruction_1) {
|
|
98
|
+
return __awaiter(this, arguments, void 0, function* (instruction, customElements = [], image) {
|
|
87
99
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
88
100
|
if (!(inferenceResponse instanceof ui_control_commands_1.ControlCommand)) {
|
|
89
101
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Can not execute command');
|
|
@@ -91,8 +103,8 @@ class InferenceClient {
|
|
|
91
103
|
return inferenceResponse;
|
|
92
104
|
});
|
|
93
105
|
}
|
|
94
|
-
getDetectedElements(
|
|
95
|
-
return __awaiter(this,
|
|
106
|
+
getDetectedElements(instruction_1, image_1) {
|
|
107
|
+
return __awaiter(this, arguments, void 0, function* (instruction, image, customElements = []) {
|
|
96
108
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
97
109
|
if (!(inferenceResponse instanceof annotation_1.Annotation)) {
|
|
98
110
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Unable to get the detected elements');
|
|
@@ -100,8 +112,8 @@ class InferenceClient {
|
|
|
100
112
|
return inferenceResponse.detected_elements;
|
|
101
113
|
});
|
|
102
114
|
}
|
|
103
|
-
predictImageAnnotation(
|
|
104
|
-
return __awaiter(this,
|
|
115
|
+
predictImageAnnotation(image_1) {
|
|
116
|
+
return __awaiter(this, arguments, void 0, function* (image, customElements = []) {
|
|
105
117
|
const inferenceResponse = yield this.inference(customElements, image);
|
|
106
118
|
if (!(inferenceResponse instanceof annotation_1.Annotation)) {
|
|
107
119
|
throw new inference_response_error_1.InferenceResponseError('Internal Error. Can not execute annotation');
|
|
@@ -109,5 +121,18 @@ class InferenceClient {
|
|
|
109
121
|
return inferenceResponse;
|
|
110
122
|
});
|
|
111
123
|
}
|
|
124
|
+
predictVQAAnswer(prompt, image, config) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
const inferenceResponse = yield this.vqaInference(image, prompt, config);
|
|
127
|
+
const { response } = inferenceResponse.data;
|
|
128
|
+
try {
|
|
129
|
+
return JSON.parse(response);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
logger_1.logger.warn(`Response is no valid JSON: ${response}`);
|
|
133
|
+
}
|
|
134
|
+
return response;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
112
137
|
}
|
|
113
138
|
exports.InferenceClient = InferenceClient;
|
|
@@ -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
|
+
}
|