@aiscene/shared 8.0.4 → 8.0.5
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/env/parse-model-config.mjs +1 -1
- package/dist/es/env/types.mjs +16 -3
- package/dist/es/img/index.mjs +3 -3
- package/dist/es/img/transform.mjs +113 -3
- package/dist/lib/env/parse-model-config.js +1 -1
- package/dist/lib/env/types.js +27 -2
- package/dist/lib/img/index.js +29 -5
- package/dist/lib/img/transform.js +135 -4
- package/dist/types/env/types.d.ts +13 -5
- package/dist/types/img/index.d.ts +2 -2
- package/dist/types/img/transform.d.ts +22 -2
- package/package.json +1 -1
- package/src/env/types.ts +28 -2
- package/src/img/transform.ts +1 -1
|
@@ -5,7 +5,7 @@ import { assert } from "../utils.mjs";
|
|
|
5
5
|
import { maskConfig, parseJson } from "./helper.mjs";
|
|
6
6
|
import { initDebugConfig } from "./init-debug.mjs";
|
|
7
7
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
8
|
-
const getCurrentVersion = ()=>"8.0.
|
|
8
|
+
const getCurrentVersion = ()=>"8.0.5";
|
|
9
9
|
const getInvalidModelFamilyMessage = (modelFamily)=>`Invalid MIDSCENE_MODEL_FAMILY value: ${modelFamily}. Current version v${getCurrentVersion()} accepts the following model families: ${MODEL_FAMILY_VALUES.join(', ')}. You can also visit ${MODEL_CONFIG_DOC_URL} for the latest configuration information.`;
|
|
10
10
|
const KEYS_MAP = {
|
|
11
11
|
insight: INSIGHT_MODEL_CONFIG_KEYS,
|
package/dist/es/env/types.mjs
CHANGED
|
@@ -24,6 +24,7 @@ const MIDSCENE_MODEL_RETRY_INTERVAL = 'MIDSCENE_MODEL_RETRY_INTERVAL';
|
|
|
24
24
|
const MIDSCENE_MODEL_REASONING_EFFORT = 'MIDSCENE_MODEL_REASONING_EFFORT';
|
|
25
25
|
const MIDSCENE_MODEL_REASONING_ENABLED = 'MIDSCENE_MODEL_REASONING_ENABLED';
|
|
26
26
|
const MIDSCENE_MODEL_REASONING_BUDGET = 'MIDSCENE_MODEL_REASONING_BUDGET';
|
|
27
|
+
const MIDSCENE_MODEL_RESPONSE_FORMAT = 'MIDSCENE_MODEL_RESPONSE_FORMAT';
|
|
27
28
|
const OPENAI_API_KEY = 'OPENAI_API_KEY';
|
|
28
29
|
const OPENAI_BASE_URL = 'OPENAI_BASE_URL';
|
|
29
30
|
const MIDSCENE_OPENAI_INIT_CONFIG_JSON = 'MIDSCENE_OPENAI_INIT_CONFIG_JSON';
|
|
@@ -51,6 +52,7 @@ const MIDSCENE_PREFERRED_LANGUAGE = 'MIDSCENE_PREFERRED_LANGUAGE';
|
|
|
51
52
|
const MIDSCENE_CACHE_MAX_FILENAME_LENGTH = 'MIDSCENE_CACHE_MAX_FILENAME_LENGTH';
|
|
52
53
|
const MIDSCENE_REPLANNING_CYCLE_LIMIT = 'MIDSCENE_REPLANNING_CYCLE_LIMIT';
|
|
53
54
|
const MIDSCENE_RUN_DIR = 'MIDSCENE_RUN_DIR';
|
|
55
|
+
const MIDSCENE_RECORD_MODEL_CALL = 'MIDSCENE_RECORD_MODEL_CALL';
|
|
54
56
|
const MIDSCENE_INSIGHT_MODEL_NAME = 'MIDSCENE_INSIGHT_MODEL_NAME';
|
|
55
57
|
const MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = 'MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY';
|
|
56
58
|
const MIDSCENE_INSIGHT_MODEL_HTTP_PROXY = 'MIDSCENE_INSIGHT_MODEL_HTTP_PROXY';
|
|
@@ -66,6 +68,7 @@ const MIDSCENE_INSIGHT_MODEL_FAMILY = 'MIDSCENE_INSIGHT_MODEL_FAMILY';
|
|
|
66
68
|
const MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT = 'MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT';
|
|
67
69
|
const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = 'MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED';
|
|
68
70
|
const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = 'MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET';
|
|
71
|
+
const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = 'MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT';
|
|
69
72
|
const MIDSCENE_PLANNING_MODEL_NAME = 'MIDSCENE_PLANNING_MODEL_NAME';
|
|
70
73
|
const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = 'MIDSCENE_PLANNING_MODEL_SOCKS_PROXY';
|
|
71
74
|
const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = 'MIDSCENE_PLANNING_MODEL_HTTP_PROXY';
|
|
@@ -81,6 +84,7 @@ const MIDSCENE_PLANNING_MODEL_FAMILY = 'MIDSCENE_PLANNING_MODEL_FAMILY';
|
|
|
81
84
|
const MIDSCENE_PLANNING_MODEL_REASONING_EFFORT = 'MIDSCENE_PLANNING_MODEL_REASONING_EFFORT';
|
|
82
85
|
const MIDSCENE_PLANNING_MODEL_REASONING_ENABLED = 'MIDSCENE_PLANNING_MODEL_REASONING_ENABLED';
|
|
83
86
|
const MIDSCENE_PLANNING_MODEL_REASONING_BUDGET = 'MIDSCENE_PLANNING_MODEL_REASONING_BUDGET';
|
|
87
|
+
const MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT = 'MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT';
|
|
84
88
|
const MIDSCENE_MODEL_FAMILY = 'MIDSCENE_MODEL_FAMILY';
|
|
85
89
|
const UNUSED_ENV_KEYS = [
|
|
86
90
|
MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG
|
|
@@ -89,7 +93,8 @@ const BASIC_ENV_KEYS = [
|
|
|
89
93
|
MIDSCENE_DEBUG_MODE,
|
|
90
94
|
MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
91
95
|
MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
92
|
-
MIDSCENE_RUN_DIR
|
|
96
|
+
MIDSCENE_RUN_DIR,
|
|
97
|
+
MIDSCENE_RECORD_MODEL_CALL
|
|
93
98
|
];
|
|
94
99
|
const BOOLEAN_ENV_KEYS = [
|
|
95
100
|
MIDSCENE_CACHE,
|
|
@@ -140,6 +145,7 @@ const MODEL_ENV_KEYS = [
|
|
|
140
145
|
MIDSCENE_MODEL_REASONING_EFFORT,
|
|
141
146
|
MIDSCENE_MODEL_REASONING_ENABLED,
|
|
142
147
|
MIDSCENE_MODEL_REASONING_BUDGET,
|
|
148
|
+
MIDSCENE_MODEL_RESPONSE_FORMAT,
|
|
143
149
|
MIDSCENE_USE_VLM_UI_TARS,
|
|
144
150
|
MIDSCENE_USE_QWEN_VL,
|
|
145
151
|
MIDSCENE_USE_QWEN3_VL,
|
|
@@ -166,6 +172,7 @@ const MODEL_ENV_KEYS = [
|
|
|
166
172
|
MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT,
|
|
167
173
|
MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED,
|
|
168
174
|
MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
175
|
+
MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT,
|
|
169
176
|
MIDSCENE_PLANNING_MODEL_NAME,
|
|
170
177
|
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
171
178
|
MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
|
|
@@ -181,6 +188,7 @@ const MODEL_ENV_KEYS = [
|
|
|
181
188
|
MIDSCENE_PLANNING_MODEL_REASONING_EFFORT,
|
|
182
189
|
MIDSCENE_PLANNING_MODEL_REASONING_ENABLED,
|
|
183
190
|
MIDSCENE_PLANNING_MODEL_REASONING_BUDGET,
|
|
191
|
+
MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT,
|
|
184
192
|
MIDSCENE_MODEL_FAMILY
|
|
185
193
|
];
|
|
186
194
|
const ALL_ENV_KEYS = [
|
|
@@ -195,6 +203,7 @@ const MODEL_FAMILY_VALUES = [
|
|
|
195
203
|
'gemini',
|
|
196
204
|
'qwen2.5-vl',
|
|
197
205
|
'qwen3-vl',
|
|
206
|
+
'qwen3',
|
|
198
207
|
'qwen3.5',
|
|
199
208
|
'qwen3.6',
|
|
200
209
|
'vlm-ui-tars',
|
|
@@ -203,7 +212,11 @@ const MODEL_FAMILY_VALUES = [
|
|
|
203
212
|
'glm-v',
|
|
204
213
|
'auto-glm',
|
|
205
214
|
'auto-glm-multilingual',
|
|
206
|
-
'gpt-5'
|
|
215
|
+
'gpt-5',
|
|
216
|
+
'deepseek',
|
|
217
|
+
'kimi',
|
|
218
|
+
'kimi3',
|
|
219
|
+
'xiaomi-mimo'
|
|
207
220
|
];
|
|
208
221
|
var types_UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
209
222
|
UITarsModelVersion["V1_0"] = "1.0";
|
|
@@ -212,4 +225,4 @@ var types_UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
|
212
225
|
UITarsModelVersion["DOUBAO_1_5_20B"] = "doubao-1.5-20B";
|
|
213
226
|
return UITarsModelVersion;
|
|
214
227
|
}({});
|
|
215
|
-
export { ALL_ENV_KEYS, BASIC_ENV_KEYS, BOOLEAN_ENV_KEYS, DOCKER_CONTAINER, GLOBAL_ENV_KEYS, MATCH_BY_POSITION, MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_CACHE, MIDSCENE_CACHE_MAX_FILENAME_LENGTH, MIDSCENE_CHROME_PATH, MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG, MIDSCENE_DEBUG_MODE, MIDSCENE_DEBUG_MODEL_PROFILE, MIDSCENE_DEBUG_MODEL_RESPONSE, MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, MIDSCENE_IOS_DEVICE_UDID, MIDSCENE_IOS_SIMULATOR_UDID, MIDSCENE_LANGFUSE_DEBUG, MIDSCENE_LANGSMITH_DEBUG, MIDSCENE_MCP_ANDROID_MODE, MIDSCENE_MCP_CHROME_PATH, MIDSCENE_MCP_USE_PUPPETEER_MODE, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_MAX_TOKENS, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, MIDSCENE_PREFERRED_LANGUAGE, MIDSCENE_REPLANNING_CYCLE_LIMIT, MIDSCENE_REPORT_QUIET, MIDSCENE_REPORT_TAG_NAME, MIDSCENE_RUN_DIR, MIDSCENE_USE_DOUBAO_VISION, MIDSCENE_USE_GEMINI, MIDSCENE_USE_QWEN3_VL, MIDSCENE_USE_QWEN_VL, MIDSCENE_USE_VLM_UI_TARS, MIDSCENE_USE_VL_MODEL, MODEL_ENV_KEYS, MODEL_FAMILY_VALUES, NUMBER_ENV_KEYS, OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MAX_TOKENS, STRING_ENV_KEYS, types_UITarsModelVersion as UITarsModelVersion, UNUSED_ENV_KEYS };
|
|
228
|
+
export { ALL_ENV_KEYS, BASIC_ENV_KEYS, BOOLEAN_ENV_KEYS, DOCKER_CONTAINER, GLOBAL_ENV_KEYS, MATCH_BY_POSITION, MIDSCENE_ADB_PATH, MIDSCENE_ADB_REMOTE_HOST, MIDSCENE_ADB_REMOTE_PORT, MIDSCENE_ANDROID_IME_STRATEGY, MIDSCENE_CACHE, MIDSCENE_CACHE_MAX_FILENAME_LENGTH, MIDSCENE_CHROME_PATH, MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG, MIDSCENE_DEBUG_MODE, MIDSCENE_DEBUG_MODEL_PROFILE, MIDSCENE_DEBUG_MODEL_RESPONSE, MIDSCENE_INSIGHT_MODEL_API_KEY, MIDSCENE_INSIGHT_MODEL_BASE_URL, MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON, MIDSCENE_INSIGHT_MODEL_FAMILY, MIDSCENE_INSIGHT_MODEL_HTTP_PROXY, MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON, MIDSCENE_INSIGHT_MODEL_NAME, MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET, MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT, MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED, MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT, MIDSCENE_INSIGHT_MODEL_RETRY_COUNT, MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL, MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY, MIDSCENE_INSIGHT_MODEL_TEMPERATURE, MIDSCENE_INSIGHT_MODEL_TIMEOUT, MIDSCENE_IOS_DEVICE_CLASS_OVERRIDE, MIDSCENE_IOS_DEVICE_UDID, MIDSCENE_IOS_SIMULATOR_UDID, MIDSCENE_LANGFUSE_DEBUG, MIDSCENE_LANGSMITH_DEBUG, MIDSCENE_MCP_ANDROID_MODE, MIDSCENE_MCP_CHROME_PATH, MIDSCENE_MCP_USE_PUPPETEER_MODE, MIDSCENE_MODEL_API_KEY, MIDSCENE_MODEL_BASE_URL, MIDSCENE_MODEL_EXTRA_BODY_JSON, MIDSCENE_MODEL_FAMILY, MIDSCENE_MODEL_HTTP_PROXY, MIDSCENE_MODEL_INIT_CONFIG_JSON, MIDSCENE_MODEL_MAX_TOKENS, MIDSCENE_MODEL_NAME, MIDSCENE_MODEL_REASONING_BUDGET, MIDSCENE_MODEL_REASONING_EFFORT, MIDSCENE_MODEL_REASONING_ENABLED, MIDSCENE_MODEL_RESPONSE_FORMAT, MIDSCENE_MODEL_RETRY_COUNT, MIDSCENE_MODEL_RETRY_INTERVAL, MIDSCENE_MODEL_SOCKS_PROXY, MIDSCENE_MODEL_TEMPERATURE, MIDSCENE_MODEL_TIMEOUT, MIDSCENE_OPENAI_HTTP_PROXY, MIDSCENE_OPENAI_INIT_CONFIG_JSON, MIDSCENE_OPENAI_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_API_KEY, MIDSCENE_PLANNING_MODEL_BASE_URL, MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON, MIDSCENE_PLANNING_MODEL_FAMILY, MIDSCENE_PLANNING_MODEL_HTTP_PROXY, MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON, MIDSCENE_PLANNING_MODEL_NAME, MIDSCENE_PLANNING_MODEL_REASONING_BUDGET, MIDSCENE_PLANNING_MODEL_REASONING_EFFORT, MIDSCENE_PLANNING_MODEL_REASONING_ENABLED, MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT, MIDSCENE_PLANNING_MODEL_RETRY_COUNT, MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL, MIDSCENE_PLANNING_MODEL_SOCKS_PROXY, MIDSCENE_PLANNING_MODEL_TEMPERATURE, MIDSCENE_PLANNING_MODEL_TIMEOUT, MIDSCENE_PREFERRED_LANGUAGE, MIDSCENE_RECORD_MODEL_CALL, MIDSCENE_REPLANNING_CYCLE_LIMIT, MIDSCENE_REPORT_QUIET, MIDSCENE_REPORT_TAG_NAME, MIDSCENE_RUN_DIR, MIDSCENE_USE_DOUBAO_VISION, MIDSCENE_USE_GEMINI, MIDSCENE_USE_QWEN3_VL, MIDSCENE_USE_QWEN_VL, MIDSCENE_USE_VLM_UI_TARS, MIDSCENE_USE_VL_MODEL, MODEL_ENV_KEYS, MODEL_FAMILY_VALUES, NUMBER_ENV_KEYS, OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MAX_TOKENS, STRING_ENV_KEYS, types_UITarsModelVersion as UITarsModelVersion, UNUSED_ENV_KEYS };
|
package/dist/es/img/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { imageInfoOfBase64, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, validateScreenshotBuffer } from "./info.mjs";
|
|
2
|
-
import { createImgBase64ByFormat, cropByRect, httpImg2Base64, localImg2Base64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
1
|
+
import { encodedImageInfoOfBuffer, imageInfoOfBase64, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, validateScreenshotBuffer } from "./info.mjs";
|
|
2
|
+
import { constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
3
3
|
import { annotateRects, compositeElementInfoImg, processImageElementInfo } from "./box-select.mjs";
|
|
4
|
-
export { annotateRects, compositeElementInfoImg, createImgBase64ByFormat, cropByRect, httpImg2Base64, imageInfoOfBase64, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
4
|
+
export { annotateRects, compositeElementInfoImg, constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, encodedImageInfoOfBuffer, httpImg2Base64, imageInfoOfBase64, inferBase64ImageFormat, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
@@ -7,6 +7,7 @@ import { getDebug } from "../logger.mjs";
|
|
|
7
7
|
import { ifInNode } from "../utils.mjs";
|
|
8
8
|
import get_photon from "./get-photon.mjs";
|
|
9
9
|
import get_sharp from "./get-sharp.mjs";
|
|
10
|
+
import { encodedImageInfoOfBuffer } from "./info.mjs";
|
|
10
11
|
const imgDebug = getDebug('img');
|
|
11
12
|
async function saveBase64Image(options) {
|
|
12
13
|
const { base64Data, outputPath } = options;
|
|
@@ -69,7 +70,116 @@ async function resizeAndConvertImgBuffer(inputFormat, inputData, newSize) {
|
|
|
69
70
|
format: 'jpeg'
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
+
const rawBase64BodyPattern = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
74
|
+
const base64ImageDataUrlPattern = /^data:image\/(?:png|jpe?g);base64,[A-Za-z0-9+/=\s]+$/i;
|
|
75
|
+
const supportedScreenshotDataUriPattern = /^data:image\/(png|jpe?g);base64,([A-Za-z0-9+/=\s]+)$/i;
|
|
76
|
+
function normalizeBase64Body(body) {
|
|
77
|
+
return body.replace(/\s/g, '');
|
|
78
|
+
}
|
|
79
|
+
function detectImageMimeTypeFromBuffer(buffer) {
|
|
80
|
+
if (buffer.length >= 8 && 0x89 === buffer[0] && 0x50 === buffer[1] && 0x4e === buffer[2] && 0x47 === buffer[3] && 0x0d === buffer[4] && 0x0a === buffer[5] && 0x1a === buffer[6] && 0x0a === buffer[7]) return 'image/png';
|
|
81
|
+
if (buffer.length >= 3 && 0xff === buffer[0] && 0xd8 === buffer[1] && 0xff === buffer[2]) return 'image/jpeg';
|
|
82
|
+
}
|
|
83
|
+
function inferBase64ImageFormat(base64Body) {
|
|
84
|
+
const buffer = Buffer.from(normalizeBase64Body(base64Body), 'base64');
|
|
85
|
+
const mimeType = detectImageMimeTypeFromBuffer(buffer);
|
|
86
|
+
if ('image/jpeg' === mimeType) return 'jpeg';
|
|
87
|
+
return 'png';
|
|
88
|
+
}
|
|
89
|
+
const createImgBase64ByFormat = (format, body)=>`data:image/${format};base64,${normalizeBase64Body(body)}`;
|
|
90
|
+
const normalizeScreenshotBase64 = (base64, options)=>{
|
|
91
|
+
const label = options?.label ?? 'screenshot base64';
|
|
92
|
+
const trimmedBase64 = base64.trim();
|
|
93
|
+
if (!trimmedBase64) throw new Error(`${label} cannot be empty`);
|
|
94
|
+
const dataUriMatch = trimmedBase64.match(supportedScreenshotDataUriPattern);
|
|
95
|
+
if (dataUriMatch) {
|
|
96
|
+
const imageFormat = 'jpg' === dataUriMatch[1].toLowerCase() ? 'jpeg' : dataUriMatch[1].toLowerCase();
|
|
97
|
+
const body = normalizeBase64Body(dataUriMatch[2]);
|
|
98
|
+
if (!body) throw new Error(`${label} cannot be empty`);
|
|
99
|
+
return createImgBase64ByFormat(imageFormat, body);
|
|
100
|
+
}
|
|
101
|
+
if (trimmedBase64.startsWith('data:')) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
102
|
+
if (!rawBase64BodyPattern.test(normalizeBase64Body(trimmedBase64))) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
103
|
+
return createImgBase64ByFormat('png', trimmedBase64);
|
|
104
|
+
};
|
|
105
|
+
const normalizeBase64Image = (base64)=>{
|
|
106
|
+
const trimmedBase64 = base64.trim();
|
|
107
|
+
if (base64ImageDataUrlPattern.test(trimmedBase64)) return trimmedBase64.replace(/\s/g, '');
|
|
108
|
+
const base64Body = normalizeBase64Body(trimmedBase64);
|
|
109
|
+
node_assert(base64Body, 'base64 image must include image data');
|
|
110
|
+
return createImgBase64ByFormat(inferBase64ImageFormat(base64Body), base64Body);
|
|
111
|
+
};
|
|
112
|
+
function assertValidJpegQuality(jpegQuality) {
|
|
113
|
+
if (!Number.isInteger(jpegQuality) || jpegQuality < 1 || jpegQuality > 100) throw new Error(`jpegQuality must be an integer between 1 and 100. Received: ${jpegQuality}`);
|
|
114
|
+
}
|
|
115
|
+
function assertValidImageSize(size, label) {
|
|
116
|
+
if (!Number.isInteger(size.width) || !Number.isInteger(size.height) || size.width <= 0 || size.height <= 0) throw new Error(`${label} width and height must be positive integers. Received width: ${size.width}, height: ${size.height}`);
|
|
117
|
+
}
|
|
118
|
+
async function convertImgBufferToJpeg(inputData, jpegQuality = 90) {
|
|
119
|
+
assertValidJpegQuality(jpegQuality);
|
|
120
|
+
if (ifInNode) try {
|
|
121
|
+
const Sharp = await get_sharp();
|
|
122
|
+
return await Sharp(inputData).jpeg({
|
|
123
|
+
quality: jpegQuality
|
|
124
|
+
}).toBuffer();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
imgDebug('Sharp failed, falling back to Photon:', error);
|
|
127
|
+
}
|
|
128
|
+
const { PhotonImage } = await get_photon();
|
|
129
|
+
const inputBytes = new Uint8Array(inputData);
|
|
130
|
+
const bytesliceResult = PhotonImage.new_from_byteslice(inputBytes);
|
|
131
|
+
const image = bytesliceResult instanceof Promise ? await bytesliceResult : bytesliceResult;
|
|
132
|
+
try {
|
|
133
|
+
return Buffer.from(image.get_bytes_jpeg(jpegQuality));
|
|
134
|
+
} finally{
|
|
135
|
+
image.free();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function convertBase64ImageToJpeg(inputBase64, jpegQuality = 90) {
|
|
139
|
+
assertValidJpegQuality(jpegQuality);
|
|
140
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
141
|
+
const { body } = parseBase64(normalized);
|
|
142
|
+
const imageBuffer = Buffer.from(body, 'base64');
|
|
143
|
+
const detectedMimeType = detectImageMimeTypeFromBuffer(imageBuffer);
|
|
144
|
+
if ('image/jpeg' === detectedMimeType) return createImgBase64ByFormat('jpeg', body);
|
|
145
|
+
if ('image/png' !== detectedMimeType) throw new Error(`inputBase64 must contain a PNG or JPEG image. Detected: ${detectedMimeType ?? 'unsupported format'}`);
|
|
146
|
+
const jpegBuffer = await convertImgBufferToJpeg(imageBuffer, jpegQuality);
|
|
147
|
+
return createImgBase64ByFormat('jpeg', jpegBuffer.toString('base64'));
|
|
148
|
+
}
|
|
149
|
+
async function resizeBase64ImageToJpeg(inputBase64, options) {
|
|
150
|
+
const jpegQuality = options.jpegQuality ?? 90;
|
|
151
|
+
assertValidJpegQuality(jpegQuality);
|
|
152
|
+
assertValidImageSize(options.targetSize, 'targetSize');
|
|
153
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
154
|
+
const { body, mimeType } = parseBase64(normalized);
|
|
155
|
+
const imageBuffer = Buffer.from(body, 'base64');
|
|
156
|
+
const sourceSize = encodedImageInfoOfBuffer(imageBuffer);
|
|
157
|
+
if (options.sourceSize) {
|
|
158
|
+
assertValidImageSize(options.sourceSize, 'sourceSize');
|
|
159
|
+
if (options.sourceSize.width !== sourceSize.width || options.sourceSize.height !== sourceSize.height) throw new Error(`sourceSize ${options.sourceSize.width}x${options.sourceSize.height} does not match encoded image dimensions ${sourceSize.width}x${sourceSize.height}`);
|
|
160
|
+
}
|
|
161
|
+
const dimensionsUnchanged = sourceSize.width === options.targetSize.width && sourceSize.height === options.targetSize.height;
|
|
162
|
+
if (dimensionsUnchanged) return convertBase64ImageToJpeg(normalized, jpegQuality);
|
|
163
|
+
const { buffer } = await resizeAndConvertImgBuffer(mimeType.split('/')[1], imageBuffer, options.targetSize);
|
|
164
|
+
return createImgBase64ByFormat('jpeg', buffer.toString('base64'));
|
|
165
|
+
}
|
|
166
|
+
async function constrainBase64ImageToMaxSize(inputBase64, options) {
|
|
167
|
+
if (!Number.isInteger(options.maxSize) || options.maxSize <= 0) throw new Error(`maxSize must be a positive integer. Received: ${options.maxSize}`);
|
|
168
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
169
|
+
const { body } = parseBase64(normalized);
|
|
170
|
+
const sourceSize = encodedImageInfoOfBuffer(Buffer.from(body, 'base64'));
|
|
171
|
+
const largestDimension = Math.max(sourceSize.width, sourceSize.height);
|
|
172
|
+
if (largestDimension <= options.maxSize) return normalized;
|
|
173
|
+
const scale = options.maxSize / largestDimension;
|
|
174
|
+
return resizeBase64ImageToJpeg(normalized, {
|
|
175
|
+
targetSize: {
|
|
176
|
+
width: Math.max(1, Math.round(sourceSize.width * scale)),
|
|
177
|
+
height: Math.max(1, Math.round(sourceSize.height * scale))
|
|
178
|
+
},
|
|
179
|
+
sourceSize,
|
|
180
|
+
jpegQuality: options.jpegQuality
|
|
181
|
+
});
|
|
182
|
+
}
|
|
73
183
|
async function resizeImgBase64(inputBase64, newSize) {
|
|
74
184
|
const { body, mimeType } = parseBase64(inputBase64);
|
|
75
185
|
const imageBuffer = Buffer.from(body, 'base64');
|
|
@@ -146,7 +256,7 @@ async function paddingToMatchBlockByBase64(imageBase64, blockSize = 28) {
|
|
|
146
256
|
photonImage.free();
|
|
147
257
|
}
|
|
148
258
|
}
|
|
149
|
-
async function cropByRect(imageBase64, rect, paddingImage) {
|
|
259
|
+
async function cropByRect(imageBase64, rect, paddingImage = false) {
|
|
150
260
|
const { crop } = await get_photon();
|
|
151
261
|
const photonImage = await photonFromBase64(imageBase64);
|
|
152
262
|
const { left, top, width, height } = rect;
|
|
@@ -272,4 +382,4 @@ async function scaleImage(imageBase64, scale) {
|
|
|
272
382
|
imageBase64: base64
|
|
273
383
|
};
|
|
274
384
|
}
|
|
275
|
-
export { createImgBase64ByFormat, cropByRect, httpImg2Base64, localImg2Base64, paddingToMatchBlock, paddingToMatchBlockByBase64, parseBase64, photonFromBase64, photonToBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o };
|
|
385
|
+
export { constrainBase64ImageToMaxSize, convertBase64ImageToJpeg, convertImgBufferToJpeg, createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlock, paddingToMatchBlockByBase64, parseBase64, photonFromBase64, photonToBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeBase64ImageToJpeg, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o };
|
|
@@ -37,7 +37,7 @@ 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
39
|
const MODEL_CONFIG_DOC_URL = 'https://midscenejs.com/model-common-config.html';
|
|
40
|
-
const getCurrentVersion = ()=>"8.0.
|
|
40
|
+
const getCurrentVersion = ()=>"8.0.5";
|
|
41
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.`;
|
|
42
42
|
const KEYS_MAP = {
|
|
43
43
|
insight: external_constants_js_namespaceObject.INSIGHT_MODEL_CONFIG_KEYS,
|
package/dist/lib/env/types.js
CHANGED
|
@@ -51,6 +51,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
51
51
|
MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET: ()=>MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
52
52
|
MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT: ()=>MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT,
|
|
53
53
|
MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED: ()=>MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED,
|
|
54
|
+
MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT: ()=>MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT,
|
|
54
55
|
MIDSCENE_INSIGHT_MODEL_RETRY_COUNT: ()=>MIDSCENE_INSIGHT_MODEL_RETRY_COUNT,
|
|
55
56
|
MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL: ()=>MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL,
|
|
56
57
|
MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY: ()=>MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY,
|
|
@@ -75,6 +76,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
75
76
|
MIDSCENE_MODEL_REASONING_BUDGET: ()=>MIDSCENE_MODEL_REASONING_BUDGET,
|
|
76
77
|
MIDSCENE_MODEL_REASONING_EFFORT: ()=>MIDSCENE_MODEL_REASONING_EFFORT,
|
|
77
78
|
MIDSCENE_MODEL_REASONING_ENABLED: ()=>MIDSCENE_MODEL_REASONING_ENABLED,
|
|
79
|
+
MIDSCENE_MODEL_RESPONSE_FORMAT: ()=>MIDSCENE_MODEL_RESPONSE_FORMAT,
|
|
78
80
|
MIDSCENE_MODEL_RETRY_COUNT: ()=>MIDSCENE_MODEL_RETRY_COUNT,
|
|
79
81
|
MIDSCENE_MODEL_RETRY_INTERVAL: ()=>MIDSCENE_MODEL_RETRY_INTERVAL,
|
|
80
82
|
MIDSCENE_MODEL_SOCKS_PROXY: ()=>MIDSCENE_MODEL_SOCKS_PROXY,
|
|
@@ -93,12 +95,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
93
95
|
MIDSCENE_PLANNING_MODEL_REASONING_BUDGET: ()=>MIDSCENE_PLANNING_MODEL_REASONING_BUDGET,
|
|
94
96
|
MIDSCENE_PLANNING_MODEL_REASONING_EFFORT: ()=>MIDSCENE_PLANNING_MODEL_REASONING_EFFORT,
|
|
95
97
|
MIDSCENE_PLANNING_MODEL_REASONING_ENABLED: ()=>MIDSCENE_PLANNING_MODEL_REASONING_ENABLED,
|
|
98
|
+
MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT: ()=>MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT,
|
|
96
99
|
MIDSCENE_PLANNING_MODEL_RETRY_COUNT: ()=>MIDSCENE_PLANNING_MODEL_RETRY_COUNT,
|
|
97
100
|
MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL: ()=>MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL,
|
|
98
101
|
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY: ()=>MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
99
102
|
MIDSCENE_PLANNING_MODEL_TEMPERATURE: ()=>MIDSCENE_PLANNING_MODEL_TEMPERATURE,
|
|
100
103
|
MIDSCENE_PLANNING_MODEL_TIMEOUT: ()=>MIDSCENE_PLANNING_MODEL_TIMEOUT,
|
|
101
104
|
MIDSCENE_PREFERRED_LANGUAGE: ()=>MIDSCENE_PREFERRED_LANGUAGE,
|
|
105
|
+
MIDSCENE_RECORD_MODEL_CALL: ()=>MIDSCENE_RECORD_MODEL_CALL,
|
|
102
106
|
MIDSCENE_REPLANNING_CYCLE_LIMIT: ()=>MIDSCENE_REPLANNING_CYCLE_LIMIT,
|
|
103
107
|
MIDSCENE_REPORT_QUIET: ()=>MIDSCENE_REPORT_QUIET,
|
|
104
108
|
MIDSCENE_REPORT_TAG_NAME: ()=>MIDSCENE_REPORT_TAG_NAME,
|
|
@@ -145,6 +149,7 @@ const MIDSCENE_MODEL_RETRY_INTERVAL = 'MIDSCENE_MODEL_RETRY_INTERVAL';
|
|
|
145
149
|
const MIDSCENE_MODEL_REASONING_EFFORT = 'MIDSCENE_MODEL_REASONING_EFFORT';
|
|
146
150
|
const MIDSCENE_MODEL_REASONING_ENABLED = 'MIDSCENE_MODEL_REASONING_ENABLED';
|
|
147
151
|
const MIDSCENE_MODEL_REASONING_BUDGET = 'MIDSCENE_MODEL_REASONING_BUDGET';
|
|
152
|
+
const MIDSCENE_MODEL_RESPONSE_FORMAT = 'MIDSCENE_MODEL_RESPONSE_FORMAT';
|
|
148
153
|
const OPENAI_API_KEY = 'OPENAI_API_KEY';
|
|
149
154
|
const OPENAI_BASE_URL = 'OPENAI_BASE_URL';
|
|
150
155
|
const MIDSCENE_OPENAI_INIT_CONFIG_JSON = 'MIDSCENE_OPENAI_INIT_CONFIG_JSON';
|
|
@@ -172,6 +177,7 @@ const MIDSCENE_PREFERRED_LANGUAGE = 'MIDSCENE_PREFERRED_LANGUAGE';
|
|
|
172
177
|
const MIDSCENE_CACHE_MAX_FILENAME_LENGTH = 'MIDSCENE_CACHE_MAX_FILENAME_LENGTH';
|
|
173
178
|
const MIDSCENE_REPLANNING_CYCLE_LIMIT = 'MIDSCENE_REPLANNING_CYCLE_LIMIT';
|
|
174
179
|
const MIDSCENE_RUN_DIR = 'MIDSCENE_RUN_DIR';
|
|
180
|
+
const MIDSCENE_RECORD_MODEL_CALL = 'MIDSCENE_RECORD_MODEL_CALL';
|
|
175
181
|
const MIDSCENE_INSIGHT_MODEL_NAME = 'MIDSCENE_INSIGHT_MODEL_NAME';
|
|
176
182
|
const MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = 'MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY';
|
|
177
183
|
const MIDSCENE_INSIGHT_MODEL_HTTP_PROXY = 'MIDSCENE_INSIGHT_MODEL_HTTP_PROXY';
|
|
@@ -187,6 +193,7 @@ const MIDSCENE_INSIGHT_MODEL_FAMILY = 'MIDSCENE_INSIGHT_MODEL_FAMILY';
|
|
|
187
193
|
const MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT = 'MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT';
|
|
188
194
|
const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = 'MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED';
|
|
189
195
|
const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = 'MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET';
|
|
196
|
+
const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = 'MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT';
|
|
190
197
|
const MIDSCENE_PLANNING_MODEL_NAME = 'MIDSCENE_PLANNING_MODEL_NAME';
|
|
191
198
|
const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = 'MIDSCENE_PLANNING_MODEL_SOCKS_PROXY';
|
|
192
199
|
const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = 'MIDSCENE_PLANNING_MODEL_HTTP_PROXY';
|
|
@@ -202,6 +209,7 @@ const MIDSCENE_PLANNING_MODEL_FAMILY = 'MIDSCENE_PLANNING_MODEL_FAMILY';
|
|
|
202
209
|
const MIDSCENE_PLANNING_MODEL_REASONING_EFFORT = 'MIDSCENE_PLANNING_MODEL_REASONING_EFFORT';
|
|
203
210
|
const MIDSCENE_PLANNING_MODEL_REASONING_ENABLED = 'MIDSCENE_PLANNING_MODEL_REASONING_ENABLED';
|
|
204
211
|
const MIDSCENE_PLANNING_MODEL_REASONING_BUDGET = 'MIDSCENE_PLANNING_MODEL_REASONING_BUDGET';
|
|
212
|
+
const MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT = 'MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT';
|
|
205
213
|
const MIDSCENE_MODEL_FAMILY = 'MIDSCENE_MODEL_FAMILY';
|
|
206
214
|
const UNUSED_ENV_KEYS = [
|
|
207
215
|
MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG
|
|
@@ -210,7 +218,8 @@ const BASIC_ENV_KEYS = [
|
|
|
210
218
|
MIDSCENE_DEBUG_MODE,
|
|
211
219
|
MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
212
220
|
MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
213
|
-
MIDSCENE_RUN_DIR
|
|
221
|
+
MIDSCENE_RUN_DIR,
|
|
222
|
+
MIDSCENE_RECORD_MODEL_CALL
|
|
214
223
|
];
|
|
215
224
|
const BOOLEAN_ENV_KEYS = [
|
|
216
225
|
MIDSCENE_CACHE,
|
|
@@ -261,6 +270,7 @@ const MODEL_ENV_KEYS = [
|
|
|
261
270
|
MIDSCENE_MODEL_REASONING_EFFORT,
|
|
262
271
|
MIDSCENE_MODEL_REASONING_ENABLED,
|
|
263
272
|
MIDSCENE_MODEL_REASONING_BUDGET,
|
|
273
|
+
MIDSCENE_MODEL_RESPONSE_FORMAT,
|
|
264
274
|
MIDSCENE_USE_VLM_UI_TARS,
|
|
265
275
|
MIDSCENE_USE_QWEN_VL,
|
|
266
276
|
MIDSCENE_USE_QWEN3_VL,
|
|
@@ -287,6 +297,7 @@ const MODEL_ENV_KEYS = [
|
|
|
287
297
|
MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT,
|
|
288
298
|
MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED,
|
|
289
299
|
MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
300
|
+
MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT,
|
|
290
301
|
MIDSCENE_PLANNING_MODEL_NAME,
|
|
291
302
|
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
292
303
|
MIDSCENE_PLANNING_MODEL_HTTP_PROXY,
|
|
@@ -302,6 +313,7 @@ const MODEL_ENV_KEYS = [
|
|
|
302
313
|
MIDSCENE_PLANNING_MODEL_REASONING_EFFORT,
|
|
303
314
|
MIDSCENE_PLANNING_MODEL_REASONING_ENABLED,
|
|
304
315
|
MIDSCENE_PLANNING_MODEL_REASONING_BUDGET,
|
|
316
|
+
MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT,
|
|
305
317
|
MIDSCENE_MODEL_FAMILY
|
|
306
318
|
];
|
|
307
319
|
const ALL_ENV_KEYS = [
|
|
@@ -316,6 +328,7 @@ const MODEL_FAMILY_VALUES = [
|
|
|
316
328
|
'gemini',
|
|
317
329
|
'qwen2.5-vl',
|
|
318
330
|
'qwen3-vl',
|
|
331
|
+
'qwen3',
|
|
319
332
|
'qwen3.5',
|
|
320
333
|
'qwen3.6',
|
|
321
334
|
'vlm-ui-tars',
|
|
@@ -324,7 +337,11 @@ const MODEL_FAMILY_VALUES = [
|
|
|
324
337
|
'glm-v',
|
|
325
338
|
'auto-glm',
|
|
326
339
|
'auto-glm-multilingual',
|
|
327
|
-
'gpt-5'
|
|
340
|
+
'gpt-5',
|
|
341
|
+
'deepseek',
|
|
342
|
+
'kimi',
|
|
343
|
+
'kimi3',
|
|
344
|
+
'xiaomi-mimo'
|
|
328
345
|
];
|
|
329
346
|
var UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
330
347
|
UITarsModelVersion["V1_0"] = "1.0";
|
|
@@ -360,6 +377,7 @@ exports.MIDSCENE_INSIGHT_MODEL_NAME = __webpack_exports__.MIDSCENE_INSIGHT_MODEL
|
|
|
360
377
|
exports.MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET;
|
|
361
378
|
exports.MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT;
|
|
362
379
|
exports.MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED;
|
|
380
|
+
exports.MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT;
|
|
363
381
|
exports.MIDSCENE_INSIGHT_MODEL_RETRY_COUNT = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_RETRY_COUNT;
|
|
364
382
|
exports.MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL;
|
|
365
383
|
exports.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = __webpack_exports__.MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY;
|
|
@@ -384,6 +402,7 @@ exports.MIDSCENE_MODEL_NAME = __webpack_exports__.MIDSCENE_MODEL_NAME;
|
|
|
384
402
|
exports.MIDSCENE_MODEL_REASONING_BUDGET = __webpack_exports__.MIDSCENE_MODEL_REASONING_BUDGET;
|
|
385
403
|
exports.MIDSCENE_MODEL_REASONING_EFFORT = __webpack_exports__.MIDSCENE_MODEL_REASONING_EFFORT;
|
|
386
404
|
exports.MIDSCENE_MODEL_REASONING_ENABLED = __webpack_exports__.MIDSCENE_MODEL_REASONING_ENABLED;
|
|
405
|
+
exports.MIDSCENE_MODEL_RESPONSE_FORMAT = __webpack_exports__.MIDSCENE_MODEL_RESPONSE_FORMAT;
|
|
387
406
|
exports.MIDSCENE_MODEL_RETRY_COUNT = __webpack_exports__.MIDSCENE_MODEL_RETRY_COUNT;
|
|
388
407
|
exports.MIDSCENE_MODEL_RETRY_INTERVAL = __webpack_exports__.MIDSCENE_MODEL_RETRY_INTERVAL;
|
|
389
408
|
exports.MIDSCENE_MODEL_SOCKS_PROXY = __webpack_exports__.MIDSCENE_MODEL_SOCKS_PROXY;
|
|
@@ -402,12 +421,14 @@ exports.MIDSCENE_PLANNING_MODEL_NAME = __webpack_exports__.MIDSCENE_PLANNING_MOD
|
|
|
402
421
|
exports.MIDSCENE_PLANNING_MODEL_REASONING_BUDGET = __webpack_exports__.MIDSCENE_PLANNING_MODEL_REASONING_BUDGET;
|
|
403
422
|
exports.MIDSCENE_PLANNING_MODEL_REASONING_EFFORT = __webpack_exports__.MIDSCENE_PLANNING_MODEL_REASONING_EFFORT;
|
|
404
423
|
exports.MIDSCENE_PLANNING_MODEL_REASONING_ENABLED = __webpack_exports__.MIDSCENE_PLANNING_MODEL_REASONING_ENABLED;
|
|
424
|
+
exports.MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT = __webpack_exports__.MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT;
|
|
405
425
|
exports.MIDSCENE_PLANNING_MODEL_RETRY_COUNT = __webpack_exports__.MIDSCENE_PLANNING_MODEL_RETRY_COUNT;
|
|
406
426
|
exports.MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL = __webpack_exports__.MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL;
|
|
407
427
|
exports.MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = __webpack_exports__.MIDSCENE_PLANNING_MODEL_SOCKS_PROXY;
|
|
408
428
|
exports.MIDSCENE_PLANNING_MODEL_TEMPERATURE = __webpack_exports__.MIDSCENE_PLANNING_MODEL_TEMPERATURE;
|
|
409
429
|
exports.MIDSCENE_PLANNING_MODEL_TIMEOUT = __webpack_exports__.MIDSCENE_PLANNING_MODEL_TIMEOUT;
|
|
410
430
|
exports.MIDSCENE_PREFERRED_LANGUAGE = __webpack_exports__.MIDSCENE_PREFERRED_LANGUAGE;
|
|
431
|
+
exports.MIDSCENE_RECORD_MODEL_CALL = __webpack_exports__.MIDSCENE_RECORD_MODEL_CALL;
|
|
411
432
|
exports.MIDSCENE_REPLANNING_CYCLE_LIMIT = __webpack_exports__.MIDSCENE_REPLANNING_CYCLE_LIMIT;
|
|
412
433
|
exports.MIDSCENE_REPORT_QUIET = __webpack_exports__.MIDSCENE_REPORT_QUIET;
|
|
413
434
|
exports.MIDSCENE_REPORT_TAG_NAME = __webpack_exports__.MIDSCENE_REPORT_TAG_NAME;
|
|
@@ -455,6 +476,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
455
476
|
"MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET",
|
|
456
477
|
"MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT",
|
|
457
478
|
"MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED",
|
|
479
|
+
"MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT",
|
|
458
480
|
"MIDSCENE_INSIGHT_MODEL_RETRY_COUNT",
|
|
459
481
|
"MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL",
|
|
460
482
|
"MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY",
|
|
@@ -479,6 +501,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
479
501
|
"MIDSCENE_MODEL_REASONING_BUDGET",
|
|
480
502
|
"MIDSCENE_MODEL_REASONING_EFFORT",
|
|
481
503
|
"MIDSCENE_MODEL_REASONING_ENABLED",
|
|
504
|
+
"MIDSCENE_MODEL_RESPONSE_FORMAT",
|
|
482
505
|
"MIDSCENE_MODEL_RETRY_COUNT",
|
|
483
506
|
"MIDSCENE_MODEL_RETRY_INTERVAL",
|
|
484
507
|
"MIDSCENE_MODEL_SOCKS_PROXY",
|
|
@@ -497,12 +520,14 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
497
520
|
"MIDSCENE_PLANNING_MODEL_REASONING_BUDGET",
|
|
498
521
|
"MIDSCENE_PLANNING_MODEL_REASONING_EFFORT",
|
|
499
522
|
"MIDSCENE_PLANNING_MODEL_REASONING_ENABLED",
|
|
523
|
+
"MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT",
|
|
500
524
|
"MIDSCENE_PLANNING_MODEL_RETRY_COUNT",
|
|
501
525
|
"MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL",
|
|
502
526
|
"MIDSCENE_PLANNING_MODEL_SOCKS_PROXY",
|
|
503
527
|
"MIDSCENE_PLANNING_MODEL_TEMPERATURE",
|
|
504
528
|
"MIDSCENE_PLANNING_MODEL_TIMEOUT",
|
|
505
529
|
"MIDSCENE_PREFERRED_LANGUAGE",
|
|
530
|
+
"MIDSCENE_RECORD_MODEL_CALL",
|
|
506
531
|
"MIDSCENE_REPLANNING_CYCLE_LIMIT",
|
|
507
532
|
"MIDSCENE_REPORT_QUIET",
|
|
508
533
|
"MIDSCENE_REPORT_TAG_NAME",
|
package/dist/lib/img/index.js
CHANGED
|
@@ -24,24 +24,32 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
27
|
+
convertImgBufferToJpeg: ()=>external_transform_js_namespaceObject.convertImgBufferToJpeg,
|
|
28
|
+
convertBase64ImageToJpeg: ()=>external_transform_js_namespaceObject.convertBase64ImageToJpeg,
|
|
29
|
+
inferBase64ImageFormat: ()=>external_transform_js_namespaceObject.inferBase64ImageFormat,
|
|
28
30
|
localImg2Base64: ()=>external_transform_js_namespaceObject.localImg2Base64,
|
|
31
|
+
constrainBase64ImageToMaxSize: ()=>external_transform_js_namespaceObject.constrainBase64ImageToMaxSize,
|
|
32
|
+
paddingToMatchBlockByBase64: ()=>external_transform_js_namespaceObject.paddingToMatchBlockByBase64,
|
|
29
33
|
parseBase64: ()=>external_transform_js_namespaceObject.parseBase64,
|
|
30
34
|
resizeAndConvertImgBuffer: ()=>external_transform_js_namespaceObject.resizeAndConvertImgBuffer,
|
|
31
35
|
resizeImgBase64: ()=>external_transform_js_namespaceObject.resizeImgBase64,
|
|
32
|
-
saveBase64Image: ()=>external_transform_js_namespaceObject.saveBase64Image,
|
|
33
36
|
isValidImageBuffer: ()=>external_info_js_namespaceObject.isValidImageBuffer,
|
|
37
|
+
saveBase64Image: ()=>external_transform_js_namespaceObject.saveBase64Image,
|
|
34
38
|
validateScreenshotBuffer: ()=>external_info_js_namespaceObject.validateScreenshotBuffer,
|
|
39
|
+
normalizeScreenshotBase64: ()=>external_transform_js_namespaceObject.normalizeScreenshotBase64,
|
|
35
40
|
preProcessImageUrl: ()=>external_transform_js_namespaceObject.preProcessImageUrl,
|
|
36
41
|
annotateRects: ()=>external_box_select_js_namespaceObject.annotateRects,
|
|
37
42
|
compositeElementInfoImg: ()=>external_box_select_js_namespaceObject.compositeElementInfoImg,
|
|
38
43
|
isValidPNGImageBuffer: ()=>external_info_js_namespaceObject.isValidPNGImageBuffer,
|
|
39
|
-
processImageElementInfo: ()=>external_box_select_js_namespaceObject.processImageElementInfo,
|
|
40
44
|
cropByRect: ()=>external_transform_js_namespaceObject.cropByRect,
|
|
41
|
-
|
|
45
|
+
normalizeBase64Image: ()=>external_transform_js_namespaceObject.normalizeBase64Image,
|
|
46
|
+
processImageElementInfo: ()=>external_box_select_js_namespaceObject.processImageElementInfo,
|
|
42
47
|
isValidJPEGImageBuffer: ()=>external_info_js_namespaceObject.isValidJPEGImageBuffer,
|
|
43
|
-
|
|
48
|
+
resizeBase64ImageToJpeg: ()=>external_transform_js_namespaceObject.resizeBase64ImageToJpeg,
|
|
49
|
+
scaleImage: ()=>external_transform_js_namespaceObject.scaleImage,
|
|
50
|
+
encodedImageInfoOfBuffer: ()=>external_info_js_namespaceObject.encodedImageInfoOfBuffer,
|
|
44
51
|
createImgBase64ByFormat: ()=>external_transform_js_namespaceObject.createImgBase64ByFormat,
|
|
52
|
+
zoomForGPT4o: ()=>external_transform_js_namespaceObject.zoomForGPT4o,
|
|
45
53
|
imageInfoOfBase64: ()=>external_info_js_namespaceObject.imageInfoOfBase64,
|
|
46
54
|
httpImg2Base64: ()=>external_transform_js_namespaceObject.httpImg2Base64
|
|
47
55
|
});
|
|
@@ -50,19 +58,27 @@ const external_transform_js_namespaceObject = require("./transform.js");
|
|
|
50
58
|
const external_box_select_js_namespaceObject = require("./box-select.js");
|
|
51
59
|
exports.annotateRects = __webpack_exports__.annotateRects;
|
|
52
60
|
exports.compositeElementInfoImg = __webpack_exports__.compositeElementInfoImg;
|
|
61
|
+
exports.constrainBase64ImageToMaxSize = __webpack_exports__.constrainBase64ImageToMaxSize;
|
|
62
|
+
exports.convertBase64ImageToJpeg = __webpack_exports__.convertBase64ImageToJpeg;
|
|
63
|
+
exports.convertImgBufferToJpeg = __webpack_exports__.convertImgBufferToJpeg;
|
|
53
64
|
exports.createImgBase64ByFormat = __webpack_exports__.createImgBase64ByFormat;
|
|
54
65
|
exports.cropByRect = __webpack_exports__.cropByRect;
|
|
66
|
+
exports.encodedImageInfoOfBuffer = __webpack_exports__.encodedImageInfoOfBuffer;
|
|
55
67
|
exports.httpImg2Base64 = __webpack_exports__.httpImg2Base64;
|
|
56
68
|
exports.imageInfoOfBase64 = __webpack_exports__.imageInfoOfBase64;
|
|
69
|
+
exports.inferBase64ImageFormat = __webpack_exports__.inferBase64ImageFormat;
|
|
57
70
|
exports.isValidImageBuffer = __webpack_exports__.isValidImageBuffer;
|
|
58
71
|
exports.isValidJPEGImageBuffer = __webpack_exports__.isValidJPEGImageBuffer;
|
|
59
72
|
exports.isValidPNGImageBuffer = __webpack_exports__.isValidPNGImageBuffer;
|
|
60
73
|
exports.localImg2Base64 = __webpack_exports__.localImg2Base64;
|
|
74
|
+
exports.normalizeBase64Image = __webpack_exports__.normalizeBase64Image;
|
|
75
|
+
exports.normalizeScreenshotBase64 = __webpack_exports__.normalizeScreenshotBase64;
|
|
61
76
|
exports.paddingToMatchBlockByBase64 = __webpack_exports__.paddingToMatchBlockByBase64;
|
|
62
77
|
exports.parseBase64 = __webpack_exports__.parseBase64;
|
|
63
78
|
exports.preProcessImageUrl = __webpack_exports__.preProcessImageUrl;
|
|
64
79
|
exports.processImageElementInfo = __webpack_exports__.processImageElementInfo;
|
|
65
80
|
exports.resizeAndConvertImgBuffer = __webpack_exports__.resizeAndConvertImgBuffer;
|
|
81
|
+
exports.resizeBase64ImageToJpeg = __webpack_exports__.resizeBase64ImageToJpeg;
|
|
66
82
|
exports.resizeImgBase64 = __webpack_exports__.resizeImgBase64;
|
|
67
83
|
exports.saveBase64Image = __webpack_exports__.saveBase64Image;
|
|
68
84
|
exports.scaleImage = __webpack_exports__.scaleImage;
|
|
@@ -71,19 +87,27 @@ exports.zoomForGPT4o = __webpack_exports__.zoomForGPT4o;
|
|
|
71
87
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
72
88
|
"annotateRects",
|
|
73
89
|
"compositeElementInfoImg",
|
|
90
|
+
"constrainBase64ImageToMaxSize",
|
|
91
|
+
"convertBase64ImageToJpeg",
|
|
92
|
+
"convertImgBufferToJpeg",
|
|
74
93
|
"createImgBase64ByFormat",
|
|
75
94
|
"cropByRect",
|
|
95
|
+
"encodedImageInfoOfBuffer",
|
|
76
96
|
"httpImg2Base64",
|
|
77
97
|
"imageInfoOfBase64",
|
|
98
|
+
"inferBase64ImageFormat",
|
|
78
99
|
"isValidImageBuffer",
|
|
79
100
|
"isValidJPEGImageBuffer",
|
|
80
101
|
"isValidPNGImageBuffer",
|
|
81
102
|
"localImg2Base64",
|
|
103
|
+
"normalizeBase64Image",
|
|
104
|
+
"normalizeScreenshotBase64",
|
|
82
105
|
"paddingToMatchBlockByBase64",
|
|
83
106
|
"parseBase64",
|
|
84
107
|
"preProcessImageUrl",
|
|
85
108
|
"processImageElementInfo",
|
|
86
109
|
"resizeAndConvertImgBuffer",
|
|
110
|
+
"resizeBase64ImageToJpeg",
|
|
87
111
|
"resizeImgBase64",
|
|
88
112
|
"saveBase64Image",
|
|
89
113
|
"scaleImage",
|
|
@@ -33,18 +33,25 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
|
|
36
|
+
convertImgBufferToJpeg: ()=>convertImgBufferToJpeg,
|
|
37
|
+
convertBase64ImageToJpeg: ()=>convertBase64ImageToJpeg,
|
|
38
|
+
inferBase64ImageFormat: ()=>inferBase64ImageFormat,
|
|
37
39
|
localImg2Base64: ()=>localImg2Base64,
|
|
40
|
+
constrainBase64ImageToMaxSize: ()=>constrainBase64ImageToMaxSize,
|
|
41
|
+
paddingToMatchBlockByBase64: ()=>paddingToMatchBlockByBase64,
|
|
42
|
+
parseBase64: ()=>parseBase64,
|
|
38
43
|
photonFromBase64: ()=>photonFromBase64,
|
|
39
44
|
photonToBase64: ()=>photonToBase64,
|
|
40
|
-
parseBase64: ()=>parseBase64,
|
|
41
45
|
resizeAndConvertImgBuffer: ()=>resizeAndConvertImgBuffer,
|
|
42
46
|
resizeImgBase64: ()=>resizeImgBase64,
|
|
43
47
|
saveBase64Image: ()=>saveBase64Image,
|
|
48
|
+
normalizeScreenshotBase64: ()=>normalizeScreenshotBase64,
|
|
44
49
|
preProcessImageUrl: ()=>preProcessImageUrl,
|
|
45
50
|
cropByRect: ()=>cropByRect,
|
|
46
51
|
scaleImage: ()=>scaleImage,
|
|
52
|
+
normalizeBase64Image: ()=>normalizeBase64Image,
|
|
47
53
|
zoomForGPT4o: ()=>zoomForGPT4o,
|
|
54
|
+
resizeBase64ImageToJpeg: ()=>resizeBase64ImageToJpeg,
|
|
48
55
|
createImgBase64ByFormat: ()=>createImgBase64ByFormat,
|
|
49
56
|
paddingToMatchBlock: ()=>paddingToMatchBlock,
|
|
50
57
|
httpImg2Base64: ()=>httpImg2Base64
|
|
@@ -62,6 +69,7 @@ const external_get_photon_js_namespaceObject = require("./get-photon.js");
|
|
|
62
69
|
var external_get_photon_js_default = /*#__PURE__*/ __webpack_require__.n(external_get_photon_js_namespaceObject);
|
|
63
70
|
const external_get_sharp_js_namespaceObject = require("./get-sharp.js");
|
|
64
71
|
var external_get_sharp_js_default = /*#__PURE__*/ __webpack_require__.n(external_get_sharp_js_namespaceObject);
|
|
72
|
+
const external_info_js_namespaceObject = require("./info.js");
|
|
65
73
|
const imgDebug = (0, external_logger_js_namespaceObject.getDebug)('img');
|
|
66
74
|
async function saveBase64Image(options) {
|
|
67
75
|
const { base64Data, outputPath } = options;
|
|
@@ -124,7 +132,116 @@ async function resizeAndConvertImgBuffer(inputFormat, inputData, newSize) {
|
|
|
124
132
|
format: 'jpeg'
|
|
125
133
|
};
|
|
126
134
|
}
|
|
127
|
-
const
|
|
135
|
+
const rawBase64BodyPattern = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
136
|
+
const base64ImageDataUrlPattern = /^data:image\/(?:png|jpe?g);base64,[A-Za-z0-9+/=\s]+$/i;
|
|
137
|
+
const supportedScreenshotDataUriPattern = /^data:image\/(png|jpe?g);base64,([A-Za-z0-9+/=\s]+)$/i;
|
|
138
|
+
function normalizeBase64Body(body) {
|
|
139
|
+
return body.replace(/\s/g, '');
|
|
140
|
+
}
|
|
141
|
+
function detectImageMimeTypeFromBuffer(buffer) {
|
|
142
|
+
if (buffer.length >= 8 && 0x89 === buffer[0] && 0x50 === buffer[1] && 0x4e === buffer[2] && 0x47 === buffer[3] && 0x0d === buffer[4] && 0x0a === buffer[5] && 0x1a === buffer[6] && 0x0a === buffer[7]) return 'image/png';
|
|
143
|
+
if (buffer.length >= 3 && 0xff === buffer[0] && 0xd8 === buffer[1] && 0xff === buffer[2]) return 'image/jpeg';
|
|
144
|
+
}
|
|
145
|
+
function inferBase64ImageFormat(base64Body) {
|
|
146
|
+
const buffer = external_node_buffer_namespaceObject.Buffer.from(normalizeBase64Body(base64Body), 'base64');
|
|
147
|
+
const mimeType = detectImageMimeTypeFromBuffer(buffer);
|
|
148
|
+
if ('image/jpeg' === mimeType) return 'jpeg';
|
|
149
|
+
return 'png';
|
|
150
|
+
}
|
|
151
|
+
const createImgBase64ByFormat = (format, body)=>`data:image/${format};base64,${normalizeBase64Body(body)}`;
|
|
152
|
+
const normalizeScreenshotBase64 = (base64, options)=>{
|
|
153
|
+
const label = options?.label ?? 'screenshot base64';
|
|
154
|
+
const trimmedBase64 = base64.trim();
|
|
155
|
+
if (!trimmedBase64) throw new Error(`${label} cannot be empty`);
|
|
156
|
+
const dataUriMatch = trimmedBase64.match(supportedScreenshotDataUriPattern);
|
|
157
|
+
if (dataUriMatch) {
|
|
158
|
+
const imageFormat = 'jpg' === dataUriMatch[1].toLowerCase() ? 'jpeg' : dataUriMatch[1].toLowerCase();
|
|
159
|
+
const body = normalizeBase64Body(dataUriMatch[2]);
|
|
160
|
+
if (!body) throw new Error(`${label} cannot be empty`);
|
|
161
|
+
return createImgBase64ByFormat(imageFormat, body);
|
|
162
|
+
}
|
|
163
|
+
if (trimmedBase64.startsWith('data:')) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
164
|
+
if (!rawBase64BodyPattern.test(normalizeBase64Body(trimmedBase64))) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
165
|
+
return createImgBase64ByFormat('png', trimmedBase64);
|
|
166
|
+
};
|
|
167
|
+
const normalizeBase64Image = (base64)=>{
|
|
168
|
+
const trimmedBase64 = base64.trim();
|
|
169
|
+
if (base64ImageDataUrlPattern.test(trimmedBase64)) return trimmedBase64.replace(/\s/g, '');
|
|
170
|
+
const base64Body = normalizeBase64Body(trimmedBase64);
|
|
171
|
+
external_node_assert_default()(base64Body, 'base64 image must include image data');
|
|
172
|
+
return createImgBase64ByFormat(inferBase64ImageFormat(base64Body), base64Body);
|
|
173
|
+
};
|
|
174
|
+
function assertValidJpegQuality(jpegQuality) {
|
|
175
|
+
if (!Number.isInteger(jpegQuality) || jpegQuality < 1 || jpegQuality > 100) throw new Error(`jpegQuality must be an integer between 1 and 100. Received: ${jpegQuality}`);
|
|
176
|
+
}
|
|
177
|
+
function assertValidImageSize(size, label) {
|
|
178
|
+
if (!Number.isInteger(size.width) || !Number.isInteger(size.height) || size.width <= 0 || size.height <= 0) throw new Error(`${label} width and height must be positive integers. Received width: ${size.width}, height: ${size.height}`);
|
|
179
|
+
}
|
|
180
|
+
async function convertImgBufferToJpeg(inputData, jpegQuality = 90) {
|
|
181
|
+
assertValidJpegQuality(jpegQuality);
|
|
182
|
+
if (external_utils_js_namespaceObject.ifInNode) try {
|
|
183
|
+
const Sharp = await external_get_sharp_js_default()();
|
|
184
|
+
return await Sharp(inputData).jpeg({
|
|
185
|
+
quality: jpegQuality
|
|
186
|
+
}).toBuffer();
|
|
187
|
+
} catch (error) {
|
|
188
|
+
imgDebug('Sharp failed, falling back to Photon:', error);
|
|
189
|
+
}
|
|
190
|
+
const { PhotonImage } = await external_get_photon_js_default()();
|
|
191
|
+
const inputBytes = new Uint8Array(inputData);
|
|
192
|
+
const bytesliceResult = PhotonImage.new_from_byteslice(inputBytes);
|
|
193
|
+
const image = bytesliceResult instanceof Promise ? await bytesliceResult : bytesliceResult;
|
|
194
|
+
try {
|
|
195
|
+
return external_node_buffer_namespaceObject.Buffer.from(image.get_bytes_jpeg(jpegQuality));
|
|
196
|
+
} finally{
|
|
197
|
+
image.free();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
async function convertBase64ImageToJpeg(inputBase64, jpegQuality = 90) {
|
|
201
|
+
assertValidJpegQuality(jpegQuality);
|
|
202
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
203
|
+
const { body } = parseBase64(normalized);
|
|
204
|
+
const imageBuffer = external_node_buffer_namespaceObject.Buffer.from(body, 'base64');
|
|
205
|
+
const detectedMimeType = detectImageMimeTypeFromBuffer(imageBuffer);
|
|
206
|
+
if ('image/jpeg' === detectedMimeType) return createImgBase64ByFormat('jpeg', body);
|
|
207
|
+
if ('image/png' !== detectedMimeType) throw new Error(`inputBase64 must contain a PNG or JPEG image. Detected: ${detectedMimeType ?? 'unsupported format'}`);
|
|
208
|
+
const jpegBuffer = await convertImgBufferToJpeg(imageBuffer, jpegQuality);
|
|
209
|
+
return createImgBase64ByFormat('jpeg', jpegBuffer.toString('base64'));
|
|
210
|
+
}
|
|
211
|
+
async function resizeBase64ImageToJpeg(inputBase64, options) {
|
|
212
|
+
const jpegQuality = options.jpegQuality ?? 90;
|
|
213
|
+
assertValidJpegQuality(jpegQuality);
|
|
214
|
+
assertValidImageSize(options.targetSize, 'targetSize');
|
|
215
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
216
|
+
const { body, mimeType } = parseBase64(normalized);
|
|
217
|
+
const imageBuffer = external_node_buffer_namespaceObject.Buffer.from(body, 'base64');
|
|
218
|
+
const sourceSize = (0, external_info_js_namespaceObject.encodedImageInfoOfBuffer)(imageBuffer);
|
|
219
|
+
if (options.sourceSize) {
|
|
220
|
+
assertValidImageSize(options.sourceSize, 'sourceSize');
|
|
221
|
+
if (options.sourceSize.width !== sourceSize.width || options.sourceSize.height !== sourceSize.height) throw new Error(`sourceSize ${options.sourceSize.width}x${options.sourceSize.height} does not match encoded image dimensions ${sourceSize.width}x${sourceSize.height}`);
|
|
222
|
+
}
|
|
223
|
+
const dimensionsUnchanged = sourceSize.width === options.targetSize.width && sourceSize.height === options.targetSize.height;
|
|
224
|
+
if (dimensionsUnchanged) return convertBase64ImageToJpeg(normalized, jpegQuality);
|
|
225
|
+
const { buffer } = await resizeAndConvertImgBuffer(mimeType.split('/')[1], imageBuffer, options.targetSize);
|
|
226
|
+
return createImgBase64ByFormat('jpeg', buffer.toString('base64'));
|
|
227
|
+
}
|
|
228
|
+
async function constrainBase64ImageToMaxSize(inputBase64, options) {
|
|
229
|
+
if (!Number.isInteger(options.maxSize) || options.maxSize <= 0) throw new Error(`maxSize must be a positive integer. Received: ${options.maxSize}`);
|
|
230
|
+
const normalized = normalizeBase64Image(inputBase64);
|
|
231
|
+
const { body } = parseBase64(normalized);
|
|
232
|
+
const sourceSize = (0, external_info_js_namespaceObject.encodedImageInfoOfBuffer)(external_node_buffer_namespaceObject.Buffer.from(body, 'base64'));
|
|
233
|
+
const largestDimension = Math.max(sourceSize.width, sourceSize.height);
|
|
234
|
+
if (largestDimension <= options.maxSize) return normalized;
|
|
235
|
+
const scale = options.maxSize / largestDimension;
|
|
236
|
+
return resizeBase64ImageToJpeg(normalized, {
|
|
237
|
+
targetSize: {
|
|
238
|
+
width: Math.max(1, Math.round(sourceSize.width * scale)),
|
|
239
|
+
height: Math.max(1, Math.round(sourceSize.height * scale))
|
|
240
|
+
},
|
|
241
|
+
sourceSize,
|
|
242
|
+
jpegQuality: options.jpegQuality
|
|
243
|
+
});
|
|
244
|
+
}
|
|
128
245
|
async function resizeImgBase64(inputBase64, newSize) {
|
|
129
246
|
const { body, mimeType } = parseBase64(inputBase64);
|
|
130
247
|
const imageBuffer = external_node_buffer_namespaceObject.Buffer.from(body, 'base64');
|
|
@@ -201,7 +318,7 @@ async function paddingToMatchBlockByBase64(imageBase64, blockSize = 28) {
|
|
|
201
318
|
photonImage.free();
|
|
202
319
|
}
|
|
203
320
|
}
|
|
204
|
-
async function cropByRect(imageBase64, rect, paddingImage) {
|
|
321
|
+
async function cropByRect(imageBase64, rect, paddingImage = false) {
|
|
205
322
|
const { crop } = await external_get_photon_js_default()();
|
|
206
323
|
const photonImage = await photonFromBase64(imageBase64);
|
|
207
324
|
const { left, top, width, height } = rect;
|
|
@@ -327,10 +444,16 @@ async function scaleImage(imageBase64, scale) {
|
|
|
327
444
|
imageBase64: base64
|
|
328
445
|
};
|
|
329
446
|
}
|
|
447
|
+
exports.constrainBase64ImageToMaxSize = __webpack_exports__.constrainBase64ImageToMaxSize;
|
|
448
|
+
exports.convertBase64ImageToJpeg = __webpack_exports__.convertBase64ImageToJpeg;
|
|
449
|
+
exports.convertImgBufferToJpeg = __webpack_exports__.convertImgBufferToJpeg;
|
|
330
450
|
exports.createImgBase64ByFormat = __webpack_exports__.createImgBase64ByFormat;
|
|
331
451
|
exports.cropByRect = __webpack_exports__.cropByRect;
|
|
332
452
|
exports.httpImg2Base64 = __webpack_exports__.httpImg2Base64;
|
|
453
|
+
exports.inferBase64ImageFormat = __webpack_exports__.inferBase64ImageFormat;
|
|
333
454
|
exports.localImg2Base64 = __webpack_exports__.localImg2Base64;
|
|
455
|
+
exports.normalizeBase64Image = __webpack_exports__.normalizeBase64Image;
|
|
456
|
+
exports.normalizeScreenshotBase64 = __webpack_exports__.normalizeScreenshotBase64;
|
|
334
457
|
exports.paddingToMatchBlock = __webpack_exports__.paddingToMatchBlock;
|
|
335
458
|
exports.paddingToMatchBlockByBase64 = __webpack_exports__.paddingToMatchBlockByBase64;
|
|
336
459
|
exports.parseBase64 = __webpack_exports__.parseBase64;
|
|
@@ -338,15 +461,22 @@ exports.photonFromBase64 = __webpack_exports__.photonFromBase64;
|
|
|
338
461
|
exports.photonToBase64 = __webpack_exports__.photonToBase64;
|
|
339
462
|
exports.preProcessImageUrl = __webpack_exports__.preProcessImageUrl;
|
|
340
463
|
exports.resizeAndConvertImgBuffer = __webpack_exports__.resizeAndConvertImgBuffer;
|
|
464
|
+
exports.resizeBase64ImageToJpeg = __webpack_exports__.resizeBase64ImageToJpeg;
|
|
341
465
|
exports.resizeImgBase64 = __webpack_exports__.resizeImgBase64;
|
|
342
466
|
exports.saveBase64Image = __webpack_exports__.saveBase64Image;
|
|
343
467
|
exports.scaleImage = __webpack_exports__.scaleImage;
|
|
344
468
|
exports.zoomForGPT4o = __webpack_exports__.zoomForGPT4o;
|
|
345
469
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
470
|
+
"constrainBase64ImageToMaxSize",
|
|
471
|
+
"convertBase64ImageToJpeg",
|
|
472
|
+
"convertImgBufferToJpeg",
|
|
346
473
|
"createImgBase64ByFormat",
|
|
347
474
|
"cropByRect",
|
|
348
475
|
"httpImg2Base64",
|
|
476
|
+
"inferBase64ImageFormat",
|
|
349
477
|
"localImg2Base64",
|
|
478
|
+
"normalizeBase64Image",
|
|
479
|
+
"normalizeScreenshotBase64",
|
|
350
480
|
"paddingToMatchBlock",
|
|
351
481
|
"paddingToMatchBlockByBase64",
|
|
352
482
|
"parseBase64",
|
|
@@ -354,6 +484,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
354
484
|
"photonToBase64",
|
|
355
485
|
"preProcessImageUrl",
|
|
356
486
|
"resizeAndConvertImgBuffer",
|
|
487
|
+
"resizeBase64ImageToJpeg",
|
|
357
488
|
"resizeImgBase64",
|
|
358
489
|
"saveBase64Image",
|
|
359
490
|
"scaleImage",
|
|
@@ -24,6 +24,9 @@ export declare const MIDSCENE_MODEL_RETRY_INTERVAL = "MIDSCENE_MODEL_RETRY_INTER
|
|
|
24
24
|
export declare const MIDSCENE_MODEL_REASONING_EFFORT = "MIDSCENE_MODEL_REASONING_EFFORT";
|
|
25
25
|
export declare const MIDSCENE_MODEL_REASONING_ENABLED = "MIDSCENE_MODEL_REASONING_ENABLED";
|
|
26
26
|
export declare const MIDSCENE_MODEL_REASONING_BUDGET = "MIDSCENE_MODEL_REASONING_BUDGET";
|
|
27
|
+
export declare const MIDSCENE_MODEL_RESPONSE_FORMAT = "MIDSCENE_MODEL_RESPONSE_FORMAT";
|
|
28
|
+
export type TModelReasoningEnabled = boolean | 'default';
|
|
29
|
+
export type TModelResponseFormat = 'none' | 'auto';
|
|
27
30
|
/**
|
|
28
31
|
* @deprecated Use MIDSCENE_MODEL_API_KEY instead. This is kept for backward compatibility.
|
|
29
32
|
*/
|
|
@@ -69,6 +72,7 @@ export declare const MIDSCENE_PREFERRED_LANGUAGE = "MIDSCENE_PREFERRED_LANGUAGE"
|
|
|
69
72
|
export declare const MIDSCENE_CACHE_MAX_FILENAME_LENGTH = "MIDSCENE_CACHE_MAX_FILENAME_LENGTH";
|
|
70
73
|
export declare const MIDSCENE_REPLANNING_CYCLE_LIMIT = "MIDSCENE_REPLANNING_CYCLE_LIMIT";
|
|
71
74
|
export declare const MIDSCENE_RUN_DIR = "MIDSCENE_RUN_DIR";
|
|
75
|
+
export declare const MIDSCENE_RECORD_MODEL_CALL = "MIDSCENE_RECORD_MODEL_CALL";
|
|
72
76
|
export declare const MIDSCENE_INSIGHT_MODEL_NAME = "MIDSCENE_INSIGHT_MODEL_NAME";
|
|
73
77
|
export declare const MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY = "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY";
|
|
74
78
|
export declare const MIDSCENE_INSIGHT_MODEL_HTTP_PROXY = "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY";
|
|
@@ -84,6 +88,7 @@ export declare const MIDSCENE_INSIGHT_MODEL_FAMILY = "MIDSCENE_INSIGHT_MODEL_FAM
|
|
|
84
88
|
export declare const MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT = "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT";
|
|
85
89
|
export declare const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED = "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED";
|
|
86
90
|
export declare const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET = "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET";
|
|
91
|
+
export declare const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT = "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT";
|
|
87
92
|
export declare const MIDSCENE_PLANNING_MODEL_NAME = "MIDSCENE_PLANNING_MODEL_NAME";
|
|
88
93
|
export declare const MIDSCENE_PLANNING_MODEL_SOCKS_PROXY = "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY";
|
|
89
94
|
export declare const MIDSCENE_PLANNING_MODEL_HTTP_PROXY = "MIDSCENE_PLANNING_MODEL_HTTP_PROXY";
|
|
@@ -99,6 +104,7 @@ export declare const MIDSCENE_PLANNING_MODEL_FAMILY = "MIDSCENE_PLANNING_MODEL_F
|
|
|
99
104
|
export declare const MIDSCENE_PLANNING_MODEL_REASONING_EFFORT = "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT";
|
|
100
105
|
export declare const MIDSCENE_PLANNING_MODEL_REASONING_ENABLED = "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED";
|
|
101
106
|
export declare const MIDSCENE_PLANNING_MODEL_REASONING_BUDGET = "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET";
|
|
107
|
+
export declare const MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT = "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT";
|
|
102
108
|
export declare const MIDSCENE_MODEL_FAMILY = "MIDSCENE_MODEL_FAMILY";
|
|
103
109
|
/**
|
|
104
110
|
* env keys declared but unused
|
|
@@ -108,7 +114,7 @@ export declare const UNUSED_ENV_KEYS: string[];
|
|
|
108
114
|
* env keys for debug or basic run
|
|
109
115
|
* can not be override by overrideAIConfig
|
|
110
116
|
*/
|
|
111
|
-
export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR"];
|
|
117
|
+
export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_RECORD_MODEL_CALL"];
|
|
112
118
|
export declare const BOOLEAN_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET"];
|
|
113
119
|
export declare const NUMBER_ENV_KEYS: readonly ["MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT"];
|
|
114
120
|
export declare const STRING_ENV_KEYS: readonly ["MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
|
|
@@ -123,14 +129,14 @@ export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_MCP_
|
|
|
123
129
|
* Can be override by both agent.modelConfig and overrideAIConfig
|
|
124
130
|
* Can only be access after agent.constructor
|
|
125
131
|
*/
|
|
126
|
-
export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_FAMILY"];
|
|
127
|
-
export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER", "MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_FAMILY"];
|
|
132
|
+
export declare const MODEL_ENV_KEYS: readonly ["MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_RESPONSE_FORMAT", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT", "MIDSCENE_MODEL_FAMILY"];
|
|
133
|
+
export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_RECORD_MODEL_CALL", "MIDSCENE_CACHE", "MIDSCENE_MCP_USE_PUPPETEER_MODE", "MIDSCENE_MCP_ANDROID_MODE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_MODEL_MAX_TOKENS", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "MIDSCENE_MODEL_MAX_TOKENS", "OPENAI_MAX_TOKENS", "MIDSCENE_ADB_PATH", "MIDSCENE_ADB_REMOTE_HOST", "MIDSCENE_ADB_REMOTE_PORT", "MIDSCENE_ANDROID_IME_STRATEGY", "MIDSCENE_IOS_DEVICE_UDID", "MIDSCENE_IOS_SIMULATOR_UDID", "MIDSCENE_REPORT_TAG_NAME", "MIDSCENE_PREFERRED_LANGUAGE", "MATCH_BY_POSITION", "MIDSCENE_CHROME_PATH", "MIDSCENE_MCP_CHROME_PATH", "DOCKER_CONTAINER", "MIDSCENE_MODEL_NAME", "MIDSCENE_MODEL_INIT_CONFIG_JSON", "MIDSCENE_MODEL_EXTRA_BODY_JSON", "MIDSCENE_MODEL_API_KEY", "MIDSCENE_MODEL_BASE_URL", "MIDSCENE_MODEL_SOCKS_PROXY", "MIDSCENE_MODEL_HTTP_PROXY", "MIDSCENE_MODEL_TIMEOUT", "MIDSCENE_MODEL_TEMPERATURE", "MIDSCENE_MODEL_RETRY_COUNT", "MIDSCENE_MODEL_RETRY_INTERVAL", "MIDSCENE_MODEL_REASONING_EFFORT", "MIDSCENE_MODEL_REASONING_ENABLED", "MIDSCENE_MODEL_REASONING_BUDGET", "MIDSCENE_MODEL_RESPONSE_FORMAT", "MIDSCENE_USE_VLM_UI_TARS", "MIDSCENE_USE_QWEN_VL", "MIDSCENE_USE_QWEN3_VL", "MIDSCENE_USE_DOUBAO_VISION", "MIDSCENE_USE_GEMINI", "MIDSCENE_USE_VL_MODEL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "MIDSCENE_OPENAI_INIT_CONFIG_JSON", "MIDSCENE_OPENAI_HTTP_PROXY", "MIDSCENE_OPENAI_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_NAME", "MIDSCENE_INSIGHT_MODEL_SOCKS_PROXY", "MIDSCENE_INSIGHT_MODEL_HTTP_PROXY", "MIDSCENE_INSIGHT_MODEL_BASE_URL", "MIDSCENE_INSIGHT_MODEL_API_KEY", "MIDSCENE_INSIGHT_MODEL_INIT_CONFIG_JSON", "MIDSCENE_INSIGHT_MODEL_EXTRA_BODY_JSON", "MIDSCENE_INSIGHT_MODEL_TIMEOUT", "MIDSCENE_INSIGHT_MODEL_TEMPERATURE", "MIDSCENE_INSIGHT_MODEL_RETRY_COUNT", "MIDSCENE_INSIGHT_MODEL_RETRY_INTERVAL", "MIDSCENE_INSIGHT_MODEL_FAMILY", "MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT", "MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED", "MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET", "MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT", "MIDSCENE_PLANNING_MODEL_NAME", "MIDSCENE_PLANNING_MODEL_SOCKS_PROXY", "MIDSCENE_PLANNING_MODEL_HTTP_PROXY", "MIDSCENE_PLANNING_MODEL_BASE_URL", "MIDSCENE_PLANNING_MODEL_API_KEY", "MIDSCENE_PLANNING_MODEL_INIT_CONFIG_JSON", "MIDSCENE_PLANNING_MODEL_EXTRA_BODY_JSON", "MIDSCENE_PLANNING_MODEL_TIMEOUT", "MIDSCENE_PLANNING_MODEL_TEMPERATURE", "MIDSCENE_PLANNING_MODEL_RETRY_COUNT", "MIDSCENE_PLANNING_MODEL_RETRY_INTERVAL", "MIDSCENE_PLANNING_MODEL_FAMILY", "MIDSCENE_PLANNING_MODEL_REASONING_EFFORT", "MIDSCENE_PLANNING_MODEL_REASONING_ENABLED", "MIDSCENE_PLANNING_MODEL_REASONING_BUDGET", "MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT", "MIDSCENE_MODEL_FAMILY"];
|
|
128
134
|
export type TEnvKeys = (typeof ALL_ENV_KEYS)[number];
|
|
129
135
|
export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
|
|
130
136
|
/**
|
|
131
137
|
* valid Model family types
|
|
132
138
|
*/
|
|
133
|
-
export type TModelFamily = 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3.5' | 'qwen3.6' | 'doubao-vision' | 'doubao-seed' | 'gemini' | 'vlm-ui-tars' | 'vlm-ui-tars-doubao' | 'vlm-ui-tars-doubao-1.5' | 'glm-v' | 'auto-glm' | 'auto-glm-multilingual' | 'gpt-5';
|
|
139
|
+
export type TModelFamily = 'qwen2.5-vl' | 'qwen3-vl' | 'qwen3' | 'qwen3.5' | 'qwen3.6' | 'doubao-vision' | 'doubao-seed' | 'gemini' | 'vlm-ui-tars' | 'vlm-ui-tars-doubao' | 'vlm-ui-tars-doubao-1.5' | 'glm-v' | 'auto-glm' | 'auto-glm-multilingual' | 'gpt-5' | 'deepseek' | 'kimi' | 'kimi3' | 'xiaomi-mimo';
|
|
134
140
|
export declare const MODEL_FAMILY_VALUES: TModelFamily[];
|
|
135
141
|
export interface IModelConfigForInsight {
|
|
136
142
|
[MIDSCENE_INSIGHT_MODEL_NAME]: string;
|
|
@@ -177,6 +183,7 @@ export interface IModelConfigForDefault {
|
|
|
177
183
|
[MIDSCENE_MODEL_REASONING_EFFORT]?: string;
|
|
178
184
|
[MIDSCENE_MODEL_REASONING_ENABLED]?: string;
|
|
179
185
|
[MIDSCENE_MODEL_REASONING_BUDGET]?: string;
|
|
186
|
+
[MIDSCENE_MODEL_RESPONSE_FORMAT]?: TModelResponseFormat;
|
|
180
187
|
}
|
|
181
188
|
export interface IModelConfigForDefaultLegacy {
|
|
182
189
|
[MIDSCENE_MODEL_NAME]: string;
|
|
@@ -281,12 +288,13 @@ export interface IModelConfig {
|
|
|
281
288
|
* Enable/disable reasoning for the model.
|
|
282
289
|
* Passed through to model-family-specific parameters (e.g., enable_thinking for qwen, thinking.type for doubao/glm-v).
|
|
283
290
|
*/
|
|
284
|
-
reasoningEnabled?:
|
|
291
|
+
reasoningEnabled?: TModelReasoningEnabled;
|
|
285
292
|
/**
|
|
286
293
|
* Reasoning token budget for the model.
|
|
287
294
|
* Passed through to model-family-specific parameters (e.g., thinking_budget for qwen).
|
|
288
295
|
*/
|
|
289
296
|
reasoningBudget?: number;
|
|
297
|
+
responseFormat?: TModelResponseFormat;
|
|
290
298
|
/**
|
|
291
299
|
* Model family - unified model configuration
|
|
292
300
|
* Maps directly to model families like 'qwen2.5-vl', 'qwen3-vl', 'doubao-vision', 'doubao-seed', etc.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, validateScreenshotBuffer, type ValidateScreenshotBufferOptions, } from './info';
|
|
2
|
-
export { resizeAndConvertImgBuffer, resizeImgBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, } from './transform';
|
|
1
|
+
export { encodedImageInfoOfBuffer, imageInfoOfBase64, isValidPNGImageBuffer, isValidJPEGImageBuffer, isValidImageBuffer, validateScreenshotBuffer, type ValidateScreenshotBufferOptions, } from './info';
|
|
2
|
+
export { resizeAndConvertImgBuffer, convertImgBufferToJpeg, convertBase64ImageToJpeg, constrainBase64ImageToMaxSize, resizeBase64ImageToJpeg, resizeImgBase64, zoomForGPT4o, saveBase64Image, paddingToMatchBlockByBase64, cropByRect, scaleImage, localImg2Base64, httpImg2Base64, preProcessImageUrl, parseBase64, createImgBase64ByFormat, inferBase64ImageFormat, normalizeBase64Image, normalizeScreenshotBase64, type NormalizeScreenshotBase64Options, type ConstrainBase64ImageToMaxSizeOptions, type JpegBase64DataUrl, type ResizeBase64ImageToJpegOptions, } from './transform';
|
|
3
3
|
export { processImageElementInfo, compositeElementInfoImg, annotateRects, } from './box-select';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
2
|
import type { PhotonImage as PhotonImageType } from '@silvia-odwyer/photon-node';
|
|
3
|
-
import type { Rect } from '../types';
|
|
3
|
+
import type { Rect, Size } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Saves a Base64-encoded image to a file
|
|
6
6
|
*
|
|
@@ -26,7 +26,27 @@ export declare function resizeAndConvertImgBuffer(inputFormat: string, inputData
|
|
|
26
26
|
buffer: Buffer;
|
|
27
27
|
format: string;
|
|
28
28
|
}>;
|
|
29
|
+
export declare function inferBase64ImageFormat(base64Body: string): string;
|
|
29
30
|
export declare const createImgBase64ByFormat: (format: string, body: string) => string;
|
|
31
|
+
export interface NormalizeScreenshotBase64Options {
|
|
32
|
+
label?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const normalizeScreenshotBase64: (base64: string, options?: NormalizeScreenshotBase64Options) => string;
|
|
35
|
+
export declare const normalizeBase64Image: (base64: string) => string;
|
|
36
|
+
export type JpegBase64DataUrl = `data:image/jpeg;base64,${string}`;
|
|
37
|
+
export interface ResizeBase64ImageToJpegOptions {
|
|
38
|
+
sourceSize?: Size;
|
|
39
|
+
targetSize: Size;
|
|
40
|
+
jpegQuality?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ConstrainBase64ImageToMaxSizeOptions {
|
|
43
|
+
maxSize: number;
|
|
44
|
+
jpegQuality?: number;
|
|
45
|
+
}
|
|
46
|
+
export declare function convertImgBufferToJpeg(inputData: Buffer, jpegQuality?: number): Promise<Buffer>;
|
|
47
|
+
export declare function convertBase64ImageToJpeg(inputBase64: string, jpegQuality?: number): Promise<JpegBase64DataUrl>;
|
|
48
|
+
export declare function resizeBase64ImageToJpeg(inputBase64: string, options: ResizeBase64ImageToJpegOptions): Promise<JpegBase64DataUrl>;
|
|
49
|
+
export declare function constrainBase64ImageToMaxSize(inputBase64: string, options: ConstrainBase64ImageToMaxSizeOptions): Promise<string>;
|
|
30
50
|
export declare function resizeImgBase64(inputBase64: string, newSize: {
|
|
31
51
|
width: number;
|
|
32
52
|
height: number;
|
|
@@ -58,7 +78,7 @@ export declare function paddingToMatchBlockByBase64(imageBase64: string, blockSi
|
|
|
58
78
|
height: number;
|
|
59
79
|
imageBase64: string;
|
|
60
80
|
}>;
|
|
61
|
-
export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage
|
|
81
|
+
export declare function cropByRect(imageBase64: string, rect: Rect, paddingImage?: boolean): Promise<{
|
|
62
82
|
width: number;
|
|
63
83
|
height: number;
|
|
64
84
|
imageBase64: string;
|
package/package.json
CHANGED
package/src/env/types.ts
CHANGED
|
@@ -36,6 +36,10 @@ export const MIDSCENE_MODEL_REASONING_ENABLED =
|
|
|
36
36
|
'MIDSCENE_MODEL_REASONING_ENABLED';
|
|
37
37
|
export const MIDSCENE_MODEL_REASONING_BUDGET =
|
|
38
38
|
'MIDSCENE_MODEL_REASONING_BUDGET';
|
|
39
|
+
export const MIDSCENE_MODEL_RESPONSE_FORMAT = 'MIDSCENE_MODEL_RESPONSE_FORMAT';
|
|
40
|
+
|
|
41
|
+
export type TModelReasoningEnabled = boolean | 'default';
|
|
42
|
+
export type TModelResponseFormat = 'none' | 'auto';
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* @deprecated Use MIDSCENE_MODEL_API_KEY instead. This is kept for backward compatibility.
|
|
@@ -93,6 +97,7 @@ export const MIDSCENE_REPLANNING_CYCLE_LIMIT =
|
|
|
93
97
|
'MIDSCENE_REPLANNING_CYCLE_LIMIT';
|
|
94
98
|
|
|
95
99
|
export const MIDSCENE_RUN_DIR = 'MIDSCENE_RUN_DIR';
|
|
100
|
+
export const MIDSCENE_RECORD_MODEL_CALL = 'MIDSCENE_RECORD_MODEL_CALL';
|
|
96
101
|
|
|
97
102
|
// INSIGHT (unified VQA and Grounding)
|
|
98
103
|
export const MIDSCENE_INSIGHT_MODEL_NAME = 'MIDSCENE_INSIGHT_MODEL_NAME';
|
|
@@ -121,6 +126,8 @@ export const MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED =
|
|
|
121
126
|
'MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED';
|
|
122
127
|
export const MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET =
|
|
123
128
|
'MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET';
|
|
129
|
+
export const MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT =
|
|
130
|
+
'MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT';
|
|
124
131
|
|
|
125
132
|
// PLANNING
|
|
126
133
|
export const MIDSCENE_PLANNING_MODEL_NAME = 'MIDSCENE_PLANNING_MODEL_NAME';
|
|
@@ -151,6 +158,8 @@ export const MIDSCENE_PLANNING_MODEL_REASONING_ENABLED =
|
|
|
151
158
|
'MIDSCENE_PLANNING_MODEL_REASONING_ENABLED';
|
|
152
159
|
export const MIDSCENE_PLANNING_MODEL_REASONING_BUDGET =
|
|
153
160
|
'MIDSCENE_PLANNING_MODEL_REASONING_BUDGET';
|
|
161
|
+
export const MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT =
|
|
162
|
+
'MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT';
|
|
154
163
|
export const MIDSCENE_MODEL_FAMILY = 'MIDSCENE_MODEL_FAMILY';
|
|
155
164
|
|
|
156
165
|
/**
|
|
@@ -167,6 +176,7 @@ export const BASIC_ENV_KEYS = [
|
|
|
167
176
|
MIDSCENE_DEBUG_MODEL_PROFILE,
|
|
168
177
|
MIDSCENE_DEBUG_MODEL_RESPONSE,
|
|
169
178
|
MIDSCENE_RUN_DIR,
|
|
179
|
+
MIDSCENE_RECORD_MODEL_CALL,
|
|
170
180
|
] as const;
|
|
171
181
|
|
|
172
182
|
export const BOOLEAN_ENV_KEYS = [
|
|
@@ -233,6 +243,7 @@ export const MODEL_ENV_KEYS = [
|
|
|
233
243
|
MIDSCENE_MODEL_REASONING_EFFORT,
|
|
234
244
|
MIDSCENE_MODEL_REASONING_ENABLED,
|
|
235
245
|
MIDSCENE_MODEL_REASONING_BUDGET,
|
|
246
|
+
MIDSCENE_MODEL_RESPONSE_FORMAT,
|
|
236
247
|
MIDSCENE_USE_VLM_UI_TARS,
|
|
237
248
|
MIDSCENE_USE_QWEN_VL,
|
|
238
249
|
MIDSCENE_USE_QWEN3_VL,
|
|
@@ -261,6 +272,7 @@ export const MODEL_ENV_KEYS = [
|
|
|
261
272
|
MIDSCENE_INSIGHT_MODEL_REASONING_EFFORT,
|
|
262
273
|
MIDSCENE_INSIGHT_MODEL_REASONING_ENABLED,
|
|
263
274
|
MIDSCENE_INSIGHT_MODEL_REASONING_BUDGET,
|
|
275
|
+
MIDSCENE_INSIGHT_MODEL_RESPONSE_FORMAT,
|
|
264
276
|
// PLANNING
|
|
265
277
|
MIDSCENE_PLANNING_MODEL_NAME,
|
|
266
278
|
MIDSCENE_PLANNING_MODEL_SOCKS_PROXY,
|
|
@@ -277,6 +289,7 @@ export const MODEL_ENV_KEYS = [
|
|
|
277
289
|
MIDSCENE_PLANNING_MODEL_REASONING_EFFORT,
|
|
278
290
|
MIDSCENE_PLANNING_MODEL_REASONING_ENABLED,
|
|
279
291
|
MIDSCENE_PLANNING_MODEL_REASONING_BUDGET,
|
|
292
|
+
MIDSCENE_PLANNING_MODEL_RESPONSE_FORMAT,
|
|
280
293
|
MIDSCENE_MODEL_FAMILY,
|
|
281
294
|
] as const;
|
|
282
295
|
|
|
@@ -296,6 +309,7 @@ export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
|
|
|
296
309
|
export type TModelFamily =
|
|
297
310
|
| 'qwen2.5-vl'
|
|
298
311
|
| 'qwen3-vl'
|
|
312
|
+
| 'qwen3'
|
|
299
313
|
| 'qwen3.5'
|
|
300
314
|
| 'qwen3.6'
|
|
301
315
|
| 'doubao-vision'
|
|
@@ -307,7 +321,11 @@ export type TModelFamily =
|
|
|
307
321
|
| 'glm-v'
|
|
308
322
|
| 'auto-glm'
|
|
309
323
|
| 'auto-glm-multilingual'
|
|
310
|
-
| 'gpt-5'
|
|
324
|
+
| 'gpt-5'
|
|
325
|
+
| 'deepseek'
|
|
326
|
+
| 'kimi'
|
|
327
|
+
| 'kimi3'
|
|
328
|
+
| 'xiaomi-mimo';
|
|
311
329
|
|
|
312
330
|
export const MODEL_FAMILY_VALUES: TModelFamily[] = [
|
|
313
331
|
'doubao-vision',
|
|
@@ -315,6 +333,7 @@ export const MODEL_FAMILY_VALUES: TModelFamily[] = [
|
|
|
315
333
|
'gemini',
|
|
316
334
|
'qwen2.5-vl',
|
|
317
335
|
'qwen3-vl',
|
|
336
|
+
'qwen3',
|
|
318
337
|
'qwen3.5',
|
|
319
338
|
'qwen3.6',
|
|
320
339
|
'vlm-ui-tars',
|
|
@@ -324,6 +343,10 @@ export const MODEL_FAMILY_VALUES: TModelFamily[] = [
|
|
|
324
343
|
'auto-glm',
|
|
325
344
|
'auto-glm-multilingual',
|
|
326
345
|
'gpt-5',
|
|
346
|
+
'deepseek',
|
|
347
|
+
'kimi',
|
|
348
|
+
'kimi3',
|
|
349
|
+
'xiaomi-mimo',
|
|
327
350
|
];
|
|
328
351
|
|
|
329
352
|
export interface IModelConfigForInsight {
|
|
@@ -393,6 +416,8 @@ export interface IModelConfigForDefault {
|
|
|
393
416
|
[MIDSCENE_MODEL_REASONING_ENABLED]?: string;
|
|
394
417
|
// reasoning budget (number as string)
|
|
395
418
|
[MIDSCENE_MODEL_REASONING_BUDGET]?: string;
|
|
419
|
+
// Response format strategy (none/auto)
|
|
420
|
+
[MIDSCENE_MODEL_RESPONSE_FORMAT]?: TModelResponseFormat;
|
|
396
421
|
}
|
|
397
422
|
|
|
398
423
|
export interface IModelConfigForDefaultLegacy {
|
|
@@ -509,12 +534,13 @@ export interface IModelConfig {
|
|
|
509
534
|
* Enable/disable reasoning for the model.
|
|
510
535
|
* Passed through to model-family-specific parameters (e.g., enable_thinking for qwen, thinking.type for doubao/glm-v).
|
|
511
536
|
*/
|
|
512
|
-
reasoningEnabled?:
|
|
537
|
+
reasoningEnabled?: TModelReasoningEnabled;
|
|
513
538
|
/**
|
|
514
539
|
* Reasoning token budget for the model.
|
|
515
540
|
* Passed through to model-family-specific parameters (e.g., thinking_budget for qwen).
|
|
516
541
|
*/
|
|
517
542
|
reasoningBudget?: number;
|
|
543
|
+
responseFormat?: TModelResponseFormat;
|
|
518
544
|
/**
|
|
519
545
|
* Model family - unified model configuration
|
|
520
546
|
* Maps directly to model families like 'qwen2.5-vl', 'qwen3-vl', 'doubao-vision', 'doubao-seed', etc.
|
package/src/img/transform.ts
CHANGED