@midscene/shared 1.9.7 → 1.9.8-beta-20260618014851.0
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/agent-tools/agent-behavior-init-args.mjs +44 -0
- package/dist/es/{mcp → agent-tools}/base-tools.mjs +1 -8
- package/dist/es/{mcp → agent-tools}/chrome-path.mjs +14 -3
- package/dist/es/{mcp → agent-tools}/index.mjs +1 -3
- package/dist/es/{mcp → agent-tools}/tool-generator.mjs +6 -5
- package/dist/es/cli/cli-runner.mjs +1 -1
- package/dist/es/env/parse-model-config.mjs +1 -1
- package/dist/es/env/types.mjs +3 -5
- package/dist/es/img/index.mjs +2 -2
- package/dist/es/img/transform.mjs +18 -1
- package/dist/es/utils.mjs +2 -6
- package/dist/lib/agent-tools/agent-behavior-init-args.js +87 -0
- package/dist/lib/{mcp → agent-tools}/base-tools.js +1 -8
- package/dist/lib/{mcp → agent-tools}/chrome-path.js +13 -2
- package/dist/lib/{mcp → agent-tools}/index.js +10 -24
- package/dist/lib/{mcp → agent-tools}/tool-generator.js +6 -5
- package/dist/lib/cli/cli-runner.js +1 -1
- package/dist/lib/env/parse-model-config.js +1 -1
- package/dist/lib/env/types.js +5 -10
- package/dist/lib/img/index.js +3 -0
- package/dist/lib/img/transform.js +20 -0
- package/dist/lib/utils.js +8 -15
- package/dist/types/agent-tools/agent-behavior-init-args.d.ts +17 -0
- package/dist/types/{mcp → agent-tools}/base-tools.d.ts +7 -13
- package/dist/types/{mcp → agent-tools}/index.d.ts +1 -3
- package/dist/types/{mcp → agent-tools}/init-arg-utils.d.ts +3 -3
- package/dist/types/{mcp → agent-tools}/tool-defaults.d.ts +5 -6
- package/dist/types/{mcp → agent-tools}/tool-generator.d.ts +1 -1
- package/dist/types/{mcp → agent-tools}/types.d.ts +20 -13
- package/dist/types/cli/cli-args.d.ts +1 -1
- package/dist/types/cli/cli-runner.d.ts +2 -2
- package/dist/types/env/types.d.ts +8 -6
- package/dist/types/img/index.d.ts +1 -1
- package/dist/types/img/transform.d.ts +4 -0
- package/dist/types/key-alias-utils.d.ts +2 -2
- package/dist/types/utils.d.ts +0 -1
- package/package.json +15 -8
- package/src/agent-tools/agent-behavior-init-args.ts +109 -0
- package/src/{mcp → agent-tools}/base-tools.ts +8 -33
- package/src/{mcp → agent-tools}/chrome-path.ts +20 -3
- package/src/{mcp → agent-tools}/index.ts +1 -3
- package/src/{mcp → agent-tools}/init-arg-utils.ts +3 -3
- package/src/{mcp → agent-tools}/tool-defaults.ts +5 -6
- package/src/{mcp → agent-tools}/tool-generator.ts +14 -7
- package/src/{mcp → agent-tools}/types.ts +22 -10
- package/src/cli/cli-args.ts +1 -1
- package/src/cli/cli-runner.ts +4 -4
- package/src/env/types.ts +5 -5
- package/src/img/index.ts +2 -0
- package/src/img/transform.ts +45 -0
- package/src/key-alias-utils.ts +2 -2
- package/src/utils.ts +1 -10
- package/dist/es/mcp/base-server.mjs +0 -295
- package/dist/es/mcp/inject-report-html-plugin.mjs +0 -53
- package/dist/es/mcp/launcher-helper.mjs +0 -52
- package/dist/lib/mcp/base-server.js +0 -345
- package/dist/lib/mcp/inject-report-html-plugin.js +0 -98
- package/dist/lib/mcp/launcher-helper.js +0 -86
- package/dist/types/mcp/base-server.d.ts +0 -106
- package/dist/types/mcp/inject-report-html-plugin.d.ts +0 -18
- package/dist/types/mcp/launcher-helper.d.ts +0 -94
- package/src/mcp/base-server.ts +0 -529
- package/src/mcp/inject-report-html-plugin.ts +0 -119
- package/src/mcp/launcher-helper.ts +0 -200
- /package/dist/es/{mcp → agent-tools}/cli-report-session.mjs +0 -0
- /package/dist/es/{mcp → agent-tools}/error-formatter.mjs +0 -0
- /package/dist/es/{mcp → agent-tools}/init-arg-utils.mjs +0 -0
- /package/dist/es/{mcp → agent-tools}/tool-defaults.mjs +0 -0
- /package/dist/es/{mcp → agent-tools}/types.mjs +0 -0
- /package/dist/es/{mcp → agent-tools}/user-prompt.mjs +0 -0
- /package/dist/lib/{mcp → agent-tools}/cli-report-session.js +0 -0
- /package/dist/lib/{mcp → agent-tools}/error-formatter.js +0 -0
- /package/dist/lib/{mcp → agent-tools}/init-arg-utils.js +0 -0
- /package/dist/lib/{mcp → agent-tools}/tool-defaults.js +0 -0
- /package/dist/lib/{mcp → agent-tools}/types.js +0 -0
- /package/dist/lib/{mcp → agent-tools}/user-prompt.js +0 -0
- /package/dist/types/{mcp → agent-tools}/chrome-path.d.ts +0 -0
- /package/dist/types/{mcp → agent-tools}/cli-report-session.d.ts +0 -0
- /package/dist/types/{mcp → agent-tools}/error-formatter.d.ts +0 -0
- /package/dist/types/{mcp → agent-tools}/user-prompt.d.ts +0 -0
- /package/src/{mcp → agent-tools}/cli-report-session.ts +0 -0
- /package/src/{mcp → agent-tools}/error-formatter.ts +0 -0
- /package/src/{mcp → agent-tools}/user-prompt.ts +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const agentBehaviorInitArgShape = {
|
|
3
|
+
aiActContext: z.string().optional().describe('Background knowledge passed to aiAct. Default: no extra context.'),
|
|
4
|
+
replanningCycleLimit: z.number().int().nonnegative().optional().describe('Maximum number of replanning cycles for aiAct. Default: model adapter default.'),
|
|
5
|
+
waitAfterAction: z.number().nonnegative().optional().describe('Wait time in milliseconds after each action execution. Default: 300ms.'),
|
|
6
|
+
screenshotShrinkFactor: z.number().min(1).optional().describe('Screenshot shrink factor before sending images to AI. Default: 1; high values may reduce recognition quality, especially on mobile.')
|
|
7
|
+
};
|
|
8
|
+
function extractAgentBehaviorInitArgs(extracted) {
|
|
9
|
+
if (!extracted) return;
|
|
10
|
+
const agentOptions = {
|
|
11
|
+
...'string' == typeof extracted.aiActContext ? {
|
|
12
|
+
aiActContext: extracted.aiActContext
|
|
13
|
+
} : {},
|
|
14
|
+
...'string' == typeof extracted.aiActionContext ? {
|
|
15
|
+
aiActionContext: extracted.aiActionContext
|
|
16
|
+
} : {},
|
|
17
|
+
...'number' == typeof extracted.replanningCycleLimit ? {
|
|
18
|
+
replanningCycleLimit: extracted.replanningCycleLimit
|
|
19
|
+
} : {},
|
|
20
|
+
...'number' == typeof extracted.waitAfterAction ? {
|
|
21
|
+
waitAfterAction: extracted.waitAfterAction
|
|
22
|
+
} : {},
|
|
23
|
+
...'number' == typeof extracted.screenshotShrinkFactor ? {
|
|
24
|
+
screenshotShrinkFactor: extracted.screenshotShrinkFactor
|
|
25
|
+
} : {}
|
|
26
|
+
};
|
|
27
|
+
return Object.keys(agentOptions).length > 0 ? agentOptions : void 0;
|
|
28
|
+
}
|
|
29
|
+
function stableJsonValue(value) {
|
|
30
|
+
if (Array.isArray(value)) return value.map(stableJsonValue);
|
|
31
|
+
if (value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).sort(([left], [right])=>left.localeCompare(right)).map(([key, nestedValue])=>[
|
|
32
|
+
key,
|
|
33
|
+
stableJsonValue(nestedValue)
|
|
34
|
+
]));
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function getAgentInitArgsSignature(initArgs) {
|
|
38
|
+
if (!initArgs || 0 === Object.keys(initArgs).length) return;
|
|
39
|
+
return JSON.stringify(stableJsonValue(initArgs));
|
|
40
|
+
}
|
|
41
|
+
function shouldRebuildAgentForInitArgs(currentSignature, nextSignature) {
|
|
42
|
+
return currentSignature !== nextSignature && (void 0 !== currentSignature || void 0 !== nextSignature);
|
|
43
|
+
}
|
|
44
|
+
export { agentBehaviorInitArgShape, extractAgentBehaviorInitArgs, getAgentInitArgsSignature, shouldRebuildAgentForInitArgs };
|
|
@@ -15,7 +15,7 @@ function _define_property(obj, key, value) {
|
|
|
15
15
|
else obj[key] = value;
|
|
16
16
|
return obj;
|
|
17
17
|
}
|
|
18
|
-
const debug = getDebug('
|
|
18
|
+
const debug = getDebug('agent-tools:base-tools');
|
|
19
19
|
class BaseMidsceneTools {
|
|
20
20
|
getInitArgKeys() {
|
|
21
21
|
return this.initArgSpec ? Object.keys(this.initArgSpec.shape) : [];
|
|
@@ -104,12 +104,6 @@ class BaseMidsceneTools {
|
|
|
104
104
|
this.toolDefinitions.push(...actionTools, ...commonTools);
|
|
105
105
|
debug('Total tools prepared:', this.toolDefinitions.length);
|
|
106
106
|
}
|
|
107
|
-
attachToServer(server) {
|
|
108
|
-
this.mcpServer = server;
|
|
109
|
-
if (0 === this.toolDefinitions.length) debug('Warning: No tools to register. Tools may be initialized lazily.');
|
|
110
|
-
for (const toolDef of this.toolDefinitions)this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
|
|
111
|
-
debug('Registered', this.toolDefinitions.length, 'tools');
|
|
112
|
-
}
|
|
113
107
|
async destroy() {
|
|
114
108
|
await this.agent?.destroy?.();
|
|
115
109
|
}
|
|
@@ -155,7 +149,6 @@ class BaseMidsceneTools {
|
|
|
155
149
|
};
|
|
156
150
|
}
|
|
157
151
|
constructor(){
|
|
158
|
-
_define_property(this, "mcpServer", void 0);
|
|
159
152
|
_define_property(this, "agent", void 0);
|
|
160
153
|
_define_property(this, "toolDefinitions", []);
|
|
161
154
|
_define_property(this, "toolDefaults", {});
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { MIDSCENE_MCP_CHROME_PATH, globalConfigManager } from "../env/index.mjs";
|
|
2
|
+
import { MIDSCENE_CHROME_PATH, MIDSCENE_MCP_CHROME_PATH, globalConfigManager } from "../env/index.mjs";
|
|
3
|
+
import { getDebug } from "../logger.mjs";
|
|
4
|
+
const warnChromePath = getDebug('agent-tools:chrome-path', {
|
|
5
|
+
console: true
|
|
6
|
+
});
|
|
7
|
+
let hasWarnedLegacyChromePath = false;
|
|
3
8
|
function getSystemChromePath() {
|
|
4
9
|
const platform = process.platform;
|
|
5
10
|
const chromePaths = {
|
|
@@ -26,10 +31,16 @@ function getSystemChromePath() {
|
|
|
26
31
|
return paths.find((p)=>existsSync(p));
|
|
27
32
|
}
|
|
28
33
|
function resolveChromePath() {
|
|
29
|
-
const
|
|
34
|
+
const primaryEnvPath = globalConfigManager.getEnvConfigValue(MIDSCENE_CHROME_PATH);
|
|
35
|
+
const legacyEnvPath = globalConfigManager.getEnvConfigValue(MIDSCENE_MCP_CHROME_PATH);
|
|
36
|
+
const envPath = primaryEnvPath || legacyEnvPath;
|
|
37
|
+
if (!primaryEnvPath && legacyEnvPath && !hasWarnedLegacyChromePath) {
|
|
38
|
+
warnChromePath('MIDSCENE_MCP_CHROME_PATH is deprecated. Use MIDSCENE_CHROME_PATH instead.');
|
|
39
|
+
hasWarnedLegacyChromePath = true;
|
|
40
|
+
}
|
|
30
41
|
if (envPath && 'auto' !== envPath && existsSync(envPath)) return envPath;
|
|
31
42
|
const systemPath = getSystemChromePath();
|
|
32
43
|
if (systemPath) return systemPath;
|
|
33
|
-
throw new Error('Chrome not found. Install Google Chrome or set
|
|
44
|
+
throw new Error('Chrome not found. Install Google Chrome or set MIDSCENE_CHROME_PATH environment variable.');
|
|
34
45
|
}
|
|
35
46
|
export { getSystemChromePath, resolveChromePath };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export * from "./base-server.mjs";
|
|
2
1
|
export * from "./base-tools.mjs";
|
|
3
2
|
export * from "./tool-defaults.mjs";
|
|
3
|
+
export * from "./agent-behavior-init-args.mjs";
|
|
4
4
|
export * from "./init-arg-utils.mjs";
|
|
5
5
|
export * from "./error-formatter.mjs";
|
|
6
6
|
export * from "./tool-generator.mjs";
|
|
7
7
|
export * from "./types.mjs";
|
|
8
|
-
export * from "./inject-report-html-plugin.mjs";
|
|
9
|
-
export * from "./launcher-helper.mjs";
|
|
10
8
|
export * from "./chrome-path.mjs";
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { getZodDescription, getZodTypeName, isMidsceneLocatorField, unwrapZodField } from "../zod-schema-utils.mjs";
|
|
4
4
|
import { getErrorMessage } from "./error-formatter.mjs";
|
|
5
5
|
import { composeUserPrompt, promptInputExtraSchema } from "./user-prompt.mjs";
|
|
6
|
-
function
|
|
6
|
+
function describeActionForTool(action) {
|
|
7
7
|
const actionDesc = action.description || `Execute ${action.name} action`;
|
|
8
8
|
if (!action.paramSchema) return `${action.name} action, ${actionDesc}`;
|
|
9
9
|
const shape = getZodObjectShape(action.paramSchema);
|
|
@@ -48,13 +48,14 @@ function getZodObjectShape(value) {
|
|
|
48
48
|
function isRecord(value) {
|
|
49
49
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
50
50
|
}
|
|
51
|
-
function makePromptOptional(shape, wrapInOptional) {
|
|
51
|
+
function makePromptOptional(shape, wrapInOptional, description) {
|
|
52
52
|
const newShape = {
|
|
53
53
|
...shape
|
|
54
54
|
};
|
|
55
55
|
newShape.prompt = shape.prompt.optional();
|
|
56
56
|
let newSchema = z.object(newShape).passthrough();
|
|
57
57
|
if (wrapInOptional) newSchema = newSchema.optional();
|
|
58
|
+
if (description) newSchema = newSchema.describe(description);
|
|
58
59
|
return newSchema;
|
|
59
60
|
}
|
|
60
61
|
function transformSchemaField(key, value) {
|
|
@@ -62,7 +63,7 @@ function transformSchemaField(key, value) {
|
|
|
62
63
|
const shape = getZodObjectShape(innerValue);
|
|
63
64
|
if (shape && isMidsceneLocatorField(innerValue)) return [
|
|
64
65
|
key,
|
|
65
|
-
makePromptOptional(shape, isOptional)
|
|
66
|
+
makePromptOptional(shape, isOptional, getZodDescription(value))
|
|
66
67
|
];
|
|
67
68
|
return [
|
|
68
69
|
key,
|
|
@@ -74,7 +75,7 @@ function extractActionSchema(paramSchema, actionName) {
|
|
|
74
75
|
const shape = getZodObjectShape(paramSchema);
|
|
75
76
|
if (!shape) {
|
|
76
77
|
const typeName = paramSchema?._def?.typeName ?? 'unknown';
|
|
77
|
-
throw new Error(`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI
|
|
78
|
+
throw new Error(`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI tool schemas must be a ZodObject (e.g. z.object({ uri: z.string() })) or undefined. Wrap primitive fields in an object schema.`);
|
|
78
79
|
}
|
|
79
80
|
return Object.fromEntries(Object.entries(shape).map(([key, value])=>transformSchemaField(key, value)));
|
|
80
81
|
}
|
|
@@ -326,7 +327,7 @@ function generateToolsFromActionSpace(actionSpace, getAgent, sanitizeArgs = (arg
|
|
|
326
327
|
};
|
|
327
328
|
return {
|
|
328
329
|
name: action.name,
|
|
329
|
-
description:
|
|
330
|
+
description: describeActionForTool(action),
|
|
330
331
|
schema,
|
|
331
332
|
cli: initArgCliMetadata,
|
|
332
333
|
handler: async (args)=>{
|
|
@@ -2,8 +2,8 @@ import { existsSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
|
+
import { stripBehaviorFlags } from "../agent-tools/tool-defaults.mjs";
|
|
5
6
|
import { getDebug } from "../logger.mjs";
|
|
6
|
-
import { stripBehaviorFlags } from "../mcp/tool-defaults.mjs";
|
|
7
7
|
import { canonicalizeCliArgKeys, formatCliValidationError, getCliOptionDisplay, parseCliArgs, parseValue } from "./cli-args.mjs";
|
|
8
8
|
import { CLIError, reportCLIError } from "./cli-error.mjs";
|
|
9
9
|
const debug = getDebug('cli-runner');
|
|
@@ -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 = ()=>"1.9.
|
|
8
|
+
const getCurrentVersion = ()=>"1.9.8-beta-20260618014851.0";
|
|
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
|
@@ -5,9 +5,8 @@ const MIDSCENE_DEBUG_MODEL_PROFILE = 'MIDSCENE_DEBUG_MODEL_PROFILE';
|
|
|
5
5
|
const MIDSCENE_DEBUG_MODEL_RESPONSE = 'MIDSCENE_DEBUG_MODEL_RESPONSE';
|
|
6
6
|
const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = 'MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG';
|
|
7
7
|
const MIDSCENE_DEBUG_MODE = 'MIDSCENE_DEBUG_MODE';
|
|
8
|
-
const
|
|
8
|
+
const MIDSCENE_CHROME_PATH = 'MIDSCENE_CHROME_PATH';
|
|
9
9
|
const MIDSCENE_MCP_CHROME_PATH = 'MIDSCENE_MCP_CHROME_PATH';
|
|
10
|
-
const MIDSCENE_MCP_ANDROID_MODE = 'MIDSCENE_MCP_ANDROID_MODE';
|
|
11
10
|
const DOCKER_CONTAINER = 'DOCKER_CONTAINER';
|
|
12
11
|
const MIDSCENE_LANGSMITH_DEBUG = 'MIDSCENE_LANGSMITH_DEBUG';
|
|
13
12
|
const MIDSCENE_LANGFUSE_DEBUG = 'MIDSCENE_LANGFUSE_DEBUG';
|
|
@@ -90,8 +89,6 @@ const BASIC_ENV_KEYS = [
|
|
|
90
89
|
];
|
|
91
90
|
const BOOLEAN_ENV_KEYS = [
|
|
92
91
|
MIDSCENE_CACHE,
|
|
93
|
-
MIDSCENE_MCP_USE_PUPPETEER_MODE,
|
|
94
|
-
MIDSCENE_MCP_ANDROID_MODE,
|
|
95
92
|
MIDSCENE_LANGSMITH_DEBUG,
|
|
96
93
|
MIDSCENE_LANGFUSE_DEBUG,
|
|
97
94
|
MIDSCENE_REPORT_QUIET
|
|
@@ -110,6 +107,7 @@ const STRING_ENV_KEYS = [
|
|
|
110
107
|
MIDSCENE_REPORT_TAG_NAME,
|
|
111
108
|
MIDSCENE_PREFERRED_LANGUAGE,
|
|
112
109
|
MATCH_BY_POSITION,
|
|
110
|
+
MIDSCENE_CHROME_PATH,
|
|
113
111
|
MIDSCENE_MCP_CHROME_PATH,
|
|
114
112
|
DOCKER_CONTAINER
|
|
115
113
|
];
|
|
@@ -208,4 +206,4 @@ var types_UITarsModelVersion = /*#__PURE__*/ function(UITarsModelVersion) {
|
|
|
208
206
|
UITarsModelVersion["DOUBAO_1_5_20B"] = "doubao-1.5-20B";
|
|
209
207
|
return UITarsModelVersion;
|
|
210
208
|
}({});
|
|
211
|
-
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_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,
|
|
209
|
+
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_CHROME_PATH, 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_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, STRING_ENV_KEYS, types_UITarsModelVersion as UITarsModelVersion, UNUSED_ENV_KEYS };
|
package/dist/es/img/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { imageInfoOfBase64, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, validateScreenshotBuffer } from "./info.mjs";
|
|
2
|
-
import { createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
2
|
+
import { createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o } from "./transform.mjs";
|
|
3
3
|
import { annotateRects, compositeElementInfoImg, compositePointMarkerImg, processImageElementInfo } from "./box-select.mjs";
|
|
4
|
-
export { annotateRects, compositeElementInfoImg, compositePointMarkerImg, createImgBase64ByFormat, cropByRect, httpImg2Base64, imageInfoOfBase64, inferBase64ImageFormat, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, normalizeBase64Image, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
4
|
+
export { annotateRects, compositeElementInfoImg, compositePointMarkerImg, createImgBase64ByFormat, cropByRect, httpImg2Base64, imageInfoOfBase64, inferBase64ImageFormat, isValidImageBuffer, isValidJPEGImageBuffer, isValidPNGImageBuffer, localImg2Base64, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlockByBase64, parseBase64, preProcessImageUrl, processImageElementInfo, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, validateScreenshotBuffer, zoomForGPT4o };
|
|
@@ -71,6 +71,8 @@ async function resizeAndConvertImgBuffer(inputFormat, inputData, newSize) {
|
|
|
71
71
|
}
|
|
72
72
|
const normalizeBase64Body = (body)=>body.replace(/\s/g, '');
|
|
73
73
|
const base64ImageDataUrlPattern = /^data:image\/[a-zA-Z0-9.+-]+;base64,/i;
|
|
74
|
+
const supportedScreenshotDataUriPattern = /^data:image\/(png|jpe?g);base64,([\s\S]*)$/i;
|
|
75
|
+
const rawBase64BodyPattern = /^[A-Za-z0-9+/=\s]+$/;
|
|
74
76
|
const inferBase64ImageFormat = (base64Body)=>{
|
|
75
77
|
if (base64Body.startsWith('iVBORw0KGgo')) return 'png';
|
|
76
78
|
return 'jpeg';
|
|
@@ -83,6 +85,21 @@ function detectImageMimeTypeFromBuffer(buffer) {
|
|
|
83
85
|
if (buffer.length >= 2 && 0x42 === buffer[0] && 0x4d === buffer[1]) return 'image/bmp';
|
|
84
86
|
}
|
|
85
87
|
const createImgBase64ByFormat = (format, body)=>`data:image/${format};base64,${normalizeBase64Body(body)}`;
|
|
88
|
+
const normalizeScreenshotBase64 = (base64, options)=>{
|
|
89
|
+
const label = options?.label ?? 'screenshot base64';
|
|
90
|
+
const trimmedBase64 = base64.trim();
|
|
91
|
+
if (!trimmedBase64) throw new Error(`${label} cannot be empty`);
|
|
92
|
+
const dataUriMatch = trimmedBase64.match(supportedScreenshotDataUriPattern);
|
|
93
|
+
if (dataUriMatch) {
|
|
94
|
+
const imageFormat = 'jpg' === dataUriMatch[1].toLowerCase() ? 'jpeg' : dataUriMatch[1].toLowerCase();
|
|
95
|
+
const body = dataUriMatch[2];
|
|
96
|
+
if (!normalizeBase64Body(body)) throw new Error(`${label} cannot be empty`);
|
|
97
|
+
return createImgBase64ByFormat(imageFormat, body);
|
|
98
|
+
}
|
|
99
|
+
if (trimmedBase64.startsWith('data:')) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
100
|
+
if (!rawBase64BodyPattern.test(trimmedBase64)) throw new Error(`${label} must be a PNG/JPEG data URI or raw PNG base64 string`);
|
|
101
|
+
return createImgBase64ByFormat('png', trimmedBase64);
|
|
102
|
+
};
|
|
86
103
|
const normalizeBase64Image = (base64)=>{
|
|
87
104
|
const trimmedBase64 = base64.trim();
|
|
88
105
|
if (base64ImageDataUrlPattern.test(trimmedBase64)) return trimmedBase64;
|
|
@@ -293,4 +310,4 @@ async function scaleImage(imageBase64, scale) {
|
|
|
293
310
|
imageBase64: base64
|
|
294
311
|
};
|
|
295
312
|
}
|
|
296
|
-
export { createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Body, normalizeBase64Image, paddingToMatchBlock, paddingToMatchBlockByBase64, parseBase64, photonFromBase64, photonToBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o };
|
|
313
|
+
export { createImgBase64ByFormat, cropByRect, httpImg2Base64, inferBase64ImageFormat, localImg2Base64, normalizeBase64Body, normalizeBase64Image, normalizeScreenshotBase64, paddingToMatchBlock, paddingToMatchBlockByBase64, parseBase64, photonFromBase64, photonToBase64, preProcessImageUrl, resizeAndConvertImgBuffer, resizeImgBase64, saveBase64Image, scaleImage, zoomForGPT4o };
|
package/dist/es/utils.mjs
CHANGED
|
@@ -34,12 +34,8 @@ function generateHashId(rect, content = '') {
|
|
|
34
34
|
function assert(condition, message) {
|
|
35
35
|
if (!condition) throw new Error(message || 'Assertion failed');
|
|
36
36
|
}
|
|
37
|
-
let isMcp = false;
|
|
38
|
-
function setIsMcp(value) {
|
|
39
|
-
isMcp = value;
|
|
40
|
-
}
|
|
41
37
|
function logMsg(...message) {
|
|
42
|
-
|
|
38
|
+
console.log(...message);
|
|
43
39
|
}
|
|
44
40
|
async function repeat(times, fn) {
|
|
45
41
|
for(let i = 0; i < times; i++)await fn(i);
|
|
@@ -69,4 +65,4 @@ function mergeAndNormalizeAppNameMapping(defaultMapping, userMapping) {
|
|
|
69
65
|
if (userMapping) for (const [key, value] of Object.entries(userMapping))result[normalizeForComparison(key)] = value;
|
|
70
66
|
return result;
|
|
71
67
|
}
|
|
72
|
-
export { antiEscapeScriptTag, assert, escapeScriptTag, generateHashId, ifInBrowser, ifInNode, ifInWorker, isPlainObject, logMsg, mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat, replaceIllegalPathCharsAndSpace,
|
|
68
|
+
export { antiEscapeScriptTag, assert, escapeScriptTag, generateHashId, ifInBrowser, ifInNode, ifInWorker, isPlainObject, logMsg, mergeAndNormalizeAppNameMapping, normalizeForComparison, repeat, replaceIllegalPathCharsAndSpace, uuid };
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
extractAgentBehaviorInitArgs: ()=>extractAgentBehaviorInitArgs,
|
|
28
|
+
agentBehaviorInitArgShape: ()=>agentBehaviorInitArgShape,
|
|
29
|
+
getAgentInitArgsSignature: ()=>getAgentInitArgsSignature,
|
|
30
|
+
shouldRebuildAgentForInitArgs: ()=>shouldRebuildAgentForInitArgs
|
|
31
|
+
});
|
|
32
|
+
const external_zod_namespaceObject = require("zod");
|
|
33
|
+
const agentBehaviorInitArgShape = {
|
|
34
|
+
aiActContext: external_zod_namespaceObject.z.string().optional().describe('Background knowledge passed to aiAct. Default: no extra context.'),
|
|
35
|
+
replanningCycleLimit: external_zod_namespaceObject.z.number().int().nonnegative().optional().describe('Maximum number of replanning cycles for aiAct. Default: model adapter default.'),
|
|
36
|
+
waitAfterAction: external_zod_namespaceObject.z.number().nonnegative().optional().describe('Wait time in milliseconds after each action execution. Default: 300ms.'),
|
|
37
|
+
screenshotShrinkFactor: external_zod_namespaceObject.z.number().min(1).optional().describe('Screenshot shrink factor before sending images to AI. Default: 1; high values may reduce recognition quality, especially on mobile.')
|
|
38
|
+
};
|
|
39
|
+
function extractAgentBehaviorInitArgs(extracted) {
|
|
40
|
+
if (!extracted) return;
|
|
41
|
+
const agentOptions = {
|
|
42
|
+
...'string' == typeof extracted.aiActContext ? {
|
|
43
|
+
aiActContext: extracted.aiActContext
|
|
44
|
+
} : {},
|
|
45
|
+
...'string' == typeof extracted.aiActionContext ? {
|
|
46
|
+
aiActionContext: extracted.aiActionContext
|
|
47
|
+
} : {},
|
|
48
|
+
...'number' == typeof extracted.replanningCycleLimit ? {
|
|
49
|
+
replanningCycleLimit: extracted.replanningCycleLimit
|
|
50
|
+
} : {},
|
|
51
|
+
...'number' == typeof extracted.waitAfterAction ? {
|
|
52
|
+
waitAfterAction: extracted.waitAfterAction
|
|
53
|
+
} : {},
|
|
54
|
+
...'number' == typeof extracted.screenshotShrinkFactor ? {
|
|
55
|
+
screenshotShrinkFactor: extracted.screenshotShrinkFactor
|
|
56
|
+
} : {}
|
|
57
|
+
};
|
|
58
|
+
return Object.keys(agentOptions).length > 0 ? agentOptions : void 0;
|
|
59
|
+
}
|
|
60
|
+
function stableJsonValue(value) {
|
|
61
|
+
if (Array.isArray(value)) return value.map(stableJsonValue);
|
|
62
|
+
if (value && 'object' == typeof value) return Object.fromEntries(Object.entries(value).sort(([left], [right])=>left.localeCompare(right)).map(([key, nestedValue])=>[
|
|
63
|
+
key,
|
|
64
|
+
stableJsonValue(nestedValue)
|
|
65
|
+
]));
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
function getAgentInitArgsSignature(initArgs) {
|
|
69
|
+
if (!initArgs || 0 === Object.keys(initArgs).length) return;
|
|
70
|
+
return JSON.stringify(stableJsonValue(initArgs));
|
|
71
|
+
}
|
|
72
|
+
function shouldRebuildAgentForInitArgs(currentSignature, nextSignature) {
|
|
73
|
+
return currentSignature !== nextSignature && (void 0 !== currentSignature || void 0 !== nextSignature);
|
|
74
|
+
}
|
|
75
|
+
exports.agentBehaviorInitArgShape = __webpack_exports__.agentBehaviorInitArgShape;
|
|
76
|
+
exports.extractAgentBehaviorInitArgs = __webpack_exports__.extractAgentBehaviorInitArgs;
|
|
77
|
+
exports.getAgentInitArgsSignature = __webpack_exports__.getAgentInitArgsSignature;
|
|
78
|
+
exports.shouldRebuildAgentForInitArgs = __webpack_exports__.shouldRebuildAgentForInitArgs;
|
|
79
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
80
|
+
"agentBehaviorInitArgShape",
|
|
81
|
+
"extractAgentBehaviorInitArgs",
|
|
82
|
+
"getAgentInitArgsSignature",
|
|
83
|
+
"shouldRebuildAgentForInitArgs"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -43,7 +43,7 @@ function _define_property(obj, key, value) {
|
|
|
43
43
|
else obj[key] = value;
|
|
44
44
|
return obj;
|
|
45
45
|
}
|
|
46
|
-
const debug = (0, logger_namespaceObject.getDebug)('
|
|
46
|
+
const debug = (0, logger_namespaceObject.getDebug)('agent-tools:base-tools');
|
|
47
47
|
class BaseMidsceneTools {
|
|
48
48
|
getInitArgKeys() {
|
|
49
49
|
return this.initArgSpec ? Object.keys(this.initArgSpec.shape) : [];
|
|
@@ -132,12 +132,6 @@ class BaseMidsceneTools {
|
|
|
132
132
|
this.toolDefinitions.push(...actionTools, ...commonTools);
|
|
133
133
|
debug('Total tools prepared:', this.toolDefinitions.length);
|
|
134
134
|
}
|
|
135
|
-
attachToServer(server) {
|
|
136
|
-
this.mcpServer = server;
|
|
137
|
-
if (0 === this.toolDefinitions.length) debug('Warning: No tools to register. Tools may be initialized lazily.');
|
|
138
|
-
for (const toolDef of this.toolDefinitions)this.mcpServer.tool(toolDef.name, toolDef.description, toolDef.schema, toolDef.handler);
|
|
139
|
-
debug('Registered', this.toolDefinitions.length, 'tools');
|
|
140
|
-
}
|
|
141
135
|
async destroy() {
|
|
142
136
|
await this.agent?.destroy?.();
|
|
143
137
|
}
|
|
@@ -183,7 +177,6 @@ class BaseMidsceneTools {
|
|
|
183
177
|
};
|
|
184
178
|
}
|
|
185
179
|
constructor(){
|
|
186
|
-
_define_property(this, "mcpServer", void 0);
|
|
187
180
|
_define_property(this, "agent", void 0);
|
|
188
181
|
_define_property(this, "toolDefinitions", []);
|
|
189
182
|
_define_property(this, "toolDefaults", {});
|
|
@@ -29,6 +29,11 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
29
29
|
});
|
|
30
30
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
31
31
|
const index_js_namespaceObject = require("../env/index.js");
|
|
32
|
+
const external_logger_js_namespaceObject = require("../logger.js");
|
|
33
|
+
const warnChromePath = (0, external_logger_js_namespaceObject.getDebug)('agent-tools:chrome-path', {
|
|
34
|
+
console: true
|
|
35
|
+
});
|
|
36
|
+
let hasWarnedLegacyChromePath = false;
|
|
32
37
|
function getSystemChromePath() {
|
|
33
38
|
const platform = process.platform;
|
|
34
39
|
const chromePaths = {
|
|
@@ -55,11 +60,17 @@ function getSystemChromePath() {
|
|
|
55
60
|
return paths.find((p)=>(0, external_node_fs_namespaceObject.existsSync)(p));
|
|
56
61
|
}
|
|
57
62
|
function resolveChromePath() {
|
|
58
|
-
const
|
|
63
|
+
const primaryEnvPath = index_js_namespaceObject.globalConfigManager.getEnvConfigValue(index_js_namespaceObject.MIDSCENE_CHROME_PATH);
|
|
64
|
+
const legacyEnvPath = index_js_namespaceObject.globalConfigManager.getEnvConfigValue(index_js_namespaceObject.MIDSCENE_MCP_CHROME_PATH);
|
|
65
|
+
const envPath = primaryEnvPath || legacyEnvPath;
|
|
66
|
+
if (!primaryEnvPath && legacyEnvPath && !hasWarnedLegacyChromePath) {
|
|
67
|
+
warnChromePath('MIDSCENE_MCP_CHROME_PATH is deprecated. Use MIDSCENE_CHROME_PATH instead.');
|
|
68
|
+
hasWarnedLegacyChromePath = true;
|
|
69
|
+
}
|
|
59
70
|
if (envPath && 'auto' !== envPath && (0, external_node_fs_namespaceObject.existsSync)(envPath)) return envPath;
|
|
60
71
|
const systemPath = getSystemChromePath();
|
|
61
72
|
if (systemPath) return systemPath;
|
|
62
|
-
throw new Error('Chrome not found. Install Google Chrome or set
|
|
73
|
+
throw new Error('Chrome not found. Install Google Chrome or set MIDSCENE_CHROME_PATH environment variable.');
|
|
63
74
|
}
|
|
64
75
|
exports.getSystemChromePath = __webpack_exports__.getSystemChromePath;
|
|
65
76
|
exports.resolveChromePath = __webpack_exports__.resolveChromePath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"./
|
|
4
|
-
module.exports = require("./
|
|
3
|
+
"./agent-behavior-init-args" (module) {
|
|
4
|
+
module.exports = require("./agent-behavior-init-args.js");
|
|
5
5
|
},
|
|
6
6
|
"./base-tools" (module) {
|
|
7
7
|
module.exports = require("./base-tools.js");
|
|
@@ -15,12 +15,6 @@ var __webpack_modules__ = {
|
|
|
15
15
|
"./init-arg-utils" (module) {
|
|
16
16
|
module.exports = require("./init-arg-utils.js");
|
|
17
17
|
},
|
|
18
|
-
"./inject-report-html-plugin" (module) {
|
|
19
|
-
module.exports = require("./inject-report-html-plugin.js");
|
|
20
|
-
},
|
|
21
|
-
"./launcher-helper" (module) {
|
|
22
|
-
module.exports = require("./launcher-helper.js");
|
|
23
|
-
},
|
|
24
18
|
"./tool-defaults" (module) {
|
|
25
19
|
module.exports = require("./tool-defaults.js");
|
|
26
20
|
},
|
|
@@ -74,17 +68,17 @@ function __webpack_require__(moduleId) {
|
|
|
74
68
|
var __webpack_exports__ = {};
|
|
75
69
|
(()=>{
|
|
76
70
|
__webpack_require__.r(__webpack_exports__);
|
|
77
|
-
var
|
|
71
|
+
var _base_tools__rspack_import_0 = __webpack_require__("./base-tools");
|
|
78
72
|
var __rspack_reexport = {};
|
|
79
|
-
for(const __rspack_import_key in
|
|
73
|
+
for(const __rspack_import_key in _base_tools__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_base_tools__rspack_import_0[__rspack_import_key];
|
|
80
74
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
81
|
-
var
|
|
75
|
+
var _tool_defaults__rspack_import_1 = __webpack_require__("./tool-defaults");
|
|
82
76
|
var __rspack_reexport = {};
|
|
83
|
-
for(const __rspack_import_key in
|
|
77
|
+
for(const __rspack_import_key in _tool_defaults__rspack_import_1)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_tool_defaults__rspack_import_1[__rspack_import_key];
|
|
84
78
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
85
|
-
var
|
|
79
|
+
var _agent_behavior_init_args__rspack_import_2 = __webpack_require__("./agent-behavior-init-args");
|
|
86
80
|
var __rspack_reexport = {};
|
|
87
|
-
for(const __rspack_import_key in
|
|
81
|
+
for(const __rspack_import_key in _agent_behavior_init_args__rspack_import_2)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_agent_behavior_init_args__rspack_import_2[__rspack_import_key];
|
|
88
82
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
89
83
|
var _init_arg_utils__rspack_import_3 = __webpack_require__("./init-arg-utils");
|
|
90
84
|
var __rspack_reexport = {};
|
|
@@ -102,17 +96,9 @@ var __webpack_exports__ = {};
|
|
|
102
96
|
var __rspack_reexport = {};
|
|
103
97
|
for(const __rspack_import_key in _types__rspack_import_6)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_types__rspack_import_6[__rspack_import_key];
|
|
104
98
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
105
|
-
var
|
|
106
|
-
var __rspack_reexport = {};
|
|
107
|
-
for(const __rspack_import_key in _inject_report_html_plugin__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_inject_report_html_plugin__rspack_import_7[__rspack_import_key];
|
|
108
|
-
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
109
|
-
var _launcher_helper__rspack_import_8 = __webpack_require__("./launcher-helper");
|
|
110
|
-
var __rspack_reexport = {};
|
|
111
|
-
for(const __rspack_import_key in _launcher_helper__rspack_import_8)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_launcher_helper__rspack_import_8[__rspack_import_key];
|
|
112
|
-
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
113
|
-
var _chrome_path__rspack_import_9 = __webpack_require__("./chrome-path");
|
|
99
|
+
var _chrome_path__rspack_import_7 = __webpack_require__("./chrome-path");
|
|
114
100
|
var __rspack_reexport = {};
|
|
115
|
-
for(const __rspack_import_key in
|
|
101
|
+
for(const __rspack_import_key in _chrome_path__rspack_import_7)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_chrome_path__rspack_import_7[__rspack_import_key];
|
|
116
102
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
117
103
|
})();
|
|
118
104
|
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
@@ -33,7 +33,7 @@ const external_zod_namespaceObject = require("zod");
|
|
|
33
33
|
const external_zod_schema_utils_js_namespaceObject = require("../zod-schema-utils.js");
|
|
34
34
|
const external_error_formatter_js_namespaceObject = require("./error-formatter.js");
|
|
35
35
|
const external_user_prompt_js_namespaceObject = require("./user-prompt.js");
|
|
36
|
-
function
|
|
36
|
+
function describeActionForTool(action) {
|
|
37
37
|
const actionDesc = action.description || `Execute ${action.name} action`;
|
|
38
38
|
if (!action.paramSchema) return `${action.name} action, ${actionDesc}`;
|
|
39
39
|
const shape = getZodObjectShape(action.paramSchema);
|
|
@@ -78,13 +78,14 @@ function getZodObjectShape(value) {
|
|
|
78
78
|
function isRecord(value) {
|
|
79
79
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
80
80
|
}
|
|
81
|
-
function makePromptOptional(shape, wrapInOptional) {
|
|
81
|
+
function makePromptOptional(shape, wrapInOptional, description) {
|
|
82
82
|
const newShape = {
|
|
83
83
|
...shape
|
|
84
84
|
};
|
|
85
85
|
newShape.prompt = shape.prompt.optional();
|
|
86
86
|
let newSchema = external_zod_namespaceObject.z.object(newShape).passthrough();
|
|
87
87
|
if (wrapInOptional) newSchema = newSchema.optional();
|
|
88
|
+
if (description) newSchema = newSchema.describe(description);
|
|
88
89
|
return newSchema;
|
|
89
90
|
}
|
|
90
91
|
function transformSchemaField(key, value) {
|
|
@@ -92,7 +93,7 @@ function transformSchemaField(key, value) {
|
|
|
92
93
|
const shape = getZodObjectShape(innerValue);
|
|
93
94
|
if (shape && (0, external_zod_schema_utils_js_namespaceObject.isMidsceneLocatorField)(innerValue)) return [
|
|
94
95
|
key,
|
|
95
|
-
makePromptOptional(shape, isOptional)
|
|
96
|
+
makePromptOptional(shape, isOptional, (0, external_zod_schema_utils_js_namespaceObject.getZodDescription)(value))
|
|
96
97
|
];
|
|
97
98
|
return [
|
|
98
99
|
key,
|
|
@@ -104,7 +105,7 @@ function extractActionSchema(paramSchema, actionName) {
|
|
|
104
105
|
const shape = getZodObjectShape(paramSchema);
|
|
105
106
|
if (!shape) {
|
|
106
107
|
const typeName = paramSchema?._def?.typeName ?? 'unknown';
|
|
107
|
-
throw new Error(`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI
|
|
108
|
+
throw new Error(`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI tool schemas must be a ZodObject (e.g. z.object({ uri: z.string() })) or undefined. Wrap primitive fields in an object schema.`);
|
|
108
109
|
}
|
|
109
110
|
return Object.fromEntries(Object.entries(shape).map(([key, value])=>transformSchemaField(key, value)));
|
|
110
111
|
}
|
|
@@ -356,7 +357,7 @@ function generateToolsFromActionSpace(actionSpace, getAgent, sanitizeArgs = (arg
|
|
|
356
357
|
};
|
|
357
358
|
return {
|
|
358
359
|
name: action.name,
|
|
359
|
-
description:
|
|
360
|
+
description: describeActionForTool(action),
|
|
360
361
|
schema,
|
|
361
362
|
cli: initArgCliMetadata,
|
|
362
363
|
handler: async (args)=>{
|
|
@@ -45,8 +45,8 @@ const external_node_os_namespaceObject = require("node:os");
|
|
|
45
45
|
const external_node_path_namespaceObject = require("node:path");
|
|
46
46
|
const external_dotenv_namespaceObject = require("dotenv");
|
|
47
47
|
var external_dotenv_default = /*#__PURE__*/ __webpack_require__.n(external_dotenv_namespaceObject);
|
|
48
|
+
const tool_defaults_js_namespaceObject = require("../agent-tools/tool-defaults.js");
|
|
48
49
|
const external_logger_js_namespaceObject = require("../logger.js");
|
|
49
|
-
const tool_defaults_js_namespaceObject = require("../mcp/tool-defaults.js");
|
|
50
50
|
const external_cli_args_js_namespaceObject = require("./cli-args.js");
|
|
51
51
|
const external_cli_error_js_namespaceObject = require("./cli-error.js");
|
|
52
52
|
const debug = (0, external_logger_js_namespaceObject.getDebug)('cli-runner');
|
|
@@ -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 = ()=>"1.9.
|
|
40
|
+
const getCurrentVersion = ()=>"1.9.8-beta-20260618014851.0";
|
|
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,
|