@midscene/ios 1.0.3-beta-20251221011051.0 → 1.0.3-beta-20251223070556.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/bin.mjs CHANGED
@@ -22,12 +22,12 @@ import { findAllMidsceneLocatorField as ai_model_findAllMidsceneLocatorField } f
22
22
  import { buildDetailedLocateParam } from "@midscene/core/yaml";
23
23
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
24
24
  import { fileURLToPath } from "node:url";
25
- import { Agent, paramStr, typeStr } from "@midscene/core/agent";
26
25
  import { getTmpDir, sleep } from "@midscene/core/utils";
27
26
  import { DEFAULT_WDA_PORT, PLAYGROUND_SERVER_PORT as constants_PLAYGROUND_SERVER_PORT } from "@midscene/shared/constants";
28
27
  import { overrideAIConfig } from "@midscene/shared/env";
29
28
  import { uuid as utils_uuid } from "@midscene/shared/utils";
30
29
  import { exec } from "node:child_process";
30
+ import { Agent } from "@midscene/core/agent";
31
31
  import { getDebug } from "@midscene/shared/logger";
32
32
  import node_assert from "node:assert";
33
33
  import { getMidsceneLocationSchema, z } from "@midscene/core";
@@ -11559,12 +11559,9 @@ class PlaygroundServer {
11559
11559
  });
11560
11560
  this._app.get('/task-progress/:requestId', async (req, res)=>{
11561
11561
  const { requestId } = req.params;
11562
- const progressMessages = this.taskProgressMessages[requestId] || [];
11563
- const lastMessage = progressMessages.length > 0 ? progressMessages[progressMessages.length - 1] : void 0;
11564
- const tip = lastMessage && 'string' == typeof lastMessage.action ? `${lastMessage.action} - ${lastMessage.description || ''}` : '';
11562
+ const executionDump = this.taskExecutionDumps[requestId] || null;
11565
11563
  res.json({
11566
- tip,
11567
- progressMessages
11564
+ executionDump
11568
11565
  });
11569
11566
  });
