@midscene/core 1.12.10-beta-20260920031616.0 → 1.13.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/agent.mjs +103 -6
- package/dist/es/agent/agent.mjs.map +1 -1
- package/dist/es/agent/index.mjs +4 -3
- package/dist/es/agent/tasks.mjs +2 -2
- package/dist/es/agent/tasks.mjs.map +1 -1
- package/dist/es/agent/test-runner-nodes.mjs +291 -40
- package/dist/es/agent/test-runner-nodes.mjs.map +1 -1
- package/dist/es/agent/utils.mjs +1 -1
- package/dist/es/device/index.mjs +15 -2
- package/dist/es/device/index.mjs.map +1 -1
- package/dist/es/dump/html-utils.mjs +37 -4
- package/dist/es/dump/html-utils.mjs.map +1 -1
- package/dist/es/dump/screenshot-store.mjs +8 -1
- package/dist/es/dump/screenshot-store.mjs.map +1 -1
- package/dist/es/report-cli.mjs +9 -4
- package/dist/es/report-cli.mjs.map +1 -1
- package/dist/es/report-generator.mjs +117 -4
- package/dist/es/report-generator.mjs.map +1 -1
- package/dist/es/report-html-template.mjs +1 -1
- package/dist/es/report.mjs +190 -41
- package/dist/es/report.mjs.map +1 -1
- package/dist/es/test-run-report.mjs.map +1 -1
- package/dist/es/test-runner/engine/case-runner.mjs +52 -0
- package/dist/es/test-runner/engine/case-runner.mjs.map +1 -0
- package/dist/es/test-runner/engine/document-runtime.mjs +273 -0
- package/dist/es/test-runner/engine/document-runtime.mjs.map +1 -0
- package/dist/es/test-runner/engine/execute-step.mjs +177 -0
- package/dist/es/test-runner/engine/execute-step.mjs.map +1 -0
- package/dist/es/test-runner/engine/execution-failure.mjs +39 -0
- package/dist/es/test-runner/engine/execution-failure.mjs.map +1 -0
- package/dist/es/test-runner/engine/index.mjs +12 -0
- package/dist/es/test-runner/engine/project-runtime.mjs +142 -0
- package/dist/es/test-runner/engine/project-runtime.mjs.map +1 -0
- package/dist/es/test-runner/engine/registry.mjs +61 -0
- package/dist/es/test-runner/engine/registry.mjs.map +1 -0
- package/dist/es/test-runner/engine/resource-operations.mjs +211 -0
- package/dist/es/test-runner/engine/resource-operations.mjs.map +1 -0
- package/dist/es/test-runner/engine/run-collected-case.mjs +193 -0
- package/dist/es/test-runner/engine/run-collected-case.mjs.map +1 -0
- package/dist/es/test-runner/engine/run-workflow-document.mjs +155 -0
- package/dist/es/test-runner/engine/run-workflow-document.mjs.map +1 -0
- package/dist/es/test-runner/engine/scheduler.mjs +27 -0
- package/dist/es/test-runner/engine/scheduler.mjs.map +1 -0
- package/dist/es/test-runner/engine/scope-teardown.mjs +16 -0
- package/dist/es/test-runner/engine/scope-teardown.mjs.map +1 -0
- package/dist/es/test-runner/engine/types.mjs +0 -0
- package/dist/es/test-runner/errors.mjs +201 -0
- package/dist/es/test-runner/errors.mjs.map +1 -0
- package/dist/es/test-runner/execution-record.mjs +83 -0
- package/dist/es/test-runner/execution-record.mjs.map +1 -0
- package/dist/es/test-runner/index.mjs +12 -0
- package/dist/es/test-runner/node/define-node.mjs +44 -0
- package/dist/es/test-runner/node/define-node.mjs.map +1 -0
- package/dist/es/test-runner/node/index.mjs +2 -0
- package/dist/es/test-runner/node/types.mjs +0 -0
- package/dist/es/test-runner/parser/document-format.mjs +21 -0
- package/dist/es/test-runner/parser/document-format.mjs.map +1 -0
- package/dist/es/test-runner/parser/normalize.mjs +87 -0
- package/dist/es/test-runner/parser/normalize.mjs.map +1 -0
- package/dist/es/test-runner/parser/types.mjs +0 -0
- package/dist/es/test-runner/project.mjs +0 -0
- package/dist/es/test-runner/reporting/agent-report.mjs +23 -0
- package/dist/es/test-runner/reporting/agent-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/execution-record.mjs +73 -0
- package/dist/es/test-runner/reporting/execution-record.mjs.map +1 -0
- package/dist/es/test-runner/reporting/merge-report.mjs +231 -0
- package/dist/es/test-runner/reporting/merge-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/sanitize.mjs +162 -0
- package/dist/es/test-runner/reporting/sanitize.mjs.map +1 -0
- package/dist/es/test-runner/reporting/test-run-report.mjs +327 -0
- package/dist/es/test-runner/reporting/test-run-report.mjs.map +1 -0
- package/dist/es/test-runner/reporting/types.mjs +0 -0
- package/dist/es/utils.mjs +1 -1
- package/dist/es/yaml/execution-context.node.mjs +6 -0
- package/dist/es/yaml/execution-context.node.mjs.map +1 -0
- package/dist/es/yaml/execution-context.stub.mjs +8 -0
- package/dist/es/yaml/execution-context.stub.mjs.map +1 -0
- package/dist/es/yaml/execution-session.mjs +90 -0
- package/dist/es/yaml/execution-session.mjs.map +1 -0
- package/dist/es/yaml/index.mjs +2 -1
- package/dist/es/yaml/legacy-yaml-execution-record.mjs +47 -0
- package/dist/es/yaml/legacy-yaml-execution-record.mjs.map +1 -0
- package/dist/es/yaml/legacy-yaml-report.mjs +52 -0
- package/dist/es/yaml/legacy-yaml-report.mjs.map +1 -0
- package/dist/es/yaml/legacy-yaml-runtime.mjs +119 -0
- package/dist/es/yaml/legacy-yaml-runtime.mjs.map +1 -0
- package/dist/es/yaml/player-state.mjs +15 -0
- package/dist/es/yaml/player-state.mjs.map +1 -0
- package/dist/es/yaml/player.mjs +214 -348
- package/dist/es/yaml/player.mjs.map +1 -1
- package/dist/es/yaml/report-policy.mjs +7 -0
- package/dist/es/yaml/report-policy.mjs.map +1 -0
- package/dist/es/yaml/test-runner-compat.mjs +301 -0
- package/dist/es/yaml/test-runner-compat.mjs.map +1 -0
- package/dist/es/yaml/test-runner-nodes.mjs +147 -0
- package/dist/es/yaml/test-runner-nodes.mjs.map +1 -0
- package/dist/es/yaml/utils.mjs +12 -1
- package/dist/es/yaml/utils.mjs.map +1 -1
- package/dist/es/yaml-runtime.mjs +7 -0
- package/dist/es/yaml.mjs.map +1 -1
- package/dist/lib/agent/agent.js +103 -6
- package/dist/lib/agent/agent.js.map +1 -1
- package/dist/lib/agent/index.js +37 -3
- package/dist/lib/agent/tasks.js +2 -2
- package/dist/lib/agent/tasks.js.map +1 -1
- package/dist/lib/agent/test-runner-nodes.js +329 -45
- package/dist/lib/agent/test-runner-nodes.js.map +1 -1
- package/dist/lib/agent/utils.js +1 -1
- package/dist/lib/device/index.js +15 -2
- package/dist/lib/device/index.js.map +1 -1
- package/dist/lib/dump/html-utils.js +43 -4
- package/dist/lib/dump/html-utils.js.map +1 -1
- package/dist/lib/dump/screenshot-store.js +8 -1
- package/dist/lib/dump/screenshot-store.js.map +1 -1
- package/dist/lib/report-cli.js +8 -3
- package/dist/lib/report-cli.js.map +1 -1
- package/dist/lib/report-generator.js +114 -1
- package/dist/lib/report-generator.js.map +1 -1
- package/dist/lib/report-html-template.js +1 -1
- package/dist/lib/report.js +187 -38
- package/dist/lib/report.js.map +1 -1
- package/dist/lib/test-run-report.js.map +1 -1
- package/dist/lib/test-runner/engine/case-runner.js +89 -0
- package/dist/lib/test-runner/engine/case-runner.js.map +1 -0
- package/dist/lib/test-runner/engine/document-runtime.js +307 -0
- package/dist/lib/test-runner/engine/document-runtime.js.map +1 -0
- package/dist/lib/test-runner/engine/execute-step.js +211 -0
- package/dist/lib/test-runner/engine/execute-step.js.map +1 -0
- package/dist/lib/test-runner/engine/execution-failure.js +79 -0
- package/dist/lib/test-runner/engine/execution-failure.js.map +1 -0
- package/dist/lib/test-runner/engine/index.js +137 -0
- package/dist/lib/test-runner/engine/index.js.map +1 -0
- package/dist/lib/test-runner/engine/project-runtime.js +176 -0
- package/dist/lib/test-runner/engine/project-runtime.js.map +1 -0
- package/dist/lib/test-runner/engine/registry.js +95 -0
- package/dist/lib/test-runner/engine/registry.js.map +1 -0
- package/dist/lib/test-runner/engine/resource-operations.js +272 -0
- package/dist/lib/test-runner/engine/resource-operations.js.map +1 -0
- package/dist/lib/test-runner/engine/run-collected-case.js +227 -0
- package/dist/lib/test-runner/engine/run-collected-case.js.map +1 -0
- package/dist/lib/test-runner/engine/run-workflow-document.js +189 -0
- package/dist/lib/test-runner/engine/run-workflow-document.js.map +1 -0
- package/dist/lib/test-runner/engine/scheduler.js +64 -0
- package/dist/lib/test-runner/engine/scheduler.js.map +1 -0
- package/dist/lib/test-runner/engine/scope-teardown.js +50 -0
- package/dist/lib/test-runner/engine/scope-teardown.js.map +1 -0
- package/dist/lib/test-runner/engine/types.js +20 -0
- package/dist/lib/test-runner/engine/types.js.map +1 -0
- package/dist/lib/test-runner/errors.js +283 -0
- package/dist/lib/test-runner/errors.js.map +1 -0
- package/dist/lib/test-runner/execution-record.js +123 -0
- package/dist/lib/test-runner/execution-record.js.map +1 -0
- package/dist/lib/test-runner/index.js +137 -0
- package/dist/lib/test-runner/index.js.map +1 -0
- package/dist/lib/test-runner/node/define-node.js +78 -0
- package/dist/lib/test-runner/node/define-node.js.map +1 -0
- package/dist/lib/test-runner/node/index.js +67 -0
- package/dist/lib/test-runner/node/index.js.map +1 -0
- package/dist/lib/test-runner/node/types.js +20 -0
- package/dist/lib/test-runner/node/types.js.map +1 -0
- package/dist/lib/test-runner/parser/document-format.js +58 -0
- package/dist/lib/test-runner/parser/document-format.js.map +1 -0
- package/dist/lib/test-runner/parser/normalize.js +124 -0
- package/dist/lib/test-runner/parser/normalize.js.map +1 -0
- package/dist/lib/test-runner/parser/types.js +20 -0
- package/dist/lib/test-runner/parser/types.js.map +1 -0
- package/dist/lib/test-runner/project.js +20 -0
- package/dist/lib/test-runner/project.js.map +1 -0
- package/dist/lib/test-runner/reporting/agent-report.js +57 -0
- package/dist/lib/test-runner/reporting/agent-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/execution-record.js +107 -0
- package/dist/lib/test-runner/reporting/execution-record.js.map +1 -0
- package/dist/lib/test-runner/reporting/merge-report.js +265 -0
- package/dist/lib/test-runner/reporting/merge-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/sanitize.js +202 -0
- package/dist/lib/test-runner/reporting/sanitize.js.map +1 -0
- package/dist/lib/test-runner/reporting/test-run-report.js +364 -0
- package/dist/lib/test-runner/reporting/test-run-report.js.map +1 -0
- package/dist/lib/test-runner/reporting/types.js +20 -0
- package/dist/lib/test-runner/reporting/types.js.map +1 -0
- package/dist/lib/utils.js +1 -1
- package/dist/lib/yaml/execution-context.node.js +43 -0
- package/dist/lib/yaml/execution-context.node.js.map +1 -0
- package/dist/lib/yaml/execution-context.stub.js +45 -0
- package/dist/lib/yaml/execution-context.stub.js.map +1 -0
- package/dist/lib/yaml/execution-session.js +136 -0
- package/dist/lib/yaml/execution-session.js.map +1 -0
- package/dist/lib/yaml/index.js +49 -7
- package/dist/lib/yaml/legacy-yaml-execution-record.js +81 -0
- package/dist/lib/yaml/legacy-yaml-execution-record.js.map +1 -0
- package/dist/lib/yaml/legacy-yaml-report.js +86 -0
- package/dist/lib/yaml/legacy-yaml-report.js.map +1 -0
- package/dist/lib/yaml/legacy-yaml-runtime.js +156 -0
- package/dist/lib/yaml/legacy-yaml-runtime.js.map +1 -0
- package/dist/lib/yaml/player-state.js +52 -0
- package/dist/lib/yaml/player-state.js.map +1 -0
- package/dist/lib/yaml/player.js +213 -347
- package/dist/lib/yaml/player.js.map +1 -1
- package/dist/lib/yaml/report-policy.js +41 -0
- package/dist/lib/yaml/report-policy.js.map +1 -0
- package/dist/lib/yaml/test-runner-compat.js +344 -0
- package/dist/lib/yaml/test-runner-compat.js.map +1 -0
- package/dist/lib/yaml/test-runner-nodes.js +184 -0
- package/dist/lib/yaml/test-runner-nodes.js.map +1 -0
- package/dist/lib/yaml/utils.js +18 -1
- package/dist/lib/yaml/utils.js.map +1 -1
- package/dist/lib/yaml-runtime.js +67 -0
- package/dist/lib/yaml-runtime.js.map +1 -0
- package/dist/lib/yaml.js.map +1 -1
- package/dist/types/agent/agent.d.ts +14 -1
- package/dist/types/agent/agent.d.ts.map +1 -1
- package/dist/types/agent/index.d.ts +4 -3
- package/dist/types/agent/index.d.ts.map +1 -1
- package/dist/types/agent/tasks.d.ts +1 -1
- package/dist/types/agent/tasks.d.ts.map +1 -1
- package/dist/types/agent/test-runner-nodes.d.ts +226 -0
- package/dist/types/agent/test-runner-nodes.d.ts.map +1 -1
- package/dist/types/device/index.d.ts +1 -1
- package/dist/types/device/index.d.ts.map +1 -1
- package/dist/types/dump/html-utils.d.ts +4 -0
- package/dist/types/dump/html-utils.d.ts.map +1 -1
- package/dist/types/dump/screenshot-store.d.ts +2 -1
- package/dist/types/dump/screenshot-store.d.ts.map +1 -1
- package/dist/types/report-cli.d.ts.map +1 -1
- package/dist/types/report-generator.d.ts +10 -0
- package/dist/types/report-generator.d.ts.map +1 -1
- package/dist/types/report.d.ts +3 -1
- package/dist/types/report.d.ts.map +1 -1
- package/dist/types/test-run-report.d.ts +18 -2
- package/dist/types/test-run-report.d.ts.map +1 -1
- package/dist/types/test-runner/engine/case-runner.d.ts +13 -0
- package/dist/types/test-runner/engine/case-runner.d.ts.map +1 -0
- package/dist/types/test-runner/engine/document-runtime.d.ts +4 -0
- package/dist/types/test-runner/engine/document-runtime.d.ts.map +1 -0
- package/dist/types/test-runner/engine/execute-step.d.ts +17 -0
- package/dist/types/test-runner/engine/execute-step.d.ts.map +1 -0
- package/dist/types/test-runner/engine/execution-failure.d.ts +13 -0
- package/dist/types/test-runner/engine/execution-failure.d.ts.map +1 -0
- package/dist/types/test-runner/engine/index.d.ts +13 -0
- package/dist/types/test-runner/engine/index.d.ts.map +1 -0
- package/dist/types/test-runner/engine/project-runtime.d.ts +3 -0
- package/dist/types/test-runner/engine/project-runtime.d.ts.map +1 -0
- package/dist/types/test-runner/engine/registry.d.ts +12 -0
- package/dist/types/test-runner/engine/registry.d.ts.map +1 -0
- package/dist/types/test-runner/engine/resource-operations.d.ts +32 -0
- package/dist/types/test-runner/engine/resource-operations.d.ts.map +1 -0
- package/dist/types/test-runner/engine/run-collected-case.d.ts +4 -0
- package/dist/types/test-runner/engine/run-collected-case.d.ts.map +1 -0
- package/dist/types/test-runner/engine/run-workflow-document.d.ts +4 -0
- package/dist/types/test-runner/engine/run-workflow-document.d.ts.map +1 -0
- package/dist/types/test-runner/engine/scheduler.d.ts +12 -0
- package/dist/types/test-runner/engine/scheduler.d.ts.map +1 -0
- package/dist/types/test-runner/engine/scope-teardown.d.ts +3 -0
- package/dist/types/test-runner/engine/scope-teardown.d.ts.map +1 -0
- package/dist/types/test-runner/engine/types.d.ts +226 -0
- package/dist/types/test-runner/engine/types.d.ts.map +1 -0
- package/dist/types/test-runner/errors.d.ts +79 -0
- package/dist/types/test-runner/errors.d.ts.map +1 -0
- package/dist/types/test-runner/execution-record.d.ts +43 -0
- package/dist/types/test-runner/execution-record.d.ts.map +1 -0
- package/dist/types/test-runner/index.d.ts +20 -0
- package/dist/types/test-runner/index.d.ts.map +1 -0
- package/dist/types/test-runner/node/define-node.d.ts +4 -0
- package/dist/types/test-runner/node/define-node.d.ts.map +1 -0
- package/dist/types/test-runner/node/index.d.ts +3 -0
- package/dist/types/test-runner/node/index.d.ts.map +1 -0
- package/dist/types/test-runner/node/types.d.ts +66 -0
- package/dist/types/test-runner/node/types.d.ts.map +1 -0
- package/dist/types/test-runner/parser/document-format.d.ts +8 -0
- package/dist/types/test-runner/parser/document-format.d.ts.map +1 -0
- package/dist/types/test-runner/parser/normalize.d.ts +9 -0
- package/dist/types/test-runner/parser/normalize.d.ts.map +1 -0
- package/dist/types/test-runner/parser/types.d.ts +69 -0
- package/dist/types/test-runner/parser/types.d.ts.map +1 -0
- package/dist/types/test-runner/project.d.ts +75 -0
- package/dist/types/test-runner/project.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/agent-report.d.ts +9 -0
- package/dist/types/test-runner/reporting/agent-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/execution-record.d.ts +9 -0
- package/dist/types/test-runner/reporting/execution-record.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/merge-report.d.ts +15 -0
- package/dist/types/test-runner/reporting/merge-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/sanitize.d.ts +6 -0
- package/dist/types/test-runner/reporting/sanitize.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/test-run-report.d.ts +5 -0
- package/dist/types/test-runner/reporting/test-run-report.d.ts.map +1 -0
- package/dist/types/test-runner/reporting/types.d.ts +34 -0
- package/dist/types/test-runner/reporting/types.d.ts.map +1 -0
- package/dist/types/yaml/execution-context.node.d.ts +4 -0
- package/dist/types/yaml/execution-context.node.d.ts.map +1 -0
- package/dist/types/yaml/execution-context.stub.d.ts +6 -0
- package/dist/types/yaml/execution-context.stub.d.ts.map +1 -0
- package/dist/types/yaml/execution-session.d.ts +17 -0
- package/dist/types/yaml/execution-session.d.ts.map +1 -0
- package/dist/types/yaml/index.d.ts +1 -1
- package/dist/types/yaml/index.d.ts.map +1 -1
- package/dist/types/yaml/legacy-yaml-execution-record.d.ts +24 -0
- package/dist/types/yaml/legacy-yaml-execution-record.d.ts.map +1 -0
- package/dist/types/yaml/legacy-yaml-report.d.ts +19 -0
- package/dist/types/yaml/legacy-yaml-report.d.ts.map +1 -0
- package/dist/types/yaml/legacy-yaml-runtime.d.ts +23 -0
- package/dist/types/yaml/legacy-yaml-runtime.d.ts.map +1 -0
- package/dist/types/yaml/player-state.d.ts +11 -0
- package/dist/types/yaml/player-state.d.ts.map +1 -0
- package/dist/types/yaml/player.d.ts +11 -3
- package/dist/types/yaml/player.d.ts.map +1 -1
- package/dist/types/yaml/report-policy.d.ts +4 -0
- package/dist/types/yaml/report-policy.d.ts.map +1 -0
- package/dist/types/yaml/test-runner-compat.d.ts +17 -0
- package/dist/types/yaml/test-runner-compat.d.ts.map +1 -0
- package/dist/types/yaml/test-runner-nodes.d.ts +6 -0
- package/dist/types/yaml/test-runner-nodes.d.ts.map +1 -0
- package/dist/types/yaml/utils.d.ts +9 -0
- package/dist/types/yaml/utils.d.ts.map +1 -1
- package/dist/types/yaml-runtime.d.ts +13 -0
- package/dist/types/yaml-runtime.d.ts.map +1 -0
- package/dist/types/yaml.d.ts +25 -7
- package/dist/types/yaml.d.ts.map +1 -1
- package/package.json +28 -2
package/dist/lib/yaml/player.js
CHANGED
|
@@ -26,14 +26,20 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
ScriptPlayer: ()=>ScriptPlayer
|
|
28
28
|
});
|
|
29
|
-
const
|
|
29
|
+
const promises_namespaceObject = require("node:fs/promises");
|
|
30
30
|
const external_node_path_namespaceObject = require("node:path");
|
|
31
|
-
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
32
|
-
const external_zod_namespaceObject = require("zod");
|
|
33
|
-
const task_status_js_namespaceObject = require("../dump/task-status.js");
|
|
34
31
|
const common_namespaceObject = require("@midscene/shared/common");
|
|
35
32
|
const logger_namespaceObject = require("@midscene/shared/logger");
|
|
33
|
+
const utils_namespaceObject = require("@midscene/shared/utils");
|
|
34
|
+
const execution_failure_js_namespaceObject = require("../test-runner/engine/execution-failure.js");
|
|
35
|
+
const resource_operations_js_namespaceObject = require("../test-runner/engine/resource-operations.js");
|
|
36
36
|
const external_cleanup_js_namespaceObject = require("./cleanup.js");
|
|
37
|
+
const external_execution_session_js_namespaceObject = require("./execution-session.js");
|
|
38
|
+
const external_legacy_yaml_execution_record_js_namespaceObject = require("./legacy-yaml-execution-record.js");
|
|
39
|
+
const external_legacy_yaml_report_js_namespaceObject = require("./legacy-yaml-report.js");
|
|
40
|
+
const external_legacy_yaml_runtime_js_namespaceObject = require("./legacy-yaml-runtime.js");
|
|
41
|
+
const external_player_state_js_namespaceObject = require("./player-state.js");
|
|
42
|
+
const external_test_runner_compat_js_namespaceObject = require("./test-runner-compat.js");
|
|
37
43
|
const external_utils_js_namespaceObject = require("./utils.js");
|
|
38
44
|
function _define_property(obj, key, value) {
|
|
39
45
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -46,57 +52,12 @@ function _define_property(obj, key, value) {
|
|
|
46
52
|
return obj;
|
|
47
53
|
}
|
|
48
54
|
const debug = (0, logger_namespaceObject.getDebug)('yaml-player');
|
|
49
|
-
const aiTaskHandlerMap = {
|
|
50
|
-
aiQuery: 'aiQuery',
|
|
51
|
-
aiNumber: 'aiNumber',
|
|
52
|
-
aiString: 'aiString',
|
|
53
|
-
aiBoolean: 'aiBoolean',
|
|
54
|
-
aiAsk: 'aiAsk',
|
|
55
|
-
aiLocate: 'aiLocate'
|
|
56
|
-
};
|
|
57
|
-
const isStringParamSchema = (schema)=>{
|
|
58
|
-
if (!schema) return false;
|
|
59
|
-
const schemaDef = schema?._def;
|
|
60
|
-
if (!schemaDef?.typeName) return false;
|
|
61
|
-
switch(schemaDef.typeName){
|
|
62
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodString:
|
|
63
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodEnum:
|
|
64
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
65
|
-
return true;
|
|
66
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodLiteral:
|
|
67
|
-
return 'string' == typeof schemaDef.value;
|
|
68
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodOptional:
|
|
69
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodNullable:
|
|
70
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodDefault:
|
|
71
|
-
return isStringParamSchema(schemaDef.innerType);
|
|
72
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodEffects:
|
|
73
|
-
return isStringParamSchema(schemaDef.schema);
|
|
74
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodPipeline:
|
|
75
|
-
return isStringParamSchema(schemaDef.out);
|
|
76
|
-
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodUnion:
|
|
77
|
-
{
|
|
78
|
-
const options = schemaDef.options;
|
|
79
|
-
return Array.isArray(options) ? options.every((option)=>isStringParamSchema(option)) : false;
|
|
80
|
-
}
|
|
81
|
-
default:
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const buildShortcutActionParam = (actionName, interfaceAlias, value)=>{
|
|
86
|
-
if ('Launch' === actionName || 'launch' === interfaceAlias) return {
|
|
87
|
-
uri: value
|
|
88
|
-
};
|
|
89
|
-
if ('Terminate' === actionName || 'terminate' === interfaceAlias) return {
|
|
90
|
-
uri: value
|
|
91
|
-
};
|
|
92
|
-
if ('RunAdbShell' === actionName || 'runAdbShell' === interfaceAlias || 'RunHdcShell' === actionName || 'runHdcShell' === interfaceAlias) return {
|
|
93
|
-
command: value
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
55
|
class ScriptPlayer {
|
|
97
56
|
setResult(key, value) {
|
|
98
57
|
const keyToUse = key || this.unnamedResultIndex++;
|
|
99
|
-
if (this.result[keyToUse])
|
|
58
|
+
if (this.result[keyToUse]) (0, logger_namespaceObject.getDebug)('yaml-player', {
|
|
59
|
+
console: true
|
|
60
|
+
})(`result key ${keyToUse} already exists, will overwrite`);
|
|
100
61
|
this.result[keyToUse] = value;
|
|
101
62
|
return this.flushResult();
|
|
102
63
|
}
|
|
@@ -108,7 +69,7 @@ class ScriptPlayer {
|
|
|
108
69
|
const taskIndexToNotify = 'number' == typeof taskIndex ? taskIndex : this.currentTaskIndex;
|
|
109
70
|
if ('number' != typeof taskIndexToNotify) return;
|
|
110
71
|
const taskStatus = this.taskStatusList[taskIndexToNotify];
|
|
111
|
-
|
|
72
|
+
this.onTaskStatusChange?.(taskStatus);
|
|
112
73
|
}
|
|
113
74
|
async setTaskStatus(index, statusValue, error) {
|
|
114
75
|
this.taskStatusList[index].status = statusValue;
|
|
@@ -118,266 +79,78 @@ class ScriptPlayer {
|
|
|
118
79
|
setTaskIndex(taskIndex) {
|
|
119
80
|
this.currentTaskIndex = taskIndex;
|
|
120
81
|
}
|
|
121
|
-
flushResult() {
|
|
82
|
+
async flushResult() {
|
|
122
83
|
if (this.output) {
|
|
123
84
|
const output = (0, external_node_path_namespaceObject.resolve)(process.cwd(), this.output);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
85
|
+
await this.publish(output, async ()=>{
|
|
86
|
+
const outputDir = (0, external_node_path_namespaceObject.dirname)(output);
|
|
87
|
+
await (0, promises_namespaceObject.mkdir)(outputDir, {
|
|
88
|
+
recursive: true
|
|
89
|
+
});
|
|
90
|
+
await (0, promises_namespaceObject.writeFile)(output, JSON.stringify(this.result || {}, void 0, 2));
|
|
127
91
|
});
|
|
128
|
-
(0, external_node_fs_namespaceObject.writeFileSync)(output, JSON.stringify(this.result || {}, void 0, 2));
|
|
129
92
|
}
|
|
130
93
|
}
|
|
131
|
-
flushUnstableLogContent() {
|
|
94
|
+
async flushUnstableLogContent() {
|
|
132
95
|
if (this.unstableLogContent) {
|
|
133
96
|
const content = this.interfaceAgent?._unstableLogContent();
|
|
134
97
|
const filePath = (0, external_node_path_namespaceObject.resolve)(process.cwd(), this.unstableLogContent);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
98
|
+
await this.publish(filePath, async ()=>{
|
|
99
|
+
const outputDir = (0, external_node_path_namespaceObject.dirname)(filePath);
|
|
100
|
+
await (0, promises_namespaceObject.mkdir)(outputDir, {
|
|
101
|
+
recursive: true
|
|
102
|
+
});
|
|
103
|
+
await (0, promises_namespaceObject.writeFile)(filePath, JSON.stringify(content, null, 2));
|
|
138
104
|
});
|
|
139
|
-
(0, external_node_fs_namespaceObject.writeFileSync)(filePath, JSON.stringify(content, null, 2));
|
|
140
105
|
}
|
|
141
106
|
}
|
|
107
|
+
async publish(path, write) {
|
|
108
|
+
try {
|
|
109
|
+
await write();
|
|
110
|
+
} catch (cause) {
|
|
111
|
+
const error = new execution_failure_js_namespaceObject.WorkflowPublicationError('write-result', path, cause);
|
|
112
|
+
this.publicationErrors.push(error);
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
createRuntime(agent) {
|
|
117
|
+
return (0, external_legacy_yaml_runtime_js_namespaceObject.createLegacyYamlRuntime)({
|
|
118
|
+
agent,
|
|
119
|
+
actionSpace: this.actionSpace,
|
|
120
|
+
sourcePath: this.scriptPath,
|
|
121
|
+
setResult: (key, value)=>this.setResult(key, value)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
142
124
|
async playTask(taskStatus, agent) {
|
|
143
125
|
const { flow } = taskStatus;
|
|
144
126
|
(0, utils_namespaceObject.assert)(flow, 'missing flow in task');
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
await this.playFlowItem(agent, flowItem, flowItemRecord, flowItemIndex);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
this.failedReportExecutionInCurrentStep = this.hasFailedReportExecutionSince(agent, executionCountBeforeStep);
|
|
156
|
-
throw error;
|
|
127
|
+
const statusIndex = this.taskStatusList.indexOf(taskStatus);
|
|
128
|
+
const declaredIndex = taskStatus.index;
|
|
129
|
+
const taskIndex = statusIndex >= 0 ? statusIndex : 'number' == typeof declaredIndex && Number.isInteger(declaredIndex) ? declaredIndex : 0;
|
|
130
|
+
const state = (0, external_player_state_js_namespaceObject.getLegacyYamlPlayerState)(this);
|
|
131
|
+
state.executionResult = await this.createRuntime(agent).runTask(taskStatus, taskIndex, {
|
|
132
|
+
onStepStart: (info)=>{
|
|
133
|
+
if ('case' === info.scope && 'steps' === info.case.phase) taskStatus.currentStep = info.case.stepIndex;
|
|
157
134
|
}
|
|
158
|
-
}
|
|
135
|
+
});
|
|
136
|
+
const outcome = state.executionResult.cases[0];
|
|
137
|
+
if (!outcome || 'not-run' === outcome.status) throw new Error(`Task "${taskStatus.name}" did not run.`);
|
|
138
|
+
if ('failed' === outcome.status) throw (0, external_legacy_yaml_runtime_js_namespaceObject.legacyYamlOutcomeError)(outcome);
|
|
159
139
|
this.reportFile = agent.reportFile;
|
|
160
140
|
await this.flushUnstableLogContent();
|
|
161
141
|
}
|
|
162
|
-
hasFailedReportExecutionSince(agent, executionCountBefore) {
|
|
163
|
-
const executions = (agent.dump?.executions ?? []).slice(executionCountBefore);
|
|
164
|
-
return 'failed' === (0, task_status_js_namespaceObject.deriveCaseStatus)(executions);
|
|
165
|
-
}
|
|
166
|
-
async playFlowItem(agent, flowItem, flowItemRecord, flowItemIndex) {
|
|
167
|
-
if ('Finalize' in flowItemRecord) return;
|
|
168
|
-
debug(`playing step ${flowItemIndex}, flowItem=${JSON.stringify(flowItem)}`);
|
|
169
|
-
const simpleAIKey = Object.keys(aiTaskHandlerMap).find((key)=>Object.prototype.hasOwnProperty.call(flowItemRecord, key));
|
|
170
|
-
if ('aiAct' in flowItem || 'aiAction' in flowItem || 'ai' in flowItem) {
|
|
171
|
-
const actionTask = flowItem;
|
|
172
|
-
const { aiAct, aiAction, ai, instruction, ...actionOptions } = actionTask;
|
|
173
|
-
const actionPrompt = aiAct ?? aiAction ?? ai;
|
|
174
|
-
let promptForAI;
|
|
175
|
-
if ('string' == typeof instruction && instruction) promptForAI = instruction;
|
|
176
|
-
else if (instruction && 'object' == typeof instruction && 'string' == typeof instruction.prompt && instruction.prompt) promptForAI = instruction;
|
|
177
|
-
else if (actionPrompt && 'object' == typeof actionPrompt && 'string' == typeof actionPrompt.prompt && actionPrompt.prompt) promptForAI = actionPrompt;
|
|
178
|
-
else if ('string' == typeof actionPrompt && actionPrompt) promptForAI = actionPrompt;
|
|
179
|
-
(0, utils_namespaceObject.assert)(promptForAI, 'missing prompt for ai (aiAct)');
|
|
180
|
-
await agent.aiAct(promptForAI, actionOptions);
|
|
181
|
-
} else if ('runGherkinScenario' in flowItem) {
|
|
182
|
-
const gherkinScenarioTask = flowItem;
|
|
183
|
-
const { runGherkinScenario } = gherkinScenarioTask;
|
|
184
|
-
(0, utils_namespaceObject.assert)(runGherkinScenario, 'missing scenario for runGherkinScenario');
|
|
185
|
-
await agent.runGherkinScenario(runGherkinScenario, {
|
|
186
|
-
cacheable: false
|
|
187
|
-
});
|
|
188
|
-
} else if ('aiAssert' in flowItem) {
|
|
189
|
-
const assertTask = flowItem;
|
|
190
|
-
const { aiAssert: prompt, errorMessage: msg, name, ...restOpts } = assertTask;
|
|
191
|
-
(0, utils_namespaceObject.assert)(prompt, 'missing prompt for aiAssert');
|
|
192
|
-
(0, utils_namespaceObject.assert)(!Object.prototype.hasOwnProperty.call(assertTask, 'observe'), '`observe` is not supported in YAML aiAssert. Use agent.startObserving() from code instead.');
|
|
193
|
-
const result = await agent.aiAssert(prompt, msg, {
|
|
194
|
-
...restOpts,
|
|
195
|
-
keepRawResponse: true
|
|
196
|
-
});
|
|
197
|
-
const pass = result?.pass;
|
|
198
|
-
const thought = result?.thought;
|
|
199
|
-
const message = result?.message;
|
|
200
|
-
this.setResult(name, {
|
|
201
|
-
pass,
|
|
202
|
-
thought,
|
|
203
|
-
message
|
|
204
|
-
});
|
|
205
|
-
if (!pass) throw new Error(message);
|
|
206
|
-
} else if (simpleAIKey) {
|
|
207
|
-
const { [simpleAIKey]: prompt, name, ...options } = flowItem;
|
|
208
|
-
(0, utils_namespaceObject.assert)(prompt, `missing prompt for ${simpleAIKey}`);
|
|
209
|
-
(0, utils_namespaceObject.assert)(!Object.prototype.hasOwnProperty.call(flowItem, 'observe'), '`observe` is not supported in YAML flow items. Use agent.startObserving() from code instead.');
|
|
210
|
-
const agentMethod = agent[aiTaskHandlerMap[simpleAIKey]];
|
|
211
|
-
(0, utils_namespaceObject.assert)('function' == typeof agentMethod, `missing agent method for ${simpleAIKey}`);
|
|
212
|
-
const aiResult = await agentMethod.call(agent, prompt, options);
|
|
213
|
-
this.setResult(name, aiResult);
|
|
214
|
-
} else if ('aiWaitFor' in flowItem) {
|
|
215
|
-
const waitForTask = flowItem;
|
|
216
|
-
const { aiWaitFor, timeout, ...restWaitForOpts } = waitForTask;
|
|
217
|
-
const prompt = aiWaitFor;
|
|
218
|
-
(0, utils_namespaceObject.assert)(prompt, 'missing prompt for aiWaitFor');
|
|
219
|
-
const waitForOptions = {
|
|
220
|
-
...restWaitForOpts,
|
|
221
|
-
...void 0 !== timeout ? {
|
|
222
|
-
timeout,
|
|
223
|
-
timeoutMs: timeout
|
|
224
|
-
} : {}
|
|
225
|
-
};
|
|
226
|
-
await agent.aiWaitFor(prompt, waitForOptions);
|
|
227
|
-
} else if ('sleep' in flowItem) {
|
|
228
|
-
const sleepTask = flowItem;
|
|
229
|
-
const ms = sleepTask.sleep;
|
|
230
|
-
let msNumber = ms;
|
|
231
|
-
if ('string' == typeof ms) msNumber = Number.parseInt(ms, 10);
|
|
232
|
-
(0, utils_namespaceObject.assert)(Number.isFinite(msNumber) && msNumber > 0, `ms for sleep must be greater than 0, but got ${ms}`);
|
|
233
|
-
await agent.sleep(msNumber);
|
|
234
|
-
} else if ("javascript" in flowItem) {
|
|
235
|
-
const evaluateJavaScriptTask = flowItem;
|
|
236
|
-
const result = await agent.evaluateJavaScript(evaluateJavaScriptTask.javascript);
|
|
237
|
-
this.setResult(evaluateJavaScriptTask.name, result);
|
|
238
|
-
} else if ('logScreenshot' in flowItem || 'recordToReport' in flowItem) {
|
|
239
|
-
const recordTask = flowItem;
|
|
240
|
-
const title = recordTask.recordToReport ?? recordTask.logScreenshot ?? 'untitled';
|
|
241
|
-
const content = recordTask.content || '';
|
|
242
|
-
await agent.recordToReport(title, {
|
|
243
|
-
content
|
|
244
|
-
});
|
|
245
|
-
} else if ('aiInput' in flowItem) {
|
|
246
|
-
const { aiInput, value: rawValue, ...inputTask } = flowItem;
|
|
247
|
-
let locatePrompt;
|
|
248
|
-
let value;
|
|
249
|
-
if (inputTask.locate) {
|
|
250
|
-
value = aiInput || rawValue;
|
|
251
|
-
locatePrompt = inputTask.locate;
|
|
252
|
-
} else {
|
|
253
|
-
locatePrompt = aiInput || '';
|
|
254
|
-
value = rawValue;
|
|
255
|
-
}
|
|
256
|
-
await agent.callActionInActionSpace('Input', {
|
|
257
|
-
...inputTask,
|
|
258
|
-
...void 0 !== value ? {
|
|
259
|
-
value: String(value)
|
|
260
|
-
} : {},
|
|
261
|
-
...locatePrompt ? {
|
|
262
|
-
locate: (0, external_utils_js_namespaceObject.buildDetailedLocateParam)(locatePrompt, inputTask)
|
|
263
|
-
} : {}
|
|
264
|
-
});
|
|
265
|
-
} else if ('aiKeyboardPress' in flowItem) {
|
|
266
|
-
const { aiKeyboardPress, ...keyboardPressTask } = flowItem;
|
|
267
|
-
let locatePrompt;
|
|
268
|
-
let keyName;
|
|
269
|
-
if (keyboardPressTask.locate) {
|
|
270
|
-
keyName = aiKeyboardPress;
|
|
271
|
-
locatePrompt = keyboardPressTask.locate;
|
|
272
|
-
} else if (keyboardPressTask.keyName) {
|
|
273
|
-
keyName = keyboardPressTask.keyName;
|
|
274
|
-
locatePrompt = aiKeyboardPress;
|
|
275
|
-
} else keyName = aiKeyboardPress;
|
|
276
|
-
await agent.callActionInActionSpace('KeyboardPress', {
|
|
277
|
-
...keyboardPressTask,
|
|
278
|
-
...keyName ? {
|
|
279
|
-
keyName
|
|
280
|
-
} : {},
|
|
281
|
-
...locatePrompt ? {
|
|
282
|
-
locate: (0, external_utils_js_namespaceObject.buildDetailedLocateParam)(locatePrompt, keyboardPressTask)
|
|
283
|
-
} : {}
|
|
284
|
-
});
|
|
285
|
-
} else if ('aiScroll' in flowItem) {
|
|
286
|
-
const { aiScroll, ...scrollTask } = flowItem;
|
|
287
|
-
const { locate, ...scrollOptions } = scrollTask;
|
|
288
|
-
const locatePrompt = locate ?? aiScroll ?? void 0;
|
|
289
|
-
await agent.aiScroll(locatePrompt, scrollOptions);
|
|
290
|
-
} else if ('aiTap' in flowItem) {
|
|
291
|
-
const { aiTap, prompt, locate, ...tapOptions } = flowItem;
|
|
292
|
-
let locatePrompt;
|
|
293
|
-
let opts = tapOptions;
|
|
294
|
-
const locateObj = locate ?? ('object' == typeof aiTap && null !== aiTap ? aiTap.locate : void 0);
|
|
295
|
-
if ('string' == typeof aiTap && aiTap) locatePrompt = aiTap;
|
|
296
|
-
else if ('object' == typeof locateObj && locateObj?.prompt) {
|
|
297
|
-
const { prompt: lp, ...locateOpts } = locateObj;
|
|
298
|
-
locatePrompt = lp;
|
|
299
|
-
opts = {
|
|
300
|
-
...locateOpts,
|
|
301
|
-
...tapOptions
|
|
302
|
-
};
|
|
303
|
-
} else locatePrompt = aiTap?.prompt || prompt || locateObj;
|
|
304
|
-
(0, utils_namespaceObject.assert)(locatePrompt, 'missing prompt for aiTap');
|
|
305
|
-
await agent.aiTap(locatePrompt, opts);
|
|
306
|
-
} else {
|
|
307
|
-
const actionSpace = this.actionSpace;
|
|
308
|
-
let locatePromptShortcut;
|
|
309
|
-
let actionParamForMatchedAction;
|
|
310
|
-
const matchedAction = actionSpace.find((action)=>{
|
|
311
|
-
const actionInterfaceAlias = action.interfaceAlias;
|
|
312
|
-
if (actionInterfaceAlias && Object.prototype.hasOwnProperty.call(flowItem, actionInterfaceAlias)) {
|
|
313
|
-
actionParamForMatchedAction = flowItem[actionInterfaceAlias];
|
|
314
|
-
if ('string' == typeof actionParamForMatchedAction) locatePromptShortcut = actionParamForMatchedAction;
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
const keyOfActionInActionSpace = action.name;
|
|
318
|
-
if (Object.prototype.hasOwnProperty.call(flowItem, keyOfActionInActionSpace)) {
|
|
319
|
-
actionParamForMatchedAction = flowItem[keyOfActionInActionSpace];
|
|
320
|
-
if ('string' == typeof actionParamForMatchedAction) locatePromptShortcut = actionParamForMatchedAction;
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
return false;
|
|
324
|
-
});
|
|
325
|
-
(0, utils_namespaceObject.assert)(matchedAction, `unknown flowItem in yaml: ${JSON.stringify(flowItem)}`);
|
|
326
|
-
const schemaIsStringParam = isStringParamSchema(matchedAction.paramSchema);
|
|
327
|
-
let stringParamToCall;
|
|
328
|
-
const resultName = flowItem.name;
|
|
329
|
-
const timeout = flowItem.timeout;
|
|
330
|
-
const hasRunAdbShellAlias = Object.prototype.hasOwnProperty.call(flowItem, 'runAdbShell');
|
|
331
|
-
if (hasRunAdbShellAlias && 'string' == typeof actionParamForMatchedAction && 'number' == typeof timeout && 'function' == typeof agent.runAdbShell) {
|
|
332
|
-
const result = await agent.runAdbShell(actionParamForMatchedAction, {
|
|
333
|
-
timeout
|
|
334
|
-
});
|
|
335
|
-
if (void 0 !== result) this.setResult(resultName, result);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
const specialActionParamToCall = 'string' == typeof actionParamForMatchedAction ? buildShortcutActionParam(matchedAction.name, matchedAction.interfaceAlias, actionParamForMatchedAction) : void 0;
|
|
339
|
-
if (specialActionParamToCall) {
|
|
340
|
-
debug(`matchedAction: ${matchedAction.name}`, `flowParams: ${JSON.stringify(specialActionParamToCall)}`);
|
|
341
|
-
const result = await agent.callActionInActionSpace(matchedAction.name, specialActionParamToCall);
|
|
342
|
-
if (void 0 !== result) this.setResult(resultName, result);
|
|
343
|
-
} else if ('string' == typeof actionParamForMatchedAction && schemaIsStringParam) {
|
|
344
|
-
if (matchedAction.paramSchema) {
|
|
345
|
-
const parseResult = matchedAction.paramSchema.safeParse(actionParamForMatchedAction);
|
|
346
|
-
if (parseResult.success && 'string' == typeof parseResult.data) stringParamToCall = parseResult.data;
|
|
347
|
-
else if (!parseResult.success) {
|
|
348
|
-
debug(`parse failed for action ${matchedAction.name} with string param`, parseResult.error);
|
|
349
|
-
stringParamToCall = actionParamForMatchedAction;
|
|
350
|
-
}
|
|
351
|
-
} else stringParamToCall = actionParamForMatchedAction;
|
|
352
|
-
if (void 0 !== stringParamToCall) {
|
|
353
|
-
debug(`matchedAction: ${matchedAction.name}`, `flowParams: ${JSON.stringify(stringParamToCall)}`);
|
|
354
|
-
const result = await agent.callActionInActionSpace(matchedAction.name, stringParamToCall);
|
|
355
|
-
const resultName = flowItem.name;
|
|
356
|
-
if (void 0 !== result) this.setResult(resultName, result);
|
|
357
|
-
}
|
|
358
|
-
} else {
|
|
359
|
-
const sourceForParams = locatePromptShortcut && 'string' == typeof actionParamForMatchedAction ? {
|
|
360
|
-
...flowItem,
|
|
361
|
-
prompt: locatePromptShortcut
|
|
362
|
-
} : 'object' == typeof actionParamForMatchedAction && null !== actionParamForMatchedAction ? actionParamForMatchedAction : flowItem;
|
|
363
|
-
const { locateParam, restParams } = (0, external_utils_js_namespaceObject.buildDetailedLocateParamAndRestParams)(locatePromptShortcut || '', sourceForParams, [
|
|
364
|
-
matchedAction.name,
|
|
365
|
-
matchedAction.interfaceAlias || '_never_mind_'
|
|
366
|
-
]);
|
|
367
|
-
const flowParams = {
|
|
368
|
-
...restParams,
|
|
369
|
-
locate: locateParam
|
|
370
|
-
};
|
|
371
|
-
debug(`matchedAction: ${matchedAction.name}`, `flowParams: ${JSON.stringify(flowParams, null, 2)}`);
|
|
372
|
-
const result = await agent.callActionInActionSpace(matchedAction.name, flowParams);
|
|
373
|
-
const resultName = flowItem.name;
|
|
374
|
-
if (void 0 !== result) this.setResult(resultName, result);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
142
|
async run() {
|
|
379
|
-
|
|
380
|
-
|
|
143
|
+
return (0, external_execution_session_js_namespaceObject.runInYamlExecutionContext)(()=>this.runInContext());
|
|
144
|
+
}
|
|
145
|
+
async runInContext() {
|
|
146
|
+
const startedAt = new Date();
|
|
147
|
+
const runId = (0, utils_namespaceObject.uuid)();
|
|
148
|
+
const state = (0, external_player_state_js_namespaceObject.getLegacyYamlPlayerState)(this);
|
|
149
|
+
state.executionResult = void 0;
|
|
150
|
+
state.executionRecord = void 0;
|
|
151
|
+
this.publicationErrors = [];
|
|
152
|
+
const { android, ios, harmony, computer } = this.script;
|
|
153
|
+
const webEnv = (0, external_utils_js_namespaceObject.resolveWebTarget)(this.script)?.target;
|
|
381
154
|
const androidEnv = android;
|
|
382
155
|
const iosEnv = ios;
|
|
383
156
|
const harmonyEnv = harmony;
|
|
@@ -386,65 +159,155 @@ class ScriptPlayer {
|
|
|
386
159
|
this.setPlayerStatus('running');
|
|
387
160
|
let agent = null;
|
|
388
161
|
let freeFn = [];
|
|
162
|
+
let setupError;
|
|
163
|
+
let executionError;
|
|
164
|
+
let cleanupError;
|
|
165
|
+
let signal;
|
|
166
|
+
let session;
|
|
389
167
|
try {
|
|
390
168
|
const { agent: newAgent, freeFn: newFreeFn } = await this.setupAgent(platform);
|
|
391
|
-
this.actionSpace = await newAgent.getActionSpace();
|
|
392
169
|
agent = newAgent;
|
|
170
|
+
agent._prepareForTestRunner?.();
|
|
171
|
+
freeFn = [
|
|
172
|
+
...newFreeFn || []
|
|
173
|
+
];
|
|
174
|
+
session = (0, external_execution_session_js_namespaceObject.enterYamlExecution)(agent);
|
|
175
|
+
signal = (0, external_execution_session_js_namespaceObject.currentYamlSignal)(agent);
|
|
176
|
+
signal?.throwIfAborted();
|
|
177
|
+
this.actionSpace = await agent.getActionSpace();
|
|
393
178
|
const originalOnTaskStartTip = agent.onTaskStartTip;
|
|
394
179
|
agent.onTaskStartTip = (tip)=>{
|
|
395
180
|
if ('running' === this.status) this.agentStatusTip = tip;
|
|
396
181
|
originalOnTaskStartTip?.(tip);
|
|
397
182
|
};
|
|
398
|
-
freeFn
|
|
399
|
-
|
|
400
|
-
{
|
|
401
|
-
|
|
402
|
-
fn: ()=>{
|
|
403
|
-
if (agent) agent.onTaskStartTip = originalOnTaskStartTip;
|
|
404
|
-
}
|
|
183
|
+
freeFn.push({
|
|
184
|
+
name: 'restore-agent-onTaskStartTip',
|
|
185
|
+
fn: ()=>{
|
|
186
|
+
if (agent) agent.onTaskStartTip = originalOnTaskStartTip;
|
|
405
187
|
}
|
|
406
|
-
|
|
407
|
-
} catch (
|
|
408
|
-
|
|
409
|
-
|
|
188
|
+
});
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof external_execution_session_js_namespaceObject.YamlExecutionOwnershipError) throw error;
|
|
191
|
+
setupError = error;
|
|
192
|
+
this.setPlayerStatus('error', error);
|
|
410
193
|
}
|
|
411
194
|
this.interfaceAgent = agent;
|
|
412
|
-
|
|
413
|
-
this.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
195
|
+
const document = (0, external_test_runner_compat_js_namespaceObject.collectLegacyYamlDocument)(this.script, this.scriptPath ?? '<inline-yaml>', this.actionSpace);
|
|
196
|
+
const runtime = agent && !setupError ? this.createRuntime(agent) : void 0;
|
|
197
|
+
try {
|
|
198
|
+
if (runtime && agent) {
|
|
199
|
+
state.executionResult = await runtime.runScript(this.script, {
|
|
200
|
+
document,
|
|
201
|
+
signal,
|
|
202
|
+
createDocumentRunId: ()=>runId,
|
|
203
|
+
onCaseStart: (collectedCase)=>{
|
|
204
|
+
const taskIndex = collectedCase.caseIndex;
|
|
205
|
+
this.setTaskIndex(taskIndex);
|
|
206
|
+
return this.setTaskStatus(taskIndex, 'running');
|
|
207
|
+
},
|
|
208
|
+
onStepStart: (info)=>{
|
|
209
|
+
if ('case' !== info.scope || 'steps' !== info.case.phase) return;
|
|
210
|
+
const taskStatus = this.taskStatusList[info.case.caseIndex];
|
|
211
|
+
if (taskStatus) taskStatus.currentStep = info.case.stepIndex;
|
|
212
|
+
},
|
|
213
|
+
onCaseOutcome: async (outcome)=>{
|
|
214
|
+
if ('not-run' === outcome.status) return;
|
|
215
|
+
const taskIndex = outcome.caseIndex;
|
|
216
|
+
const taskStatus = this.taskStatusList[taskIndex];
|
|
217
|
+
(0, utils_namespaceObject.assert)(taskStatus, `missing YAML task at index ${taskIndex}`);
|
|
218
|
+
this.reportFile = agent?.reportFile;
|
|
219
|
+
if ('success' === outcome.status) {
|
|
220
|
+
await this.setTaskStatus(taskIndex, 'done');
|
|
221
|
+
await this.flushUnstableLogContent();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const error = (0, external_legacy_yaml_runtime_js_namespaceObject.legacyYamlOutcomeError)(outcome);
|
|
225
|
+
await this.setTaskStatus(taskIndex, 'error', error);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
const stoppedOnFailure = state.executionResult.cases.some((outcome)=>'failed' === outcome.status && !this.taskStatusList[outcome.caseIndex]?.continueOnError);
|
|
229
|
+
this.setPlayerStatus(stoppedOnFailure || signal?.aborted ? 'error' : 'done');
|
|
440
230
|
}
|
|
441
|
-
|
|
442
|
-
|
|
231
|
+
} catch (error) {
|
|
232
|
+
executionError = error;
|
|
233
|
+
if (error instanceof execution_failure_js_namespaceObject.WorkflowExecutionFailure) state.executionResult = error.result;
|
|
234
|
+
this.setPlayerStatus('error', error);
|
|
443
235
|
}
|
|
444
|
-
|
|
445
|
-
else this.setPlayerStatus('done');
|
|
236
|
+
this.reportFile = agent?.reportFile;
|
|
446
237
|
this.agentStatusTip = '';
|
|
447
|
-
|
|
238
|
+
try {
|
|
239
|
+
if (session?.isRoot && agent) await (0, resource_operations_js_namespaceObject.cleanupResources)([
|
|
240
|
+
agent
|
|
241
|
+
], ()=>(0, external_cleanup_js_namespaceObject.runFreeFnCleanup)(freeFn), {
|
|
242
|
+
owner: this,
|
|
243
|
+
signal,
|
|
244
|
+
onDeferredError: (error)=>(0, logger_namespaceObject.getDebug)('yaml-player', {
|
|
245
|
+
console: true
|
|
246
|
+
})(`Deferred YAML cleanup failed: ${String(error)}`)
|
|
247
|
+
});
|
|
248
|
+
else await (0, external_cleanup_js_namespaceObject.runFreeFnCleanup)(freeFn);
|
|
249
|
+
} catch (error) {
|
|
250
|
+
cleanupError = error;
|
|
251
|
+
this.setPlayerStatus('error', setupError ?? executionError ?? error);
|
|
252
|
+
}
|
|
253
|
+
const endedAt = new Date();
|
|
254
|
+
const cleanupErrors = cleanupError instanceof AggregateError ? cleanupError.errors : void 0 === cleanupError ? [] : [
|
|
255
|
+
cleanupError
|
|
256
|
+
];
|
|
257
|
+
state.executionRecord = (0, external_legacy_yaml_execution_record_js_namespaceObject.createLegacyYamlExecutionRecord)({
|
|
258
|
+
runId,
|
|
259
|
+
attemptIndex: 0,
|
|
260
|
+
script: this.script,
|
|
261
|
+
document,
|
|
262
|
+
startedAt,
|
|
263
|
+
endedAt,
|
|
264
|
+
execution: state.executionResult,
|
|
265
|
+
setupError,
|
|
266
|
+
executionError,
|
|
267
|
+
cleanupErrors,
|
|
268
|
+
aborted: signal?.aborted ?? false,
|
|
269
|
+
publicationErrors: this.publicationErrors,
|
|
270
|
+
outputs: this.result,
|
|
271
|
+
reportFile: agent?.reportFile,
|
|
272
|
+
children: session?.children
|
|
273
|
+
});
|
|
274
|
+
let reportError;
|
|
275
|
+
if (!session || session.isRoot) try {
|
|
276
|
+
const published = await (0, external_legacy_yaml_report_js_namespaceObject.publishLegacyYamlReport)({
|
|
277
|
+
agent,
|
|
278
|
+
record: state.executionRecord,
|
|
279
|
+
runId,
|
|
280
|
+
script: this.script,
|
|
281
|
+
scriptPath: this.scriptPath,
|
|
282
|
+
fallbackReportFileName: state.fallbackReportFileName
|
|
283
|
+
});
|
|
284
|
+
this.reportFile = published.reportFile;
|
|
285
|
+
state.executionRecord = published.record;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
reportError = error;
|
|
288
|
+
this.setPlayerStatus('error', setupError ?? executionError ?? cleanupError ?? error);
|
|
289
|
+
state.executionRecord = Object.freeze({
|
|
290
|
+
...state.executionRecord,
|
|
291
|
+
status: 'failed',
|
|
292
|
+
reportError: error
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
session?.finish(state.executionRecord);
|
|
296
|
+
if (reportError) {
|
|
297
|
+
const errors = [
|
|
298
|
+
setupError,
|
|
299
|
+
executionError,
|
|
300
|
+
...cleanupErrors,
|
|
301
|
+
reportError
|
|
302
|
+
].filter((error)=>void 0 !== error);
|
|
303
|
+
throw 1 === errors.length ? reportError : new AggregateError(errors, 'YAML execution/report finalization failed');
|
|
304
|
+
}
|
|
305
|
+
if (executionError && cleanupError) throw new AggregateError([
|
|
306
|
+
executionError,
|
|
307
|
+
...cleanupErrors
|
|
308
|
+
], 'YAML execution and cleanup failed');
|
|
309
|
+
if (executionError) throw executionError;
|
|
310
|
+
if (cleanupError) throw cleanupError;
|
|
448
311
|
}
|
|
449
312
|
constructor(script, setupAgent, onTaskStatusChange, scriptPath){
|
|
450
313
|
_define_property(this, "script", void 0);
|
|
@@ -456,6 +319,7 @@ class ScriptPlayer {
|
|
|
456
319
|
_define_property(this, "reportFile", void 0);
|
|
457
320
|
_define_property(this, "result", void 0);
|
|
458
321
|
_define_property(this, "unnamedResultIndex", void 0);
|
|
322
|
+
_define_property(this, "publicationErrors", void 0);
|
|
459
323
|
_define_property(this, "output", void 0);
|
|
460
324
|
_define_property(this, "unstableLogContent", void 0);
|
|
461
325
|
_define_property(this, "errorInSetup", void 0);
|
|
@@ -464,33 +328,35 @@ class ScriptPlayer {
|
|
|
464
328
|
_define_property(this, "target", void 0);
|
|
465
329
|
_define_property(this, "actionSpace", void 0);
|
|
466
330
|
_define_property(this, "scriptPath", void 0);
|
|
467
|
-
_define_property(this, "failedReportExecutionInCurrentStep", void 0);
|
|
468
331
|
this.script = script;
|
|
469
332
|
this.setupAgent = setupAgent;
|
|
470
333
|
this.onTaskStatusChange = onTaskStatusChange;
|
|
471
334
|
this.taskStatusList = [];
|
|
472
335
|
this.status = 'init';
|
|
473
336
|
this.unnamedResultIndex = 0;
|
|
337
|
+
this.publicationErrors = [];
|
|
474
338
|
this.interfaceAgent = null;
|
|
475
339
|
this.actionSpace = [];
|
|
476
|
-
this.failedReportExecutionInCurrentStep = false;
|
|
477
340
|
this.scriptPath = scriptPath;
|
|
341
|
+
(0, external_test_runner_compat_js_namespaceObject.collectLegacyYamlDocument)(script, scriptPath);
|
|
342
|
+
(0, external_player_state_js_namespaceObject.initializeLegacyYamlPlayerState)(this);
|
|
478
343
|
this.result = {};
|
|
479
|
-
this.target = script
|
|
344
|
+
this.target = (0, external_utils_js_namespaceObject.resolveWebTarget)(script)?.target || script.android || script.ios || script.harmony || script.computer || script.config;
|
|
345
|
+
const outputConfig = (0, external_utils_js_namespaceObject.resolveYamlOutputConfig)(script);
|
|
480
346
|
if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) {
|
|
481
347
|
this.output = void 0;
|
|
482
348
|
debug('output is undefined in browser or worker');
|
|
483
|
-
} else if (
|
|
484
|
-
this.output = (0, external_node_path_namespaceObject.resolve)(process.cwd(),
|
|
349
|
+
} else if (outputConfig.output) {
|
|
350
|
+
this.output = (0, external_node_path_namespaceObject.resolve)(process.cwd(), outputConfig.output);
|
|
485
351
|
debug('setting output by config.output', this.output);
|
|
486
352
|
} else {
|
|
487
353
|
const scriptName = this.scriptPath ? (0, external_node_path_namespaceObject.basename)(this.scriptPath, '.yaml').replace(/\.(ya?ml)$/i, '') : "script";
|
|
488
|
-
this.output = (0, external_node_path_namespaceObject.join)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), `${scriptName}-${
|
|
354
|
+
this.output = (0, external_node_path_namespaceObject.join)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), `${scriptName}-${(0, utils_namespaceObject.uuid)()}.json`);
|
|
489
355
|
debug("setting output by script path", this.output);
|
|
490
356
|
}
|
|
491
357
|
if (utils_namespaceObject.ifInBrowser || utils_namespaceObject.ifInWorker) this.unstableLogContent = void 0;
|
|
492
|
-
else if ('string' == typeof
|
|
493
|
-
else if (
|
|
358
|
+
else if ('string' == typeof outputConfig.unstableLogContent) this.unstableLogContent = (0, external_node_path_namespaceObject.resolve)(process.cwd(), outputConfig.unstableLogContent);
|
|
359
|
+
else if (true === outputConfig.unstableLogContent) this.unstableLogContent = (0, external_node_path_namespaceObject.join)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), 'unstableLogContent.json');
|
|
494
360
|
this.taskStatusList = (script.tasks || []).map((task, taskIndex)=>({
|
|
495
361
|
...task,
|
|
496
362
|
index: taskIndex,
|