@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml/player.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/yaml/player.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { assert, ifInBrowser, ifInWorker } from '@midscene/shared/utils';\nimport { type ZodTypeAny, z } from 'zod';\n\n// previous defined yaml flow, as a helper\ninterface MidsceneYamlFlowItemAIInput extends LocateOption {\n // previous version\n // aiInput: string; // value to input\n // locate: TUserPrompt; // where to input\n aiInput: TUserPrompt | undefined; // where to input\n value: string | number; // value to input\n mode?: 'replace' | 'clear' | 'typeOnly';\n autoDismissKeyboard?: boolean;\n keyboardTypeDelay?: number;\n inputStrategy?: InputStrategy;\n}\n\ninterface MidsceneYamlFlowItemAIKeyboardPress extends LocateOption {\n // previous version\n // aiKeyboardPress: string;\n // locate?: TUserPrompt; // where to press, optional\n aiKeyboardPress: TUserPrompt | undefined; // where to press\n keyName: string; // key to press\n}\n\ninterface MidsceneYamlFlowItemAIScroll extends LocateOption, ScrollParam {\n // previous version\n // aiScroll: null;\n // locate?: TUserPrompt; // which area to scroll, optional\n aiScroll: TUserPrompt | undefined; // which area to scroll\n}\n\ntype RuntimeYamlFlowItem =\n | MidsceneYamlFlowItem\n | MidsceneYamlFlowItemAIInput\n | MidsceneYamlFlowItemAIKeyboardPress\n | MidsceneYamlFlowItemAIScroll;\n\nimport type { Agent } from '@/agent/agent';\nimport type { TUserPrompt } from '@/common';\nimport type { InputStrategy } from '@/device';\nimport { deriveCaseStatus } from '@/dump/task-status';\nimport type {\n DeviceAction,\n FreeFn,\n LocateOption,\n MidsceneYamlFlowItem,\n MidsceneYamlFlowItemAIAction,\n MidsceneYamlFlowItemAIAssert,\n MidsceneYamlFlowItemAIWaitFor,\n MidsceneYamlFlowItemEvaluateJavaScript,\n MidsceneYamlFlowItemLogScreenshot,\n MidsceneYamlFlowItemRunGherkinScenario,\n MidsceneYamlFlowItemSleep,\n MidsceneYamlScript,\n MidsceneYamlScriptEnv,\n ScriptPlayerStatusValue,\n ScriptPlayerTaskStatus,\n ScrollParam,\n} from '@/types';\nimport { getMidsceneRunSubDir } from '@midscene/shared/common';\nimport { getDebug } from '@midscene/shared/logger';\nimport { runFreeFnCleanup } from './cleanup';\nimport {\n buildDetailedLocateParam,\n buildDetailedLocateParamAndRestParams,\n} from './utils';\n\nconst debug = getDebug('yaml-player');\n\nconst aiTaskHandlerMap = {\n aiQuery: 'aiQuery',\n aiNumber: 'aiNumber',\n aiString: 'aiString',\n aiBoolean: 'aiBoolean',\n aiAsk: 'aiAsk',\n aiLocate: 'aiLocate',\n} as const;\n\ntype AISimpleTaskKey = keyof typeof aiTaskHandlerMap;\n\nconst isStringParamSchema = (schema?: ZodTypeAny): boolean => {\n if (!schema) {\n return false;\n }\n\n const schemaDef = (schema as any)?._def;\n if (!schemaDef?.typeName) {\n return false;\n }\n\n switch (schemaDef.typeName) {\n case z.ZodFirstPartyTypeKind.ZodString:\n case z.ZodFirstPartyTypeKind.ZodEnum:\n case z.ZodFirstPartyTypeKind.ZodNativeEnum:\n return true;\n case z.ZodFirstPartyTypeKind.ZodLiteral:\n return typeof schemaDef.value === 'string';\n case z.ZodFirstPartyTypeKind.ZodOptional:\n case z.ZodFirstPartyTypeKind.ZodNullable:\n case z.ZodFirstPartyTypeKind.ZodDefault:\n return isStringParamSchema(schemaDef.innerType);\n case z.ZodFirstPartyTypeKind.ZodEffects:\n return isStringParamSchema(schemaDef.schema);\n case z.ZodFirstPartyTypeKind.ZodPipeline:\n return isStringParamSchema(schemaDef.out);\n case z.ZodFirstPartyTypeKind.ZodUnion: {\n const options = schemaDef.options as ZodTypeAny[] | undefined;\n return Array.isArray(options)\n ? options.every((option) => isStringParamSchema(option))\n : false;\n }\n default:\n return false;\n }\n};\n\nconst buildShortcutActionParam = (\n actionName: string,\n interfaceAlias: string | undefined,\n value: string,\n) => {\n if (actionName === 'Launch' || interfaceAlias === 'launch') {\n return { uri: value };\n }\n\n if (actionName === 'Terminate' || interfaceAlias === 'terminate') {\n return { uri: value };\n }\n\n if (\n actionName === 'RunAdbShell' ||\n interfaceAlias === 'runAdbShell' ||\n actionName === 'RunHdcShell' ||\n interfaceAlias === 'runHdcShell'\n ) {\n return { command: value };\n }\n\n return undefined;\n};\nexport class ScriptPlayer<T extends MidsceneYamlScriptEnv> {\n public currentTaskIndex?: number;\n public taskStatusList: ScriptPlayerTaskStatus[] = [];\n public status: ScriptPlayerStatusValue = 'init';\n public reportFile?: string | null;\n public result: Record<string, any>;\n private unnamedResultIndex = 0;\n public output?: string | null;\n public unstableLogContent?: string | null;\n public errorInSetup?: Error;\n private interfaceAgent: Agent | null = null;\n public agentStatusTip?: string;\n public target?: MidsceneYamlScriptEnv;\n private actionSpace: DeviceAction[] = [];\n private scriptPath?: string;\n private failedReportExecutionInCurrentStep = false;\n constructor(\n private script: MidsceneYamlScript,\n private setupAgent: (platform: T) => Promise<{\n agent: Agent;\n freeFn: FreeFn[];\n }>,\n public onTaskStatusChange?: (taskStatus: ScriptPlayerTaskStatus) => void,\n scriptPath?: string,\n ) {\n this.scriptPath = scriptPath;\n this.result = {};\n\n this.target =\n script.target ||\n script.web ||\n script.android ||\n script.ios ||\n script.computer ||\n script.config;\n\n if (ifInBrowser || ifInWorker) {\n this.output = undefined;\n debug('output is undefined in browser or worker');\n } else if (this.target?.output) {\n this.output = resolve(process.cwd(), this.target.output);\n debug('setting output by config.output', this.output);\n } else {\n const scriptName = this.scriptPath\n ? basename(this.scriptPath, '.yaml').replace(/\\.(ya?ml)$/i, '')\n : 'script';\n this.output = join(\n getMidsceneRunSubDir('output'),\n `${scriptName}-${Date.now()}.json`,\n );\n debug('setting output by script path', this.output);\n }\n\n if (ifInBrowser || ifInWorker) {\n this.unstableLogContent = undefined;\n } else if (typeof this.target?.unstableLogContent === 'string') {\n this.unstableLogContent = resolve(\n process.cwd(),\n this.target.unstableLogContent,\n );\n } else if (this.target?.unstableLogContent === true) {\n this.unstableLogContent = join(\n getMidsceneRunSubDir('output'),\n 'unstableLogContent.json',\n );\n }\n\n this.taskStatusList = (script.tasks || []).map((task, taskIndex) => ({\n ...task,\n index: taskIndex,\n status: 'init',\n totalSteps: task.flow?.length || 0,\n }));\n }\n\n private setResult(key: string | undefined, value: any) {\n const keyToUse = key || this.unnamedResultIndex++;\n if (this.result[keyToUse]) {\n console.warn(`result key ${keyToUse} already exists, will overwrite`);\n }\n this.result[keyToUse] = value;\n\n return this.flushResult();\n }\n\n private setPlayerStatus(status: ScriptPlayerStatusValue, error?: Error) {\n this.status = status;\n this.errorInSetup = error;\n }\n\n private notifyCurrentTaskStatusChange(taskIndex?: number) {\n const taskIndexToNotify =\n typeof taskIndex === 'number' ? taskIndex : this.currentTaskIndex;\n\n if (typeof taskIndexToNotify !== 'number') {\n return;\n }\n\n const taskStatus = this.taskStatusList[taskIndexToNotify];\n if (this.onTaskStatusChange) {\n this.onTaskStatusChange(taskStatus);\n }\n }\n\n private async setTaskStatus(\n index: number,\n statusValue: ScriptPlayerStatusValue,\n error?: Error,\n ) {\n this.taskStatusList[index].status = statusValue;\n if (error) {\n this.taskStatusList[index].error = error;\n }\n\n this.notifyCurrentTaskStatusChange(index);\n }\n\n private setTaskIndex(taskIndex: number) {\n this.currentTaskIndex = taskIndex;\n }\n\n private flushResult() {\n if (this.output) {\n const output = resolve(process.cwd(), this.output);\n const outputDir = dirname(output);\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n writeFileSync(output, JSON.stringify(this.result || {}, undefined, 2));\n }\n }\n\n private flushUnstableLogContent() {\n if (this.unstableLogContent) {\n const content = this.interfaceAgent?._unstableLogContent();\n const filePath = resolve(process.cwd(), this.unstableLogContent);\n const outputDir = dirname(filePath);\n if (!existsSync(outputDir)) {\n mkdirSync(outputDir, { recursive: true });\n }\n writeFileSync(filePath, JSON.stringify(content, null, 2));\n }\n }\n\n async playTask(taskStatus: ScriptPlayerTaskStatus, agent: Agent) {\n const { flow } = taskStatus;\n assert(flow, 'missing flow in task');\n\n for (const flowItemIndex in flow) {\n const currentStep = Number.parseInt(flowItemIndex, 10);\n taskStatus.currentStep = currentStep;\n const flowItem = flow[flowItemIndex] as RuntimeYamlFlowItem;\n const flowItemRecord = flowItem as Record<string, unknown>;\n const executionCountBeforeStep = agent.dump?.executions?.length ?? 0;\n this.failedReportExecutionInCurrentStep = false;\n\n try {\n await this.playFlowItem(agent, flowItem, flowItemRecord, flowItemIndex);\n } catch (error) {\n this.failedReportExecutionInCurrentStep =\n this.hasFailedReportExecutionSince(agent, executionCountBeforeStep);\n throw error;\n }\n }\n this.reportFile = agent.reportFile;\n await this.flushUnstableLogContent();\n }\n\n private hasFailedReportExecutionSince(\n agent: Agent,\n executionCountBefore: number,\n ) {\n const executions = (agent.dump?.executions ?? []).slice(\n executionCountBefore,\n );\n return deriveCaseStatus(executions) === 'failed';\n }\n\n private async playFlowItem(\n agent: Agent,\n flowItem: RuntimeYamlFlowItem,\n flowItemRecord: Record<string, unknown>,\n flowItemIndex: string,\n ) {\n // Skip Finalize action from cache - it's a planning-only marker\n if ('Finalize' in flowItemRecord) {\n return;\n }\n\n debug(\n `playing step ${flowItemIndex}, flowItem=${JSON.stringify(flowItem)}`,\n );\n const simpleAIKey = (\n Object.keys(aiTaskHandlerMap) as AISimpleTaskKey[]\n ).find((key) => Object.prototype.hasOwnProperty.call(flowItemRecord, key));\n if (\n 'aiAct' in (flowItem as MidsceneYamlFlowItemAIAction) ||\n 'aiAction' in (flowItem as MidsceneYamlFlowItemAIAction) ||\n 'ai' in (flowItem as MidsceneYamlFlowItemAIAction)\n ) {\n const actionTask = flowItem as MidsceneYamlFlowItemAIAction;\n const { aiAct, aiAction, ai, instruction, ...actionOptions } =\n actionTask as any;\n const actionPrompt = aiAct ?? aiAction ?? ai;\n let promptForAI: TUserPrompt | undefined;\n\n if (typeof instruction === 'string' && instruction) {\n promptForAI = instruction;\n } else if (\n instruction &&\n typeof instruction === 'object' &&\n typeof (instruction as { prompt?: unknown }).prompt === 'string' &&\n (instruction as { prompt?: string }).prompt\n ) {\n promptForAI = instruction as TUserPrompt;\n } else if (\n actionPrompt &&\n typeof actionPrompt === 'object' &&\n typeof (actionPrompt as { prompt?: unknown }).prompt === 'string' &&\n (actionPrompt as { prompt?: string }).prompt\n ) {\n promptForAI = actionPrompt as TUserPrompt;\n } else if (typeof actionPrompt === 'string' && actionPrompt) {\n promptForAI = actionPrompt;\n }\n\n assert(promptForAI, 'missing prompt for ai (aiAct)');\n await agent.aiAct(promptForAI, actionOptions);\n } else if (\n 'runGherkinScenario' in\n (flowItem as MidsceneYamlFlowItemRunGherkinScenario)\n ) {\n const gherkinScenarioTask =\n flowItem as MidsceneYamlFlowItemRunGherkinScenario;\n const { runGherkinScenario } = gherkinScenarioTask;\n assert(runGherkinScenario, 'missing scenario for runGherkinScenario');\n await agent.runGherkinScenario(runGherkinScenario, {\n cacheable: false,\n });\n } else if ('aiAssert' in (flowItem as MidsceneYamlFlowItemAIAssert)) {\n const assertTask = flowItem as MidsceneYamlFlowItemAIAssert;\n const {\n aiAssert: prompt,\n errorMessage: msg,\n name,\n ...restOpts\n } = assertTask;\n assert(prompt, 'missing prompt for aiAssert');\n assert(\n !Object.prototype.hasOwnProperty.call(assertTask, 'observe'),\n '`observe` is not supported in YAML aiAssert. Use agent.startObserving() from code instead.',\n );\n\n const result = await agent.aiAssert(prompt, msg, {\n ...restOpts,\n keepRawResponse: true,\n });\n const pass = result?.pass;\n const thought = result?.thought;\n const message = result?.message;\n\n this.setResult(name, { pass, thought, message });\n\n if (!pass) {\n throw new Error(message);\n }\n } else if (simpleAIKey) {\n const {\n [simpleAIKey]: prompt,\n name,\n ...options\n } = flowItem as Record<string, any>;\n assert(prompt, `missing prompt for ${simpleAIKey}`);\n assert(\n !Object.prototype.hasOwnProperty.call(flowItem, 'observe'),\n '`observe` is not supported in YAML flow items. Use agent.startObserving() from code instead.',\n );\n\n const agentMethod = (agent as any)[aiTaskHandlerMap[simpleAIKey]];\n assert(\n typeof agentMethod === 'function',\n `missing agent method for ${simpleAIKey}`,\n );\n const aiResult = await agentMethod.call(agent, prompt, options);\n this.setResult(name, aiResult);\n } else if ('aiWaitFor' in (flowItem as MidsceneYamlFlowItemAIWaitFor)) {\n const waitForTask = flowItem as MidsceneYamlFlowItemAIWaitFor;\n const { aiWaitFor, timeout, ...restWaitForOpts } = waitForTask;\n const prompt = aiWaitFor;\n assert(prompt, 'missing prompt for aiWaitFor');\n const waitForOptions = {\n ...restWaitForOpts,\n ...(timeout !== undefined ? { timeout, timeoutMs: timeout } : {}),\n };\n await agent.aiWaitFor(prompt, waitForOptions);\n } else if ('sleep' in flowItem) {\n const sleepTask = flowItem as unknown as MidsceneYamlFlowItemSleep;\n const ms = sleepTask.sleep;\n let msNumber = ms;\n if (typeof ms === 'string') {\n msNumber = Number.parseInt(ms, 10);\n }\n assert(\n Number.isFinite(msNumber) && msNumber > 0,\n `ms for sleep must be greater than 0, but got ${ms}`,\n );\n await agent.sleep(msNumber);\n } else if ('javascript' in flowItem) {\n const evaluateJavaScriptTask =\n flowItem as unknown as MidsceneYamlFlowItemEvaluateJavaScript;\n\n const result = await agent.evaluateJavaScript(\n evaluateJavaScriptTask.javascript,\n );\n this.setResult(evaluateJavaScriptTask.name, result);\n } else if (\n 'logScreenshot' in (flowItem as MidsceneYamlFlowItemLogScreenshot) ||\n 'recordToReport' in (flowItem as MidsceneYamlFlowItemLogScreenshot)\n ) {\n const recordTask = flowItem as MidsceneYamlFlowItemLogScreenshot;\n const title =\n recordTask.recordToReport ?? recordTask.logScreenshot ?? 'untitled';\n const content = recordTask.content || '';\n await agent.recordToReport(title, { content });\n } else if ('aiInput' in flowItem) {\n // may be input empty string ''\n const {\n aiInput,\n value: rawValue,\n ...inputTask\n } = flowItem as unknown as MidsceneYamlFlowItemAIInput;\n\n // Compatibility with previous version:\n // Old format: { aiInput: string (value), locate: TUserPrompt }\n // New format - 1: { aiInput: TUserPrompt, value: string | number }\n // New format - 2: { aiInput: undefined, locate: TUserPrompt, value: string | number }\n let locatePrompt: TUserPrompt | undefined;\n let value: string | number | undefined;\n if ((inputTask as any).locate) {\n // Old format - aiInput is the value, locate is the prompt\n // Keep backward compatibility: empty string is treated as no value\n value = (aiInput as string | number) || rawValue;\n locatePrompt = (inputTask as any).locate;\n } else {\n // New format - aiInput is the prompt, value is the value\n locatePrompt = aiInput || '';\n value = rawValue;\n }\n\n // Convert value to string for Input action\n await agent.callActionInActionSpace('Input', {\n ...inputTask,\n ...(value !== undefined ? { value: String(value) } : {}),\n ...(locatePrompt\n ? { locate: buildDetailedLocateParam(locatePrompt, inputTask) }\n : {}),\n });\n } else if ('aiKeyboardPress' in flowItem) {\n const { aiKeyboardPress, ...keyboardPressTask } =\n flowItem as unknown as MidsceneYamlFlowItemAIKeyboardPress;\n\n // Compatibility with previous version:\n // Old format: { aiKeyboardPress: string (key), locate?: TUserPrompt }\n // New format - 1: { aiKeyboardPress: TUserPrompt, keyName: string }\n // New format - 2: { aiKeyboardPress: , locate?: TUserPrompt, keyName: string }\n let locatePrompt: TUserPrompt | undefined;\n let keyName: string | undefined;\n if ((keyboardPressTask as any).locate) {\n // Old format - aiKeyboardPress is the key, locate is the prompt\n keyName = aiKeyboardPress as string;\n locatePrompt = (keyboardPressTask as any).locate;\n } else if (keyboardPressTask.keyName) {\n // New format - aiKeyboardPress is the prompt, key is the key\n keyName = keyboardPressTask.keyName;\n locatePrompt = aiKeyboardPress;\n } else {\n keyName = aiKeyboardPress as string;\n }\n\n await agent.callActionInActionSpace('KeyboardPress', {\n ...keyboardPressTask,\n ...(keyName ? { keyName } : {}),\n ...(locatePrompt\n ? {\n locate: buildDetailedLocateParam(locatePrompt, keyboardPressTask),\n }\n : {}),\n });\n } else if ('aiScroll' in flowItem) {\n const { aiScroll, ...scrollTask } =\n flowItem as unknown as MidsceneYamlFlowItemAIScroll;\n\n // Compatibility with previous version:\n // Old format: { aiScroll: null, locate?: TUserPrompt, direction, scrollType, distance? }\n // New format - 1: { aiScroll: TUserPrompt, direction, scrollType, distance? }\n // New format - 2: { aiScroll: undefined, locate: TUserPrompt, direction, scrollType, distance? }\n const { locate, ...scrollOptions } = scrollTask as any;\n const locatePrompt: TUserPrompt | undefined =\n locate ?? aiScroll ?? undefined;\n\n await agent.aiScroll(locatePrompt, scrollOptions);\n } else if ('aiTap' in flowItem) {\n const { aiTap, prompt, locate, ...tapOptions } = flowItem as any;\n\n let locatePrompt: TUserPrompt;\n let opts = tapOptions;\n // Support both formats:\n // 1. { aiTap: null, locate: { prompt, images, ... } } (locate as sibling key)\n // 2. { aiTap: { locate: { prompt, images, ... } } } (locate nested in aiTap)\n const locateObj =\n locate ??\n (typeof aiTap === 'object' && aiTap !== null\n ? aiTap.locate\n : undefined);\n\n if (typeof aiTap === 'string' && aiTap) {\n // User YAML: aiTap: 'search input box'\n locatePrompt = aiTap;\n } else if (typeof locateObj === 'object' && locateObj?.prompt) {\n // buildYamlFlowFromPlans: { aiTap: '', locate: { prompt, deepLocate, cacheable } }\n const { prompt: lp, ...locateOpts } = locateObj;\n locatePrompt = lp;\n opts = { ...locateOpts, ...tapOptions };\n } else {\n // User YAML: aiTap: { prompt: '...' } or aiTap: null + prompt: '...'\n locatePrompt = aiTap?.prompt || prompt || locateObj;\n }\n\n assert(locatePrompt, 'missing prompt for aiTap');\n await agent.aiTap(locatePrompt, opts);\n } else {\n // generic action, find the action in actionSpace\n\n /* for aiRightClick, the parameters are a flattened data for the 'locate', these are all valid data\n\n - aiRightClick: 'search input box'\n - aiRightClick: 'search input box'\n deepLocate: true\n cacheable: false\n - aiRightClick:\n prompt: 'search input box'\n - aiRightClick:\n prompt: 'search input box'\n deepLocate: true\n cacheable: false\n */\n\n const actionSpace = this.actionSpace;\n let locatePromptShortcut: string | undefined;\n let actionParamForMatchedAction: unknown;\n const matchedAction = actionSpace.find((action) => {\n const actionInterfaceAlias = action.interfaceAlias;\n if (\n actionInterfaceAlias &&\n Object.prototype.hasOwnProperty.call(flowItem, actionInterfaceAlias)\n ) {\n actionParamForMatchedAction =\n flowItem[actionInterfaceAlias as keyof typeof flowItem];\n if (typeof actionParamForMatchedAction === 'string') {\n locatePromptShortcut = actionParamForMatchedAction;\n }\n return true;\n }\n\n const keyOfActionInActionSpace = action.name;\n if (\n Object.prototype.hasOwnProperty.call(\n flowItem,\n keyOfActionInActionSpace,\n )\n ) {\n actionParamForMatchedAction =\n flowItem[keyOfActionInActionSpace as keyof typeof flowItem];\n if (typeof actionParamForMatchedAction === 'string') {\n locatePromptShortcut = actionParamForMatchedAction;\n }\n return true;\n }\n\n return false;\n });\n\n assert(\n matchedAction,\n `unknown flowItem in yaml: ${JSON.stringify(flowItem)}`,\n );\n\n const schemaIsStringParam = isStringParamSchema(\n matchedAction.paramSchema,\n );\n let stringParamToCall: string | undefined;\n const resultName = (flowItem as any).name;\n const timeout = (flowItem as any).timeout;\n const hasRunAdbShellAlias = Object.prototype.hasOwnProperty.call(\n flowItem,\n 'runAdbShell',\n );\n\n if (\n hasRunAdbShellAlias &&\n typeof actionParamForMatchedAction === 'string' &&\n typeof timeout === 'number' &&\n typeof (agent as any).runAdbShell === 'function'\n ) {\n const result = await (agent as any).runAdbShell(\n actionParamForMatchedAction,\n { timeout },\n );\n if (result !== undefined) {\n this.setResult(resultName, result);\n }\n return;\n }\n\n const specialActionParamToCall =\n typeof actionParamForMatchedAction === 'string'\n ? buildShortcutActionParam(\n matchedAction.name,\n matchedAction.interfaceAlias,\n actionParamForMatchedAction,\n )\n : undefined;\n if (specialActionParamToCall) {\n debug(\n `matchedAction: ${matchedAction.name}`,\n `flowParams: ${JSON.stringify(specialActionParamToCall)}`,\n );\n const result = await agent.callActionInActionSpace(\n matchedAction.name,\n specialActionParamToCall,\n );\n\n if (result !== undefined) {\n this.setResult(resultName, result);\n }\n } else if (\n typeof actionParamForMatchedAction === 'string' &&\n schemaIsStringParam\n ) {\n if (matchedAction.paramSchema) {\n const parseResult = matchedAction.paramSchema.safeParse(\n actionParamForMatchedAction,\n );\n if (parseResult.success && typeof parseResult.data === 'string') {\n stringParamToCall = parseResult.data;\n } else if (!parseResult.success) {\n debug(\n `parse failed for action ${matchedAction.name} with string param`,\n parseResult.error,\n );\n stringParamToCall = actionParamForMatchedAction;\n }\n } else {\n stringParamToCall = actionParamForMatchedAction;\n }\n\n if (stringParamToCall !== undefined) {\n debug(\n `matchedAction: ${matchedAction.name}`,\n `flowParams: ${JSON.stringify(stringParamToCall)}`,\n );\n const result = await agent.callActionInActionSpace(\n matchedAction.name,\n stringParamToCall,\n );\n\n // Store result if there's a name property in flowItem\n const resultName = (flowItem as any).name;\n if (result !== undefined) {\n this.setResult(resultName, result);\n }\n }\n } else {\n // Determine the source for parameter extraction:\n // - If we have a locatePromptShortcut, use the flowItem (for actions like aiTap with prompt)\n // - Otherwise, use actionParamForMatchedAction (for actions like runWdaRequest with structured params)\n const sourceForParams =\n locatePromptShortcut &&\n typeof actionParamForMatchedAction === 'string'\n ? { ...flowItem, prompt: locatePromptShortcut }\n : typeof actionParamForMatchedAction === 'object' &&\n actionParamForMatchedAction !== null\n ? actionParamForMatchedAction\n : flowItem;\n\n const { locateParam, restParams } =\n buildDetailedLocateParamAndRestParams(\n locatePromptShortcut || '',\n sourceForParams as LocateOption,\n [\n matchedAction.name,\n matchedAction.interfaceAlias || '_never_mind_',\n ],\n );\n\n const flowParams = {\n ...restParams,\n locate: locateParam,\n };\n\n debug(\n `matchedAction: ${matchedAction.name}`,\n `flowParams: ${JSON.stringify(flowParams, null, 2)}`,\n );\n const result = await agent.callActionInActionSpace(\n matchedAction.name,\n flowParams,\n );\n\n // Store result if there's a name property in flowItem\n const resultName = (flowItem as any).name;\n if (result !== undefined) {\n this.setResult(resultName, result);\n }\n }\n }\n }\n\n async run() {\n const { target, web, android, ios, harmony, computer, tasks } = this.script;\n const webEnv = web || target;\n const androidEnv = android;\n const iosEnv = ios;\n const harmonyEnv = harmony;\n const computerEnv = computer;\n const platform =\n webEnv || androidEnv || iosEnv || harmonyEnv || computerEnv;\n\n this.setPlayerStatus('running');\n\n let agent: Agent | null = null;\n let freeFn: FreeFn[] = [];\n try {\n const { agent: newAgent, freeFn: newFreeFn } = await this.setupAgent(\n platform as T,\n );\n this.actionSpace = await newAgent.getActionSpace();\n agent = newAgent;\n const originalOnTaskStartTip = agent.onTaskStartTip;\n agent.onTaskStartTip = (tip) => {\n if (this.status === 'running') {\n this.agentStatusTip = tip;\n }\n originalOnTaskStartTip?.(tip);\n };\n freeFn = [\n ...(newFreeFn || []),\n {\n name: 'restore-agent-onTaskStartTip',\n fn: () => {\n if (agent) {\n agent.onTaskStartTip = originalOnTaskStartTip;\n }\n },\n },\n ];\n } catch (e) {\n this.setPlayerStatus('error', e as Error);\n return;\n }\n this.interfaceAgent = agent;\n\n let taskIndex = 0;\n this.setPlayerStatus('running');\n let errorFlag = false;\n while (taskIndex < tasks.length) {\n const taskStatus = this.taskStatusList[taskIndex];\n this.setTaskStatus(taskIndex, 'running' as any);\n this.setTaskIndex(taskIndex);\n this.failedReportExecutionInCurrentStep = false;\n\n try {\n await this.playTask(taskStatus, this.interfaceAgent);\n this.setTaskStatus(taskIndex, 'done' as any);\n } catch (e) {\n this.setTaskStatus(taskIndex, 'error' as any, e as Error);\n const recordErrorToReport = (agent as any).recordErrorToReport;\n if (\n !this.failedReportExecutionInCurrentStep &&\n typeof recordErrorToReport === 'function'\n ) {\n try {\n await recordErrorToReport.call(\n agent,\n `YAML task failed - ${taskStatus.name}`,\n {\n error: e as Error,\n content: `Step ${taskStatus.currentStep ?? 0} failed while running YAML task \"${taskStatus.name}\".`,\n },\n );\n } catch (reportError) {\n debug('failed to record yaml error to report', reportError);\n }\n }\n\n if (taskStatus.continueOnError) {\n // nothing more to do\n } else {\n this.reportFile = agent.reportFile;\n errorFlag = true;\n break;\n }\n }\n this.reportFile = agent?.reportFile;\n taskIndex++;\n }\n\n if (errorFlag) {\n this.setPlayerStatus('error');\n } else {\n this.setPlayerStatus('done');\n }\n this.agentStatusTip = '';\n\n await runFreeFnCleanup(freeFn);\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","aiTaskHandlerMap","isStringParamSchema","schema","schemaDef","z","options","Array","option","buildShortcutActionParam","actionName","interfaceAlias","value","ScriptPlayer","keyToUse","console","status","error","taskIndex","taskIndexToNotify","taskStatus","index","statusValue","output","resolve","process","outputDir","dirname","existsSync","mkdirSync","writeFileSync","JSON","undefined","content","filePath","agent","flow","assert","flowItemIndex","currentStep","Number","flowItem","flowItemRecord","executionCountBeforeStep","executionCountBefore","executions","deriveCaseStatus","simpleAIKey","actionTask","aiAct","aiAction","ai","instruction","actionOptions","actionPrompt","promptForAI","gherkinScenarioTask","runGherkinScenario","assertTask","prompt","msg","name","restOpts","result","pass","thought","message","Error","agentMethod","aiResult","waitForTask","aiWaitFor","timeout","restWaitForOpts","waitForOptions","sleepTask","ms","msNumber","evaluateJavaScriptTask","recordTask","title","aiInput","rawValue","inputTask","locatePrompt","String","buildDetailedLocateParam","aiKeyboardPress","keyboardPressTask","keyName","aiScroll","scrollTask","locate","scrollOptions","aiTap","tapOptions","opts","locateObj","lp","locateOpts","actionSpace","locatePromptShortcut","actionParamForMatchedAction","matchedAction","action","actionInterfaceAlias","keyOfActionInActionSpace","schemaIsStringParam","stringParamToCall","resultName","hasRunAdbShellAlias","specialActionParamToCall","parseResult","sourceForParams","locateParam","restParams","buildDetailedLocateParamAndRestParams","flowParams","target","web","android","ios","harmony","computer","tasks","webEnv","androidEnv","iosEnv","harmonyEnv","computerEnv","platform","freeFn","newAgent","newFreeFn","originalOnTaskStartTip","tip","e","errorFlag","recordErrorToReport","reportError","runFreeFnCleanup","script","setupAgent","onTaskStatusChange","scriptPath","ifInBrowser","ifInWorker","scriptName","basename","join","getMidsceneRunSubDir","Date","task"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;;;;;;;;;;;;;;;AC+DA,MAAMI,QAAQC,AAAAA,IAAAA,uBAAAA,QAAAA,AAAAA,EAAS;AAEvB,MAAMC,mBAAmB;IACvB,SAAS;IACT,UAAU;IACV,UAAU;IACV,WAAW;IACX,OAAO;IACP,UAAU;AACZ;AAIA,MAAMC,sBAAsB,CAACC;IAC3B,IAAI,CAACA,QACH,OAAO;IAGT,MAAMC,YAAaD,QAAgB;IACnC,IAAI,CAACC,WAAW,UACd,OAAO;IAGT,OAAQA,UAAU,QAAQ;QACxB,KAAKC,6BAAAA,CAAAA,CAAAA,qBAAAA,CAAAA,SAAiC;QACtC,KAAKA,6BAAAA,CAAAA,CAAAA,qBAAAA,CAAAA,OAA+B;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AC,MAAM;QACpD;QAEA,IAAIkJ,sBAAAA,WAAWA,IAAIC,sBAAAA,UAAUA,EAC3B,IAAI,CAAC,kBAAkB,GAAGlH;aACrB,IAAI,AAA2C,YAA3C,OAAO,IAAI,CAAC,MAAM,EAAE,oBAC7B,IAAI,CAAC,kBAAkB,GAAGR,AAAAA,IAAAA,mCAAAA,OAAAA,AAAAA,EACxBC,QAAQ,GAAG,IACX,IAAI,CAAC,MAAM,CAAC,kBAAkB;aAE3B,IAAI,IAAI,CAAC,MAAM,EAAE,uBAAuB,MAC7C,IAAI,CAAC,kBAAkB,GAAG4H,AAAAA,IAAAA,mCAAAA,IAAAA,AAAAA,EACxBC,AAAAA,IAAAA,uBAAAA,oBAAAA,AAAAA,EAAqB,WACrB;QAIJ,IAAI,CAAC,cAAc,GAAIT,AAAAA,CAAAA,OAAO,KAAK,IAAI,EAAC,EAAG,GAAG,CAAC,CAACW,MAAMtI,YAAe;gBACnE,GAAGsI,IAAI;gBACP,OAAOtI;gBACP,QAAQ;gBACR,YAAYsI,KAAK,IAAI,EAAE,UAAU;YACnC;IACF;AAmoBF"}
|
|
1
|
+
{"version":3,"file":"yaml/player.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/yaml/player.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { mkdir, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport type { Agent } from '@/agent/agent';\nimport type {\n DeviceAction,\n FreeFn,\n MidsceneYamlScript,\n MidsceneYamlScriptEnv,\n ScriptPlayerStatusValue,\n ScriptPlayerTaskStatus,\n} from '@/types';\nimport { getMidsceneRunSubDir } from '@midscene/shared/common';\nimport { getDebug } from '@midscene/shared/logger';\nimport { assert, ifInBrowser, ifInWorker, uuid } from '@midscene/shared/utils';\nimport type { WorkflowDocumentExecutionResult } from '../test-runner';\nimport {\n WorkflowExecutionFailure,\n WorkflowPublicationError,\n} from '../test-runner/engine/execution-failure';\nimport { cleanupResources } from '../test-runner/engine/resource-operations';\nimport { runFreeFnCleanup } from './cleanup';\nimport {\n YamlExecutionOwnershipError,\n currentYamlSignal,\n enterYamlExecution,\n runInYamlExecutionContext,\n} from './execution-session';\nimport { createLegacyYamlExecutionRecord } from './legacy-yaml-execution-record';\nimport { publishLegacyYamlReport } from './legacy-yaml-report';\nimport {\n createLegacyYamlRuntime,\n legacyYamlOutcomeError,\n} from './legacy-yaml-runtime';\nimport {\n getLegacyYamlPlayerState,\n initializeLegacyYamlPlayerState,\n} from './player-state';\nimport { collectLegacyYamlDocument } from './test-runner-compat';\nimport { resolveWebTarget, resolveYamlOutputConfig } from './utils';\n\nconst debug = getDebug('yaml-player');\n\n/**\n * Compatibility facade for the legacy YAML API.\n *\n * Execution is delegated to the shared Runner kernel through\n * createLegacyYamlRuntime(). This class keeps the mutable status, result,\n * progress, output, and setup/cleanup behavior exposed by the old API.\n */\nexport class ScriptPlayer<T extends MidsceneYamlScriptEnv> {\n public currentTaskIndex?: number;\n public taskStatusList: ScriptPlayerTaskStatus[] = [];\n public status: ScriptPlayerStatusValue = 'init';\n public reportFile?: string | null;\n public result: Record<string, any>;\n private unnamedResultIndex = 0;\n private publicationErrors: WorkflowPublicationError[] = [];\n public output?: string | null;\n public unstableLogContent?: string | null;\n public errorInSetup?: Error;\n private interfaceAgent: Agent | null = null;\n public agentStatusTip?: string;\n public target?: MidsceneYamlScriptEnv;\n private actionSpace: DeviceAction[] = [];\n private scriptPath?: string;\n\n constructor(\n private script: MidsceneYamlScript,\n private setupAgent: (platform: T) => Promise<{\n agent: Agent;\n freeFn: FreeFn[];\n }>,\n public onTaskStatusChange?: (taskStatus: ScriptPlayerTaskStatus) => void,\n scriptPath?: string,\n ) {\n this.scriptPath = scriptPath;\n // Collection validates syntax but defers old task/Step errors until execution.\n collectLegacyYamlDocument(script, scriptPath);\n initializeLegacyYamlPlayerState(this);\n this.result = {};\n\n this.target =\n resolveWebTarget(script)?.target ||\n script.android ||\n script.ios ||\n script.harmony ||\n script.computer ||\n script.config;\n const outputConfig = resolveYamlOutputConfig(script);\n\n if (ifInBrowser || ifInWorker) {\n this.output = undefined;\n debug('output is undefined in browser or worker');\n } else if (outputConfig.output) {\n this.output = resolve(process.cwd(), outputConfig.output);\n debug('setting output by config.output', this.output);\n } else {\n const scriptName = this.scriptPath\n ? basename(this.scriptPath, '.yaml').replace(/\\.(ya?ml)$/i, '')\n : 'script';\n this.output = join(\n getMidsceneRunSubDir('output'),\n `${scriptName}-${uuid()}.json`,\n );\n debug('setting output by script path', this.output);\n }\n\n if (ifInBrowser || ifInWorker) {\n this.unstableLogContent = undefined;\n } else if (typeof outputConfig.unstableLogContent === 'string') {\n this.unstableLogContent = resolve(\n process.cwd(),\n outputConfig.unstableLogContent,\n );\n } else if (outputConfig.unstableLogContent === true) {\n this.unstableLogContent = join(\n getMidsceneRunSubDir('output'),\n 'unstableLogContent.json',\n );\n }\n\n this.taskStatusList = (script.tasks || []).map((task, taskIndex) => ({\n ...task,\n index: taskIndex,\n status: 'init',\n totalSteps: task.flow?.length || 0,\n }));\n }\n\n private setResult(key: string | undefined, value: any) {\n const keyToUse = key || this.unnamedResultIndex++;\n if (this.result[keyToUse]) {\n getDebug('yaml-player', { console: true })(\n `result key ${keyToUse} already exists, will overwrite`,\n );\n }\n this.result[keyToUse] = value;\n\n return this.flushResult();\n }\n\n private setPlayerStatus(status: ScriptPlayerStatusValue, error?: Error) {\n this.status = status;\n this.errorInSetup = error;\n }\n\n private notifyCurrentTaskStatusChange(taskIndex?: number) {\n const taskIndexToNotify =\n typeof taskIndex === 'number' ? taskIndex : this.currentTaskIndex;\n\n if (typeof taskIndexToNotify !== 'number') return;\n\n const taskStatus = this.taskStatusList[taskIndexToNotify];\n this.onTaskStatusChange?.(taskStatus);\n }\n\n private async setTaskStatus(\n index: number,\n statusValue: ScriptPlayerStatusValue,\n error?: Error,\n ) {\n this.taskStatusList[index].status = statusValue;\n if (error) this.taskStatusList[index].error = error;\n this.notifyCurrentTaskStatusChange(index);\n }\n\n private setTaskIndex(taskIndex: number) {\n this.currentTaskIndex = taskIndex;\n }\n\n private async flushResult() {\n if (this.output) {\n const output = resolve(process.cwd(), this.output);\n await this.publish(output, async () => {\n const outputDir = dirname(output);\n await mkdir(outputDir, { recursive: true });\n await writeFile(\n output,\n JSON.stringify(this.result || {}, undefined, 2),\n );\n });\n }\n }\n\n private async flushUnstableLogContent() {\n if (this.unstableLogContent) {\n const content = this.interfaceAgent?._unstableLogContent();\n const filePath = resolve(process.cwd(), this.unstableLogContent);\n await this.publish(filePath, async () => {\n const outputDir = dirname(filePath);\n await mkdir(outputDir, { recursive: true });\n await writeFile(filePath, JSON.stringify(content, null, 2));\n });\n }\n }\n\n private async publish(path: string, write: () => Promise<void>) {\n try {\n await write();\n } catch (cause) {\n const error = new WorkflowPublicationError('write-result', path, cause);\n this.publicationErrors.push(error);\n throw error;\n }\n }\n\n private createRuntime(agent: Agent) {\n return createLegacyYamlRuntime({\n agent,\n actionSpace: this.actionSpace,\n sourcePath: this.scriptPath,\n setResult: (key, value) => this.setResult(key, value),\n });\n }\n\n async playTask(taskStatus: ScriptPlayerTaskStatus, agent: Agent) {\n const { flow } = taskStatus;\n assert(flow, 'missing flow in task');\n const statusIndex = this.taskStatusList.indexOf(taskStatus);\n const declaredIndex = (\n taskStatus as ScriptPlayerTaskStatus & {\n index?: unknown;\n }\n ).index;\n const taskIndex =\n statusIndex >= 0\n ? statusIndex\n : typeof declaredIndex === 'number' && Number.isInteger(declaredIndex)\n ? declaredIndex\n : 0;\n\n const state = getLegacyYamlPlayerState(this);\n state.executionResult = await this.createRuntime(agent).runTask(\n taskStatus,\n taskIndex,\n {\n onStepStart: (info) => {\n if (info.scope === 'case' && info.case.phase === 'steps') {\n taskStatus.currentStep = info.case.stepIndex;\n }\n },\n },\n );\n\n const outcome = state.executionResult.cases[0];\n if (!outcome || outcome.status === 'not-run') {\n throw new Error(`Task \"${taskStatus.name}\" did not run.`);\n }\n if (outcome.status === 'failed') throw legacyYamlOutcomeError(outcome);\n\n this.reportFile = agent.reportFile;\n await this.flushUnstableLogContent();\n }\n\n async run() {\n return runInYamlExecutionContext(() => this.runInContext());\n }\n\n private async runInContext() {\n const startedAt = new Date();\n const runId = uuid();\n const state = getLegacyYamlPlayerState(this);\n state.executionResult = undefined;\n state.executionRecord = undefined;\n this.publicationErrors = [];\n const { android, ios, harmony, computer } = this.script;\n const webEnv = resolveWebTarget(this.script)?.target;\n const androidEnv = android;\n const iosEnv = ios;\n const harmonyEnv = harmony;\n const computerEnv = computer;\n const platform =\n webEnv || androidEnv || iosEnv || harmonyEnv || computerEnv;\n\n this.setPlayerStatus('running');\n\n let agent: Agent | null = null;\n let freeFn: FreeFn[] = [];\n let setupError: unknown;\n let executionError: unknown;\n let cleanupError: unknown;\n let signal: AbortSignal | undefined;\n let session: ReturnType<typeof enterYamlExecution> | undefined;\n try {\n const { agent: newAgent, freeFn: newFreeFn } = await this.setupAgent(\n platform as T,\n );\n // Register ownership immediately: discovering actions can fail too.\n agent = newAgent;\n agent._prepareForTestRunner?.();\n freeFn = [...(newFreeFn || [])];\n session = enterYamlExecution(agent);\n signal = currentYamlSignal(agent);\n signal?.throwIfAborted();\n this.actionSpace = await agent.getActionSpace();\n const originalOnTaskStartTip = agent.onTaskStartTip;\n agent.onTaskStartTip = (tip) => {\n if (this.status === 'running') this.agentStatusTip = tip;\n originalOnTaskStartTip?.(tip);\n };\n freeFn.push({\n name: 'restore-agent-onTaskStartTip',\n fn: () => {\n if (agent) agent.onTaskStartTip = originalOnTaskStartTip;\n },\n });\n } catch (error) {\n // A rejected borrower must not close or publish into another run's Agent.\n if (error instanceof YamlExecutionOwnershipError) throw error;\n setupError = error;\n this.setPlayerStatus('error', error as Error);\n }\n this.interfaceAgent = agent;\n\n const document = collectLegacyYamlDocument(\n this.script,\n this.scriptPath ?? '<inline-yaml>',\n this.actionSpace,\n );\n const runtime =\n agent && !setupError ? this.createRuntime(agent) : undefined;\n try {\n if (runtime && agent) {\n state.executionResult = await runtime.runScript(this.script, {\n document,\n signal,\n createDocumentRunId: () => runId,\n onCaseStart: (collectedCase) => {\n const taskIndex = collectedCase.caseIndex;\n this.setTaskIndex(taskIndex);\n return this.setTaskStatus(taskIndex, 'running');\n },\n onStepStart: (info) => {\n if (info.scope !== 'case' || info.case.phase !== 'steps') return;\n const taskStatus = this.taskStatusList[info.case.caseIndex];\n if (taskStatus) taskStatus.currentStep = info.case.stepIndex;\n },\n onCaseOutcome: async (outcome) => {\n if (outcome.status === 'not-run') return;\n const taskIndex = outcome.caseIndex;\n const taskStatus = this.taskStatusList[taskIndex];\n assert(taskStatus, `missing YAML task at index ${taskIndex}`);\n\n this.reportFile = agent?.reportFile;\n if (outcome.status === 'success') {\n await this.setTaskStatus(taskIndex, 'done');\n await this.flushUnstableLogContent();\n return;\n }\n\n const error = legacyYamlOutcomeError(outcome);\n await this.setTaskStatus(taskIndex, 'error', error);\n },\n });\n const stoppedOnFailure = state.executionResult.cases.some(\n (outcome) =>\n outcome.status === 'failed' &&\n !this.taskStatusList[outcome.caseIndex]?.continueOnError,\n );\n this.setPlayerStatus(\n stoppedOnFailure || signal?.aborted ? 'error' : 'done',\n );\n }\n } catch (error) {\n executionError = error;\n if (error instanceof WorkflowExecutionFailure)\n state.executionResult = error.result as WorkflowDocumentExecutionResult;\n this.setPlayerStatus('error', error as Error);\n }\n\n this.reportFile = agent?.reportFile;\n this.agentStatusTip = '';\n\n try {\n // A timeout settles the Runner before an uncooperative device action.\n // Never dispose its Agent while that action is still using it.\n if (session?.isRoot && agent) {\n await cleanupResources([agent], () => runFreeFnCleanup(freeFn), {\n owner: this,\n signal,\n onDeferredError: (error) =>\n getDebug('yaml-player', { console: true })(\n `Deferred YAML cleanup failed: ${String(error)}`,\n ),\n });\n } else await runFreeFnCleanup(freeFn);\n } catch (error) {\n cleanupError = error;\n this.setPlayerStatus(\n 'error',\n (setupError ?? executionError ?? error) as Error,\n );\n }\n\n const endedAt = new Date();\n const cleanupErrors =\n cleanupError instanceof AggregateError\n ? cleanupError.errors\n : cleanupError === undefined\n ? []\n : [cleanupError];\n state.executionRecord = createLegacyYamlExecutionRecord({\n runId,\n attemptIndex: 0,\n script: this.script,\n document,\n startedAt,\n endedAt,\n execution: state.executionResult,\n setupError,\n executionError,\n cleanupErrors,\n aborted: signal?.aborted ?? false,\n publicationErrors: this.publicationErrors,\n outputs: this.result,\n reportFile: agent?.reportFile,\n children: session?.children,\n });\n let reportError: unknown;\n if (!session || session.isRoot) {\n try {\n const published = await publishLegacyYamlReport({\n agent,\n record: state.executionRecord,\n runId,\n script: this.script,\n scriptPath: this.scriptPath,\n fallbackReportFileName: state.fallbackReportFileName,\n });\n this.reportFile = published.reportFile;\n state.executionRecord = published.record;\n } catch (error) {\n reportError = error;\n this.setPlayerStatus(\n 'error',\n (setupError ?? executionError ?? cleanupError ?? error) as Error,\n );\n state.executionRecord = Object.freeze({\n ...state.executionRecord,\n status: 'failed',\n reportError: error,\n });\n }\n }\n session?.finish(state.executionRecord);\n if (reportError) {\n const errors = [\n setupError,\n executionError,\n ...cleanupErrors,\n reportError,\n ].filter((error) => error !== undefined);\n throw errors.length === 1\n ? reportError\n : new AggregateError(\n errors,\n 'YAML execution/report finalization failed',\n );\n }\n if (executionError && cleanupError) {\n throw new AggregateError(\n [executionError, ...cleanupErrors],\n 'YAML execution and cleanup failed',\n );\n }\n if (executionError) throw executionError;\n if (cleanupError) throw cleanupError;\n }\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","debug","getDebug","ScriptPlayer","value","keyToUse","status","error","taskIndex","taskIndexToNotify","taskStatus","index","statusValue","output","resolve","process","outputDir","dirname","mkdir","writeFile","JSON","undefined","content","filePath","path","write","cause","WorkflowPublicationError","agent","createLegacyYamlRuntime","flow","assert","statusIndex","declaredIndex","Number","state","getLegacyYamlPlayerState","info","outcome","Error","legacyYamlOutcomeError","runInYamlExecutionContext","startedAt","Date","runId","uuid","android","ios","harmony","computer","webEnv","resolveWebTarget","androidEnv","iosEnv","harmonyEnv","computerEnv","platform","freeFn","setupError","executionError","cleanupError","signal","session","newAgent","newFreeFn","enterYamlExecution","currentYamlSignal","originalOnTaskStartTip","tip","YamlExecutionOwnershipError","document","collectLegacyYamlDocument","runtime","collectedCase","stoppedOnFailure","WorkflowExecutionFailure","cleanupResources","runFreeFnCleanup","String","endedAt","cleanupErrors","AggregateError","createLegacyYamlExecutionRecord","reportError","published","publishLegacyYamlReport","errors","script","setupAgent","onTaskStatusChange","scriptPath","initializeLegacyYamlPlayerState","outputConfig","resolveYamlOutputConfig","ifInBrowser","ifInWorker","scriptName","basename","join","getMidsceneRunSubDir","task"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO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kBAAkB;aAE5B,IAAIA,AAAoC,SAApCA,aAAa,kBAAkB,EACxC,IAAI,CAAC,kBAAkB,GAAGM,AAAAA,IAAAA,mCAAAA,IAAAA,AAAAA,EACxBC,AAAAA,IAAAA,uBAAAA,oBAAAA,AAAAA,EAAqB,WACrB;QAIJ,IAAI,CAAC,cAAc,GAAIZ,AAAAA,CAAAA,OAAO,KAAK,IAAI,EAAC,EAAG,GAAG,CAAC,CAACa,MAAM5F,YAAe;gBACnE,GAAG4F,IAAI;gBACP,OAAO5F;gBACP,QAAQ;gBACR,YAAY4F,KAAK,IAAI,EAAE,UAAU;YACnC;IACF;AAqVF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
isYamlReportEnabled: ()=>isYamlReportEnabled
|
|
28
|
+
});
|
|
29
|
+
function isYamlReportEnabled(script) {
|
|
30
|
+
const webTarget = script.page ?? script.browser ?? script.web ?? script.target;
|
|
31
|
+
return (script.agent?.generateReport ?? webTarget?.generateReport) !== false;
|
|
32
|
+
}
|
|
33
|
+
exports.isYamlReportEnabled = __webpack_exports__.isYamlReportEnabled;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"isYamlReportEnabled"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=report-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/report-policy.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/yaml/report-policy.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { MidsceneYamlScript, MidsceneYamlTargetConfig } from '../types';\n\n/** Match old web-target options followed by explicit Agent overrides. */\nexport function isYamlReportEnabled(\n script: MidsceneYamlTargetConfig & Pick<MidsceneYamlScript, 'agent'>,\n): boolean {\n // Report intent remains useful before target or task validation succeeds.\n // Target grammar is validated by the parser, not by report publication.\n const webTarget =\n script.page ?? script.browser ?? script.web ?? script.target;\n return (script.agent?.generateReport ?? webTarget?.generateReport) !== false;\n}\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","isYamlReportEnabled","script","webTarget"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;ACHO,SAASI,oBACdC,MAAoE;IAIpE,MAAMC,YACJD,OAAO,IAAI,IAAIA,OAAO,OAAO,IAAIA,OAAO,GAAG,IAAIA,OAAO,MAAM;IAC9D,OAAQA,AAAAA,CAAAA,OAAO,KAAK,EAAE,kBAAkBC,WAAW,cAAa,MAAO;AACzE"}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
collectLegacyYamlTask: ()=>collectLegacyYamlTask,
|
|
28
|
+
compileLegacyFlowItem: ()=>compileLegacyFlowItem,
|
|
29
|
+
collectLegacyYamlTaskDocument: ()=>collectLegacyYamlTaskDocument,
|
|
30
|
+
collectLegacyYamlDocument: ()=>collectLegacyYamlDocument
|
|
31
|
+
});
|
|
32
|
+
const external_zod_namespaceObject = require("zod");
|
|
33
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
34
|
+
const isStringParamSchema = (schema)=>{
|
|
35
|
+
if (!schema) return false;
|
|
36
|
+
const schemaDef = schema?._def;
|
|
37
|
+
if (!schemaDef?.typeName) return false;
|
|
38
|
+
switch(schemaDef.typeName){
|
|
39
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodString:
|
|
40
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodEnum:
|
|
41
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
42
|
+
return true;
|
|
43
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodLiteral:
|
|
44
|
+
return 'string' == typeof schemaDef.value;
|
|
45
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodOptional:
|
|
46
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodNullable:
|
|
47
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodDefault:
|
|
48
|
+
return isStringParamSchema(schemaDef.innerType);
|
|
49
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodEffects:
|
|
50
|
+
return isStringParamSchema(schemaDef.schema);
|
|
51
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodPipeline:
|
|
52
|
+
return isStringParamSchema(schemaDef.out);
|
|
53
|
+
case external_zod_namespaceObject.z.ZodFirstPartyTypeKind.ZodUnion:
|
|
54
|
+
{
|
|
55
|
+
const options = schemaDef.options;
|
|
56
|
+
return Array.isArray(options) ? options.every((option)=>isStringParamSchema(option)) : false;
|
|
57
|
+
}
|
|
58
|
+
default:
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const buildShortcutActionParam = (actionName, interfaceAlias, value)=>{
|
|
63
|
+
if ('Launch' === actionName || 'launch' === interfaceAlias) return {
|
|
64
|
+
uri: value
|
|
65
|
+
};
|
|
66
|
+
if ('Terminate' === actionName || 'terminate' === interfaceAlias) return {
|
|
67
|
+
uri: value
|
|
68
|
+
};
|
|
69
|
+
if ('RunAdbShell' === actionName || 'runAdbShell' === interfaceAlias || 'RunHdcShell' === actionName || 'runHdcShell' === interfaceAlias) return {
|
|
70
|
+
command: value
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
function compileLegacyFlowItem(flowItem, actionSpace = []) {
|
|
74
|
+
if ('object' != typeof flowItem || null === flowItem || Array.isArray(flowItem)) return {
|
|
75
|
+
node: 'legacyValidationError',
|
|
76
|
+
input: {
|
|
77
|
+
message: 'flow item must be an object'
|
|
78
|
+
},
|
|
79
|
+
meta: {
|
|
80
|
+
continueOnError: false
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const raw = flowItem;
|
|
84
|
+
const { name, ...flow } = raw;
|
|
85
|
+
const step = (node, input, captureResult = false)=>({
|
|
86
|
+
node,
|
|
87
|
+
input,
|
|
88
|
+
meta: {
|
|
89
|
+
continueOnError: false,
|
|
90
|
+
...captureResult ? {
|
|
91
|
+
captureResult: true,
|
|
92
|
+
...'string' == typeof name && name.length > 0 ? {
|
|
93
|
+
resultName: name
|
|
94
|
+
} : {}
|
|
95
|
+
} : {}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const invalid = (message)=>step('legacyValidationError', {
|
|
99
|
+
message
|
|
100
|
+
});
|
|
101
|
+
if ('Finalize' in flow) return step('Finalize', {});
|
|
102
|
+
if ('aiAct' in flow || 'aiAction' in flow || 'ai' in flow) {
|
|
103
|
+
const { aiAct, aiAction, ai, instruction, ...options } = raw;
|
|
104
|
+
const actionPrompt = aiAct ?? aiAction ?? ai;
|
|
105
|
+
const hasPrompt = (value)=>'string' == typeof value && value || value && 'object' == typeof value && 'string' == typeof value.prompt && value.prompt;
|
|
106
|
+
const prompt = hasPrompt(instruction) ? instruction : hasPrompt(actionPrompt) ? actionPrompt : void 0;
|
|
107
|
+
return prompt ? step('aiAct', {
|
|
108
|
+
prompt,
|
|
109
|
+
options
|
|
110
|
+
}) : invalid('missing prompt for ai (aiAct)');
|
|
111
|
+
}
|
|
112
|
+
if ('runGherkinScenario' in flow) return flow.runGherkinScenario ? step('runGherkinScenario', {
|
|
113
|
+
scenario: flow.runGherkinScenario,
|
|
114
|
+
options: {
|
|
115
|
+
cacheable: false
|
|
116
|
+
}
|
|
117
|
+
}) : invalid('missing scenario for runGherkinScenario');
|
|
118
|
+
if ('aiAssert' in flow) {
|
|
119
|
+
const { aiAssert: prompt, errorMessage: message, ...options } = flow;
|
|
120
|
+
if (!prompt) return invalid('missing prompt for aiAssert');
|
|
121
|
+
if (Object.hasOwn(raw, 'observe')) return invalid('`observe` is not supported in YAML aiAssert. Use agent.startObserving() from code instead.');
|
|
122
|
+
return step('aiAssert', {
|
|
123
|
+
prompt,
|
|
124
|
+
options: {
|
|
125
|
+
...options,
|
|
126
|
+
keepRawResponse: true
|
|
127
|
+
},
|
|
128
|
+
message
|
|
129
|
+
}, true);
|
|
130
|
+
}
|
|
131
|
+
for (const node of [
|
|
132
|
+
'aiQuery',
|
|
133
|
+
'aiNumber',
|
|
134
|
+
'aiString',
|
|
135
|
+
'aiBoolean',
|
|
136
|
+
'aiAsk',
|
|
137
|
+
'aiLocate'
|
|
138
|
+
])if (node in flow) {
|
|
139
|
+
const { [node]: prompt, ...options } = flow;
|
|
140
|
+
if (!prompt) return invalid(`missing prompt for ${node}`);
|
|
141
|
+
if (Object.hasOwn(raw, 'observe')) return invalid('`observe` is not supported in YAML flow items. Use agent.startObserving() from code instead.');
|
|
142
|
+
return step(node, {
|
|
143
|
+
prompt,
|
|
144
|
+
options
|
|
145
|
+
}, true);
|
|
146
|
+
}
|
|
147
|
+
if ('aiWaitFor' in flow) {
|
|
148
|
+
const { aiWaitFor: prompt, timeout, ...options } = raw;
|
|
149
|
+
if (!prompt) return invalid('missing prompt for aiWaitFor');
|
|
150
|
+
return step('aiWaitFor', {
|
|
151
|
+
prompt,
|
|
152
|
+
options: {
|
|
153
|
+
...options,
|
|
154
|
+
...void 0 === timeout ? {} : {
|
|
155
|
+
timeout,
|
|
156
|
+
timeoutMs: timeout
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
if ('sleep' in flow) {
|
|
162
|
+
const ms = 'string' == typeof flow.sleep ? Number.parseInt(flow.sleep, 10) : flow.sleep;
|
|
163
|
+
if (!Number.isFinite(ms) || ms <= 0) return invalid(`ms for sleep must be greater than 0, but got ${flow.sleep}`);
|
|
164
|
+
return step('sleep', {
|
|
165
|
+
ms
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if ("javascript" in flow) return step("javascript", {
|
|
169
|
+
script: flow.javascript
|
|
170
|
+
}, true);
|
|
171
|
+
if ('recordToReport' in flow || 'logScreenshot' in flow) return step('recordToReport', {
|
|
172
|
+
title: flow.recordToReport ?? flow.logScreenshot ?? 'untitled',
|
|
173
|
+
options: {
|
|
174
|
+
content: flow.content || ''
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
if ('aiInput' in flow) {
|
|
178
|
+
const { aiInput, value: rawValue, ...options } = raw;
|
|
179
|
+
const prompt = options.locate || aiInput || '';
|
|
180
|
+
const value = options.locate ? aiInput || rawValue : rawValue;
|
|
181
|
+
return step('action', {
|
|
182
|
+
name: 'Input',
|
|
183
|
+
params: {
|
|
184
|
+
...options,
|
|
185
|
+
...void 0 === value ? {} : {
|
|
186
|
+
value: String(value)
|
|
187
|
+
},
|
|
188
|
+
...prompt ? {
|
|
189
|
+
locate: (0, external_utils_js_namespaceObject.buildDetailedLocateParam)(prompt, options)
|
|
190
|
+
} : {}
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if ('aiKeyboardPress' in flow) {
|
|
195
|
+
const { aiKeyboardPress, ...options } = raw;
|
|
196
|
+
const prompt = options.locate ? options.locate : options.keyName ? aiKeyboardPress : void 0;
|
|
197
|
+
const keyName = options.locate ? aiKeyboardPress : options.keyName || aiKeyboardPress;
|
|
198
|
+
return step('action', {
|
|
199
|
+
name: 'KeyboardPress',
|
|
200
|
+
params: {
|
|
201
|
+
...options,
|
|
202
|
+
...keyName ? {
|
|
203
|
+
keyName
|
|
204
|
+
} : {},
|
|
205
|
+
...prompt ? {
|
|
206
|
+
locate: (0, external_utils_js_namespaceObject.buildDetailedLocateParam)(prompt, options)
|
|
207
|
+
} : {}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
if ('aiScroll' in flow) {
|
|
212
|
+
const { aiScroll, locate, ...options } = raw;
|
|
213
|
+
return step('aiScroll', {
|
|
214
|
+
prompt: locate ?? aiScroll ?? void 0,
|
|
215
|
+
options
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
if ('aiTap' in flow) {
|
|
219
|
+
const { aiTap, prompt, locate, ...tapOptions } = raw;
|
|
220
|
+
const nested = locate ?? ('object' == typeof aiTap && null !== aiTap ? aiTap.locate : void 0);
|
|
221
|
+
let locatePrompt;
|
|
222
|
+
let options = tapOptions;
|
|
223
|
+
if ('string' == typeof aiTap && aiTap) locatePrompt = aiTap;
|
|
224
|
+
else if (nested && 'object' == typeof nested && nested.prompt) {
|
|
225
|
+
const { prompt: nestedPrompt, ...nestedOptions } = nested;
|
|
226
|
+
locatePrompt = nestedPrompt;
|
|
227
|
+
options = {
|
|
228
|
+
...nestedOptions,
|
|
229
|
+
...tapOptions
|
|
230
|
+
};
|
|
231
|
+
} else locatePrompt = aiTap && 'object' == typeof aiTap && 'string' == typeof aiTap.prompt && aiTap.prompt ? Object.hasOwn(aiTap, 'images') || Object.hasOwn(aiTap, 'convertHttpImage2Base64') ? aiTap : aiTap.prompt : prompt || nested;
|
|
232
|
+
return locatePrompt ? step('aiTap', {
|
|
233
|
+
prompt: locatePrompt,
|
|
234
|
+
options
|
|
235
|
+
}) : invalid('missing prompt for aiTap');
|
|
236
|
+
}
|
|
237
|
+
if ('string' == typeof flow.runAdbShell && 'number' == typeof flow.timeout) return step('runAdbShell', {
|
|
238
|
+
command: flow.runAdbShell,
|
|
239
|
+
timeout: flow.timeout
|
|
240
|
+
}, true);
|
|
241
|
+
const action = actionSpace.find((item)=>item.interfaceAlias && Object.hasOwn(flow, item.interfaceAlias) || Object.hasOwn(flow, item.name));
|
|
242
|
+
if (!action) return step('legacyAction', {
|
|
243
|
+
flow
|
|
244
|
+
}, true);
|
|
245
|
+
const key = action?.interfaceAlias && Object.hasOwn(flow, action.interfaceAlias) ? action.interfaceAlias : action.name;
|
|
246
|
+
const value = flow[key];
|
|
247
|
+
if ('string' == typeof value) {
|
|
248
|
+
const shortcut = buildShortcutActionParam(action.name, action.interfaceAlias, value);
|
|
249
|
+
if (shortcut) return step('action', {
|
|
250
|
+
name: action.name,
|
|
251
|
+
params: shortcut
|
|
252
|
+
}, true);
|
|
253
|
+
if (isStringParamSchema(action.paramSchema)) return step('action', {
|
|
254
|
+
name: action.name,
|
|
255
|
+
params: value
|
|
256
|
+
}, true);
|
|
257
|
+
}
|
|
258
|
+
const prompt = 'string' == typeof value ? value : '';
|
|
259
|
+
const source = prompt ? {
|
|
260
|
+
...flow,
|
|
261
|
+
prompt
|
|
262
|
+
} : value && 'object' == typeof value ? value : flow;
|
|
263
|
+
const { locateParam, restParams } = (0, external_utils_js_namespaceObject.buildDetailedLocateParamAndRestParams)(prompt, source, [
|
|
264
|
+
action.name,
|
|
265
|
+
action.interfaceAlias ?? ''
|
|
266
|
+
]);
|
|
267
|
+
return step('action', {
|
|
268
|
+
name: action.name,
|
|
269
|
+
params: {
|
|
270
|
+
...restParams,
|
|
271
|
+
locate: locateParam
|
|
272
|
+
}
|
|
273
|
+
}, true);
|
|
274
|
+
}
|
|
275
|
+
const legacyDocumentId = (sourcePath)=>`legacy-yaml:${sourcePath}`;
|
|
276
|
+
const collectLegacyYamlTask = (task, taskIndex, sourcePath = '<inline-yaml>', actionSpace = [])=>{
|
|
277
|
+
const documentId = legacyDocumentId(sourcePath);
|
|
278
|
+
const projectId = 'legacy-yaml';
|
|
279
|
+
return {
|
|
280
|
+
caseId: `${documentId}:task:${taskIndex}`,
|
|
281
|
+
projectId,
|
|
282
|
+
sourcePath,
|
|
283
|
+
caseIndex: taskIndex,
|
|
284
|
+
definition: {
|
|
285
|
+
name: task.name,
|
|
286
|
+
onFailure: task.continueOnError ? 'continue' : 'stop-document',
|
|
287
|
+
steps: Array.isArray(task.flow) ? task.flow.map((flowItem)=>compileLegacyFlowItem(flowItem, actionSpace)) : [
|
|
288
|
+
{
|
|
289
|
+
node: 'legacyValidationError',
|
|
290
|
+
input: {
|
|
291
|
+
message: 'missing flow in task'
|
|
292
|
+
},
|
|
293
|
+
meta: {
|
|
294
|
+
continueOnError: false
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
const legacyYamlDocument = (sourcePath, cases)=>({
|
|
302
|
+
documentId: legacyDocumentId(sourcePath),
|
|
303
|
+
projectId: 'legacy-yaml',
|
|
304
|
+
sourcePath,
|
|
305
|
+
lifecycle: {
|
|
306
|
+
beforeAll: [],
|
|
307
|
+
beforeEach: [],
|
|
308
|
+
afterEach: [],
|
|
309
|
+
afterAll: []
|
|
310
|
+
},
|
|
311
|
+
cases
|
|
312
|
+
});
|
|
313
|
+
const collectLegacyYamlTaskDocument = (task, taskIndex, sourcePath = '<inline-yaml>', actionSpace = [])=>legacyYamlDocument(sourcePath, [
|
|
314
|
+
collectLegacyYamlTask(task, taskIndex, sourcePath, actionSpace)
|
|
315
|
+
]);
|
|
316
|
+
const collectLegacyYamlDocument = (script, sourcePath = '<inline-yaml>', actionSpace = [], identity)=>{
|
|
317
|
+
const document = legacyYamlDocument(sourcePath, (script.tasks ?? []).map((task, taskIndex)=>collectLegacyYamlTask(task, taskIndex, sourcePath, actionSpace)));
|
|
318
|
+
if (!identity) return document;
|
|
319
|
+
return {
|
|
320
|
+
...document,
|
|
321
|
+
documentId: identity.documentId,
|
|
322
|
+
projectId: identity.projectId,
|
|
323
|
+
cases: document.cases.map((item)=>({
|
|
324
|
+
...item,
|
|
325
|
+
projectId: identity.projectId,
|
|
326
|
+
caseId: identity.cases.find((original)=>original.caseIndex === item.caseIndex).caseId
|
|
327
|
+
}))
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
exports.collectLegacyYamlDocument = __webpack_exports__.collectLegacyYamlDocument;
|
|
331
|
+
exports.collectLegacyYamlTask = __webpack_exports__.collectLegacyYamlTask;
|
|
332
|
+
exports.collectLegacyYamlTaskDocument = __webpack_exports__.collectLegacyYamlTaskDocument;
|
|
333
|
+
exports.compileLegacyFlowItem = __webpack_exports__.compileLegacyFlowItem;
|
|
334
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
335
|
+
"collectLegacyYamlDocument",
|
|
336
|
+
"collectLegacyYamlTask",
|
|
337
|
+
"collectLegacyYamlTaskDocument",
|
|
338
|
+
"compileLegacyFlowItem"
|
|
339
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
340
|
+
Object.defineProperty(exports, '__esModule', {
|
|
341
|
+
value: true
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
//# sourceMappingURL=test-runner-compat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yaml/test-runner-compat.js","sources":["webpack/runtime/define_property_getters","webpack/runtime/has_own_property","webpack/runtime/make_namespace_object","../../../src/yaml/test-runner-compat.ts"],"sourcesContent":["__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type {\n MidsceneYamlFlowItem,\n MidsceneYamlScript,\n MidsceneYamlTask,\n} from '@/types';\nimport { type ZodTypeAny, z } from 'zod';\nimport type {\n CollectedCase,\n CollectedWorkflowDocument,\n NormalizedStep,\n} from '../test-runner';\nimport {\n buildDetailedLocateParam,\n buildDetailedLocateParamAndRestParams,\n} from './utils';\n\nexport interface LegacyYamlActionIdentity {\n name: string;\n interfaceAlias?: string;\n paramSchema?: ZodTypeAny;\n}\n\nconst isStringParamSchema = (schema?: ZodTypeAny): boolean => {\n if (!schema) return false;\n\n const schemaDef = (schema as any)?._def;\n if (!schemaDef?.typeName) return false;\n\n switch (schemaDef.typeName) {\n case z.ZodFirstPartyTypeKind.ZodString:\n case z.ZodFirstPartyTypeKind.ZodEnum:\n case z.ZodFirstPartyTypeKind.ZodNativeEnum:\n return true;\n case z.ZodFirstPartyTypeKind.ZodLiteral:\n return typeof schemaDef.value === 'string';\n case z.ZodFirstPartyTypeKind.ZodOptional:\n case z.ZodFirstPartyTypeKind.ZodNullable:\n case z.ZodFirstPartyTypeKind.ZodDefault:\n return isStringParamSchema(schemaDef.innerType);\n case z.ZodFirstPartyTypeKind.ZodEffects:\n return isStringParamSchema(schemaDef.schema);\n case z.ZodFirstPartyTypeKind.ZodPipeline:\n return isStringParamSchema(schemaDef.out);\n case z.ZodFirstPartyTypeKind.ZodUnion: {\n const options = schemaDef.options as ZodTypeAny[] | undefined;\n return Array.isArray(options)\n ? options.every((option) => isStringParamSchema(option))\n : false;\n }\n default:\n return false;\n }\n};\n\nconst buildShortcutActionParam = (\n actionName: string,\n interfaceAlias: string | undefined,\n value: string,\n) => {\n if (actionName === 'Launch' || interfaceAlias === 'launch') {\n return { uri: value };\n }\n\n if (actionName === 'Terminate' || interfaceAlias === 'terminate') {\n return { uri: value };\n }\n\n if (\n actionName === 'RunAdbShell' ||\n interfaceAlias === 'runAdbShell' ||\n actionName === 'RunHdcShell' ||\n interfaceAlias === 'runHdcShell'\n ) {\n return { command: value };\n }\n\n return undefined;\n};\n\n/** Translate known syntax; defer ActionSpace-dependent grammar to the YAML host. */\nexport function compileLegacyFlowItem(\n flowItem: MidsceneYamlFlowItem,\n actionSpace: readonly LegacyYamlActionIdentity[] = [],\n): NormalizedStep {\n if (\n typeof flowItem !== 'object' ||\n flowItem === null ||\n Array.isArray(flowItem)\n )\n return {\n node: 'legacyValidationError',\n input: { message: 'flow item must be an object' },\n meta: { continueOnError: false },\n };\n const raw = flowItem as Record<string, any>;\n const { name, ...flow } = raw;\n const step = (\n node: string,\n input: Record<string, unknown>,\n captureResult = false,\n ): NormalizedStep => ({\n node,\n input,\n meta: {\n continueOnError: false,\n ...(captureResult\n ? {\n captureResult: true,\n ...(typeof name === 'string' && name.length > 0\n ? { resultName: name }\n : {}),\n }\n : {}),\n },\n });\n const invalid = (message: string) =>\n step('legacyValidationError', { message });\n if ('Finalize' in flow) return step('Finalize', {});\n if ('aiAct' in flow || 'aiAction' in flow || 'ai' in flow) {\n const { aiAct, aiAction, ai, instruction, ...options } = raw;\n const actionPrompt = aiAct ?? aiAction ?? ai;\n const hasPrompt = (value: any) =>\n (typeof value === 'string' && value) ||\n (value &&\n typeof value === 'object' &&\n typeof value.prompt === 'string' &&\n value.prompt);\n const prompt = hasPrompt(instruction)\n ? instruction\n : hasPrompt(actionPrompt)\n ? actionPrompt\n : undefined;\n return prompt\n ? step('aiAct', { prompt, options })\n : invalid('missing prompt for ai (aiAct)');\n }\n if ('runGherkinScenario' in flow) {\n return flow.runGherkinScenario\n ? step('runGherkinScenario', {\n scenario: flow.runGherkinScenario,\n options: { cacheable: false },\n })\n : invalid('missing scenario for runGherkinScenario');\n }\n if ('aiAssert' in flow) {\n const { aiAssert: prompt, errorMessage: message, ...options } = flow;\n if (!prompt) return invalid('missing prompt for aiAssert');\n if (Object.hasOwn(raw, 'observe'))\n return invalid(\n '`observe` is not supported in YAML aiAssert. Use agent.startObserving() from code instead.',\n );\n return step(\n 'aiAssert',\n {\n prompt,\n options: { ...options, keepRawResponse: true },\n message,\n },\n true,\n );\n }\n for (const node of [\n 'aiQuery',\n 'aiNumber',\n 'aiString',\n 'aiBoolean',\n 'aiAsk',\n 'aiLocate',\n ]) {\n if (node in flow) {\n const { [node]: prompt, ...options } = flow;\n if (!prompt) return invalid(`missing prompt for ${node}`);\n if (Object.hasOwn(raw, 'observe'))\n return invalid(\n '`observe` is not supported in YAML flow items. Use agent.startObserving() from code instead.',\n );\n return step(node, { prompt, options }, true);\n }\n }\n if ('aiWaitFor' in flow) {\n const { aiWaitFor: prompt, timeout, ...options } = raw;\n if (!prompt) return invalid('missing prompt for aiWaitFor');\n return step('aiWaitFor', {\n prompt,\n options: {\n ...options,\n ...(timeout === undefined ? {} : { timeout, timeoutMs: timeout }),\n },\n });\n }\n if ('sleep' in flow) {\n const ms =\n typeof flow.sleep === 'string'\n ? Number.parseInt(flow.sleep, 10)\n : flow.sleep;\n // The old player rejected invalid sleep only when execution reached it.\n // Keep both that timing and its error message inside the YAML boundary.\n if (!Number.isFinite(ms) || ms <= 0)\n return invalid(\n `ms for sleep must be greater than 0, but got ${flow.sleep}`,\n );\n return step('sleep', { ms });\n }\n if ('javascript' in flow)\n return step('javascript', { script: flow.javascript }, true);\n if ('recordToReport' in flow || 'logScreenshot' in flow)\n return step('recordToReport', {\n title: flow.recordToReport ?? flow.logScreenshot ?? 'untitled',\n options: { content: flow.content || '' },\n });\n if ('aiInput' in flow) {\n const { aiInput, value: rawValue, ...options } = raw;\n const prompt = options.locate || aiInput || '';\n const value = options.locate ? aiInput || rawValue : rawValue;\n return step('action', {\n name: 'Input',\n params: {\n ...options,\n ...(value === undefined ? {} : { value: String(value) }),\n ...(prompt\n ? { locate: buildDetailedLocateParam(prompt, options) }\n : {}),\n },\n });\n }\n if ('aiKeyboardPress' in flow) {\n const { aiKeyboardPress, ...options } = raw;\n const prompt = options.locate\n ? options.locate\n : options.keyName\n ? aiKeyboardPress\n : undefined;\n const keyName = options.locate\n ? aiKeyboardPress\n : options.keyName || aiKeyboardPress;\n return step('action', {\n name: 'KeyboardPress',\n params: {\n ...options,\n ...(keyName ? { keyName } : {}),\n ...(prompt\n ? { locate: buildDetailedLocateParam(prompt, options) }\n : {}),\n },\n });\n }\n if ('aiScroll' in flow) {\n const { aiScroll, locate, ...options } = raw;\n return step('aiScroll', {\n prompt: locate ?? aiScroll ?? undefined,\n options,\n });\n }\n if ('aiTap' in flow) {\n const { aiTap, prompt, locate, ...tapOptions } = raw;\n const nested =\n locate ??\n (typeof aiTap === 'object' && aiTap !== null ? aiTap.locate : undefined);\n let locatePrompt: any;\n let options = tapOptions;\n if (typeof aiTap === 'string' && aiTap) {\n locatePrompt = aiTap;\n } else if (nested && typeof nested === 'object' && nested.prompt) {\n const { prompt: nestedPrompt, ...nestedOptions } = nested;\n locatePrompt = nestedPrompt;\n options = { ...nestedOptions, ...tapOptions };\n } else if (\n aiTap &&\n typeof aiTap === 'object' &&\n typeof aiTap.prompt === 'string' &&\n aiTap.prompt\n ) {\n // Keep structured prompt data such as images inside the private YAML\n // adapter. A prompt-only object retains the existing normalized string\n // form used by cached-plan and variable-like legacy inputs.\n locatePrompt =\n Object.hasOwn(aiTap, 'images') ||\n Object.hasOwn(aiTap, 'convertHttpImage2Base64')\n ? aiTap\n : aiTap.prompt;\n } else {\n locatePrompt = prompt || nested;\n }\n return locatePrompt\n ? step('aiTap', { prompt: locatePrompt, options })\n : invalid('missing prompt for aiTap');\n }\n if (typeof flow.runAdbShell === 'string' && typeof flow.timeout === 'number')\n return step(\n 'runAdbShell',\n { command: flow.runAdbShell, timeout: flow.timeout },\n true,\n );\n const action = actionSpace.find(\n (item) =>\n (item.interfaceAlias && Object.hasOwn(flow, item.interfaceAlias)) ||\n Object.hasOwn(flow, item.name),\n );\n if (!action) return step('legacyAction', { flow }, true);\n const key =\n action?.interfaceAlias && Object.hasOwn(flow, action.interfaceAlias)\n ? action.interfaceAlias\n : action.name;\n const value = flow[key];\n if (typeof value === 'string') {\n const shortcut = buildShortcutActionParam(\n action.name,\n action.interfaceAlias,\n value,\n );\n if (shortcut)\n return step(\n 'action',\n {\n name: action.name,\n params: shortcut,\n },\n true,\n );\n if (isStringParamSchema(action.paramSchema))\n return step('action', { name: action.name, params: value }, true);\n }\n const prompt = typeof value === 'string' ? value : '';\n const source = prompt\n ? { ...flow, prompt }\n : value && typeof value === 'object'\n ? value\n : flow;\n const { locateParam, restParams } = buildDetailedLocateParamAndRestParams(\n prompt,\n source,\n [action.name, action.interfaceAlias ?? ''],\n );\n return step(\n 'action',\n { name: action.name, params: { ...restParams, locate: locateParam } },\n true,\n );\n}\n\nconst legacyDocumentId = (sourcePath: string): string =>\n `legacy-yaml:${sourcePath}`;\n\n/** Compile one legacy task into a Runner Case with its original task index. */\nexport const collectLegacyYamlTask = (\n task: MidsceneYamlTask,\n taskIndex: number,\n sourcePath = '<inline-yaml>',\n actionSpace: readonly LegacyYamlActionIdentity[] = [],\n): CollectedCase => {\n const documentId = legacyDocumentId(sourcePath);\n const projectId = 'legacy-yaml';\n return {\n caseId: `${documentId}:task:${taskIndex}`,\n projectId,\n sourcePath,\n caseIndex: taskIndex,\n definition: {\n name: task.name,\n onFailure: task.continueOnError ? 'continue' : 'stop-document',\n steps: Array.isArray(task.flow)\n ? task.flow.map((flowItem) =>\n compileLegacyFlowItem(flowItem, actionSpace),\n )\n : [\n {\n node: 'legacyValidationError',\n input: { message: 'missing flow in task' },\n meta: { continueOnError: false },\n },\n ],\n },\n };\n};\n\nconst legacyYamlDocument = (\n sourcePath: string,\n cases: CollectedCase[],\n): CollectedWorkflowDocument => ({\n documentId: legacyDocumentId(sourcePath),\n projectId: 'legacy-yaml',\n sourcePath,\n lifecycle: {\n beforeAll: [],\n beforeEach: [],\n afterEach: [],\n afterAll: [],\n },\n cases,\n});\n\n/** Compile one legacy task into a one-Case Runner document. */\nexport const collectLegacyYamlTaskDocument = (\n task: MidsceneYamlTask,\n taskIndex: number,\n sourcePath = '<inline-yaml>',\n actionSpace: readonly LegacyYamlActionIdentity[] = [],\n): CollectedWorkflowDocument =>\n legacyYamlDocument(sourcePath, [\n collectLegacyYamlTask(task, taskIndex, sourcePath, actionSpace),\n ]);\n\n/** Compile the legacy tasks/flow shape into the Runner document/case/step IR. */\nexport const collectLegacyYamlDocument = (\n script: MidsceneYamlScript,\n sourcePath = '<inline-yaml>',\n actionSpace: readonly LegacyYamlActionIdentity[] = [],\n identity?: CollectedWorkflowDocument,\n): CollectedWorkflowDocument => {\n const document = legacyYamlDocument(\n sourcePath,\n (script.tasks ?? []).map((task, taskIndex) =>\n collectLegacyYamlTask(task, taskIndex, sourcePath, actionSpace),\n ),\n );\n if (!identity) return document;\n return {\n ...document,\n documentId: identity.documentId,\n projectId: identity.projectId,\n cases: document.cases.map((item) => ({\n ...item,\n projectId: identity.projectId,\n caseId: identity.cases.find(\n (original) => original.caseIndex === item.caseIndex,\n )!.caseId,\n })),\n };\n};\n"],"names":["__webpack_require__","definition","key","Object","obj","prop","Symbol","isStringParamSchema","schema","schemaDef","z","options","Array","option","buildShortcutActionParam","actionName","interfaceAlias","value","compileLegacyFlowItem","flowItem","actionSpace","raw","name","flow","step","node","input","captureResult","invalid","message","aiAct","aiAction","ai","instruction","actionPrompt","hasPrompt","prompt","undefined","timeout","ms","Number","aiInput","rawValue","String","buildDetailedLocateParam","aiKeyboardPress","keyName","aiScroll","locate","aiTap","tapOptions","nested","locatePrompt","nestedPrompt","nestedOptions","action","item","shortcut","source","locateParam","restParams","buildDetailedLocateParamAndRestParams","legacyDocumentId","sourcePath","collectLegacyYamlTask","task","taskIndex","documentId","projectId","legacyYamlDocument","cases","collectLegacyYamlTaskDocument","collectLegacyYamlDocument","script","identity","document","original"],"mappings":";;;IAAAA,oBAAoB,CAAC,GAAG,CAAC,UAASC;QACjC,IAAI,IAAIC,OAAOD,WACR,IAAGD,oBAAoB,CAAC,CAACC,YAAYC,QAAQ,CAACF,oBAAoB,CAAC,CAAC,UAASE,MACzEC,OAAO,cAAc,CAAC,UAASD,KAAK;YAAE,YAAY;YAAM,KAAKD,UAAU,CAACC,IAAI;QAAC;IAGzF;;;ICNAF,oBAAoB,CAAC,GAAG,CAACI,KAAKC,OAAUF,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAACC,KAAKC;;;ICClFL,oBAAoB,CAAC,GAAG,CAAC;QACxB,IAAG,AAAkB,eAAlB,OAAOM,UAA0BA,OAAO,WAAW,EACrDH,OAAO,cAAc,CAAC,UAASG,OAAO,WAAW,EAAE;YAAE,OAAO;QAAS;QAEtEH,OAAO,cAAc,CAAC,UAAS,cAAc;YAAE,OAAO;QAAK;IAC5D;;;;;;;;;;;;ACgBA,MAAMI,sBAAsB,CAACC;IAC3B,IAAI,CAACA,QAAQ,OAAO;IAEpB,MAAMC,YAAaD,QAAgB;IACnC,IAAI,CAACC,WAAW,UAA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