11570
11567
  this._app.post('/action-space', async (req, res)=>{
@@ -11629,22 +11626,9 @@ class PlaygroundServer {
11629
11626
  });
11630
11627
  if (requestId) {
11631
11628
  this.currentTaskId = requestId;
11632
- this.taskProgressMessages[requestId] = [];
11629
+ this.taskExecutionDumps[requestId] = null;
11633
11630
  this.agent.onDumpUpdate = (_dump, executionDump)=>{
11634
- if (executionDump?.tasks) this.taskProgressMessages[requestId] = executionDump.tasks.map((task, index)=>{
11635
- const action = typeStr(task);
11636
- const description = paramStr(task) || '';
11637
- const taskStatus = task.status;
11638
- const status = 'cancelled' === taskStatus ? 'failed' : taskStatus;
11639
- return {
11640
- id: `progress-task-${index}`,
11641
- taskId: `task-${index}`,
11642
- action,
11643
- description,
11644
- status,
11645
- timestamp: task.timing?.start || Date.now()
11646
- };
11647
- });
11631
+ if (executionDump) this.taskExecutionDumps[requestId] = executionDump;
11648
11632
  };
11649
11633
  }
11650
11634
  const response = {
@@ -11672,7 +11656,11 @@ class PlaygroundServer {
11672
11656
  response.error = formatErrorMessage(error);
11673
11657
  }
11674
11658
  try {
11675
- response.dump = JSON.parse(this.agent.dumpDataString());
11659
+ const dumpString = this.agent.dumpDataString();
11660
+ if (dumpString) {
11661
+ const groupedDump = JSON.parse(dumpString);
11662
+ response.dump = groupedDump.executions?.[0] || null;
11663
+ } else response.dump = null;
11676
11664
  response.reportHTML = this.agent.reportHTMLString() || null;
11677
11665
  this.agent.writeOutActionDumps();
11678
11666
  this.agent.resetDump();
@@ -11685,7 +11673,7 @@ class PlaygroundServer {
11685
11673
  if (response.error) console.error(`handle request failed after ${timeCost}ms: requestId: ${requestId}, ${response.error}`);
11686
11674
  else console.log(`handle request done after ${timeCost}ms: requestId: ${requestId}`);
11687
11675
  if (requestId) {
11688
- delete this.taskProgressMessages[requestId];
11676
+ delete this.taskExecutionDumps[requestId];
11689
11677
  if (this.currentTaskId === requestId) this.currentTaskId = null;
11690
11678
  }
11691
11679
  });
@@ -11700,12 +11688,26 @@ class PlaygroundServer {
11700
11688
  message: 'Task not found or already completed'
11701
11689
  });
11702
11690
  console.log(`Cancelling task: ${requestId}`);
11691
+ let dump = null;
11692
+ let reportHTML = null;
11693
+ try {
11694
+ const dumpString = this.agent.dumpDataString?.();
11695
+ if (dumpString) {
11696
+ const groupedDump = JSON.parse(dumpString);
11697
+ dump = groupedDump.executions?.[0] || null;
11698
+ }
11699
+ reportHTML = this.agent.reportHTMLString?.() || null;
11700
+ } catch (error) {
11701
+ console.warn('Failed to get execution data before cancel:', error);
11702
+ }
11703
11703
  await this.recreateAgent();
11704
- delete this.taskProgressMessages[requestId];
11704
+ delete this.taskExecutionDumps[requestId];
11705
11705
  this.currentTaskId = null;
11706
11706
  res.json({
11707
11707
  status: 'cancelled',
11708
- message: 'Task cancelled successfully by recreating agent'
11708
+ message: 'Task cancelled successfully',
11709
+ dump,
11710
+ reportHTML
11709
11711
  });
11710
11712
  } catch (error) {
11711
11713
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
@@ -11826,7 +11828,7 @@ class PlaygroundServer {
11826
11828
  } catch (error) {
11827
11829
  console.warn('Failed to destroy agent:', error);
11828
11830
  }
11829
- this.taskProgressMessages = {};
11831
+ this.taskExecutionDumps = {};
11830
11832
  this.server.close((error)=>{
11831
11833
  if (error) reject(error);
11832
11834
  else {
@@ -11844,7 +11846,7 @@ class PlaygroundServer {
11844
11846
  _define_property(this, "port", void 0);
11845
11847
  _define_property(this, "agent", void 0);
11846
11848
  _define_property(this, "staticPath", void 0);
11847
- _define_property(this, "taskProgressMessages", void 0);
11849
+ _define_property(this, "taskExecutionDumps", void 0);
11848
11850
  _define_property(this, "id", void 0);
11849
11851
  _define_property(this, "_initialized", false);
11850
11852
  _define_property(this, "agentFactory", void 0);
@@ -11852,7 +11854,7 @@ class PlaygroundServer {
11852
11854
  this._app = express();
11853
11855
  this.tmpDir = getTmpDir();
11854
11856
  this.staticPath = staticPath;
11855
- this.taskProgressMessages = {};
11857
+ this.taskExecutionDumps = {};
11856
11858
  this.id = id || utils_uuid();
11857
11859
  if ('function' == typeof agent) {
11858
11860
  this.agentFactory = agent;
package/dist/lib/bin.js CHANGED
@@ -11608,7 +11608,6 @@ var __webpack_exports__ = {};
11608
11608
  }
11609
11609
  const external_node_fs_namespaceObject = require("node:fs");
11610
11610
  const external_node_url_namespaceObject = require("node:url");
11611
- const agent_namespaceObject = require("@midscene/core/agent");
11612
11611
  const utils_namespaceObject = require("@midscene/core/utils");
11613
11612
  const constants_namespaceObject = require("@midscene/shared/constants");
11614
11613
  const env_namespaceObject = require("@midscene/shared/env");
@@ -11703,12 +11702,9 @@ var __webpack_exports__ = {};
11703
11702
  });
11704
11703
  this._app.get('/task-progress/:requestId', async (req, res)=>{
11705
11704
  const { requestId } = req.params;
11706
- const progressMessages = this.taskProgressMessages[requestId] || [];
11707
- const lastMessage = progressMessages.length > 0 ? progressMessages[progressMessages.length - 1] : void 0;
11708
- const tip = lastMessage && 'string' == typeof lastMessage.action ? `${lastMessage.action} - ${lastMessage.description || ''}` : '';
11705
+ const executionDump = this.taskExecutionDumps[requestId] || null;
11709
11706
  res.json({
11710
- tip,
11711
- progressMessages
11707
+ executionDump
11712
11708
  });
11713
11709
  });
11714
11710
  this._app.post('/action-space', async (req, res)=>{
@@ -11773,22 +11769,9 @@ var __webpack_exports__ = {};
11773
11769
  });
11774
11770
  if (requestId) {
11775
11771
  this.currentTaskId = requestId;
11776
- this.taskProgressMessages[requestId] = [];
11772
+ this.taskExecutionDumps[requestId] = null;
11777
11773
  this.agent.onDumpUpdate = (_dump, executionDump)=>{
11778
- if (executionDump?.tasks) this.taskProgressMessages[requestId] = executionDump.tasks.map((task, index)=>{
11779
- const action = (0, agent_namespaceObject.typeStr)(task);
11780
- const description = (0, agent_namespaceObject.paramStr)(task) || '';
11781
- const taskStatus = task.status;
11782
- const status = 'cancelled' === taskStatus ? 'failed' : taskStatus;
11783
- return {
11784
- id: `progress-task-${index}`,
11785
- taskId: `task-${index}`,
11786
- action,
11787
- description,
11788
- status,
11789
- timestamp: task.timing?.start || Date.now()
11790
- };
11791
- });
11774
+ if (executionDump) this.taskExecutionDumps[requestId] = executionDump;
11792
11775
  };
11793
11776
  }
11794
11777
  const response = {
@@ -11816,7 +11799,11 @@ var __webpack_exports__ = {};
11816
11799
  response.error = formatErrorMessage(error);
11817
11800
  }
11818
11801
  try {
11819
- response.dump = JSON.parse(this.agent.dumpDataString());
11802
+ const dumpString = this.agent.dumpDataString();
11803
+ if (dumpString) {
11804
+ const groupedDump = JSON.parse(dumpString);
11805
+ response.dump = groupedDump.executions?.[0] || null;
11806
+ } else response.dump = null;
11820
11807
  response.reportHTML = this.agent.reportHTMLString() || null;
11821
11808
  this.agent.writeOutActionDumps();
11822
11809
  this.agent.resetDump();
@@ -11829,7 +11816,7 @@ var __webpack_exports__ = {};
11829
11816
  if (response.error) console.error(`handle request failed after ${timeCost}ms: requestId: ${requestId}, ${response.error}`);
11830
11817
  else console.log(`handle request done after ${timeCost}ms: requestId: ${requestId}`);
11831
11818
  if (requestId) {
11832
- delete this.taskProgressMessages[requestId];
11819
+ delete this.taskExecutionDumps[requestId];
11833
11820
  if (this.currentTaskId === requestId) this.currentTaskId = null;
11834
11821
  }
11835
11822
  });
@@ -11844,12 +11831,26 @@ var __webpack_exports__ = {};
11844
11831
  message: 'Task not found or already completed'
11845
11832
  });
11846
11833
  console.log(`Cancelling task: ${requestId}`);
11834
+ let dump = null;
11835
+ let reportHTML = null;
11836
+ try {
11837
+ const dumpString = this.agent.dumpDataString?.();
11838
+ if (dumpString) {
11839
+ const groupedDump = JSON.parse(dumpString);
11840
+ dump = groupedDump.executions?.[0] || null;
11841
+ }
11842
+ reportHTML = this.agent.reportHTMLString?.() || null;
11843
+ } catch (error) {
11844
+ console.warn('Failed to get execution data before cancel:', error);
11845
+ }
11847
11846
  await this.recreateAgent();
11848
- delete this.taskProgressMessages[requestId];
11847
+ delete this.taskExecutionDumps[requestId];
11849
11848
  this.currentTaskId = null;
11850
11849
  res.json({
11851
11850
  status: 'cancelled',
11852
- message: 'Task cancelled successfully by recreating agent'
11851
+ message: 'Task cancelled successfully',
11852
+ dump,
11853
+ reportHTML
11853
11854
  });
11854
11855
  } catch (error) {
11855
11856
  const errorMessage = error instanceof Error ? error.message : 'Unknown error';
@@ -11970,7 +11971,7 @@ var __webpack_exports__ = {};
11970
11971
  } catch (error) {
11971
11972
  console.warn('Failed to destroy agent:', error);
11972
11973
  }
