@midscene/shared 1.9.8-beta-20260618091332.0 → 1.10.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/{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 +0 -3
- package/dist/es/{mcp → agent-tools}/tool-generator.mjs +3 -3
- 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/utils.mjs +2 -6
- 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 +16 -37
- package/dist/lib/{mcp → agent-tools}/tool-generator.js +3 -3
- 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/utils.js +8 -15
- package/dist/types/{mcp → agent-tools}/base-tools.d.ts +7 -13
- package/dist/types/{mcp → agent-tools}/index.d.ts +0 -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 +4 -9
- 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/key-alias-utils.d.ts +2 -2
- package/dist/types/utils.d.ts +0 -1
- package/package.json +16 -9
- 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 +0 -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 +6 -6
- package/src/{mcp → agent-tools}/types.ts +4 -9
- 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/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}/agent-behavior-init-args.mjs +0 -0
- /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}/agent-behavior-init-args.js +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}/agent-behavior-init-args.d.ts +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}/agent-behavior-init-args.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
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified, declarative mechanism for "force a default option on every tool
|
|
3
|
-
* call" behaviors exposed by
|
|
3
|
+
* call" behaviors exposed by device and Agent Skill CLIs.
|
|
4
4
|
*
|
|
5
5
|
* Adding a new behavior flag (e.g. `--deep-search`) is a one-line change to
|
|
6
6
|
* {@link TOOL_BEHAVIOR_FLAGS}: declare which default-option "bag" it fills.
|
|
7
|
-
* The tool generator,
|
|
7
|
+
* The tool generator, tools managers and CLI parsing are all generic
|
|
8
8
|
* over {@link ToolDefaults} and never need to learn about individual flags.
|
|
9
9
|
*
|
|
10
10
|
* See https://github.com/web-infra-dev/midscene/issues/2446.
|
|
@@ -50,13 +50,12 @@ export declare function resolveToolDefaults(isEnabled: (cli: string) => boolean)
|
|
|
50
50
|
*
|
|
51
51
|
* Behavior flags (e.g. `--deep-locate`) are global: they may appear anywhere
|
|
52
52
|
* in argv and are not tied to a specific sub-command. They are recognized by
|
|
53
|
-
* exact kebab-case match
|
|
54
|
-
* — and removed so a strict per-command parser never sees them. Every other
|
|
53
|
+
* exact kebab-case match and removed so a strict per-command parser never sees them. Every other
|
|
55
54
|
* token is returned untouched and in order for that per-command parser.
|
|
56
55
|
*
|
|
57
56
|
* This is the single place that knows how a behavior flag looks on the command
|
|
58
|
-
* line;
|
|
59
|
-
*
|
|
57
|
+
* line; the device / Agent Skill CLI resolves defaults from
|
|
58
|
+
* {@link TOOL_BEHAVIOR_FLAGS} through here / {@link resolveToolDefaults}.
|
|
60
59
|
*/
|
|
61
60
|
export declare function stripBehaviorFlags(argv: readonly string[]): {
|
|
62
61
|
rawArgs: string[];
|
|
@@ -3,7 +3,7 @@ import type { ActionSpaceItem, BaseAgent, ToolCliMetadata, ToolDefinition, ToolS
|
|
|
3
3
|
import { composeUserPrompt } from './user-prompt';
|
|
4
4
|
export { composeUserPrompt };
|
|
5
5
|
/**
|
|
6
|
-
* Converts DeviceAction from actionSpace into
|
|
6
|
+
* Converts DeviceAction from actionSpace into ToolDefinition.
|
|
7
7
|
* This is the core logic that removes need for hardcoded tool definitions
|
|
8
8
|
*/
|
|
9
9
|
export declare function generateToolsFromActionSpace(actionSpace: ActionSpaceItem[], getAgent: (args?: Record<string, unknown>) => Promise<BaseAgent>, sanitizeArgs?: (args: Record<string, unknown>) => Record<string, unknown>, initArgSchema?: ToolSchema, initArgCliMetadata?: ToolCliMetadata, toolDefaults?: ToolDefaults): ToolDefinition[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { z } from 'zod';
|
|
3
2
|
import type { ToolDefaults } from './tool-defaults';
|
|
4
3
|
/**
|
|
@@ -7,7 +6,7 @@ import type { ToolDefaults } from './tool-defaults';
|
|
|
7
6
|
export declare const defaultAppLoadingTimeoutMs = 10000;
|
|
8
7
|
export declare const defaultAppLoadingCheckIntervalMs = 2000;
|
|
9
8
|
/**
|
|
10
|
-
* Content item types for tool results
|
|
9
|
+
* Content item types for tool results.
|
|
11
10
|
*/
|
|
12
11
|
export type ToolResultContent = {
|
|
13
12
|
type: 'text';
|
|
@@ -33,7 +32,7 @@ export type ToolResultContent = {
|
|
|
33
32
|
};
|
|
34
33
|
};
|
|
35
34
|
/**
|
|
36
|
-
* Result type for tool execution
|
|
35
|
+
* Result type for tool execution.
|
|
37
36
|
*/
|
|
38
37
|
export interface ToolResult {
|
|
39
38
|
[x: string]: unknown;
|
|
@@ -58,7 +57,7 @@ export interface ToolCliMetadata {
|
|
|
58
57
|
options?: Record<string, ToolCliOption>;
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
|
-
* Tool definition for
|
|
60
|
+
* Tool definition for Midscene CLI and Skill surfaces.
|
|
62
61
|
*/
|
|
63
62
|
export interface ToolDefinition<T = Record<string, unknown>> {
|
|
64
63
|
name: string;
|
|
@@ -67,9 +66,6 @@ export interface ToolDefinition<T = Record<string, unknown>> {
|
|
|
67
66
|
handler: ToolHandler<T>;
|
|
68
67
|
cli?: ToolCliMetadata;
|
|
69
68
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Tool type for mcpKitForAgent return value
|
|
72
|
-
*/
|
|
73
69
|
export type Tool = ToolDefinition;
|
|
74
70
|
/**
|
|
75
71
|
* Action space item definition
|
|
@@ -137,10 +133,9 @@ export interface BaseDevice {
|
|
|
137
133
|
destroy?(): Promise<void>;
|
|
138
134
|
}
|
|
139
135
|
/**
|
|
140
|
-
* Interface for platform-specific
|
|
136
|
+
* Interface for platform-specific tools manager.
|
|
141
137
|
*/
|
|
142
138
|
export interface IMidsceneTools {
|
|
143
|
-
attachToServer(server: McpServer): void;
|
|
144
139
|
initTools(): Promise<void>;
|
|
145
140
|
destroy?(): Promise<void>;
|
|
146
141
|
setToolDefaults?(toolDefaults: ToolDefaults): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToolCliOption, ToolDefinition } from '../
|
|
1
|
+
import type { ToolCliOption, ToolDefinition } from '../agent-tools/types';
|
|
2
2
|
export declare function parseValue(raw: string): unknown;
|
|
3
3
|
export declare function parseCliArgs(args: string[]): Record<string, unknown>;
|
|
4
4
|
export declare function getCliOptionDisplay(key: string, cliOption?: ToolCliOption): {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BaseMidsceneTools } from '../
|
|
2
|
-
import type { ToolDefinition } from '../
|
|
1
|
+
import type { BaseMidsceneTools } from '../agent-tools/base-tools';
|
|
2
|
+
import type { ToolDefinition } from '../agent-tools/types';
|
|
3
3
|
export interface CLIExtraCommand {
|
|
4
4
|
name: string;
|
|
5
5
|
def: ToolDefinition;
|
|
@@ -5,9 +5,11 @@ export declare const MIDSCENE_DEBUG_MODEL_PROFILE = "MIDSCENE_DEBUG_MODEL_PROFIL
|
|
|
5
5
|
export declare const MIDSCENE_DEBUG_MODEL_RESPONSE = "MIDSCENE_DEBUG_MODEL_RESPONSE";
|
|
6
6
|
export declare const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG = "MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG";
|
|
7
7
|
export declare const MIDSCENE_DEBUG_MODE = "MIDSCENE_DEBUG_MODE";
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const MIDSCENE_CHROME_PATH = "MIDSCENE_CHROME_PATH";
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated Use MIDSCENE_CHROME_PATH instead. This is kept for backward compatibility.
|
|
11
|
+
*/
|
|
9
12
|
export declare const MIDSCENE_MCP_CHROME_PATH = "MIDSCENE_MCP_CHROME_PATH";
|
|
10
|
-
export declare const MIDSCENE_MCP_ANDROID_MODE = "MIDSCENE_MCP_ANDROID_MODE";
|
|
11
13
|
export declare const DOCKER_CONTAINER = "DOCKER_CONTAINER";
|
|
12
14
|
export declare const MIDSCENE_LANGSMITH_DEBUG = "MIDSCENE_LANGSMITH_DEBUG";
|
|
13
15
|
export declare const MIDSCENE_LANGFUSE_DEBUG = "MIDSCENE_LANGFUSE_DEBUG";
|
|
@@ -104,22 +106,22 @@ export declare const UNUSED_ENV_KEYS: string[];
|
|
|
104
106
|
* can not be override by overrideAIConfig
|
|
105
107
|
*/
|
|
106
108
|
export declare const BASIC_ENV_KEYS: readonly ["MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR"];
|
|
107
|
-
export declare const BOOLEAN_ENV_KEYS: readonly ["MIDSCENE_CACHE", "
|
|
109
|
+
export declare const BOOLEAN_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET"];
|
|
108
110
|
export declare const NUMBER_ENV_KEYS: readonly ["MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT"];
|
|
109
|
-
export declare const STRING_ENV_KEYS: readonly ["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_MCP_CHROME_PATH", "DOCKER_CONTAINER"];
|
|
111
|
+
export declare const STRING_ENV_KEYS: readonly ["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"];
|
|
110
112
|
/**
|
|
111
113
|
* Non model related env keys, used for globally controlling the behavior of midscene
|
|
112
114
|
* Can not be override by agent.modelConfig but can be override by overrideAIConfig
|
|
113
115
|
* Can be access at any time
|
|
114
116
|
*/
|
|
115
|
-
export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "
|
|
117
|
+
export declare const GLOBAL_ENV_KEYS: readonly ["MIDSCENE_CACHE", "MIDSCENE_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "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"];
|
|
116
118
|
/**
|
|
117
119
|
* Model related eve keys, used for declare which model to use.
|
|
118
120
|
* Can be override by both agent.modelConfig and overrideAIConfig
|
|
119
121
|
* Can only be access after agent.constructor
|
|
120
122
|
*/
|
|
121
123
|
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"];
|
|
122
|
-
export declare const ALL_ENV_KEYS: readonly [...string[], "MIDSCENE_DEBUG_MODE", "MIDSCENE_DEBUG_MODEL_PROFILE", "MIDSCENE_DEBUG_MODEL_RESPONSE", "MIDSCENE_RUN_DIR", "MIDSCENE_CACHE", "
|
|
124
|
+
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_LANGSMITH_DEBUG", "MIDSCENE_LANGFUSE_DEBUG", "MIDSCENE_REPORT_QUIET", "MIDSCENE_CACHE_MAX_FILENAME_LENGTH", "MIDSCENE_REPLANNING_CYCLE_LIMIT", "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"];
|
|
123
125
|
export type TEnvKeys = (typeof ALL_ENV_KEYS)[number];
|
|
124
126
|
export type TGlobalConfig = Record<TEnvKeys, string | undefined>;
|
|
125
127
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal-only helpers for CLI
|
|
2
|
+
* Internal-only helpers for CLI argument key aliasing.
|
|
3
3
|
* Not re-exported from the package entry point — keep consumers within
|
|
4
|
-
* `cli
|
|
4
|
+
* `cli/`.
|
|
5
5
|
*/
|
|
6
6
|
export declare function kebabToCamel(str: string): string;
|
|
7
7
|
export declare function camelToKebab(str: string): string;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export declare function generateHashId(rect: any, content?: string): string;
|
|
|
11
11
|
* @throws Error with the provided message if the condition is false
|
|
12
12
|
*/
|
|
13
13
|
export declare function assert(condition: any, message?: string): asserts condition;
|
|
14
|
-
export declare function setIsMcp(value: boolean): void;
|
|
15
14
|
export declare function logMsg(...message: Parameters<typeof console.log>): void;
|
|
16
15
|
export declare function repeat(times: number, fn: (index: number) => Promise<void>): Promise<void>;
|
|
17
16
|
export declare const escapeScriptTag: (html: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midscene/shared",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"repository": "https://github.com/web-infra-dev/midscene",
|
|
5
5
|
"homepage": "https://midscenejs.com/",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -57,16 +57,26 @@
|
|
|
57
57
|
"import": "./dist/es/common.mjs",
|
|
58
58
|
"require": "./dist/lib/common.js"
|
|
59
59
|
},
|
|
60
|
-
"./
|
|
61
|
-
"types": "./dist/types/
|
|
62
|
-
"import": "./dist/es/
|
|
63
|
-
"require": "./dist/lib/
|
|
60
|
+
"./agent-tools": {
|
|
61
|
+
"types": "./dist/types/agent-tools/index.d.ts",
|
|
62
|
+
"import": "./dist/es/agent-tools/index.mjs",
|
|
63
|
+
"require": "./dist/lib/agent-tools/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./agent-tools/*": {
|
|
66
|
+
"types": "./dist/types/agent-tools/*.d.ts",
|
|
67
|
+
"import": "./dist/es/agent-tools/*.mjs",
|
|
68
|
+
"require": "./dist/lib/agent-tools/*.js"
|
|
64
69
|
},
|
|
65
70
|
"./cli": {
|
|
66
71
|
"types": "./dist/types/cli/index.d.ts",
|
|
67
72
|
"import": "./dist/es/cli/index.mjs",
|
|
68
73
|
"require": "./dist/lib/cli/index.js"
|
|
69
74
|
},
|
|
75
|
+
"./recorder": {
|
|
76
|
+
"types": "./dist/types/recorder.d.ts",
|
|
77
|
+
"import": "./dist/es/recorder.mjs",
|
|
78
|
+
"require": "./dist/lib/recorder.js"
|
|
79
|
+
},
|
|
70
80
|
"./logger": {
|
|
71
81
|
"types": "./dist/types/logger.d.ts",
|
|
72
82
|
"import": "./dist/es/logger.mjs",
|
|
@@ -84,11 +94,9 @@
|
|
|
84
94
|
"README.md"
|
|
85
95
|
],
|
|
86
96
|
"dependencies": {
|
|
87
|
-
"@modelcontextprotocol/sdk": "1.10.2",
|
|
88
97
|
"@silvia-odwyer/photon": "0.3.3",
|
|
89
98
|
"@silvia-odwyer/photon-node": "0.3.3",
|
|
90
99
|
"debug": "4.4.0",
|
|
91
|
-
"express": "^4.21.2",
|
|
92
100
|
"js-sha256": "0.11.0",
|
|
93
101
|
"sharp": "^0.34.3",
|
|
94
102
|
"dotenv": "^16.4.5",
|
|
@@ -98,11 +106,10 @@
|
|
|
98
106
|
"devDependencies": {
|
|
99
107
|
"@rslib/core": "^0.18.3",
|
|
100
108
|
"@types/debug": "4.1.12",
|
|
101
|
-
"@types/express": "^4.17.21",
|
|
102
109
|
"@types/node": "^18.0.0",
|
|
103
110
|
"@ui-tars/shared": "1.2.0",
|
|
104
111
|
"openai": "6.3.0",
|
|
105
|
-
"rimraf": "~
|
|
112
|
+
"rimraf": "~5.0.10",
|
|
106
113
|
"typescript": "^5.8.3",
|
|
107
114
|
"vitest": "3.0.5"
|
|
108
115
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { parseBase64 } from '@midscene/shared/img';
|
|
2
2
|
import { getDebug } from '@midscene/shared/logger';
|
|
3
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
3
|
import type { z } from 'zod';
|
|
5
4
|
import { camelToKebab, getKeyAliases } from '../key-alias-utils';
|
|
6
5
|
import {
|
|
@@ -29,7 +28,7 @@ import type {
|
|
|
29
28
|
ToolSchema,
|
|
30
29
|
} from './types';
|
|
31
30
|
|
|
32
|
-
const debug = getDebug('
|
|
31
|
+
const debug = getDebug('agent-tools:base-tools');
|
|
33
32
|
|
|
34
33
|
/**
|
|
35
34
|
* Declarative description of a platform's agent init args.
|
|
@@ -39,11 +38,11 @@ const debug = getDebug('mcp:base-tools');
|
|
|
39
38
|
export interface InitArgSpec<TInitParam> {
|
|
40
39
|
/** Arg namespace, e.g. `android`, `ios`. */
|
|
41
40
|
namespace: string;
|
|
42
|
-
/** Zod shape describing the init args. Field names drive the
|
|
41
|
+
/** Zod shape describing the init args. Field names drive the tool schema. */
|
|
43
42
|
shape: Record<string, z.ZodTypeAny>;
|
|
44
43
|
/**
|
|
45
44
|
* Optional CLI presentation hints. These affect `--help` output for
|
|
46
|
-
* single-platform CLIs but do not alter
|
|
45
|
+
* single-platform CLIs but do not alter YAML protocol keys.
|
|
47
46
|
*/
|
|
48
47
|
cli?: {
|
|
49
48
|
/** Prefer bare `--device-id`-style options in platform CLI help output. */
|
|
@@ -61,7 +60,7 @@ export interface InitArgSpec<TInitParam> {
|
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
|
-
* Base class for platform-specific
|
|
63
|
+
* Base class for platform-specific Midscene tools.
|
|
65
64
|
* @typeParam TAgent - Platform-specific agent type.
|
|
66
65
|
* @typeParam TInitParam - Platform-specific init parameter consumed by
|
|
67
66
|
* `ensureAgent`. Defaults to `undefined` for platforms that take no args.
|
|
@@ -71,20 +70,19 @@ export abstract class BaseMidsceneTools<
|
|
|
71
70
|
TInitParam = unknown,
|
|
72
71
|
> implements IMidsceneTools
|
|
73
72
|
{
|
|
74
|
-
protected mcpServer?: McpServer;
|
|
75
73
|
protected agent?: TAgent;
|
|
76
74
|
protected toolDefinitions: ToolDefinition[] = [];
|
|
77
75
|
|
|
78
76
|
/**
|
|
79
77
|
* Default options injected into every generated tool call (e.g. forced deep
|
|
80
|
-
* locate / deep think). Set from
|
|
78
|
+
* locate / deep think). Set from startup/CLI behavior flags before
|
|
81
79
|
* `initTools()` so they are baked into the generated tool handlers.
|
|
82
80
|
* See https://github.com/web-infra-dev/midscene/issues/2446.
|
|
83
81
|
*/
|
|
84
82
|
protected toolDefaults: ToolDefaults = {};
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
|
-
* Declarative init-arg spec. Subclasses that accept CLI
|
|
85
|
+
* Declarative init-arg spec. Subclasses that accept CLI init args should
|
|
88
86
|
* set this once and get `extractAgentInitParam` / `sanitizeToolArgs` /
|
|
89
87
|
* `getAgentInitArgSchema` auto-implemented.
|
|
90
88
|
*
|
|
@@ -108,7 +106,7 @@ export abstract class BaseMidsceneTools<
|
|
|
108
106
|
}
|
|
109
107
|
|
|
110
108
|
/**
|
|
111
|
-
* Extract a platform-specific agent init parameter from CLI
|
|
109
|
+
* Extract a platform-specific agent init parameter from CLI tool args.
|
|
112
110
|
*/
|
|
113
111
|
protected extractAgentInitParam(
|
|
114
112
|
args: Record<string, unknown>,
|
|
@@ -161,7 +159,7 @@ export abstract class BaseMidsceneTools<
|
|
|
161
159
|
* show ergonomic bare flags while the underlying schema stays namespaced.
|
|
162
160
|
* When `preferBareKeys` is enabled, single-platform CLIs only accept the
|
|
163
161
|
* bare spellings; namespaced dotted spellings remain available through the
|
|
164
|
-
*
|
|
162
|
+
* YAML schema instead of the platform CLI surface.
|
|
165
163
|
*/
|
|
166
164
|
protected getAgentInitArgCliMetadata(): ToolCliMetadata | undefined {
|
|
167
165
|
if (!this.initArgSpec?.cli) {
|
|
@@ -272,7 +270,6 @@ export abstract class BaseMidsceneTools<
|
|
|
272
270
|
this.toolDefinitions.push(...platformTools);
|
|
273
271
|
|
|
274
272
|
// 2. Get action space: use pre-set agent if available, otherwise temp device.
|
|
275
|
-
// When called via mcpKitForAgent(), agent is set before initTools().
|
|
276
273
|
// For CLI usage, agent is deferred to the first real command.
|
|
277
274
|
let actionSpace: ActionSpaceItem[];
|
|
278
275
|
if (this.agent) {
|
|
@@ -313,28 +310,6 @@ export abstract class BaseMidsceneTools<
|
|
|
313
310
|
debug('Total tools prepared:', this.toolDefinitions.length);
|
|
314
311
|
}
|
|
315
312
|
|
|
316
|
-
/**
|
|
317
|
-
* Attach to MCP server and register all tools
|
|
318
|
-
*/
|
|
319
|
-
public attachToServer(server: McpServer): void {
|
|
320
|
-
this.mcpServer = server;
|
|
321
|
-
|
|
322
|
-
if (this.toolDefinitions.length === 0) {
|
|
323
|
-
debug('Warning: No tools to register. Tools may be initialized lazily.');
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
for (const toolDef of this.toolDefinitions) {
|
|
327
|
-
this.mcpServer.tool(
|
|
328
|
-
toolDef.name,
|
|
329
|
-
toolDef.description,
|
|
330
|
-
toolDef.schema,
|
|
331
|
-
toolDef.handler,
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
debug('Registered', this.toolDefinitions.length, 'tools');
|
|
336
|
-
}
|
|
337
|
-
|
|
338
313
|
/**
|
|
339
314
|
* Cleanup method - destroy agent and release resources
|
|
340
315
|
*/
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
MIDSCENE_CHROME_PATH,
|
|
4
|
+
MIDSCENE_MCP_CHROME_PATH,
|
|
5
|
+
globalConfigManager,
|
|
6
|
+
} from '../env';
|
|
7
|
+
import { getDebug } from '../logger';
|
|
8
|
+
|
|
9
|
+
const warnChromePath = getDebug('agent-tools:chrome-path', { console: true });
|
|
10
|
+
let hasWarnedLegacyChromePath = false;
|
|
3
11
|
|
|
4
12
|
export function getSystemChromePath(): string | undefined {
|
|
5
13
|
const platform = process.platform;
|
|
@@ -33,9 +41,18 @@ export function getSystemChromePath(): string | undefined {
|
|
|
33
41
|
}
|
|
34
42
|
|
|
35
43
|
export function resolveChromePath(): string {
|
|
36
|
-
const
|
|
44
|
+
const primaryEnvPath =
|
|
45
|
+
globalConfigManager.getEnvConfigValue(MIDSCENE_CHROME_PATH);
|
|
46
|
+
const legacyEnvPath = globalConfigManager.getEnvConfigValue(
|
|
37
47
|
MIDSCENE_MCP_CHROME_PATH,
|
|
38
48
|
);
|
|
49
|
+
const envPath = primaryEnvPath || legacyEnvPath;
|
|
50
|
+
if (!primaryEnvPath && legacyEnvPath && !hasWarnedLegacyChromePath) {
|
|
51
|
+
warnChromePath(
|
|
52
|
+
'MIDSCENE_MCP_CHROME_PATH is deprecated. Use MIDSCENE_CHROME_PATH instead.',
|
|
53
|
+
);
|
|
54
|
+
hasWarnedLegacyChromePath = true;
|
|
55
|
+
}
|
|
39
56
|
if (envPath && envPath !== 'auto' && existsSync(envPath)) {
|
|
40
57
|
return envPath;
|
|
41
58
|
}
|
|
@@ -43,6 +60,6 @@ export function resolveChromePath(): string {
|
|
|
43
60
|
if (systemPath) return systemPath;
|
|
44
61
|
|
|
45
62
|
throw new Error(
|
|
46
|
-
'Chrome not found. Install Google Chrome or set
|
|
63
|
+
'Chrome not found. Install Google Chrome or set MIDSCENE_CHROME_PATH environment variable.',
|
|
47
64
|
);
|
|
48
65
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './base-server';
|
|
2
1
|
export * from './base-tools';
|
|
3
2
|
export * from './tool-defaults';
|
|
4
3
|
export * from './agent-behavior-init-args';
|
|
@@ -6,6 +5,4 @@ export * from './init-arg-utils';
|
|
|
6
5
|
export * from './error-formatter';
|
|
7
6
|
export * from './tool-generator';
|
|
8
7
|
export * from './types';
|
|
9
|
-
export * from './inject-report-html-plugin';
|
|
10
|
-
export * from './launcher-helper';
|
|
11
8
|
export * from './chrome-path';
|
|
@@ -88,11 +88,11 @@ export function sanitizeNamespacedArgs(
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* Build a flat
|
|
91
|
+
* Build a flat tool schema whose keys are dotted `"<namespace>.<field>"`.
|
|
92
92
|
*
|
|
93
93
|
* We intentionally stay flat (rather than `{ namespace: z.object({...}) }`) so
|
|
94
|
-
* that CLI (`--android.device-id`)
|
|
95
|
-
*
|
|
94
|
+
* that CLI (`--android.device-id`) and `--help` output share the same spelling.
|
|
95
|
+
* `readNamespacedArg` understands all three input shapes:
|
|
96
96
|
* nested namespace object, dotted flat key, and bare key fallback.
|
|
97
97
|
*/
|
|
98
98
|
export function createNamespacedInitArgSchema(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Unified, declarative mechanism for "force a default option on every tool
|
|
3
|
-
* call" behaviors exposed by
|
|
3
|
+
* call" behaviors exposed by device and Agent Skill CLIs.
|
|
4
4
|
*
|
|
5
5
|
* Adding a new behavior flag (e.g. `--deep-search`) is a one-line change to
|
|
6
6
|
* {@link TOOL_BEHAVIOR_FLAGS}: declare which default-option "bag" it fills.
|
|
7
|
-
* The tool generator,
|
|
7
|
+
* The tool generator, tools managers and CLI parsing are all generic
|
|
8
8
|
* over {@link ToolDefaults} and never need to learn about individual flags.
|
|
9
9
|
*
|
|
10
10
|
* See https://github.com/web-infra-dev/midscene/issues/2446.
|
|
@@ -91,13 +91,12 @@ export function resolveToolDefaults(
|
|
|
91
91
|
*
|
|
92
92
|
* Behavior flags (e.g. `--deep-locate`) are global: they may appear anywhere
|
|
93
93
|
* in argv and are not tied to a specific sub-command. They are recognized by
|
|
94
|
-
* exact kebab-case match
|
|
95
|
-
* — and removed so a strict per-command parser never sees them. Every other
|
|
94
|
+
* exact kebab-case match and removed so a strict per-command parser never sees them. Every other
|
|
96
95
|
* token is returned untouched and in order for that per-command parser.
|
|
97
96
|
*
|
|
98
97
|
* This is the single place that knows how a behavior flag looks on the command
|
|
99
|
-
* line;
|
|
100
|
-
*
|
|
98
|
+
* line; the device / Agent Skill CLI resolves defaults from
|
|
99
|
+
* {@link TOOL_BEHAVIOR_FLAGS} through here / {@link resolveToolDefaults}.
|
|
101
100
|
*/
|
|
102
101
|
export function stripBehaviorFlags(argv: readonly string[]): {
|
|
103
102
|
rawArgs: string[];
|
|
@@ -21,10 +21,10 @@ import { composeUserPrompt, promptInputExtraSchema } from './user-prompt';
|
|
|
21
21
|
export { composeUserPrompt };
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* Generate
|
|
24
|
+
* Generate tool description from ActionSpaceItem.
|
|
25
25
|
* Format: "actionName action, description. Parameters: param1 (type) - desc; param2 (type) - desc"
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function describeActionForTool(action: ActionSpaceItem): string {
|
|
28
28
|
const actionDesc = action.description || `Execute ${action.name} action`;
|
|
29
29
|
|
|
30
30
|
if (!action.paramSchema) {
|
|
@@ -166,7 +166,7 @@ function transformSchemaField(
|
|
|
166
166
|
/**
|
|
167
167
|
* Extract and transform schema from action's paramSchema.
|
|
168
168
|
*
|
|
169
|
-
* CLI
|
|
169
|
+
* CLI tools expose parameters as named fields, so the only schema
|
|
170
170
|
* shapes we can surface are ZodObject (any number of fields) or undefined
|
|
171
171
|
* (the action takes no parameters). A primitive schema like `z.string()`
|
|
172
172
|
* silently degraded to leaking the ZodString instance's prototype methods
|
|
@@ -188,7 +188,7 @@ function extractActionSchema(
|
|
|
188
188
|
(paramSchema as unknown as { _def?: { typeName?: string } })?._def
|
|
189
189
|
?.typeName ?? 'unknown';
|
|
190
190
|
throw new Error(
|
|
191
|
-
`Action "${actionName}" declared a non-object paramSchema (${typeName}). CLI
|
|
191
|
+
`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.`,
|
|
192
192
|
);
|
|
193
193
|
}
|
|
194
194
|
|
|
@@ -543,7 +543,7 @@ function mergeToolCliMetadata(
|
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
/**
|
|
546
|
-
* Converts DeviceAction from actionSpace into
|
|
546
|
+
* Converts DeviceAction from actionSpace into ToolDefinition.
|
|
547
547
|
* This is the core logic that removes need for hardcoded tool definitions
|
|
548
548
|
*/
|
|
549
549
|
export function generateToolsFromActionSpace(
|
|
@@ -564,7 +564,7 @@ export function generateToolsFromActionSpace(
|
|
|
564
564
|
|
|
565
565
|
return {
|
|
566
566
|
name: action.name,
|
|
567
|
-
description:
|
|
567
|
+
description: describeActionForTool(action),
|
|
568
568
|
schema,
|
|
569
569
|
cli: initArgCliMetadata,
|
|
570
570
|
handler: async (args: Record<string, unknown>) => {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { z } from 'zod';
|
|
3
2
|
import type { ToolDefaults } from './tool-defaults';
|
|
4
3
|
|
|
@@ -12,7 +11,7 @@ export const defaultAppLoadingTimeoutMs = 10000;
|
|
|
12
11
|
export const defaultAppLoadingCheckIntervalMs = 2000;
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
|
-
* Content item types for tool results
|
|
14
|
+
* Content item types for tool results.
|
|
16
15
|
*/
|
|
17
16
|
export type ToolResultContent =
|
|
18
17
|
| { type: 'text'; text: string }
|
|
@@ -26,7 +25,7 @@ export type ToolResultContent =
|
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
|
-
* Result type for tool execution
|
|
28
|
+
* Result type for tool execution.
|
|
30
29
|
*/
|
|
31
30
|
export interface ToolResult {
|
|
32
31
|
[x: string]: unknown;
|
|
@@ -58,7 +57,7 @@ export interface ToolCliMetadata {
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
/**
|
|
61
|
-
* Tool definition for
|
|
60
|
+
* Tool definition for Midscene CLI and Skill surfaces.
|
|
62
61
|
*/
|
|
63
62
|
export interface ToolDefinition<T = Record<string, unknown>> {
|
|
64
63
|
name: string;
|
|
@@ -68,9 +67,6 @@ export interface ToolDefinition<T = Record<string, unknown>> {
|
|
|
68
67
|
cli?: ToolCliMetadata;
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
/**
|
|
72
|
-
* Tool type for mcpKitForAgent return value
|
|
73
|
-
*/
|
|
74
70
|
export type Tool = ToolDefinition;
|
|
75
71
|
|
|
76
72
|
/**
|
|
@@ -160,10 +156,9 @@ export interface BaseDevice {
|
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
/**
|
|
163
|
-
* Interface for platform-specific
|
|
159
|
+
* Interface for platform-specific tools manager.
|
|
164
160
|
*/
|
|
165
161
|
export interface IMidsceneTools {
|
|
166
|
-
attachToServer(server: McpServer): void;
|
|
167
162
|
initTools(): Promise<void>;
|
|
168
163
|
destroy?(): Promise<void>;
|
|
169
164
|
setToolDefaults?(toolDefaults: ToolDefaults): void;
|
package/src/cli/cli-args.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import type { ToolCliOption, ToolDefinition } from '../agent-tools/types';
|
|
2
3
|
import { getKeyAliases } from '../key-alias-utils';
|
|
3
|
-
import type { ToolCliOption, ToolDefinition } from '../mcp/types';
|
|
4
4
|
import { CLIError } from './cli-error';
|
|
5
5
|
|
|
6
6
|
export function parseValue(raw: string): unknown {
|
package/src/cli/cli-runner.ts
CHANGED
|
@@ -2,14 +2,14 @@ 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 {
|
|
6
|
-
import
|
|
7
|
-
import { stripBehaviorFlags } from '../mcp/tool-defaults';
|
|
5
|
+
import type { BaseMidsceneTools } from '../agent-tools/base-tools';
|
|
6
|
+
import { stripBehaviorFlags } from '../agent-tools/tool-defaults';
|
|
8
7
|
import type {
|
|
9
8
|
ToolDefinition,
|
|
10
9
|
ToolResult,
|
|
11
10
|
ToolResultContent,
|
|
12
|
-
} from '../
|
|
11
|
+
} from '../agent-tools/types';
|
|
12
|
+
import { getDebug } from '../logger';
|
|
13
13
|
import {
|
|
14
14
|
canonicalizeCliArgKeys,
|
|
15
15
|
formatCliValidationError,
|
package/src/env/types.ts
CHANGED
|
@@ -8,10 +8,11 @@ export const MIDSCENE_DEBUG_MODEL_RESPONSE = 'MIDSCENE_DEBUG_MODEL_RESPONSE';
|
|
|
8
8
|
export const MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG =
|
|
9
9
|
'MIDSCENE_DANGEROUSLY_PRINT_ALL_CONFIG';
|
|
10
10
|
export const MIDSCENE_DEBUG_MODE = 'MIDSCENE_DEBUG_MODE';
|
|
11
|
-
export const
|
|
12
|
-
|
|
11
|
+
export const MIDSCENE_CHROME_PATH = 'MIDSCENE_CHROME_PATH';
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use MIDSCENE_CHROME_PATH instead. This is kept for backward compatibility.
|
|
14
|
+
*/
|
|
13
15
|
export const MIDSCENE_MCP_CHROME_PATH = 'MIDSCENE_MCP_CHROME_PATH';
|
|
14
|
-
export const MIDSCENE_MCP_ANDROID_MODE = 'MIDSCENE_MCP_ANDROID_MODE';
|
|
15
16
|
export const DOCKER_CONTAINER = 'DOCKER_CONTAINER';
|
|
16
17
|
|
|
17
18
|
// Observability
|
|
@@ -166,8 +167,6 @@ export const BASIC_ENV_KEYS = [
|
|
|
166
167
|
|
|
167
168
|
export const BOOLEAN_ENV_KEYS = [
|
|
168
169
|
MIDSCENE_CACHE,
|
|
169
|
-
MIDSCENE_MCP_USE_PUPPETEER_MODE,
|
|
170
|
-
MIDSCENE_MCP_ANDROID_MODE,
|
|
171
170
|
MIDSCENE_LANGSMITH_DEBUG,
|
|
172
171
|
MIDSCENE_LANGFUSE_DEBUG,
|
|
173
172
|
MIDSCENE_REPORT_QUIET,
|
|
@@ -188,6 +187,7 @@ export const STRING_ENV_KEYS = [
|
|
|
188
187
|
MIDSCENE_REPORT_TAG_NAME,
|
|
189
188
|
MIDSCENE_PREFERRED_LANGUAGE,
|
|
190
189
|
MATCH_BY_POSITION,
|
|
190
|
+
MIDSCENE_CHROME_PATH,
|
|
191
191
|
MIDSCENE_MCP_CHROME_PATH,
|
|
192
192
|
DOCKER_CONTAINER,
|
|
193
193
|
] as const;
|
package/src/key-alias-utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal-only helpers for CLI
|
|
2
|
+
* Internal-only helpers for CLI argument key aliasing.
|
|
3
3
|
* Not re-exported from the package entry point — keep consumers within
|
|
4
|
-
* `cli
|
|
4
|
+
* `cli/`.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export function kebabToCamel(str: string): string {
|