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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.GeneralHttpClientError = void 0;
|
|
4
|
+
exports.httpClientErrorHandler = httpClientErrorHandler;
|
|
4
5
|
const server_http_client_error_1 = require("./server-http-client-error");
|
|
5
6
|
const authentication_http_client_error_1 = require("./authentication-http-client-error");
|
|
6
7
|
const client_http_client_error_1 = require("./client-http-client-error");
|
|
@@ -20,4 +21,3 @@ function httpClientErrorHandler(responseCode, errorMessage) {
|
|
|
20
21
|
}
|
|
21
22
|
return new unkown_http_client_error_1.UnkownHttpClientError(diplayedMessage);
|
|
22
23
|
}
|
|
23
|
-
exports.httpClientErrorHandler = httpClientErrorHandler;
|
|
@@ -133,8 +133,8 @@ class HttpClientGot {
|
|
|
133
133
|
return { body, headers };
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
get(
|
|
137
|
-
return __awaiter(this,
|
|
136
|
+
get(url_1) {
|
|
137
|
+
return __awaiter(this, arguments, void 0, function* (url, options = { responseType: 'json' }) {
|
|
138
138
|
const response = yield this.askuiGot.get(url, this.injectHeadersAndCookies(url, options));
|
|
139
139
|
return response.body;
|
|
140
140
|
});
|
package/dist/cjs/utils/path.js
CHANGED
|
@@ -3,9 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getPathToNodeModulesRoot =
|
|
6
|
+
exports.getPathToNodeModulesRoot = getPathToNodeModulesRoot;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
function getPathToNodeModulesRoot() {
|
|
9
9
|
return path_1.default.join(__dirname, '..', '..');
|
|
10
10
|
}
|
|
11
|
-
exports.getPathToNodeModulesRoot = getPathToNodeModulesRoot;
|
|
@@ -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];
|
|
@@ -28,7 +32,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
32
|
});
|
|
29
33
|
};
|
|
30
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.
|
|
35
|
+
exports.ProxyImportError = void 0;
|
|
36
|
+
exports.envProxyAgents = envProxyAgents;
|
|
32
37
|
const logger_1 = require("../../lib/logger");
|
|
33
38
|
class ProxyImportError extends Error {
|
|
34
39
|
}
|
|
@@ -66,4 +71,3 @@ function envProxyAgents() {
|
|
|
66
71
|
};
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
|
-
exports.envProxyAgents = envProxyAgents;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.resizeBase64ImageWithSameRatio =
|
|
12
|
+
exports.resizeBase64ImageWithSameRatio = resizeBase64ImageWithSameRatio;
|
|
13
13
|
const lib_1 = require("../lib");
|
|
14
14
|
const base_64_image_1 = require("./base_64_image/base-64-image");
|
|
15
15
|
const image_resize_errors_1 = require("./image-resize-errors");
|
|
@@ -23,8 +23,8 @@ const image_resize_errors_1 = require("./image-resize-errors");
|
|
|
23
23
|
* @returns {Promise<ResizedImage>} ResiziedImage Interface,
|
|
24
24
|
* the true pixel values = controlui-api response * resizeRatio.
|
|
25
25
|
*/
|
|
26
|
-
function resizeBase64ImageWithSameRatio(
|
|
27
|
-
return __awaiter(this,
|
|
26
|
+
function resizeBase64ImageWithSameRatio(base64ImageString_1) {
|
|
27
|
+
return __awaiter(this, arguments, void 0, function* (base64ImageString, maxEdge = 1400) {
|
|
28
28
|
lib_1.logger.debug('Image resizing');
|
|
29
29
|
try {
|
|
30
30
|
const image = yield base_64_image_1.Base64Image.fromString(base64ImageString);
|
|
@@ -44,4 +44,3 @@ function resizeBase64ImageWithSameRatio(base64ImageString, maxEdge = 1400) {
|
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
exports.resizeBase64ImageWithSameRatio = resizeBase64ImageWithSameRatio;
|
|
@@ -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;
|
|
@@ -19,8 +19,8 @@ export class CustomElement {
|
|
|
19
19
|
this.imageCompareFormat = imageCompareFormat;
|
|
20
20
|
this.mask = mask;
|
|
21
21
|
}
|
|
22
|
-
static fromJsonListWithImagePathOrImage(
|
|
23
|
-
return __awaiter(this,
|
|
22
|
+
static fromJsonListWithImagePathOrImage() {
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* (ceJson = []) {
|
|
24
24
|
return Promise.all(ceJson.map((customElement) => CustomElement.fromJsonWithImagePathOrImage(customElement)));
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -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';
|
|
@@ -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[];
|
|
@@ -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
|
}
|
|
@@ -16,12 +16,12 @@ import { Annotation } from '../core/annotation/annotation';
|
|
|
16
16
|
import { logger } from '../lib/logger';
|
|
17
17
|
import { Base64Image } from '../utils/base_64_image/base-64-image';
|
|
18
18
|
export class ExecutionRuntime {
|
|
19
|
-
constructor(uiControllerClient, inferenceClient, stepReporter) {
|
|
19
|
+
constructor(uiControllerClient, inferenceClient, stepReporter, retryStrategy) {
|
|
20
20
|
this.uiControllerClient = uiControllerClient;
|
|
21
21
|
this.inferenceClient = inferenceClient;
|
|
22
22
|
this.stepReporter = stepReporter;
|
|
23
|
+
this.retryStrategy = retryStrategy;
|
|
23
24
|
this.EXEC_REPETITION_COUNT = 25;
|
|
24
|
-
this.PREDICT_COMMAND_RETRY_COUNT = 2;
|
|
25
25
|
}
|
|
26
26
|
connect() {
|
|
27
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -53,8 +53,8 @@ export class ExecutionRuntime {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
executeInstruction(instruction) {
|
|
56
|
-
var _a, _b, _c;
|
|
57
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
var _a, _b, _c;
|
|
58
58
|
const controlCommand = yield this.predictCommandWithRetry(instruction);
|
|
59
59
|
if (controlCommand.code === ControlCommandCode.OK) {
|
|
60
60
|
return this.requestControl(controlCommand);
|
|
@@ -67,8 +67,8 @@ export class ExecutionRuntime {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
executeCommandRepeatedly(instruction) {
|
|
70
|
-
var _a, _b, _c;
|
|
71
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a, _b, _c;
|
|
72
72
|
/* eslint-disable no-await-in-loop */
|
|
73
73
|
for (let repeatCount = this.EXEC_REPETITION_COUNT; repeatCount >= 0; repeatCount -= 1) {
|
|
74
74
|
if (repeatCount === 0) {
|
|
@@ -87,6 +87,7 @@ export class ExecutionRuntime {
|
|
|
87
87
|
throw new 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 : '');
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
+
/* eslint-enable no-await-in-loop */
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
@@ -95,15 +96,15 @@ export class ExecutionRuntime {
|
|
|
95
96
|
*/
|
|
96
97
|
/* eslint-disable-next-line consistent-return */
|
|
97
98
|
predictCommandWithRetry(instruction) {
|
|
98
|
-
var _a, _b, _c;
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
var _a, _b, _c;
|
|
100
101
|
let command = yield this.predictCommand(instruction);
|
|
101
102
|
/* eslint-disable no-await-in-loop */
|
|
102
|
-
for (let k = 0; k < this.
|
|
103
|
+
for (let k = 0; k < this.retryStrategy.retryCount; k += 1) {
|
|
103
104
|
if (command.code === ControlCommandCode.OK) {
|
|
104
105
|
return command;
|
|
105
106
|
}
|
|
106
|
-
const msUntilRetry = k
|
|
107
|
+
const msUntilRetry = this.retryStrategy.getDelay(k + 1);
|
|
107
108
|
logger.debug(`Wait ${msUntilRetry} and retry predicting command...`);
|
|
108
109
|
yield delay(msUntilRetry);
|
|
109
110
|
command = yield this.predictCommand(instruction, new 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 : ''));
|
|
@@ -205,4 +206,10 @@ export class ExecutionRuntime {
|
|
|
205
206
|
return this.inferenceClient.predictImageAnnotation(base64Image, customElements);
|
|
206
207
|
});
|
|
207
208
|
}
|
|
209
|
+
predictVQA(prompt, config) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
const base64Image = yield this.takeScreenshotIfImageisNotProvided();
|
|
212
|
+
return this.inferenceClient.predictVQAAnswer(prompt, base64Image, config);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
208
215
|
}
|
|
@@ -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
|
}
|
|
@@ -29,6 +29,7 @@ export class InferenceClient {
|
|
|
29
29
|
this.urls = {
|
|
30
30
|
inference: urljoin(url, 'inference'),
|
|
31
31
|
isImageRequired: urljoin(url, 'instruction', 'is-image-required'),
|
|
32
|
+
vqaInference: urljoin(url, 'vqa', 'inference'),
|
|
32
33
|
};
|
|
33
34
|
this.httpClient.urlsToRetry = Object.values(this.urls);
|
|
34
35
|
if (this.resize !== undefined && this.resize <= 0) {
|
|
@@ -53,8 +54,8 @@ export class InferenceClient {
|
|
|
53
54
|
return resizeBase64ImageWithSameRatio(image, this.resize);
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
inference(
|
|
57
|
-
return __awaiter(this,
|
|
57
|
+
inference() {
|
|
58
|
+
return __awaiter(this, arguments, void 0, function* (customElements = [], image, instruction) {
|
|
58
59
|
const resizedImage = yield this.resizeIfNeeded(customElements, image);
|
|
59
60
|
const response = yield this.httpClient.post(this.urls.inference, this.urls.inference.includes('v4-experimental') ? {
|
|
60
61
|
image: resizedImage.base64Image,
|
|
@@ -71,13 +72,24 @@ export class InferenceClient {
|
|
|
71
72
|
return InferenceResponse.fromJson(response.body, resizedImage.resizeRatio, image);
|
|
72
73
|
});
|
|
73
74
|
}
|
|
75
|
+
vqaInference(image, prompt, config) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
const response = yield this.httpClient.post(this.urls.vqaInference, {
|
|
78
|
+
config,
|
|
79
|
+
image,
|
|
80
|
+
prompt,
|
|
81
|
+
});
|
|
82
|
+
InferenceClient.logMetaInformation(response);
|
|
83
|
+
return response.body;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
74
86
|
static logMetaInformation(response) {
|
|
75
87
|
if (response.headers['askui-usage-warnings'] !== undefined) {
|
|
76
88
|
logger.warn(response.headers['askui-usage-warnings']);
|
|
77
89
|
}
|
|
78
90
|
}
|
|
79
|
-
predictControlCommand(
|
|
80
|
-
return __awaiter(this,
|
|
91
|
+
predictControlCommand(instruction_1) {
|
|
92
|
+
return __awaiter(this, arguments, void 0, function* (instruction, customElements = [], image) {
|
|
81
93
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
82
94
|
if (!(inferenceResponse instanceof ControlCommand)) {
|
|
83
95
|
throw new InferenceResponseError('Internal Error. Can not execute command');
|
|
@@ -85,8 +97,8 @@ export class InferenceClient {
|
|
|
85
97
|
return inferenceResponse;
|
|
86
98
|
});
|
|
87
99
|
}
|
|
88
|
-
getDetectedElements(
|
|
89
|
-
return __awaiter(this,
|
|
100
|
+
getDetectedElements(instruction_1, image_1) {
|
|
101
|
+
return __awaiter(this, arguments, void 0, function* (instruction, image, customElements = []) {
|
|
90
102
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
91
103
|
if (!(inferenceResponse instanceof Annotation)) {
|
|
92
104
|
throw new InferenceResponseError('Internal Error. Unable to get the detected elements');
|
|
@@ -94,8 +106,8 @@ export class InferenceClient {
|
|
|
94
106
|
return inferenceResponse.detected_elements;
|
|
95
107
|
});
|
|
96
108
|
}
|
|
97
|
-
predictImageAnnotation(
|
|
98
|
-
return __awaiter(this,
|
|
109
|
+
predictImageAnnotation(image_1) {
|
|
110
|
+
return __awaiter(this, arguments, void 0, function* (image, customElements = []) {
|
|
99
111
|
const inferenceResponse = yield this.inference(customElements, image);
|
|
100
112
|
if (!(inferenceResponse instanceof Annotation)) {
|
|
101
113
|
throw new InferenceResponseError('Internal Error. Can not execute annotation');
|
|
@@ -103,4 +115,17 @@ export class InferenceClient {
|
|
|
103
115
|
return inferenceResponse;
|
|
104
116
|
});
|
|
105
117
|
}
|
|
118
|
+
predictVQAAnswer(prompt, image, config) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const inferenceResponse = yield this.vqaInference(image, prompt, config);
|
|
121
|
+
const { response } = inferenceResponse.data;
|
|
122
|
+
try {
|
|
123
|
+
return JSON.parse(response);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
logger.warn(`Response is no valid JSON: ${response}`);
|
|
127
|
+
}
|
|
128
|
+
return response;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
106
131
|
}
|
|
@@ -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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExponentialRetryStrategy implements a retry strategy that uses an exponential backoff algorithm.
|
|
3
|
+
*/
|
|
4
|
+
export class ExponentialRetryStrategy {
|
|
5
|
+
/**
|
|
6
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
7
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
8
|
+
*/
|
|
9
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
10
|
+
this.baseDelayMs = baseDelayMs;
|
|
11
|
+
this.retryCount = retryCount;
|
|
12
|
+
}
|
|
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) {
|
|
19
|
+
return this.baseDelayMs * (Math.pow(2, attempt));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FixedRetryStrategy implements a retry strategy that uses a constant delay for each retry attempt.
|
|
3
|
+
*/
|
|
4
|
+
export class FixedRetryStrategy {
|
|
5
|
+
/**
|
|
6
|
+
* @param baseDelayMs - The constant delay before each retry (default is 1000ms)
|
|
7
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
8
|
+
*/
|
|
9
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
10
|
+
this.baseDelayMs = baseDelayMs;
|
|
11
|
+
this.retryCount = retryCount;
|
|
12
|
+
}
|
|
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) {
|
|
19
|
+
return this.baseDelayMs;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LinearRetryStrategy implements a retry strategy that uses a linear backoff algorithm.
|
|
3
|
+
*/
|
|
4
|
+
export class LinearRetryStrategy {
|
|
5
|
+
/**
|
|
6
|
+
* @param baseDelayMs - The initial delay before the first retry (default is 1000ms)
|
|
7
|
+
* @param retryCount - The maximum number of retries (default is 3)
|
|
8
|
+
*/
|
|
9
|
+
constructor(baseDelayMs = 1000, retryCount = 3) {
|
|
10
|
+
this.baseDelayMs = baseDelayMs;
|
|
11
|
+
this.retryCount = retryCount;
|
|
12
|
+
}
|
|
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) {
|
|
19
|
+
return this.baseDelayMs * attempt;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|