@aiscene/shared 8.0.1 → 8.0.3
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/es/cli/cli-args.mjs +95 -0
- package/dist/es/cli/cli-error.mjs +24 -0
- package/dist/es/cli/cli-runner.mjs +10 -40
- package/dist/es/cli/index.mjs +4 -2
- package/dist/es/constants/example-code.mjs +2 -2
- package/dist/es/constants/index.mjs +6 -1
- package/dist/es/env/model-config-manager.mjs +3 -0
- package/dist/es/env/parse-model-config.mjs +6 -1
- package/dist/es/env/types.mjs +2 -1
- package/dist/es/env/utils.mjs +1 -9
- package/dist/es/extractor/index.mjs +2 -2
- package/dist/es/img/index.mjs +2 -2
- package/dist/es/img/info.mjs +7 -1
- package/dist/es/key-alias-utils.mjs +19 -0
- package/dist/es/mcp/base-server.mjs +10 -9
- package/dist/es/mcp/base-tools.mjs +72 -4
- package/dist/es/mcp/cli-report-session.mjs +78 -0
- package/dist/es/mcp/error-formatter.mjs +19 -0
- package/dist/es/mcp/index.mjs +2 -0
- package/dist/es/mcp/init-arg-utils.mjs +38 -0
- package/dist/es/mcp/inject-report-html-plugin.mjs +1 -1
- package/dist/es/mcp/tool-generator.mjs +65 -17
- package/dist/es/node/fs.mjs +1 -1
- package/dist/lib/cli/cli-args.js +138 -0
- package/dist/lib/cli/cli-error.js +61 -0
- package/dist/lib/cli/cli-runner.js +19 -46
- package/dist/lib/cli/index.js +8 -3
- package/dist/lib/constants/example-code.js +2 -2
- package/dist/lib/constants/index.js +23 -3
- package/dist/lib/env/model-config-manager.js +3 -0
- package/dist/lib/env/parse-model-config.js +6 -1
- package/dist/lib/env/types.js +4 -0
- package/dist/lib/env/utils.js +0 -11
- package/dist/lib/extractor/index.js +3 -0
- package/dist/lib/img/index.js +3 -0
- package/dist/lib/img/info.js +10 -1
- package/dist/lib/key-alias-utils.js +62 -0
- package/dist/lib/mcp/base-server.js +11 -10
- package/dist/lib/mcp/base-tools.js +74 -6
- package/dist/lib/mcp/cli-report-session.js +121 -0
- package/dist/lib/mcp/error-formatter.js +53 -0
- package/dist/lib/mcp/index.js +24 -10
- package/dist/lib/mcp/init-arg-utils.js +78 -0
- package/dist/lib/mcp/inject-report-html-plugin.js +1 -1
- package/dist/lib/mcp/tool-generator.js +74 -26
- package/dist/lib/node/fs.js +1 -1
- package/dist/types/cli/cli-args.d.ts +8 -0
- package/dist/types/cli/cli-error.d.ts +5 -0
- package/dist/types/cli/cli-runner.d.ts +4 -7
- package/dist/types/cli/index.d.ts +3 -1
- package/dist/types/constants/example-code.d.ts +1 -1
- package/dist/types/constants/index.d.ts +5 -0
- package/dist/types/env/types.d.ts +10 -2
- package/dist/types/env/utils.d.ts +0 -31
- package/dist/types/extractor/index.d.ts +1 -1
- package/dist/types/img/index.d.ts +1 -1
- package/dist/types/img/info.d.ts +5 -0
- package/dist/types/key-alias-utils.d.ts +9 -0
- package/dist/types/mcp/base-tools.d.ts +74 -5
- package/dist/types/mcp/cli-report-session.d.ts +12 -0
- package/dist/types/mcp/error-formatter.d.ts +12 -0
- package/dist/types/mcp/index.d.ts +2 -0
- package/dist/types/mcp/init-arg-utils.d.ts +13 -0
- package/dist/types/mcp/inject-report-html-plugin.d.ts +2 -2
- package/dist/types/mcp/launcher-helper.d.ts +3 -3
- package/dist/types/mcp/tool-generator.d.ts +3 -3
- package/dist/types/mcp/types.d.ts +9 -0
- package/package.json +1 -1
- package/src/cli/cli-args.ts +173 -0
- package/src/cli/cli-error.ts +24 -0
- package/src/cli/cli-runner.ts +37 -56
- package/src/cli/index.ts +3 -7
- package/src/constants/example-code.ts +2 -2
- package/src/constants/index.ts +10 -0
- package/src/env/model-config-manager.ts +3 -0
- package/src/env/parse-model-config.ts +19 -1
- package/src/env/types.ts +11 -2
- package/src/env/utils.ts +0 -50
- package/src/extractor/index.ts +1 -1
- package/src/img/index.ts +2 -0
- package/src/img/info.ts +27 -0
- package/src/key-alias-utils.ts +23 -0
- package/src/mcp/base-server.ts +10 -12
- package/src/mcp/base-tools.ts +218 -11
- package/src/mcp/cli-report-session.ts +130 -0
- package/src/mcp/error-formatter.ts +52 -0
- package/src/mcp/index.ts +2 -0
- package/src/mcp/init-arg-utils.ts +105 -0
- package/src/mcp/inject-report-html-plugin.ts +3 -3
- package/src/mcp/launcher-helper.ts +3 -3
- package/src/mcp/tool-generator.ts +98 -20
- package/src/mcp/types.ts +16 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
parseCliArgs: ()=>parseCliArgs,
|
|
28
|
+
parseValue: ()=>parseValue,
|
|
29
|
+
formatCliValidationError: ()=>formatCliValidationError,
|
|
30
|
+
getCliOptionDisplay: ()=>getCliOptionDisplay
|
|
31
|
+
});
|
|
32
|
+
const external_zod_namespaceObject = require("zod");
|
|
33
|
+
const external_key_alias_utils_js_namespaceObject = require("../key-alias-utils.js");
|
|
34
|
+
function parseValue(raw) {
|
|
35
|
+
if (raw.startsWith('{') || raw.startsWith('[')) try {
|
|
36
|
+
return JSON.parse(raw);
|
|
37
|
+
} catch {}
|
|
38
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) return Number(raw);
|
|
39
|
+
return raw;
|
|
40
|
+
}
|
|
41
|
+
function walkCliArgs(args, setArgValue) {
|
|
42
|
+
for(let i = 0; i < args.length; i++){
|
|
43
|
+
const arg = args[i];
|
|
44
|
+
if (!arg.startsWith('--')) continue;
|
|
45
|
+
const body = arg.slice(2);
|
|
46
|
+
const eqIdx = body.indexOf('=');
|
|
47
|
+
if (eqIdx >= 0) setArgValue(body.slice(0, eqIdx), parseValue(body.slice(eqIdx + 1)));
|
|
48
|
+
else if (args[i + 1] && !args[i + 1].startsWith('--')) {
|
|
49
|
+
i++;
|
|
50
|
+
setArgValue(body, parseValue(args[i]));
|
|
51
|
+
} else setArgValue(body, true);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function parseCliArgs(args) {
|
|
55
|
+
const result = {};
|
|
56
|
+
walkCliArgs(args, (key, value)=>{
|
|
57
|
+
result[key] = value;
|
|
58
|
+
});
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
function formatCliOptionName(name) {
|
|
62
|
+
return `--${name}`;
|
|
63
|
+
}
|
|
64
|
+
function getCliOptionDisplay(key, cliOption) {
|
|
65
|
+
const label = formatCliOptionName(cliOption?.preferredName ?? key);
|
|
66
|
+
const aliases = [
|
|
67
|
+
...new Set(cliOption?.aliases ?? [])
|
|
68
|
+
].map((alias)=>formatCliOptionName(alias)).filter((alias)=>alias !== label);
|
|
69
|
+
return {
|
|
70
|
+
label,
|
|
71
|
+
aliases
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function getAcceptedCliOptionNames(key, cliOption) {
|
|
75
|
+
return [
|
|
76
|
+
...new Set(cliOption ? [
|
|
77
|
+
cliOption.preferredName ?? key,
|
|
78
|
+
...cliOption.aliases ?? []
|
|
79
|
+
] : [
|
|
80
|
+
key,
|
|
81
|
+
...(0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(key)
|
|
82
|
+
])
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
function toOptionalCliSchemaField(field) {
|
|
86
|
+
if ('object' == typeof field && null !== field && 'function' == typeof field.optional) return field.optional();
|
|
87
|
+
const description = 'object' == typeof field && null !== field && "description" in field && 'string' == typeof field.description ? field.description : void 0;
|
|
88
|
+
return description ? external_zod_namespaceObject.z.any().describe(description) : external_zod_namespaceObject.z.any();
|
|
89
|
+
}
|
|
90
|
+
function buildCliArgSchema(def) {
|
|
91
|
+
return Object.fromEntries(Object.entries(def.schema).flatMap(([key, zodType])=>getAcceptedCliOptionNames(key, def.cli?.options?.[key]).map((cliKey)=>[
|
|
92
|
+
cliKey,
|
|
93
|
+
toOptionalCliSchemaField(zodType)
|
|
94
|
+
])));
|
|
95
|
+
}
|
|
96
|
+
function buildDisallowedCliSpellings(def) {
|
|
97
|
+
const disallowedSpellings = new Set();
|
|
98
|
+
for (const [key] of Object.entries(def.schema)){
|
|
99
|
+
const cliOption = def.cli?.options?.[key];
|
|
100
|
+
const acceptedNames = new Set(getAcceptedCliOptionNames(key, cliOption));
|
|
101
|
+
const knownSpellings = new Set([
|
|
102
|
+
key,
|
|
103
|
+
...(0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(key),
|
|
104
|
+
...cliOption?.preferredName ? (0, external_key_alias_utils_js_namespaceObject.getKeyAliases)(cliOption.preferredName) : [],
|
|
105
|
+
...cliOption?.aliases ?? []
|
|
106
|
+
]);
|
|
107
|
+
for (const spelling of knownSpellings)if (!acceptedNames.has(spelling)) disallowedSpellings.add(spelling);
|
|
108
|
+
}
|
|
109
|
+
return disallowedSpellings;
|
|
110
|
+
}
|
|
111
|
+
function formatCliValidationError(scriptName, commandName, def, rawArgs) {
|
|
112
|
+
if (0 === Object.keys(def.schema).length) return;
|
|
113
|
+
const cliSchema = external_zod_namespaceObject.z.object(buildCliArgSchema(def)).strict();
|
|
114
|
+
const parsed = cliSchema.safeParse(rawArgs);
|
|
115
|
+
if (parsed.success) return;
|
|
116
|
+
const disallowedSpellings = buildDisallowedCliSpellings(def);
|
|
117
|
+
const unknownKeys = parsed.error.issues.flatMap((issue)=>'unrecognized_keys' === issue.code ? issue.keys : []);
|
|
118
|
+
if (unknownKeys.length > 0) return unknownKeys.map((key)=>{
|
|
119
|
+
if (disallowedSpellings.has(key)) return `Unsupported option "--${key}" for ${scriptName} ${commandName}.`;
|
|
120
|
+
return `Unknown option "--${key}" for ${scriptName} ${commandName}.`;
|
|
121
|
+
}).join('\n');
|
|
122
|
+
const [issue] = parsed.error.issues;
|
|
123
|
+
const optionName = 'string' == typeof issue?.path[0] ? `--${issue.path[0]}` : 'CLI arguments';
|
|
124
|
+
return `Invalid value for "${optionName}" in ${scriptName} ${commandName}: ${issue?.message ?? parsed.error.message}`;
|
|
125
|
+
}
|
|
126
|
+
exports.formatCliValidationError = __webpack_exports__.formatCliValidationError;
|
|
127
|
+
exports.getCliOptionDisplay = __webpack_exports__.getCliOptionDisplay;
|
|
128
|
+
exports.parseCliArgs = __webpack_exports__.parseCliArgs;
|
|
129
|
+
exports.parseValue = __webpack_exports__.parseValue;
|
|
130
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
131
|
+
"formatCliValidationError",
|
|
132
|
+
"getCliOptionDisplay",
|
|
133
|
+
"parseCliArgs",
|
|
134
|
+
"parseValue"
|
|
135
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
136
|
+
Object.defineProperty(exports, '__esModule', {
|
|
137
|
+
value: true
|
|
138
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
CLIError: ()=>CLIError,
|
|
28
|
+
reportCLIError: ()=>reportCLIError
|
|
29
|
+
});
|
|
30
|
+
function _define_property(obj, key, value) {
|
|
31
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
32
|
+
value: value,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
else obj[key] = value;
|
|
38
|
+
return obj;
|
|
39
|
+
}
|
|
40
|
+
class CLIError extends Error {
|
|
41
|
+
constructor(message, exitCode = 1){
|
|
42
|
+
super(message), _define_property(this, "exitCode", void 0), this.exitCode = exitCode;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function reportCLIError(error, log = console.error) {
|
|
46
|
+
if (error instanceof CLIError) {
|
|
47
|
+
log(error.message);
|
|
48
|
+
return error.exitCode;
|
|
49
|
+
}
|
|
50
|
+
log(error);
|
|
51
|
+
return 1;
|
|
52
|
+
}
|
|
53
|
+
exports.CLIError = __webpack_exports__.CLIError;
|
|
54
|
+
exports.reportCLIError = __webpack_exports__.reportCLIError;
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
56
|
+
"CLIError",
|
|
57
|
+
"reportCLIError"
|
|
58
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
59
|
+
Object.defineProperty(exports, '__esModule', {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
|
@@ -33,10 +33,11 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
CLIError: ()=>CLIError,
|
|
37
|
-
parseCliArgs: ()=>parseCliArgs,
|
|
38
|
-
parseValue: ()=>parseValue,
|
|
36
|
+
CLIError: ()=>external_cli_error_js_namespaceObject.CLIError,
|
|
37
|
+
parseCliArgs: ()=>external_cli_args_js_namespaceObject.parseCliArgs,
|
|
38
|
+
parseValue: ()=>external_cli_args_js_namespaceObject.parseValue,
|
|
39
39
|
runToolsCLI: ()=>runToolsCLI,
|
|
40
|
+
reportCLIError: ()=>external_cli_error_js_namespaceObject.reportCLIError,
|
|
40
41
|
removePrefix: ()=>removePrefix
|
|
41
42
|
});
|
|
42
43
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
@@ -45,44 +46,9 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
45
46
|
const external_dotenv_namespaceObject = require("dotenv");
|
|
46
47
|
var external_dotenv_default = /*#__PURE__*/ __webpack_require__.n(external_dotenv_namespaceObject);
|
|
47
48
|
const external_logger_js_namespaceObject = require("../logger.js");
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
value: value,
|
|
51
|
-
enumerable: true,
|
|
52
|
-
configurable: true,
|
|
53
|
-
writable: true
|
|
54
|
-
});
|
|
55
|
-
else obj[key] = value;
|
|
56
|
-
return obj;
|
|
57
|
-
}
|
|
49
|
+
const external_cli_args_js_namespaceObject = require("./cli-args.js");
|
|
50
|
+
const external_cli_error_js_namespaceObject = require("./cli-error.js");
|
|
58
51
|
const debug = (0, external_logger_js_namespaceObject.getDebug)('cli-runner');
|
|
59
|
-
class CLIError extends Error {
|
|
60
|
-
constructor(message, exitCode = 1){
|
|
61
|
-
super(message), _define_property(this, "exitCode", void 0), this.exitCode = exitCode;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function parseValue(raw) {
|
|
65
|
-
if (raw.startsWith('{') || raw.startsWith('[')) try {
|
|
66
|
-
return JSON.parse(raw);
|
|
67
|
-
} catch {}
|
|
68
|
-
if (/^-?\d+(\.\d+)?$/.test(raw)) return Number(raw);
|
|
69
|
-
return raw;
|
|
70
|
-
}
|
|
71
|
-
function parseCliArgs(args) {
|
|
72
|
-
const result = {};
|
|
73
|
-
for(let i = 0; i < args.length; i++){
|
|
74
|
-
const arg = args[i];
|
|
75
|
-
if (!arg.startsWith('--')) continue;
|
|
76
|
-
const body = arg.slice(2);
|
|
77
|
-
const eqIdx = body.indexOf('=');
|
|
78
|
-
if (eqIdx >= 0) result[body.slice(0, eqIdx)] = parseValue(body.slice(eqIdx + 1));
|
|
79
|
-
else if (args[i + 1] && !args[i + 1].startsWith('--')) {
|
|
80
|
-
i++;
|
|
81
|
-
result[body] = parseValue(args[i]);
|
|
82
|
-
} else result[body] = true;
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}
|
|
86
52
|
function outputContentItem(item, isError) {
|
|
87
53
|
switch(item.type){
|
|
88
54
|
case 'text':
|
|
@@ -114,10 +80,13 @@ function printCommandHelp(scriptName, cmd) {
|
|
|
114
80
|
console.log(def.description);
|
|
115
81
|
const schemaEntries = Object.entries(def.schema);
|
|
116
82
|
if (schemaEntries.length > 0) {
|
|
83
|
+
const optionWidth = Math.max(22, ...schemaEntries.map(([key])=>(0, external_cli_args_js_namespaceObject.getCliOptionDisplay)(key, def.cli?.options?.[key]).label.length));
|
|
117
84
|
console.log('\nOptions:');
|
|
118
85
|
for (const [key, zodType] of schemaEntries){
|
|
86
|
+
const { label, aliases } = (0, external_cli_args_js_namespaceObject.getCliOptionDisplay)(key, def.cli?.options?.[key]);
|
|
119
87
|
const desc = zodType.description ?? '';
|
|
120
|
-
|
|
88
|
+
const aliasText = aliases.length > 0 ? ` (aliases: ${aliases.join(', ')})` : '';
|
|
89
|
+
console.log(` ${label.padEnd(optionWidth)} ${desc}${aliasText}`);
|
|
121
90
|
}
|
|
122
91
|
}
|
|
123
92
|
}
|
|
@@ -167,7 +136,7 @@ async function runToolsCLI(tools, scriptName, options) {
|
|
|
167
136
|
return;
|
|
168
137
|
}
|
|
169
138
|
if ('--version' === commandName || '-v' === commandName || 'version' === commandName.toLowerCase()) {
|
|
170
|
-
if (!cliVersion) throw new CLIError('Failed to determine CLI version');
|
|
139
|
+
if (!cliVersion) throw new external_cli_error_js_namespaceObject.CLIError('Failed to determine CLI version');
|
|
171
140
|
printVersion(scriptName, cliVersion);
|
|
172
141
|
return;
|
|
173
142
|
}
|
|
@@ -176,31 +145,35 @@ async function runToolsCLI(tools, scriptName, options) {
|
|
|
176
145
|
debug('unknown command: %s', commandName);
|
|
177
146
|
console.error(`Unknown command: ${commandName}`);
|
|
178
147
|
printHelp(scriptName, commands, cliVersion);
|
|
179
|
-
throw new CLIError(`Unknown command: ${commandName}`);
|
|
148
|
+
throw new external_cli_error_js_namespaceObject.CLIError(`Unknown command: ${commandName}`);
|
|
180
149
|
}
|
|
181
|
-
const parsedArgs = parseCliArgs(restArgs);
|
|
182
|
-
debug('command: %s, args: %s', match.name, JSON.stringify(parsedArgs));
|
|
150
|
+
const parsedArgs = (0, external_cli_args_js_namespaceObject.parseCliArgs)(restArgs);
|
|
183
151
|
if (true === parsedArgs.help) {
|
|
184
152
|
debug('showing command help for: %s', match.name);
|
|
185
153
|
printCommandHelp(scriptName, match);
|
|
186
154
|
return;
|
|
187
155
|
}
|
|
156
|
+
const cliValidationError = (0, external_cli_args_js_namespaceObject.formatCliValidationError)(scriptName, match.name, match.def, parsedArgs);
|
|
157
|
+
if (cliValidationError) throw new external_cli_error_js_namespaceObject.CLIError(cliValidationError);
|
|
158
|
+
debug('command: %s, args: %s', match.name, JSON.stringify(parsedArgs));
|
|
188
159
|
const result = await match.def.handler(parsedArgs);
|
|
189
160
|
debug('command %s completed, isError: %s', match.name, result.isError ?? false);
|
|
190
161
|
outputResult(result);
|
|
191
162
|
await tools.destroy();
|
|
192
|
-
if (result.isError) throw new CLIError('Command failed', 1);
|
|
163
|
+
if (result.isError) throw new external_cli_error_js_namespaceObject.CLIError('Command failed', 1);
|
|
193
164
|
}
|
|
194
165
|
exports.CLIError = __webpack_exports__.CLIError;
|
|
195
166
|
exports.parseCliArgs = __webpack_exports__.parseCliArgs;
|
|
196
167
|
exports.parseValue = __webpack_exports__.parseValue;
|
|
197
168
|
exports.removePrefix = __webpack_exports__.removePrefix;
|
|
169
|
+
exports.reportCLIError = __webpack_exports__.reportCLIError;
|
|
198
170
|
exports.runToolsCLI = __webpack_exports__.runToolsCLI;
|
|
199
171
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
200
172
|
"CLIError",
|
|
201
173
|
"parseCliArgs",
|
|
202
174
|
"parseValue",
|
|
203
175
|
"removePrefix",
|
|
176
|
+
"reportCLIError",
|
|
204
177
|
"runToolsCLI"
|
|
205
178
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
206
179
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/lib/cli/index.js
CHANGED
|
@@ -24,23 +24,28 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
CLIError: ()=>
|
|
28
|
-
parseCliArgs: ()=>
|
|
29
|
-
parseValue: ()=>
|
|
27
|
+
CLIError: ()=>external_cli_error_js_namespaceObject.CLIError,
|
|
28
|
+
parseCliArgs: ()=>external_cli_args_js_namespaceObject.parseCliArgs,
|
|
29
|
+
parseValue: ()=>external_cli_args_js_namespaceObject.parseValue,
|
|
30
30
|
runToolsCLI: ()=>external_cli_runner_js_namespaceObject.runToolsCLI,
|
|
31
|
+
reportCLIError: ()=>external_cli_error_js_namespaceObject.reportCLIError,
|
|
31
32
|
removePrefix: ()=>external_cli_runner_js_namespaceObject.removePrefix
|
|
32
33
|
});
|
|
34
|
+
const external_cli_error_js_namespaceObject = require("./cli-error.js");
|
|
35
|
+
const external_cli_args_js_namespaceObject = require("./cli-args.js");
|
|
33
36
|
const external_cli_runner_js_namespaceObject = require("./cli-runner.js");
|
|
34
37
|
exports.CLIError = __webpack_exports__.CLIError;
|
|
35
38
|
exports.parseCliArgs = __webpack_exports__.parseCliArgs;
|
|
36
39
|
exports.parseValue = __webpack_exports__.parseValue;
|
|
37
40
|
exports.removePrefix = __webpack_exports__.removePrefix;
|
|
41
|
+
exports.reportCLIError = __webpack_exports__.reportCLIError;
|
|
38
42
|
exports.runToolsCLI = __webpack_exports__.runToolsCLI;
|
|
39
43
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
44
|
"CLIError",
|
|
41
45
|
"parseCliArgs",
|
|
42
46
|
"parseValue",
|
|
43
47
|
"removePrefix",
|
|
48
|
+
"reportCLIError",
|
|
44
49
|
"runToolsCLI"
|
|
45
50
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
51
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -57,8 +57,8 @@ aiQuery<T>(queryObject: Record<string, string>): Promise<T> // Extracts data fro
|
|
|
57
57
|
// The following is test code for Midscene AI, for reference
|
|
58
58
|
// The following is Playwright syntax, you can use Playwright to assist in test generation
|
|
59
59
|
import { test as base } from '@playwright/test';
|
|
60
|
-
import type { PlayWrightAiFixtureType } from '@
|
|
61
|
-
import { PlaywrightAiFixture } from '@
|
|
60
|
+
import type { PlayWrightAiFixtureType } from '@aiscene/web/playwright';
|
|
61
|
+
import { PlaywrightAiFixture } from '@aiscene/web/playwright';
|
|
62
62
|
|
|
63
63
|
const test = base.extend<PlayWrightAiFixtureType>(PlaywrightAiFixture({
|
|
64
64
|
waitForNetworkIdleTimeout: 2000, // optional, the timeout for waiting for network idle between each action, default is 2000ms
|
|
@@ -25,17 +25,22 @@ var __webpack_exports__ = {};
|
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT,
|
|
28
|
-
|
|
28
|
+
SCRCPY_PUSH_TIMEOUT_MS: ()=>SCRCPY_PUSH_TIMEOUT_MS,
|
|
29
29
|
CONTAINER_MINI_WIDTH: ()=>CONTAINER_MINI_WIDTH,
|
|
30
30
|
DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_CONCURRENCY,
|
|
31
31
|
DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT: ()=>DEFAULT_WAIT_FOR_NETWORK_IDLE_TIMEOUT,
|
|
32
|
-
PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
|
|
33
32
|
TEXT_MAX_SIZE: ()=>TEXT_MAX_SIZE,
|
|
33
|
+
SCRCPY_PREVIEW_METADATA_TIMEOUT_MS: ()=>SCRCPY_PREVIEW_METADATA_TIMEOUT_MS,
|
|
34
34
|
WEBDRIVER_ELEMENT_ID_KEY: ()=>WEBDRIVER_ELEMENT_ID_KEY,
|
|
35
|
+
YAML_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.YAML_EXAMPLE_CODE,
|
|
36
|
+
CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
|
|
37
|
+
SCRCPY_VIDEO_STREAM_TIMEOUT_MS: ()=>SCRCPY_VIDEO_STREAM_TIMEOUT_MS,
|
|
38
|
+
SCRCPY_ADB_CONNECT_TIMEOUT_MS: ()=>SCRCPY_ADB_CONNECT_TIMEOUT_MS,
|
|
39
|
+
SCRCPY_START_TIMEOUT_MS: ()=>SCRCPY_START_TIMEOUT_MS,
|
|
40
|
+
PLAYGROUND_SERVER_PORT: ()=>PLAYGROUND_SERVER_PORT,
|
|
35
41
|
DEFAULT_WDA_PORT: ()=>DEFAULT_WDA_PORT,
|
|
36
42
|
NodeType: ()=>constants_NodeType,
|
|
37
43
|
PLAYWRIGHT_EXAMPLE_CODE: ()=>external_example_code_js_namespaceObject.PLAYWRIGHT_EXAMPLE_CODE,
|
|
38
|
-
CONTAINER_MINI_HEIGHT: ()=>CONTAINER_MINI_HEIGHT,
|
|
39
44
|
SCRCPY_SERVER_PORT: ()=>SCRCPY_SERVER_PORT,
|
|
40
45
|
TEXT_SIZE_THRESHOLD: ()=>TEXT_SIZE_THRESHOLD
|
|
41
46
|
});
|
|
@@ -56,6 +61,11 @@ var constants_NodeType = /*#__PURE__*/ function(NodeType) {
|
|
|
56
61
|
}({});
|
|
57
62
|
const PLAYGROUND_SERVER_PORT = 5800;
|
|
58
63
|
const SCRCPY_SERVER_PORT = 5700;
|
|
64
|
+
const SCRCPY_ADB_CONNECT_TIMEOUT_MS = 10000;
|
|
65
|
+
const SCRCPY_PUSH_TIMEOUT_MS = 10000;
|
|
66
|
+
const SCRCPY_START_TIMEOUT_MS = 15000;
|
|
67
|
+
const SCRCPY_VIDEO_STREAM_TIMEOUT_MS = 15000;
|
|
68
|
+
const SCRCPY_PREVIEW_METADATA_TIMEOUT_MS = SCRCPY_ADB_CONNECT_TIMEOUT_MS + SCRCPY_PUSH_TIMEOUT_MS + SCRCPY_START_TIMEOUT_MS + SCRCPY_VIDEO_STREAM_TIMEOUT_MS + 5000;
|
|
59
69
|
const WEBDRIVER_ELEMENT_ID_KEY = 'element-6066-11e4-a52e-4f735466cecf';
|
|
60
70
|
const DEFAULT_WDA_PORT = 8100;
|
|
61
71
|
const DEFAULT_WAIT_FOR_NAVIGATION_TIMEOUT = 5000;
|
|
@@ -70,7 +80,12 @@ exports.DEFAULT_WDA_PORT = __webpack_exports__.DEFAULT_WDA_PORT;
|
|
|
70
80
|
exports.NodeType = __webpack_exports__.NodeType;
|
|
71
81
|
exports.PLAYGROUND_SERVER_PORT = __webpack_exports__.PLAYGROUND_SERVER_PORT;
|
|
72
82
|
exports.PLAYWRIGHT_EXAMPLE_CODE = __webpack_exports__.PLAYWRIGHT_EXAMPLE_CODE;
|
|
83
|
+
exports.SCRCPY_ADB_CONNECT_TIMEOUT_MS = __webpack_exports__.SCRCPY_ADB_CONNECT_TIMEOUT_MS;
|
|
84
|
+
exports.SCRCPY_PREVIEW_METADATA_TIMEOUT_MS = __webpack_exports__.SCRCPY_PREVIEW_METADATA_TIMEOUT_MS;
|
|
85
|
+
exports.SCRCPY_PUSH_TIMEOUT_MS = __webpack_exports__.SCRCPY_PUSH_TIMEOUT_MS;
|
|
73
86
|
exports.SCRCPY_SERVER_PORT = __webpack_exports__.SCRCPY_SERVER_PORT;
|
|
87
|
+
exports.SCRCPY_START_TIMEOUT_MS = __webpack_exports__.SCRCPY_START_TIMEOUT_MS;
|
|
88
|
+
exports.SCRCPY_VIDEO_STREAM_TIMEOUT_MS = __webpack_exports__.SCRCPY_VIDEO_STREAM_TIMEOUT_MS;
|
|
74
89
|
exports.TEXT_MAX_SIZE = __webpack_exports__.TEXT_MAX_SIZE;
|
|
75
90
|
exports.TEXT_SIZE_THRESHOLD = __webpack_exports__.TEXT_SIZE_THRESHOLD;
|
|
76
91
|
exports.WEBDRIVER_ELEMENT_ID_KEY = __webpack_exports__.WEBDRIVER_ELEMENT_ID_KEY;
|
|
@@ -85,7 +100,12 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
85
100
|
"NodeType",
|
|
86
101
|
"PLAYGROUND_SERVER_PORT",
|
|
87
102
|
"PLAYWRIGHT_EXAMPLE_CODE",
|
|
103
|
+
"SCRCPY_ADB_CONNECT_TIMEOUT_MS",
|
|
104
|
+
"SCRCPY_PREVIEW_METADATA_TIMEOUT_MS",
|
|
105
|
+
"SCRCPY_PUSH_TIMEOUT_MS",
|
|
88
106
|
"SCRCPY_SERVER_PORT",
|
|
107
|
+
"SCRCPY_START_TIMEOUT_MS",
|
|
108
|
+
"SCRCPY_VIDEO_STREAM_TIMEOUT_MS",
|
|
89
109
|
"TEXT_MAX_SIZE",
|
|
90
110
|
"TEXT_SIZE_THRESHOLD",
|
|
91
111
|
"WEBDRIVER_ELEMENT_ID_KEY",
|
|
@@ -52,14 +52,17 @@ class ModelConfigManager {
|
|
|
52
52
|
this.modelConfigMap = {
|
|
53
53
|
default: {
|
|
54
54
|
...defaultConfig,
|
|
55
|
+
intent: 'default',
|
|
55
56
|
createOpenAIClient: this.createOpenAIClientFn
|
|
56
57
|
},
|
|
57
58
|
insight: {
|
|
58
59
|
...insightConfig || defaultConfig,
|
|
60
|
+
intent: 'insight',
|
|
59
61
|
createOpenAIClient: this.createOpenAIClientFn
|
|
60
62
|
},
|
|
61
63
|
planning: {
|
|
62
64
|
...planningConfig || defaultConfig,
|
|
65
|
+
intent: 'planning',
|
|
63
66
|
createOpenAIClient: this.createOpenAIClientFn
|
|
64
67
|
}
|
|
65
68
|
};
|
|
@@ -36,6 +36,9 @@ const external_logger_js_namespaceObject = require("../logger.js");
|
|
|
36
36
|
const external_utils_js_namespaceObject = require("../utils.js");
|
|
37
37
|
const external_helper_js_namespaceObject = require("./helper.js");
|
|
38
38
|
const external_init_debug_js_namespaceObject = require("./init-debug.js");
|
|
39
|
+
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
+
const getCurrentVersion = ()=>"8.0.3";
|
|
41
|
+
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${external_types_js_namespaceObject.MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
39
42
|
const KEYS_MAP = {
|
|
40
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
|
41
44
|
planning: external_constants_js_namespaceObject.PLANNING_MODEL_CONFIG_KEYS,
|
|
@@ -46,7 +49,7 @@ const getUITarsModelVersion = (modelFamily)=>{
|
|
|
46
49
|
if ('vlm-ui-tars-doubao' === modelFamily || 'vlm-ui-tars-doubao-1.5' === modelFamily) return external_types_js_namespaceObject.UITarsModelVersion.DOUBAO_1_5_20B;
|
|
47
50
|
};
|
|
48
51
|
const validateModelFamily = (modelFamily)=>{
|
|
49
|
-
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(
|
|
52
|
+
if (modelFamily && !external_types_js_namespaceObject.MODEL_FAMILY_VALUES.includes(modelFamily)) throw new Error(getInvalidModelFamilyMessage(modelFamily));
|
|
50
53
|
};
|
|
51
54
|
const legacyConfigToModelFamily = (provider)=>{
|
|
52
55
|
const isDoubao = provider[external_types_js_namespaceObject.MIDSCENE_USE_DOUBAO_VISION];
|
|
@@ -122,6 +125,7 @@ const parseOpenaiSdkConfig = ({ keys, provider, useLegacyLogic = false })=>{
|
|
|
122
125
|
modelName: modelName,
|
|
123
126
|
modelDescription,
|
|
124
127
|
intent: '-',
|
|
128
|
+
slot: '-',
|
|
125
129
|
timeout: provider[keys.timeout] ? Number(provider[keys.timeout]) : void 0,
|
|
126
130
|
temperature,
|
|
127
131
|
retryCount: (()=>{
|
|
@@ -164,6 +168,7 @@ const decideModelConfigFromIntentConfig = (intent, configMap)=>{
|
|
|
164
168
|
useLegacyLogic: 'default' === intent
|
|
165
169
|
});
|
|
166
170
|
finalResult.intent = intent;
|
|
171
|
+
finalResult.slot = intent;
|
|
167
172
|
debugLog('decideModelConfig result by agent.modelConfig() with intent', intent, (0, external_helper_js_namespaceObject.maskConfig)({
|
|
168
173
|
...finalResult
|
|
169
174
|
}));
|
package/dist/lib/env/types.js
CHANGED
|
@@ -55,6 +55,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
55
55
|
MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY: ()=>MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
|
|
56
56
|
MIDSCENE_INSIGHT_MODEL_TEMPERATURE: ()=>MIDSCENE_INSIGHT_MODEL_TEMPERATURE,
|
|
57
57
|
MIDSCENE_INSIGHT_MODEL_TIMEOUT: ()=>MIDSCENE_INSIGHT_MODEL_TIMEOUT,
|
|
58
|
+
MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE: ()=>MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE,
|
|
58
59
|
MIDSCENE_IOS_DEVICE_UDID: ()=>MIDSCENE_IOS_DEVICE_UDID,
|
|
59
60
|
MIDSCENE_IOS_SIMULATOR_UDID: ()=>MIDSCENE_IOS_SIMULATOR_UDID,
|
|
60
61
|
MIDSCENE_LANGFUSE_DEBUG: ()=>MIDSCENE_LANGFUSE_DEBUG,
|
|
@@ -154,6 +155,7 @@ const MIDSCENE_ADB_REMOTE_PORT = 'MIDSCENE_ADB_REMOTE_PORT';
|
|
|
154
155
|
const MIDSCENE_ANDROID_IME_STRATEGY = 'MIDSCENE_ANDROID_IME_STRATEGY';
|
|
155
156
|
const MIDSCENE_IOS_DEVICE_UDID = 'MIDSCENE_IOS_DEVICE_UDID';
|
|
156
157
|
const MIDSCENE_IOS_SIMULATOR_UDID = 'MIDSCENE_IOS_SIMULATOR_UDID';
|
|
158
|
+
const MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE = 'MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE';
|
|
157
159
|
const MIDSCENE_CACHE = 'MIDSCENE_CACHE';
|
|
158
160
|
const MIDSCENE_USE_VLM_UI_TARS = 'MIDSCENE_USE_VLM_UI_TARS';
|
|
159
161
|
const MIDSCENE_USE_QWEN_VL = 'MIDSCENE_USE_QWEN_VL';
|
|
@@ -359,6 +361,7 @@ exports.MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL = __webpack_exports__.MIDSCENE_INS
|
|
|
359
361
|
exports.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY;
|
|
360
362
|
exports.MIDSCENE_INSIGHT_MODEL_TEMPERATURE = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_TEMPERATURE;
|
|
361
363
|
exports.MIDSCENE_INSIGHT_MODEL_TIMEOUT = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_TIMEOUT;
|
|
364
|
+
exports.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE = __webpack_exports__.MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE;
|
|
362
365
|
exports.MIDSCENE_IOS_DEVICE_UDID = __webpack_exports__.MIDSCENE_IOS_DEVICE_UDID;
|
|
363
366
|
exports.MIDSCENE_IOS_SIMULATOR_UDID = __webpack_exports__.MIDSCENE_IOS_SIMULATOR_UDID;
|
|
364
367
|
exports.MIDSCENE_LANGFUSE_DEBUG = __webpack_exports__.MIDSCENE_LANGFUSE_DEBUG;
|
|
@@ -452,6 +455,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
452
455
|
"MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY",
|
|
453
456
|
"MIDSCENE_INSIGHT_MODEL_TEMPERATURE",
|
|
454
457
|
"MIDSCENE_INSIGHT_MODEL_TIMEOUT",
|
|
458
|
+
"MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE",
|
|
455
459
|
"MIDSCENE_IOS_DEVICE_UDID",
|
|
456
460
|
"MIDSCENE_IOS_SIMULATOR_UDID",
|
|
457
461
|
"MIDSCENE_LANGFUSE_DEBUG",
|
package/dist/lib/env/utils.js
CHANGED
|
@@ -27,7 +27,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
27
|
overrideAIConfig: ()=>overrideAIConfig,
|
|
28
28
|
globalModelConfigManager: ()=>globalModelConfigManager,
|
|
29
29
|
getPreferredLanguage: ()=>getPreferredLanguage,
|
|
30
|
-
getCurrentTime: ()=>getCurrentTime,
|
|
31
30
|
globalConfigManager: ()=>globalConfigManager
|
|
32
31
|
});
|
|
33
32
|
const external_global_config_manager_js_namespaceObject = require("./global-config-manager.js");
|
|
@@ -37,14 +36,6 @@ const globalModelConfigManager = new external_model_config_manager_js_namespaceO
|
|
|
37
36
|
const globalConfigManager = new external_global_config_manager_js_namespaceObject.GlobalConfigManager();
|
|
38
37
|
globalConfigManager.registerModelConfigManager(globalModelConfigManager);
|
|
39
38
|
globalModelConfigManager.registerGlobalConfigManager(globalConfigManager);
|
|
40
|
-
async function getCurrentTime(device, useDeviceTimestamp) {
|
|
41
|
-
if (useDeviceTimestamp && device?.getTimestamp) try {
|
|
42
|
-
return await device.getTimestamp();
|
|
43
|
-
} catch (error) {
|
|
44
|
-
console.warn(`Failed to get device time, falling back to system time: ${error}`);
|
|
45
|
-
}
|
|
46
|
-
return Date.now();
|
|
47
|
-
}
|
|
48
39
|
const getPreferredLanguage = ()=>{
|
|
49
40
|
const prefer = globalConfigManager.getEnvConfigValue(external_types_js_namespaceObject.MIDSCENE_PREFERRED_LANGUAGE);
|
|
50
41
|
if (prefer) return prefer;
|
|
@@ -55,13 +46,11 @@ const getPreferredLanguage = ()=>{
|
|
|
55
46
|
const overrideAIConfig = (newConfig, extendMode = false)=>{
|
|
56
47
|
globalConfigManager.overrideAIConfig(newConfig, extendMode);
|
|
57
48
|
};
|
|
58
|
-
exports.getCurrentTime = __webpack_exports__.getCurrentTime;
|
|
59
49
|
exports.getPreferredLanguage = __webpack_exports__.getPreferredLanguage;
|
|
60
50
|
exports.globalConfigManager = __webpack_exports__.globalConfigManager;
|
|
61
51
|
exports.globalModelConfigManager = __webpack_exports__.globalModelConfigManager;
|
|
62
52
|
exports.overrideAIConfig = __webpack_exports__.overrideAIConfig;
|
|
63
53
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
64
|
-
"getCurrentTime",
|
|
65
54
|
"getPreferredLanguage",
|
|
66
55
|
"globalConfigManager",
|
|
67
56
|
"globalModelConfigManager",
|
|
@@ -24,6 +24,7 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
generateElementByPoint: ()=>external_dom_util_js_namespaceObject.generateElementByPoint,
|
|
27
28
|
getNodeInfoByXpath: ()=>external_locator_js_namespaceObject.getNodeInfoByXpath,
|
|
28
29
|
getXpathsById: ()=>external_locator_js_namespaceObject.getXpathsById,
|
|
29
30
|
trimAttributes: ()=>external_tree_js_namespaceObject.trimAttributes,
|
|
@@ -45,6 +46,7 @@ const external_web_extractor_js_namespaceObject = require("./web-extractor.js");
|
|
|
45
46
|
const external_locator_js_namespaceObject = require("./locator.js");
|
|
46
47
|
const external_dom_util_js_namespaceObject = require("./dom-util.js");
|
|
47
48
|
exports.descriptionOfTree = __webpack_exports__.descriptionOfTree;
|
|
49
|
+
exports.generateElementByPoint = __webpack_exports__.generateElementByPoint;
|
|
48
50
|
exports.generateElementByRect = __webpack_exports__.generateElementByRect;
|
|
49
51
|
exports.getElementInfoByXpath = __webpack_exports__.getElementInfoByXpath;
|
|
50
52
|
exports.getElementXpath = __webpack_exports__.getElementXpath;
|
|
@@ -61,6 +63,7 @@ exports.webExtractNodeTreeAsString = __webpack_exports__.webExtractNodeTreeAsStr
|
|
|
61
63
|
exports.webExtractTextWithPosition = __webpack_exports__.webExtractTextWithPosition;
|
|
62
64
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
63
65
|
"descriptionOfTree",
|
|
66
|
+
"generateElementByPoint",
|
|
64
67
|
"generateElementByRect",
|
|
65
68
|
"getElementInfoByXpath",
|
|
66
69
|
"getElementXpath",
|
package/dist/lib/img/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
resizeImgBase64: ()=>external_transform_js_namespaceObject.resizeImgBase64,
|
|
32
32
|
saveBase64Image: ()=>external_transform_js_namespaceObject.saveBase64Image,
|
|
33
33
|
isValidImageBuffer: ()=>external_info_js_namespaceObject.isValidImageBuffer,
|
|
34
|
+
validateScreenshotBuffer: ()=>external_info_js_namespaceObject.validateScreenshotBuffer,
|
|
34
35
|
preProcessImageUrl: ()=>external_transform_js_namespaceObject.preProcessImageUrl,
|
|
35
36
|
annotateRects: ()=>external_box_select_js_namespaceObject.annotateRects,
|
|
36
37
|
compositeElementInfoImg: ()=>external_box_select_js_namespaceObject.compositeElementInfoImg,
|
|
@@ -65,6 +66,7 @@ exports.resizeAndConvertImgBuffer = __webpack_exports__.resizeAndConvertImgBuffe
|
|
|
65
66
|
exports.resizeImgBase64 = __webpack_exports__.resizeImgBase64;
|
|
66
67
|
exports.saveBase64Image = __webpack_exports__.saveBase64Image;
|
|
67
68
|
exports.scaleImage = __webpack_exports__.scaleImage;
|
|
69
|
+
exports.validateScreenshotBuffer = __webpack_exports__.validateScreenshotBuffer;
|
|
68
70
|
exports.zoomForGPT4o = __webpack_exports__.zoomForGPT4o;
|
|
69
71
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
70
72
|
"annotateRects",
|
|
@@ -85,6 +87,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
85
87
|
"resizeImgBase64",
|
|
86
88
|
"saveBase64Image",
|
|
87
89
|
"scaleImage",
|
|
90
|
+
"validateScreenshotBuffer",
|
|
88
91
|
"zoomForGPT4o"
|
|
89
92
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
90
93
|
Object.defineProperty(exports, '__esModule', {
|
package/dist/lib/img/info.js
CHANGED
|
@@ -35,6 +35,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
36
|
isValidPNGImageBuffer: ()=>isValidPNGImageBuffer,
|
|
37
37
|
isValidImageBuffer: ()=>isValidImageBuffer,
|
|
38
|
+
validateScreenshotBuffer: ()=>validateScreenshotBuffer,
|
|
38
39
|
imageInfoOfBase64: ()=>imageInfoOfBase64,
|
|
39
40
|
isValidJPEGImageBuffer: ()=>isValidJPEGImageBuffer
|
|
40
41
|
});
|
|
@@ -68,15 +69,23 @@ function isValidJPEGImageBuffer(buffer) {
|
|
|
68
69
|
function isValidImageBuffer(buffer) {
|
|
69
70
|
return isValidPNGImageBuffer(buffer) || isValidJPEGImageBuffer(buffer);
|
|
70
71
|
}
|
|
72
|
+
function validateScreenshotBuffer(screenshotBuffer, { label, minBufferSize = 0 }) {
|
|
73
|
+
const bufferSize = screenshotBuffer?.length ?? 0;
|
|
74
|
+
if (!screenshotBuffer || 0 === bufferSize) throw new Error(`${label} validation failed: buffer size ${bufferSize} bytes`);
|
|
75
|
+
if (!isValidImageBuffer(screenshotBuffer)) throw new Error(`${label} buffer has invalid image format`);
|
|
76
|
+
if (minBufferSize > 0 && bufferSize < minBufferSize) throw new Error(`${label} validation failed: buffer size ${bufferSize} bytes (minimum: ${minBufferSize})`);
|
|
77
|
+
}
|
|
71
78
|
exports.imageInfoOfBase64 = __webpack_exports__.imageInfoOfBase64;
|
|
72
79
|
exports.isValidImageBuffer = __webpack_exports__.isValidImageBuffer;
|
|
73
80
|
exports.isValidJPEGImageBuffer = __webpack_exports__.isValidJPEGImageBuffer;
|
|
74
81
|
exports.isValidPNGImageBuffer = __webpack_exports__.isValidPNGImageBuffer;
|
|
82
|
+
exports.validateScreenshotBuffer = __webpack_exports__.validateScreenshotBuffer;
|
|
75
83
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
76
84
|
"imageInfoOfBase64",
|
|
77
85
|
"isValidImageBuffer",
|
|
78
86
|
"isValidJPEGImageBuffer",
|
|
79
|
-
"isValidPNGImageBuffer"
|
|
87
|
+
"isValidPNGImageBuffer",
|
|
88
|
+
"validateScreenshotBuffer"
|
|
80
89
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
81
90
|
Object.defineProperty(exports, '__esModule', {
|
|
82
91
|
value: true
|