@midscene/mcp 1.0.1-beta-20251024063839.0 → 1.0.1-beta-20251027033034.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/api.mdx +54 -2
- package/dist/index.js +214 -449
- package/package.json +5 -5
package/dist/api.mdx
CHANGED
|
@@ -25,6 +25,56 @@ In Playwright and Puppeteer, there are some common parameters:
|
|
|
25
25
|
- `forceSameTabNavigation: boolean`: If true, page navigation is restricted to the current tab. (Default: true)
|
|
26
26
|
- `waitForNavigationTimeout: number`: The timeout for waiting for navigation finished. (Default: 5000ms, set to 0 means not waiting for navigation finished)
|
|
27
27
|
|
|
28
|
+
These Agents also support the following advanced configuration parameters:
|
|
29
|
+
|
|
30
|
+
- `modelConfig: () => IModelConfig`: Optional. Custom model configuration function. Allows you to dynamically configure different models through code instead of environment variables. This is particularly useful when you need to use different models for different AI tasks (such as VQA, planning, grounding, etc.).
|
|
31
|
+
|
|
32
|
+
**Example:**
|
|
33
|
+
```typescript
|
|
34
|
+
const agent = new PuppeteerAgent(page, {
|
|
35
|
+
modelConfig: () => ({
|
|
36
|
+
MIDSCENE_MODEL_NAME: 'qwen3-vl-plus',
|
|
37
|
+
MIDSCENE_MODEL_BASE_URL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
|
38
|
+
MIDSCENE_MODEL_API_KEY: 'sk-...',
|
|
39
|
+
MIDSCENE_LOCATOR_MODE: 'qwen3-vl'
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `createOpenAIClient: (openai, options) => Promise<OpenAI | undefined>`: Optional. Custom OpenAI client wrapper function. Allows you to wrap the OpenAI client instance for integrating observability tools (such as LangSmith, LangFuse) or applying custom middleware.
|
|
45
|
+
|
|
46
|
+
**Parameter Description:**
|
|
47
|
+
- `openai: OpenAI` - The base OpenAI client instance created by Midscene with all necessary configurations (API key, base URL, proxy, etc.)
|
|
48
|
+
- `options: Record<string, unknown>` - OpenAI initialization options, including:
|
|
49
|
+
- `baseURL?: string` - API endpoint URL
|
|
50
|
+
- `apiKey?: string` - API key
|
|
51
|
+
- `dangerouslyAllowBrowser: boolean` - Always true in Midscene
|
|
52
|
+
- Other OpenAI configuration options
|
|
53
|
+
|
|
54
|
+
**Return Value:**
|
|
55
|
+
- Return the wrapped OpenAI client instance, or `undefined` to use the original instance
|
|
56
|
+
|
|
57
|
+
**Example (LangSmith Integration):**
|
|
58
|
+
```typescript
|
|
59
|
+
import { wrapOpenAI } from 'langsmith/wrappers';
|
|
60
|
+
|
|
61
|
+
const agent = new PuppeteerAgent(page, {
|
|
62
|
+
createOpenAIClient: async (openai, options) => {
|
|
63
|
+
// Wrap with LangSmith for planning tasks
|
|
64
|
+
if (options.baseURL?.includes('planning')) {
|
|
65
|
+
return wrapOpenAI(openai, {
|
|
66
|
+
metadata: { task: 'planning' }
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Return the original client for other tasks
|
|
71
|
+
return openai;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Note:** `createOpenAIClient` overrides the behavior of the `MIDSCENE_LANGSMITH_DEBUG` environment variable. If you provide a custom client wrapper function, you need to handle the integration of LangSmith or other observability tools yourself.
|
|
77
|
+
|
|
28
78
|
In Puppeteer, there is also a parameter:
|
|
29
79
|
|
|
30
80
|
- `waitForNetworkIdleTimeout: number`: The timeout for waiting for network idle between each action. (Default: 2000ms, set to 0 means not waiting for network idle)
|
|
@@ -854,9 +904,11 @@ You can override environment variables at runtime by calling the `overrideAIConf
|
|
|
854
904
|
import { overrideAIConfig } from '@midscene/web/puppeteer'; // or another Agent
|
|
855
905
|
|
|
856
906
|
overrideAIConfig({
|
|
857
|
-
OPENAI_BASE_URL: '...',
|
|
858
|
-
OPENAI_API_KEY: '...',
|
|
859
907
|
MIDSCENE_MODEL_NAME: '...',
|
|
908
|
+
MODEL_BASE_URL: '...', // recommended, use new variable name
|
|
909
|
+
MODEL_API_KEY: '...', // recommended, use new variable name
|
|
910
|
+
// OPENAI_BASE_URL: '...', // deprecated but still compatible
|
|
911
|
+
// OPENAI_API_KEY: '...', // deprecated but still compatible
|
|
860
912
|
});
|
|
861
913
|
```
|
|
862
914
|
|