@swmansion/argent 0.35.1-next.11 → 0.35.1-next.12
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/cli-cmds.mjs
CHANGED
|
@@ -38588,7 +38588,7 @@ function isCi(env = process.env) {
|
|
|
38588
38588
|
var SESSION_ID2 = randomUUID5();
|
|
38589
38589
|
function readCliVersion() {
|
|
38590
38590
|
if (true) {
|
|
38591
|
-
return "0.35.1-next.
|
|
38591
|
+
return "0.35.1-next.10";
|
|
38592
38592
|
}
|
|
38593
38593
|
return "0.0.0";
|
|
38594
38594
|
}
|
package/dist/installer.mjs
CHANGED
|
@@ -17103,7 +17103,7 @@ function isCi(env = process.env) {
|
|
|
17103
17103
|
var SESSION_ID = randomUUID4();
|
|
17104
17104
|
function readCliVersion() {
|
|
17105
17105
|
if (true) {
|
|
17106
|
-
return "0.35.1-next.
|
|
17106
|
+
return "0.35.1-next.10";
|
|
17107
17107
|
}
|
|
17108
17108
|
return "0.0.0";
|
|
17109
17109
|
}
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -38058,7 +38058,7 @@ async function startMcpServer(options) {
|
|
|
38058
38058
|
const autoDescribeOn = autoDescribeEnabled();
|
|
38059
38059
|
const whatsNewOn = whatsNewEnabled();
|
|
38060
38060
|
const installedVersion = getInstalledVersion();
|
|
38061
|
-
const highlightsVersion = true ? "0.35.1-next.
|
|
38061
|
+
const highlightsVersion = true ? "0.35.1-next.10" : installedVersion;
|
|
38062
38062
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
38063
38063
|
const trees = createTreeMemory();
|
|
38064
38064
|
const screenshots = createScreenshotMemory();
|
|
@@ -263,7 +263,7 @@ export interface ArgentToolArgs {
|
|
|
263
263
|
env?: {
|
|
264
264
|
[key: string]: string;
|
|
265
265
|
};
|
|
266
|
-
/** Save the script in the shutdown list.
|
|
266
|
+
/** Save the script in the shutdown list. Pending fragment cleanup runs before the script. The script's output reaches only later shutdown steps. stepCount counts shutdown entries. */
|
|
267
267
|
shutdown?: boolean;
|
|
268
268
|
};
|
|
269
269
|
"e2e-add-step": {
|
|
@@ -277,7 +277,7 @@ export interface ArgentToolArgs {
|
|
|
277
277
|
args?: string;
|
|
278
278
|
/** Milliseconds to sleep before executing this step during replay. */
|
|
279
279
|
delayMs?: number;
|
|
280
|
-
/** Save the call in the shutdown list.
|
|
280
|
+
/** Save the call in the shutdown list. Pending fragment cleanup runs before the call. stepCount counts shutdown entries. */
|
|
281
281
|
shutdown?: boolean;
|
|
282
282
|
};
|
|
283
283
|
"e2e-execute": {
|
package/dist/tool-server.cjs
CHANGED
|
@@ -72957,7 +72957,7 @@ function isCi(env = process.env) {
|
|
|
72957
72957
|
var SESSION_ID = (0, import_node_crypto3.randomUUID)();
|
|
72958
72958
|
function readCliVersion() {
|
|
72959
72959
|
if (true) {
|
|
72960
|
-
return "0.35.1-next.
|
|
72960
|
+
return "0.35.1-next.10";
|
|
72961
72961
|
}
|
|
72962
72962
|
return "0.0.0";
|
|
72963
72963
|
}
|
|
@@ -78710,6 +78710,67 @@ function keepRecordingOutput(session, block, doc, ranAgainst) {
|
|
|
78710
78710
|
}
|
|
78711
78711
|
}
|
|
78712
78712
|
}
|
|
78713
|
+
async function runDeferredShutdown(session, ctx) {
|
|
78714
|
+
const queued = session.deferredShutdown;
|
|
78715
|
+
if (!queued?.length) return void 0;
|
|
78716
|
+
delete session.deferredShutdown;
|
|
78717
|
+
const ranAgainst = recordingOutput(session, "shutdown");
|
|
78718
|
+
const output2 = { doc: structuredClone(ranAgainst) };
|
|
78719
|
+
const steps = [];
|
|
78720
|
+
const kept = [];
|
|
78721
|
+
let thrown;
|
|
78722
|
+
for (const run2 of [...queued].reverse()) {
|
|
78723
|
+
if (!ctx?.signal?.aborted) {
|
|
78724
|
+
try {
|
|
78725
|
+
await run2(ctx, output2, steps);
|
|
78726
|
+
} catch (error63) {
|
|
78727
|
+
thrown ??= { error: error63 };
|
|
78728
|
+
}
|
|
78729
|
+
}
|
|
78730
|
+
if (ctx?.signal?.aborted) kept.unshift(run2);
|
|
78731
|
+
}
|
|
78732
|
+
if (kept.length > 0) session.deferredShutdown = [...kept, ...session.deferredShutdown ?? []];
|
|
78733
|
+
keepRecordingOutput(session, "shutdown", output2.doc, ranAgainst);
|
|
78734
|
+
if (thrown) throw thrown.error;
|
|
78735
|
+
if (steps.length === 0) return void 0;
|
|
78736
|
+
const failed3 = steps.some((s) => {
|
|
78737
|
+
const status = s.status;
|
|
78738
|
+
return status === "fail" || status === "error";
|
|
78739
|
+
});
|
|
78740
|
+
return { ok: !failed3, steps };
|
|
78741
|
+
}
|
|
78742
|
+
function fragmentShutdownNote(report) {
|
|
78743
|
+
const total = report.steps.length;
|
|
78744
|
+
const count2 = (...statuses) => report.steps.filter((s) => statuses.includes(s.status ?? "")).length;
|
|
78745
|
+
const failed3 = count2("fail", "error");
|
|
78746
|
+
const skipped = count2("skip");
|
|
78747
|
+
return `Separately, the recording ran the kept shutdown: of the fragments recorded as run: steps, as a replay does before the shutdown steps (${total} ${total === 1 ? "step" : "steps"}` + (failed3 === 0 ? "" : `, ${failed3} failed; see fragmentShutdown`) + (skipped === 0 ? "" : `, ${skipped} skipped as cancelled, which a later shutdown call or the finish runs again`) + `).`;
|
|
78748
|
+
}
|
|
78749
|
+
async function afterDeferredShutdown(session, ctx, call) {
|
|
78750
|
+
const report = await runDeferredShutdown(session, ctx);
|
|
78751
|
+
if (!report) return call();
|
|
78752
|
+
const note = fragmentShutdownNote(report);
|
|
78753
|
+
let result;
|
|
78754
|
+
try {
|
|
78755
|
+
result = await call();
|
|
78756
|
+
} catch (err) {
|
|
78757
|
+
if (err instanceof Error) err.message = `${err.message} ${note}`;
|
|
78758
|
+
throw err;
|
|
78759
|
+
}
|
|
78760
|
+
const lead = /[.!?]$/.test(result.message) ? result.message : `${result.message}.`;
|
|
78761
|
+
return { ...result, message: `${lead} ${note}`, fragmentShutdown: report };
|
|
78762
|
+
}
|
|
78763
|
+
function deferredShutdownFirst(tool) {
|
|
78764
|
+
const record2 = tool.execute.bind(tool);
|
|
78765
|
+
return {
|
|
78766
|
+
...tool,
|
|
78767
|
+
async execute(services, params, ctx) {
|
|
78768
|
+
if (!params.shutdown) return record2(services, params, ctx);
|
|
78769
|
+
const session = await requireRecordingSession(params.project_root, params.name);
|
|
78770
|
+
return afterDeferredShutdown(session, ctx, () => record2(services, params, ctx));
|
|
78771
|
+
}
|
|
78772
|
+
};
|
|
78773
|
+
}
|
|
78713
78774
|
function recordedCount(flow, block) {
|
|
78714
78775
|
return block === "shutdown" ? flow.shutdown?.length ?? 0 : flow.steps.length;
|
|
78715
78776
|
}
|
|
@@ -164485,7 +164546,7 @@ var zodSchema70 = external_exports.object({
|
|
|
164485
164546
|
});
|
|
164486
164547
|
var flowStartRecordingTool = {
|
|
164487
164548
|
id: "e2e-start-recording",
|
|
164488
|
-
description: `Start recording a new e2e test, resetting .argent/e2e/<name>.yaml to an empty e2e test and replacing any existing one.
|
|
164549
|
+
description: `Start recording a new e2e test, resetting .argent/e2e/<name>.yaml to an empty e2e test and replacing any existing one. A restart runs pending fragment cleanup from the discarded recording and reports it in \`fragmentShutdown\`.
|
|
164489
164550
|
Use when you want to capture a reusable sequence of device interactions for later replay. Load the argent-create-e2e skill first: it holds the polish, audit and replay steps. Not for Apple TV or Android TV.
|
|
164490
164551
|
Returns { message, e2eTestFile, savedTo } and optionally { restarted, discardedSteps } if a live recording of the same e2e test was discarded.
|
|
164491
164552
|
Without a link, it creates that file and fails if the .argent/e2e/ directory cannot be created or the file cannot be written. Over a link (argent link or ARGENT_TOOLS_URL, also to 127.0.0.1), your client writes the file, and \`savedTo\` is its path on your computer, or null when that write failed.
|
|
@@ -164524,6 +164585,8 @@ and without a link, an edit that renumbers the steps drops their warnings.`,
|
|
|
164524
164585
|
failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to start recording of e2e test ${params.name}: ${failureSignal2.error_code}`
|
|
164525
164586
|
},
|
|
164526
164587
|
fileInputs: fileInputs3,
|
|
164588
|
+
// A restart may run the discarded take's fragment shutdown, on the device.
|
|
164589
|
+
longRunning: true,
|
|
164527
164590
|
services: () => ({}),
|
|
164528
164591
|
async execute(_services, params, ctx) {
|
|
164529
164592
|
if (params.env) {
|
|
@@ -164566,11 +164629,13 @@ and without a link, an edit that renumbers the steps drops their warnings.`,
|
|
|
164566
164629
|
}
|
|
164567
164630
|
);
|
|
164568
164631
|
if (replaced) {
|
|
164632
|
+
const fragmentShutdown = await runDeferredShutdown(replaced, ctx);
|
|
164569
164633
|
const reset = persist2 === "host" ? `${filePath} reset to an empty e2e test.` : `${filePath} is reset to an empty e2e test once your client applies \`savedTo\` (a null \`savedTo\` means it did not).`;
|
|
164570
164634
|
const lost = discardedSteps === void 0 ? "the previous take" : `the previous take (${discardedSteps} step${discardedSteps === 1 ? "" : "s"})`;
|
|
164571
164635
|
return {
|
|
164572
|
-
message: `Restarted recording "${params.name}" \u2014 ${lost} was discarded and ` + reset,
|
|
164636
|
+
message: `Restarted recording "${params.name}" \u2014 ${lost} was discarded and ` + reset + (fragmentShutdown ? ` ${fragmentShutdownNote(fragmentShutdown)}` : ""),
|
|
164573
164637
|
restarted: true,
|
|
164638
|
+
...fragmentShutdown ? { fragmentShutdown } : {},
|
|
164574
164639
|
...discardedSteps === void 0 ? {} : { discardedSteps },
|
|
164575
164640
|
e2eTestFile: flowFile,
|
|
164576
164641
|
flowFile,
|
|
@@ -167635,7 +167700,10 @@ async function activeFlowState(session, block) {
|
|
|
167635
167700
|
}
|
|
167636
167701
|
function reportsShutdown(result) {
|
|
167637
167702
|
const steps = result?.steps;
|
|
167638
|
-
return Array.isArray(steps) && steps.some((s) =>
|
|
167703
|
+
return Array.isArray(steps) && steps.some((s) => {
|
|
167704
|
+
const step = s;
|
|
167705
|
+
return step?.shutdown === true && step.status !== "skip";
|
|
167706
|
+
});
|
|
167639
167707
|
}
|
|
167640
167708
|
async function recordNothing(session, guidance, block) {
|
|
167641
167709
|
const { stepCount, note } = await activeFlowState(session, block);
|
|
@@ -167892,11 +167960,11 @@ var zodSchema71 = external_exports.object({
|
|
|
167892
167960
|
),
|
|
167893
167961
|
delayMs: external_exports.number().int().min(0).optional().describe("Milliseconds to sleep before executing this step during replay."),
|
|
167894
167962
|
shutdown: external_exports.boolean().optional().describe(
|
|
167895
|
-
"Save the call in the shutdown list.
|
|
167963
|
+
"Save the call in the shutdown list. Pending fragment cleanup runs before the call. stepCount counts shutdown entries."
|
|
167896
167964
|
)
|
|
167897
167965
|
});
|
|
167898
167966
|
function createFlowAddStepTool(registry2) {
|
|
167899
|
-
return {
|
|
167967
|
+
return deferredShutdownFirst({
|
|
167900
167968
|
id: "e2e-add-step",
|
|
167901
167969
|
description: `Execute one MCP tool and record its step in the e2e test named by \`name\` + \`project_root\`. Use when recording and you want each action run and captured; the recording must already be open.
|
|
167902
167970
|
A coordinate \`gesture-tap\` records as a portable \`tap\` selector step; \`restart-app\` as a \`launch\`. Use \`{{output:PATH}}\` in arguments to read prior script output. The tool resolves the values for the live call and saves the references in a \`tool:\` step.
|
|
@@ -167981,7 +168049,22 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
167981
168049
|
}
|
|
167982
168050
|
const runTarget = command === RUN_TARGET_COMMAND && params.delayMs === void 0 && !referencedArgs ? await captureRunTarget(session, args, project) : void 0;
|
|
167983
168051
|
const ranAgainst = recordingOutput(session, block);
|
|
167984
|
-
const sharedOutput = runTarget?.flow ? { doc: structuredClone(ranAgainst) } : void 0;
|
|
168052
|
+
const sharedOutput = runTarget?.flow ? { doc: structuredClone(ranAgainst), deferShutdown: block === "steps" } : void 0;
|
|
168053
|
+
let queued = false;
|
|
168054
|
+
const runUnrecordedShutdown = async () => {
|
|
168055
|
+
const run2 = sharedOutput?.deferredShutdown;
|
|
168056
|
+
if (!run2) return "";
|
|
168057
|
+
delete sharedOutput.deferredShutdown;
|
|
168058
|
+
const at = session.deferredShutdown?.indexOf(run2) ?? -1;
|
|
168059
|
+
if (at >= 0) session.deferredShutdown.splice(at, 1);
|
|
168060
|
+
else if (queued) return "";
|
|
168061
|
+
const steps = [];
|
|
168062
|
+
await run2(ctx, { doc: sharedOutput.doc }, steps).catch(() => void 0);
|
|
168063
|
+
const ok = !steps.some(
|
|
168064
|
+
(s) => ["fail", "error"].includes(s.status ?? "")
|
|
168065
|
+
);
|
|
168066
|
+
return ` No step was recorded, so the shutdown: of the fragment ran now (${ok ? "it passed" : "a step failed"}), and the device is as it would be after a replay of it.`;
|
|
168067
|
+
};
|
|
167985
168068
|
let prepared;
|
|
167986
168069
|
let toolResult;
|
|
167987
168070
|
try {
|
|
@@ -168027,8 +168110,9 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
168027
168110
|
if (linked && command === RUN_TARGET_COMMAND) {
|
|
168028
168111
|
const outcome = nestedOrchestratorOutcome(RUN_TARGET_COMMAND, toolResult);
|
|
168029
168112
|
if (outcome) {
|
|
168113
|
+
const ranShutdown = await runUnrecordedShutdown();
|
|
168030
168114
|
throw new FailureError(
|
|
168031
|
-
outcome.status === "fail" ? `Cannot record this call: the nested e2e test did not pass (${outcome.reason}). A replay over the same link fails at the same step. No step was recorded. Fix the nested e2e test, then call e2e-add-step again.` : `Cannot record this call: the nested e2e test did not run (${outcome.reason}). No step was recorded
|
|
168115
|
+
(outcome.status === "fail" ? `Cannot record this call: the nested e2e test did not pass (${outcome.reason}). A replay over the same link fails at the same step. No step was recorded. Fix the nested e2e test, then call e2e-add-step again.` : `Cannot record this call: the nested e2e test did not run (${outcome.reason}). No step was recorded.`) + ranShutdown,
|
|
168032
168116
|
{
|
|
168033
168117
|
error_code: FAILURE_CODES.FLOW_FILE_INVALID,
|
|
168034
168118
|
failure_stage: "flow_add_step_nested_failed",
|
|
@@ -168138,13 +168222,21 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
168138
168222
|
delayMs: params.delayMs
|
|
168139
168223
|
};
|
|
168140
168224
|
}
|
|
168225
|
+
if (step.kind === "run" && sharedOutput?.deferredShutdown) {
|
|
168226
|
+
(session.deferredShutdown ??= []).push(sharedOutput.deferredShutdown);
|
|
168227
|
+
queued = true;
|
|
168228
|
+
}
|
|
168141
168229
|
let savedTo;
|
|
168142
168230
|
let stepCount;
|
|
168143
168231
|
try {
|
|
168144
168232
|
({ savedTo, stepCount } = await appendStepToFlow(session, step, block));
|
|
168145
168233
|
} catch (err) {
|
|
168146
|
-
|
|
168147
|
-
|
|
168234
|
+
const ranShutdown = await runUnrecordedShutdown();
|
|
168235
|
+
if (getFailureSignal(err)?.failure_stage !== "flow_output_reference") {
|
|
168236
|
+
if (err instanceof Error) err.message += ranShutdown;
|
|
168237
|
+
throw err;
|
|
168238
|
+
}
|
|
168239
|
+
const refused = (err instanceof Error ? err.message : String(err)) + ranShutdown;
|
|
168148
168240
|
throw wrapFailure(
|
|
168149
168241
|
err,
|
|
168150
168242
|
{
|
|
@@ -168169,8 +168261,8 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
168169
168261
|
});
|
|
168170
168262
|
}
|
|
168171
168263
|
const baselineWrites = project instanceof ClientProjectAccess && ctx?.flowStack === void 0 ? project.baselineDirectives() : [];
|
|
168172
|
-
const
|
|
168173
|
-
const notes = [warning,
|
|
168264
|
+
const ranShutdownNow = block === "steps" && step.kind === "run" && reportsShutdown(toolResult) ? `${step.flow} ran its shutdown: steps at the end of this call (its files came with the call, or it started its own chromium app); a replay runs them at the end of the e2e test` : void 0;
|
|
168265
|
+
const notes = [warning, ranShutdownNow].filter((n) => n !== void 0).join("; ");
|
|
168174
168266
|
return {
|
|
168175
168267
|
message: `${params.shutdown ? "Shutdown step" : "Step"} added to "${params.name}" e2e test${notes ? ` \u2014 ${notes}` : ""}`,
|
|
168176
168268
|
toolResult,
|
|
@@ -168180,7 +168272,7 @@ Returns { message, stepCount, recorded, savedTo }; \`recorded\`, not the status,
|
|
|
168180
168272
|
...baselineWrites.length > 0 ? { baselineWrites } : {}
|
|
168181
168273
|
};
|
|
168182
168274
|
}
|
|
168183
|
-
};
|
|
168275
|
+
});
|
|
168184
168276
|
}
|
|
168185
168277
|
|
|
168186
168278
|
// ../tool-server/src/tools/flows/flow-insert-echo.ts
|
|
@@ -168331,10 +168423,10 @@ var zodSchema74 = external_exports.object({
|
|
|
168331
168423
|
"Environment overrides for this script. Argent uses them immediately and saves them on the step. Values can include {{secret:NAME}} or {{output:PATH}}."
|
|
168332
168424
|
),
|
|
168333
168425
|
shutdown: external_exports.boolean().optional().describe(
|
|
168334
|
-
"Save the script in the shutdown list.
|
|
168426
|
+
"Save the script in the shutdown list. Pending fragment cleanup runs before the script. The script's output reaches only later shutdown steps. stepCount counts shutdown entries."
|
|
168335
168427
|
)
|
|
168336
168428
|
});
|
|
168337
|
-
var flowAddScriptTool = {
|
|
168429
|
+
var flowAddScriptTool = deferredShutdownFirst({
|
|
168338
168430
|
id: "e2e-add-script",
|
|
168339
168431
|
description: `Run a local JavaScript (.mjs, .js) or TypeScript (.mts, .ts) file and record it as a script step. Use when the user requests a local script in an active recording. Call it where the script must run. A successful script updates the shared output and returns it as \`outputJson\`. Later steps can read it with \`{{output:PATH}}\`. Use \`shutdown: true\` for cleanup scripts. Returns \`status\`, \`reason\` and \`stepCount\`. A failed script is not recorded. Check \`reason\` and the affected state before retrying. Record without a link (argent link or ARGENT_TOOLS_URL).`,
|
|
168340
168432
|
zodSchema: zodSchema74,
|
|
@@ -168449,7 +168541,7 @@ var flowAddScriptTool = {
|
|
|
168449
168541
|
savedTo
|
|
168450
168542
|
};
|
|
168451
168543
|
}
|
|
168452
|
-
};
|
|
168544
|
+
});
|
|
168453
168545
|
|
|
168454
168546
|
// ../tool-server/src/tools/flows/flow-finish-recording.ts
|
|
168455
168547
|
init_zod();
|
|
@@ -168499,12 +168591,14 @@ var zodSchema75 = external_exports.object({
|
|
|
168499
168591
|
});
|
|
168500
168592
|
var flowFinishRecordingTool = {
|
|
168501
168593
|
id: "e2e-finish-recording",
|
|
168502
|
-
description: `Finish recording the e2e test named by \`name\` + \`project_root\`, leaving recordings under any other key untouched. Returns the final YAML and a step summary, including \`shutdownSteps\` when shutdown has entries. Use when you have added all desired steps and want to finalize the e2e test file. Fails if that e2e test has no recording in progress.
|
|
168594
|
+
description: `Finish recording the e2e test named by \`name\` + \`project_root\`, leaving recordings under any other key untouched. Returns the final YAML and a step summary, including \`shutdownSteps\` when shutdown has entries. Runs any pending fragment cleanup first and reports it in \`fragmentShutdown\`. Use when you have added all desired steps and want to finalize the e2e test file. Fails if that e2e test has no recording in progress.
|
|
168503
168595
|
A warning e2e-add-step raised on a recorded \`await-ui-element\` is repeated in \`summary\` as a \`warning:\` line right below its step, and \`message\` counts them by kind. Read them before you convert a wait to \`await:\`/\`assert:\` or replay the e2e test.
|
|
168504
168596
|
You can still edit the .yaml file directly afterwards to remove or reorder steps.`,
|
|
168505
168597
|
zodSchema: zodSchema75,
|
|
168506
168598
|
fileInputs: PROJECT_ROOT_INPUT,
|
|
168507
168599
|
aliases: ["flow-finish-recording"],
|
|
168600
|
+
// It may run the fragments' shutdown, on the device.
|
|
168601
|
+
longRunning: true,
|
|
168508
168602
|
interaction: {
|
|
168509
168603
|
// Name the flow: other recordings stay live, so an unqualified message would
|
|
168510
168604
|
// not identify which one.
|
|
@@ -168516,12 +168610,19 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
|
|
|
168516
168610
|
failedMsg: ({ params, failureSignal: failureSignal2 }) => `Failed to finish recording of e2e test ${params.name}: ${failureSignal2.error_code}`
|
|
168517
168611
|
},
|
|
168518
168612
|
services: () => ({}),
|
|
168519
|
-
async execute(_services, params) {
|
|
168613
|
+
async execute(_services, params, ctx) {
|
|
168614
|
+
let fragmentShutdown;
|
|
168520
168615
|
const { filePath, flowFile, savedTo, flow, summary, headline } = await withFlowFileLock(
|
|
168521
168616
|
params.project_root,
|
|
168522
168617
|
params.name,
|
|
168523
168618
|
async () => {
|
|
168524
168619
|
const session = await requireRecordingSession(params.project_root, params.name);
|
|
168620
|
+
fragmentShutdown = await runDeferredShutdown(session, ctx);
|
|
168621
|
+
if (ctx?.signal?.aborted && session.deferredShutdown?.length) {
|
|
168622
|
+
throw new Error(
|
|
168623
|
+
`The finish was cancelled before the kept shutdown: of the fragments recorded as run: steps ran, so the recording "${params.name}" is still open. Call e2e-finish-recording again.`
|
|
168624
|
+
);
|
|
168625
|
+
}
|
|
168525
168626
|
const filePath2 = session.filePath;
|
|
168526
168627
|
let flowFile2;
|
|
168527
168628
|
let savedTo2;
|
|
@@ -168554,15 +168655,22 @@ You can still edit the .yaml file directly afterwards to remove or reorder steps
|
|
|
168554
168655
|
clearRecordingSession(session);
|
|
168555
168656
|
return { filePath: filePath2, flowFile: flowFile2, savedTo: savedTo2, flow: flow2, summary: summary2, headline: headline2 };
|
|
168556
168657
|
}
|
|
168557
|
-
)
|
|
168658
|
+
).catch((err) => {
|
|
168659
|
+
if (fragmentShutdown && err instanceof Error) {
|
|
168660
|
+
err.message = `${err.message} ${fragmentShutdownNote(fragmentShutdown)}`;
|
|
168661
|
+
}
|
|
168662
|
+
throw err;
|
|
168663
|
+
});
|
|
168664
|
+
const ran = fragmentShutdown;
|
|
168558
168665
|
return {
|
|
168559
168666
|
// Name the counts in `message` as well. A caller that reads only
|
|
168560
168667
|
// `message` would otherwise polish blind.
|
|
168561
|
-
message: `Finished recording "${params.name}" e2e test (${flow.steps.length} steps` + (flow.shutdown ? `, ${flow.shutdown.length} shutdown steps` : "") + `)` + headline,
|
|
168668
|
+
message: `Finished recording "${params.name}" e2e test (${flow.steps.length} steps` + (flow.shutdown ? `, ${flow.shutdown.length} shutdown steps` : "") + `)` + headline + (ran ? `. ${fragmentShutdownNote(ran)}` : ""),
|
|
168562
168669
|
path: filePath,
|
|
168563
168670
|
executionPrerequisite: flow.executionPrerequisite,
|
|
168564
168671
|
steps: flow.steps.length,
|
|
168565
168672
|
...flow.shutdown ? { shutdownSteps: flow.shutdown.length } : {},
|
|
168673
|
+
...ran ? { fragmentShutdown: ran } : {},
|
|
168566
168674
|
summary,
|
|
168567
168675
|
e2eTestFile: flowFile,
|
|
168568
168676
|
flowFile,
|
|
@@ -171864,12 +171972,16 @@ Without a link, every step kind runs.`,
|
|
|
171864
171972
|
}
|
|
171865
171973
|
const caller = ctx?.flowOutput;
|
|
171866
171974
|
if (caller) state3.output = { doc: caller.doc };
|
|
171867
|
-
|
|
171868
|
-
|
|
171869
|
-
}
|
|
171870
|
-
|
|
171975
|
+
if (caller?.deferShutdown && !thrown && canDeferShutdown(state3, viaUpload)) {
|
|
171976
|
+
caller.deferredShutdown = deferShutdown(state3);
|
|
171977
|
+
} else {
|
|
171978
|
+
try {
|
|
171979
|
+
await execShutdown(state3);
|
|
171980
|
+
} catch (error63) {
|
|
171981
|
+
thrown ??= { error: error63 };
|
|
171982
|
+
}
|
|
171983
|
+
if (caller) caller.shutdownDoc = state3.output.doc;
|
|
171871
171984
|
}
|
|
171872
|
-
if (caller) caller.shutdownDoc = state3.output.doc;
|
|
171873
171985
|
if (thrown) throw thrown.error;
|
|
171874
171986
|
} finally {
|
|
171875
171987
|
aborted2 = state3.signal?.aborted === true;
|
|
@@ -172260,6 +172372,36 @@ async function execShutdown(state3) {
|
|
|
172260
172372
|
await drainShutdown(state3, 0, thrown);
|
|
172261
172373
|
if (thrown.length > 0) throw thrown[0];
|
|
172262
172374
|
}
|
|
172375
|
+
function canDeferShutdown(state3, viaUpload) {
|
|
172376
|
+
return state3.shutdownQueue.length > 0 && !state3.signal?.aborted && !viaUpload && state3.owned.length === 0;
|
|
172377
|
+
}
|
|
172378
|
+
function deferShutdown(state3) {
|
|
172379
|
+
const queue = state3.shutdownQueue;
|
|
172380
|
+
return async (ctx, output2, reports) => {
|
|
172381
|
+
const { onStepReport: _, ...rest } = state3;
|
|
172382
|
+
const later = {
|
|
172383
|
+
...rest,
|
|
172384
|
+
ctx,
|
|
172385
|
+
signal: ctx?.signal,
|
|
172386
|
+
reports,
|
|
172387
|
+
stopped: false,
|
|
172388
|
+
pinned: false,
|
|
172389
|
+
owned: [],
|
|
172390
|
+
output: output2,
|
|
172391
|
+
scriptLogBudget: createScriptLogBudget(),
|
|
172392
|
+
...ctx?.emitProgress ? { onStepReport: ctx.emitProgress } : {},
|
|
172393
|
+
shutdownQueue: [...queue],
|
|
172394
|
+
inShutdown: false
|
|
172395
|
+
};
|
|
172396
|
+
try {
|
|
172397
|
+
await execShutdown(later);
|
|
172398
|
+
} finally {
|
|
172399
|
+
for (let i = later.owned.length - 1; i >= 0; i--) {
|
|
172400
|
+
await teardownBootedChromium(state3.registry, later.owned[i]);
|
|
172401
|
+
}
|
|
172402
|
+
}
|
|
172403
|
+
};
|
|
172404
|
+
}
|
|
172263
172405
|
async function drainShutdown(state3, floor, thrown) {
|
|
172264
172406
|
while (state3.shutdownQueue.length > floor) {
|
|
172265
172407
|
const next = state3.shutdownQueue.pop();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swmansion/argent",
|
|
3
|
-
"version": "0.35.1-next.
|
|
3
|
+
"version": "0.35.1-next.12",
|
|
4
4
|
"mcpName": "io.github.software-mansion/argent",
|
|
5
5
|
"description": "MCP server for iOS Simulator, Android Emulator, Chromium app and Mac app control",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"vitest": "^5.0.5",
|
|
99
99
|
"yaml": "^2.9.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "e58172c74a8a0372f07e8cd572af0049ff178306"
|
|
102
102
|
}
|
|
@@ -39,9 +39,11 @@ Obey these lifecycle rules:
|
|
|
39
39
|
|
|
40
40
|
## Record cleanup after the main steps
|
|
41
41
|
|
|
42
|
-
Pass `shutdown: true` to `e2e-add-step` or `e2e-add-script` for cleanup. Use the same flag on `e2e-add-echo` to label it. Actions and scripts run
|
|
42
|
+
Pass `shutdown: true` to `e2e-add-step` or `e2e-add-script` for cleanup. Use the same flag on `e2e-add-echo` to label it. Actions and scripts run during the call. Check the `recorded` line for the `shutdown` prefix and read any wait warning before continuing.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
A fragment recorded as `run:` in the main list usually defers cleanup until the first shutdown action or script, or until `e2e-finish-recording`. Read `fragmentShutdown` and the call message before assuming cleanup passed. If the call was cancelled, finish the recording or retry the shutdown call to run queued cleanup.
|
|
45
|
+
|
|
46
|
+
For an uploaded fragment or one that starts its own Chromium app, read the message for cleanup that ran immediately. If later steps need the state it removed, record the fragment's main steps individually and its cleanup with `shutdown: true`. Replace those steps after `e2e-finish-recording`. See [Shutdown](e2e-yaml.md#shutdown) for replay order.
|
|
45
47
|
|
|
46
48
|
## Start in the correct order
|
|
47
49
|
|