11973
- this.taskProgressMessages = {};
11974
+ this.taskExecutionDumps = {};
11974
11975
  this.server.close((error)=>{
11975
11976
  if (error) reject(error);
11976
11977
  else {
@@ -11988,7 +11989,7 @@ var __webpack_exports__ = {};
11988
11989
  _define_property(this, "port", void 0);
11989
11990
  _define_property(this, "agent", void 0);
11990
11991
  _define_property(this, "staticPath", void 0);
11991
- _define_property(this, "taskProgressMessages", void 0);
11992
+ _define_property(this, "taskExecutionDumps", void 0);
11992
11993
  _define_property(this, "id", void 0);
11993
11994
  _define_property(this, "_initialized", false);
11994
11995
  _define_property(this, "agentFactory", void 0);
@@ -11996,7 +11997,7 @@ var __webpack_exports__ = {};
11996
11997
  this._app = express();
11997
11998
  this.tmpDir = (0, utils_namespaceObject.getTmpDir)();
11998
11999
  this.staticPath = staticPath;
11999
- this.taskProgressMessages = {};
12000
+ this.taskExecutionDumps = {};
12000
12001
  this.id = id || (0, shared_utils_namespaceObject.uuid)();
12001
12002
  if ('function' == typeof agent) {
12002
12003
  this.agentFactory = agent;
@@ -12009,6 +12010,7 @@ var __webpack_exports__ = {};
12009
12010
  }
12010
12011
  const external_node_child_process_namespaceObject = require("node:child_process");
12011
12012
  __webpack_require__("../../node_modules/.pnpm/cors@2.8.5/node_modules/cors/lib/index.js");
12013
+ const agent_namespaceObject = require("@midscene/core/agent");
12012
12014
  const logger_namespaceObject = require("@midscene/shared/logger");
12013
12015
  const external_node_assert_namespaceObject = require("node:assert");
12014
12016
  var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/ios",
3
- "version": "1.0.3-beta-20251221011051.0",
3
+ "version": "1.0.3-beta-20251223070556.0",
4
4
  "description": "iOS automation library for Midscene",
5
5
  "keywords": [
6
6
  "iOS UI automation",
@@ -38,9 +38,9 @@
38
38
  "dependencies": {
39
39
  "@inquirer/prompts": "^7.8.6",
40
40
  "open": "10.1.0",
41
- "@midscene/core": "1.0.3-beta-20251221011051.0",
42
- "@midscene/shared": "1.0.3-beta-20251221011051.0",
43
- "@midscene/webdriver": "1.0.3-beta-20251221011051.0"
41
+ "@midscene/core": "1.0.3-beta-20251223070556.0",
42
+ "@midscene/shared": "1.0.3-beta-20251223070556.0",
43
+ "@midscene/webdriver": "1.0.3-beta-20251223070556.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@rslib/core": "^0.18.3",
@@ -50,7 +50,7 @@
50
50
  "tsx": "^4.19.2",
51
51
  "vitest": "3.0.5",
52
52
  "zod": "3.24.3",
53
- "@midscene/playground": "1.0.3-beta-20251221011051.0"
53
+ "@midscene/playground": "1.0.3-beta-20251223070556.0"
54
54
  },
55
55
  "license": "MIT",
56
56
  "scripts": {
package/static/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/430.53da0b9c.js"></script><script defer src="/static/js/index.6d26bf76.js"></script><link href="/static/css/index.f2964c15.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.7b1abe58.js"></script><script defer src="/static/js/430.53da0b9c.js"></script><script defer src="/static/js/index.bd1efdb8.js"></script><link href="/static/css/index.f2964c15.css" rel="stylesheet"></head><body><div id="root"></div></body></html>