@midscene/cli 1.0.1-beta-20251202152706.0 → 1.0.1-beta-20251203125942.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/index.mjs CHANGED
@@ -3024,7 +3024,7 @@ var __webpack_modules__ = {
3024
3024
  "./src/index.ts": function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
3025
3025
  var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
3026
3026
  var main_default = /*#__PURE__*/ __webpack_require__.n(main);
3027
- var package_namespaceObject = JSON.parse('{"rE":"1.0.1-beta-20251202152706.0"}');
3027
+ var package_namespaceObject = JSON.parse('{"rE":"1.0.1-beta-20251203125942.0"}');
3028
3028
  class Node {
3029
3029
  value;
3030
3030
  next;
@@ -3151,6 +3151,16 @@ var __webpack_modules__ = {
3151
3151
  resolve(server);
3152
3152
  });
3153
3153
  });
3154
+ function resolveTestId(cliTestId, yamlTestId, fileName) {
3155
+ return cliTestId ?? yamlTestId ?? fileName;
3156
+ }
3157
+ function buildAgentOptions(yamlAgent, preferenceTestId, fileName) {
3158
+ return {
3159
+ ...yamlAgent || {},
3160
+ cache: processCacheConfig(yamlAgent?.cache, fileName),
3161
+ testId: preferenceTestId
3162
+ };
3163
+ }
3154
3164
  async function createYamlPlayer(file, script, options) {
3155
3165
  const yamlScript = script || parseYamlScript((0, __rspack_external_node_fs_5ea92f0c.readFileSync)(file, 'utf-8'), file);
3156
3166
  const clonedYamlScript = structuredClone(yamlScript);
@@ -3158,7 +3168,7 @@ var __webpack_modules__ = {
3158
3168
  const preference = {
3159
3169
  headed: options?.headed,
3160
3170
  keepWindow: options?.keepWindow,
3161
- testId: fileName
3171
+ testId: resolveTestId(options?.testId, clonedYamlScript.agent?.testId, fileName)
3162
3172
  };
3163
3173
  const player = new ScriptPlayer(clonedYamlScript, async ()=>{
3164
3174
  const freeFn = [];
@@ -3196,7 +3206,7 @@ var __webpack_modules__ = {
3196
3206
  if (!webTarget.bridgeMode) {
3197
3207
  const { agent, freeFn: newFreeFn } = await puppeteerAgentForTarget(webTarget, {
3198
3208
  ...preference,
3199
- cache: processCacheConfig(clonedYamlScript.agent?.cache, fileName)
3209
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3200
3210
  }, options?.browser);
3201
3211
  freeFn.push(...newFreeFn);
3202
3212
  return {
@@ -3205,11 +3215,10 @@ var __webpack_modules__ = {
3205
3215
  };
3206
3216
  }
3207
3217
  node_assert('newTabWithUrl' === webTarget.bridgeMode || 'currentTab' === webTarget.bridgeMode, `bridgeMode config value must be either "newTabWithUrl" or "currentTab", but got ${webTarget.bridgeMode}`);
3208
- if (webTarget.userAgent || webTarget.viewportWidth || webTarget.viewportHeight || webTarget.viewportScale || webTarget.waitForNetworkIdle || webTarget.cookie) console.warn('puppeteer options (userAgent, viewportWidth, viewportHeight, viewportScale, waitForNetworkIdle, cookie) are not supported in bridge mode. They will be ignored.');
3218
+ if (webTarget.userAgent || webTarget.viewportWidth || webTarget.viewportHeight || webTarget.viewportScale || webTarget.waitForNetworkIdle || webTarget.cookie || webTarget.chromeArgs) console.warn('puppeteer options (userAgent, viewportWidth, viewportHeight, viewportScale, waitForNetworkIdle, cookie, chromeArgs) are not supported in bridge mode. They will be ignored.');
3209
3219
  const agent = new AgentOverChromeBridge({
3210
3220
  closeNewTabsAfterDisconnect: webTarget.closeNewTabsAfterDisconnect,
3211
- cache: processCacheConfig(clonedYamlScript.agent?.cache, fileName),
3212
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3221
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3213
3222
  });
3214
3223
  if ('newTabWithUrl' === webTarget.bridgeMode) await agent.connectNewTabWithUrl(webTarget.url);
3215
3224
  else {
@@ -3229,8 +3238,7 @@ var __webpack_modules__ = {
3229
3238
  const androidTarget = clonedYamlScript.android;
3230
3239
  const agent = await agentFromAdbDevice(androidTarget?.deviceId, {
3231
3240
  ...androidTarget,
3232
- cache: processCacheConfig(clonedYamlScript.agent?.cache, fileName),
3233
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3241
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3234
3242
  });
3235
3243
  if (androidTarget?.launch) await agent.launch(androidTarget.launch);
3236
3244
  freeFn.push({
@@ -3246,8 +3254,7 @@ var __webpack_modules__ = {
3246
3254
  const iosTarget = clonedYamlScript.ios;
3247
3255
  const agent = await agentFromWebDriverAgent({
3248
3256
  ...iosTarget,
3249
- cache: processCacheConfig(clonedYamlScript.agent?.cache, fileName),
3250
- aiActionContext: clonedYamlScript.agent?.aiActionContext
3257
+ ...buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName)
3251
3258
  });
3252
3259
  if (iosTarget?.launch) await agent.launch(iosTarget.launch);
3253
3260
  freeFn.push({
@@ -3273,10 +3280,7 @@ var __webpack_modules__ = {
3273
3280
  debug('DeviceClass', DeviceClass, 'with param', interfaceTarget.param);
3274
3281
  const device = new DeviceClass(interfaceTarget.param || {});
3275
3282
  debug('creating agent from device', device);
3276
- const agent = createAgent(device, {
3277
- ...clonedYamlScript.agent,
3278
- cache: processCacheConfig(clonedYamlScript.agent?.cache, fileName)
3279
- });
3283
+ const agent = createAgent(device, buildAgentOptions(clonedYamlScript.agent, preference.testId, fileName));
3280
3284
  freeFn.push({
3281
3285
  name: 'destroy_general_interface_agent',
3282
3286
  fn: ()=>{
@@ -11873,7 +11877,7 @@ Usage:
11873
11877
  type: 'boolean',
11874
11878
  description: `Turn on logging to help debug why certain keys or values are not being set as you expect, default is ${config_factory_defaultConfig.dotenvDebug}`
11875
11879
  }
11876
- }).version('version', 'Show version number', "1.0.1-beta-20251202152706.0").help().epilogue(`For complete list of configuration options, please visit:
11880
+ }).version('version', 'Show version number', "1.0.1-beta-20251203125942.0").help().epilogue(`For complete list of configuration options, please visit:
11877
11881
  • Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
11878
11882
  • Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
11879
11883
  • iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part