@sedum-dev/core 0.1.0-alpha.17 → 0.1.0-alpha.20
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/index.d.ts +2 -2
- package/dist/index.js +147 -118
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2696,7 +2696,8 @@ interface LocatorOptions {
|
|
|
2696
2696
|
/**
|
|
2697
2697
|
* Before returning a model-resolved target, show it outlined in a
|
|
2698
2698
|
* screenshot and refuse it as ambiguous when several elements fit the
|
|
2699
|
-
* sentence equally well. Cache hits
|
|
2699
|
+
* sentence equally well. Cache hits and picks that code made by an
|
|
2700
|
+
* ordinal or price rank ("the first", "the cheapest") are not checked.
|
|
2700
2701
|
*/
|
|
2701
2702
|
readonly targetCheck?: TargetCheckOptions;
|
|
2702
2703
|
readonly operation: Operation;
|
|
@@ -3536,7 +3537,6 @@ interface SentencePresentation {
|
|
|
3536
3537
|
/** A question the test branches on: judged once and never gating. */
|
|
3537
3538
|
readonly check?: boolean;
|
|
3538
3539
|
}
|
|
3539
|
-
/** @internal Execute one classified sentence and record it as one step. */
|
|
3540
3540
|
declare function executeSentence(page: BrowserPage, step: ClassifiedFlowSentence, dependencies: AttemptDependencies, data: Record<string, ResolvedDataEntry>, opaqueEntries: ResolvedDataEntry[], presentation?: SentencePresentation): Promise<"continue" | "failed" | FlowRunResult>;
|
|
3541
3541
|
|
|
3542
3542
|
/** Capture the current safe page and selected target for a terminal goal failure. */
|
package/dist/index.js
CHANGED
|
@@ -1894,6 +1894,23 @@ var BrowserDriverError = class extends Error {
|
|
|
1894
1894
|
var DEFAULT_NAVIGATION_TIMEOUT_MS = 3e4;
|
|
1895
1895
|
var DEFAULT_SETTLE_TIMEOUT_MS = 4e3;
|
|
1896
1896
|
var DEFAULT_ACTION_TIMEOUT_MS = 8e3;
|
|
1897
|
+
var PAGE_CLOSE_TIMEOUT_MS = 2e3;
|
|
1898
|
+
function clickDispatched(error2) {
|
|
1899
|
+
const message = error2 instanceof Error ? error2.message : "";
|
|
1900
|
+
if (!message.includes("\nCall log:")) return true;
|
|
1901
|
+
return message.includes("performing click action");
|
|
1902
|
+
}
|
|
1903
|
+
function clickFailure(hover, error2) {
|
|
1904
|
+
if (hover || clickDispatched(error2))
|
|
1905
|
+
return {
|
|
1906
|
+
actionable: false,
|
|
1907
|
+
reason: "action_started",
|
|
1908
|
+
retryable: false,
|
|
1909
|
+
callLog: safeCallLog(error2)
|
|
1910
|
+
};
|
|
1911
|
+
const message = error2 instanceof Error ? error2.message : "";
|
|
1912
|
+
return message.includes("not attached to the DOM") ? { actionable: false, reason: "stale" } : { actionable: false, reason: "not_actionable" };
|
|
1913
|
+
}
|
|
1897
1914
|
function actionTimeout(value) {
|
|
1898
1915
|
if (value === void 0) return DEFAULT_ACTION_TIMEOUT_MS;
|
|
1899
1916
|
if (!Number.isFinite(value) || value <= 0 || value > 2147483647)
|
|
@@ -1925,7 +1942,7 @@ function errorText(error2) {
|
|
|
1925
1942
|
return error2 instanceof Error ? error2.message : String(error2);
|
|
1926
1943
|
}
|
|
1927
1944
|
function isMissingExecutable(error2) {
|
|
1928
|
-
return /executable does not exist|executable.*doesn't exist|executable.*not found|channel .* is not installed|ENOENT/i.test(
|
|
1945
|
+
return /executable does not exist|executable.*doesn't exist|executable.*not found|channel .* is not installed|distribution '.*' is not found|ENOENT/i.test(
|
|
1929
1946
|
errorText(error2)
|
|
1930
1947
|
);
|
|
1931
1948
|
}
|
|
@@ -2016,7 +2033,7 @@ var PlaywrightPage = class {
|
|
|
2016
2033
|
}
|
|
2017
2034
|
async terminateTimedOutInput() {
|
|
2018
2035
|
this.terminalAfterInputTimeout = true;
|
|
2019
|
-
|
|
2036
|
+
await this.close().catch(() => void 0);
|
|
2020
2037
|
}
|
|
2021
2038
|
state() {
|
|
2022
2039
|
return {
|
|
@@ -2289,12 +2306,7 @@ var PlaywrightPage = class {
|
|
|
2289
2306
|
});
|
|
2290
2307
|
return { actionable: true, aim: dispatchAim };
|
|
2291
2308
|
} catch (error2) {
|
|
2292
|
-
return
|
|
2293
|
-
actionable: false,
|
|
2294
|
-
reason: "action_started",
|
|
2295
|
-
retryable: false,
|
|
2296
|
-
callLog: safeCallLog(error2)
|
|
2297
|
-
};
|
|
2309
|
+
return clickFailure(Boolean(aim.hover), error2);
|
|
2298
2310
|
} finally {
|
|
2299
2311
|
await hide();
|
|
2300
2312
|
}
|
|
@@ -2375,9 +2387,34 @@ var PlaywrightPage = class {
|
|
|
2375
2387
|
throw safeOperationError(error2, this.state(), "Scroll");
|
|
2376
2388
|
}
|
|
2377
2389
|
}
|
|
2390
|
+
/**
|
|
2391
|
+
* Chromium can accept a close while the page reloads and keep the tab open,
|
|
2392
|
+
* and Playwright then waits for it forever. Give up after a bound: closing
|
|
2393
|
+
* the page's context still disposes it, and every owner closes that next.
|
|
2394
|
+
*/
|
|
2378
2395
|
async close() {
|
|
2379
2396
|
if (this.page.isClosed()) return;
|
|
2380
|
-
|
|
2397
|
+
const closing = this.page.close();
|
|
2398
|
+
let timer;
|
|
2399
|
+
try {
|
|
2400
|
+
await Promise.race([
|
|
2401
|
+
closing,
|
|
2402
|
+
new Promise((_resolve, reject) => {
|
|
2403
|
+
timer = setTimeout(
|
|
2404
|
+
() => reject(
|
|
2405
|
+
new BrowserDriverError(
|
|
2406
|
+
"operation-failed",
|
|
2407
|
+
"The page did not close; close its context to dispose it."
|
|
2408
|
+
)
|
|
2409
|
+
),
|
|
2410
|
+
PAGE_CLOSE_TIMEOUT_MS
|
|
2411
|
+
);
|
|
2412
|
+
})
|
|
2413
|
+
]);
|
|
2414
|
+
} finally {
|
|
2415
|
+
clearTimeout(timer);
|
|
2416
|
+
closing.catch(() => void 0);
|
|
2417
|
+
}
|
|
2381
2418
|
}
|
|
2382
2419
|
};
|
|
2383
2420
|
var PlaywrightContext = class {
|
|
@@ -3083,22 +3120,15 @@ async function observeRoute(page, op, before, remaining) {
|
|
|
3083
3120
|
throw new StepExecutionError(op, "action_uncertain", "post_dispatch");
|
|
3084
3121
|
}
|
|
3085
3122
|
}
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
const observed = await quietPage(
|
|
3096
|
-
page,
|
|
3097
|
-
80,
|
|
3098
|
-
remaining(1e3, "post_dispatch")
|
|
3099
|
-
).catch(() => ({ quiet: false }));
|
|
3100
|
-
if (!observed.quiet)
|
|
3101
|
-
throw new StepExecutionError(op, "action_uncertain", "post_dispatch");
|
|
3123
|
+
try {
|
|
3124
|
+
if (after.document !== before.document)
|
|
3125
|
+
await page.settle({
|
|
3126
|
+
state: "domcontentloaded",
|
|
3127
|
+
timeoutMs: remaining(4e3, "post_dispatch")
|
|
3128
|
+
});
|
|
3129
|
+
if (after.route !== before.route)
|
|
3130
|
+
await quietPage(page, 80, remaining(1e3, "post_dispatch"));
|
|
3131
|
+
} catch {
|
|
3102
3132
|
}
|
|
3103
3133
|
return after.route !== before.route ? "route_changed" : "no_route_change";
|
|
3104
3134
|
}
|
|
@@ -4446,8 +4476,10 @@ function resolveInCode(sentence, pick, candidates, loose = false) {
|
|
|
4446
4476
|
))
|
|
4447
4477
|
return null;
|
|
4448
4478
|
const selected = rankedSelection(ranked, group, items);
|
|
4449
|
-
if (selected !== void 0)
|
|
4450
|
-
|
|
4479
|
+
if (selected !== void 0)
|
|
4480
|
+
return selected && { target: selected, ranked: true };
|
|
4481
|
+
const referenced = matchItemReference({ ...context, group, items });
|
|
4482
|
+
return referenced && { target: referenced, ranked: false };
|
|
4451
4483
|
}
|
|
4452
4484
|
function statedGroupPick(sentence, candidates) {
|
|
4453
4485
|
const request = new StatedGroupRequest(sentence, candidates);
|
|
@@ -5099,7 +5131,8 @@ var RuntimeSelection = class {
|
|
|
5099
5131
|
const fallback = codeFallback ? codeAfterNone(options.sentence, this.candidates) : null;
|
|
5100
5132
|
if (fallback) {
|
|
5101
5133
|
this.gate("resolved_in_code_after_none");
|
|
5102
|
-
|
|
5134
|
+
this.context.state.ranked = fallback.ranked;
|
|
5135
|
+
return this.accept(fallback.target);
|
|
5103
5136
|
}
|
|
5104
5137
|
if (!options.visionResolver || options.operation !== "click")
|
|
5105
5138
|
return this.unresolved("none");
|
|
@@ -5121,9 +5154,12 @@ var RuntimeSelection = class {
|
|
|
5121
5154
|
const { options, codeFallback } = this.context;
|
|
5122
5155
|
const anchor = codeFallback && !nameStated(options.sentence, selected) ? statedGroupPick(options.sentence, this.candidates) ?? selected : selected;
|
|
5123
5156
|
const inCode = (pick) => resolveInCode(options.sentence, pick, this.candidates) ?? (codeFallback ? resolveInCode(options.sentence, anchor, this.candidates, true) : null);
|
|
5124
|
-
const
|
|
5125
|
-
const
|
|
5126
|
-
|
|
5157
|
+
const coded = inCode(selected);
|
|
5158
|
+
const section = options.sectionMatch !== false && !coded ? resolveBySection(options.sentence, selected, this.candidates) : null;
|
|
5159
|
+
if (section) return { target: section, gate: "resolved_by_section" };
|
|
5160
|
+
if (!coded) return null;
|
|
5161
|
+
this.context.state.ranked = coded.ranked;
|
|
5162
|
+
return { target: coded.target, gate: "resolved_in_code" };
|
|
5127
5163
|
}
|
|
5128
5164
|
async verifiedItem(selected) {
|
|
5129
5165
|
const { options, verifyItems, itemVerifier } = this.context;
|
|
@@ -5441,6 +5477,7 @@ async function resolveTarget(page, resolver, options) {
|
|
|
5441
5477
|
refresh
|
|
5442
5478
|
}).resolve();
|
|
5443
5479
|
if (result.kind !== "resolved" || !options.targetCheck) return result;
|
|
5480
|
+
if (selection.ranked) return result;
|
|
5444
5481
|
const verdict2 = await checkResolvedTarget({
|
|
5445
5482
|
page,
|
|
5446
5483
|
target: result.target,
|
|
@@ -9372,33 +9409,26 @@ function failureMessage(claim2, found) {
|
|
|
9372
9409
|
const frequency = found === 1 ? "once" : `${found} times`;
|
|
9373
9410
|
return `The text appears ${frequency} on the page.`;
|
|
9374
9411
|
}
|
|
9375
|
-
function
|
|
9376
|
-
const
|
|
9377
|
-
return context.record(
|
|
9378
|
-
unsupported(context.step.source.file, context.step.source, message),
|
|
9379
|
-
{ error: { code: "text_unreadable", message } }
|
|
9380
|
-
);
|
|
9412
|
+
function lastReadFailure(context, claim2, found) {
|
|
9413
|
+
const error2 = found === null ? { code: "text_unreadable", message: "The page text could not be read." } : { code: "text_check", message: failureMessage(claim2, found) };
|
|
9414
|
+
return context.record("failed", { error: error2 });
|
|
9381
9415
|
}
|
|
9382
9416
|
async function executeTextAssertion(context, claim2, limitMs) {
|
|
9383
9417
|
const deadline = performance.now() + limitMs;
|
|
9384
9418
|
const wanted = (claim2.alternatives ?? [claim2.text]).map(
|
|
9385
9419
|
(text) => revealValues(text, context.data)
|
|
9386
9420
|
);
|
|
9387
|
-
let
|
|
9421
|
+
let found = null;
|
|
9388
9422
|
for (; ; ) {
|
|
9389
9423
|
const before = await readPageVersion(context.page);
|
|
9390
9424
|
await quietPage(context.page, 80, 2e3).catch(() => void 0);
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
}
|
|
9397
|
-
if (expectationHolds(claim2, found)) return context.record("continue");
|
|
9398
|
-
message = failureMessage(claim2, found);
|
|
9399
|
-
if (!await waitForPageChange(context, before, deadline, false)) break;
|
|
9425
|
+
found = await countMatches(context, claim2, wanted).catch(() => null);
|
|
9426
|
+
if (found !== null && expectationHolds(claim2, found))
|
|
9427
|
+
return context.record("continue");
|
|
9428
|
+
const since = found === null ? null : before;
|
|
9429
|
+
if (!await waitForPageChange(context, since, deadline, false)) break;
|
|
9400
9430
|
}
|
|
9401
|
-
return context
|
|
9431
|
+
return lastReadFailure(context, claim2, found);
|
|
9402
9432
|
}
|
|
9403
9433
|
|
|
9404
9434
|
// src/flow-runner/assertions.ts
|
|
@@ -9503,6 +9533,7 @@ async function detectStep(page, detector, report, signal) {
|
|
|
9503
9533
|
|
|
9504
9534
|
// src/flow-runner/action-recovery.ts
|
|
9505
9535
|
import { setTimeout as delay2 } from "timers/promises";
|
|
9536
|
+
var DEFAULT_ACTION_BUDGET_MS = 8e3;
|
|
9506
9537
|
async function refreshAfterQuiet(page, remainingMs, signal, locate) {
|
|
9507
9538
|
const deadline = performance.now() + remainingMs;
|
|
9508
9539
|
const quiet = await quietPage(page, 80, Math.min(4e3, remainingMs)).catch(
|
|
@@ -9527,7 +9558,7 @@ async function performWithRecovery(options) {
|
|
|
9527
9558
|
var ActionAttempts = class {
|
|
9528
9559
|
constructor(options) {
|
|
9529
9560
|
this.options = options;
|
|
9530
|
-
const budget = options.timeoutMs ??
|
|
9561
|
+
const budget = options.timeoutMs ?? DEFAULT_ACTION_BUDGET_MS;
|
|
9531
9562
|
this.deadline = this.started + budget;
|
|
9532
9563
|
const timeout = AbortSignal.timeout(Math.max(1, Math.ceil(budget)));
|
|
9533
9564
|
this.signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
|
|
@@ -9539,6 +9570,7 @@ var ActionAttempts = class {
|
|
|
9539
9570
|
signal;
|
|
9540
9571
|
last;
|
|
9541
9572
|
attempts = 0;
|
|
9573
|
+
staleRefusals = 0;
|
|
9542
9574
|
remaining() {
|
|
9543
9575
|
return this.signal.aborted ? 0 : Math.max(0, this.deadline - performance.now());
|
|
9544
9576
|
}
|
|
@@ -9571,9 +9603,9 @@ var ActionAttempts = class {
|
|
|
9571
9603
|
retryable(error2) {
|
|
9572
9604
|
if (!(error2 instanceof StepExecutionError)) return false;
|
|
9573
9605
|
if (!error2.retryable || !this.options.allowed()) return false;
|
|
9574
|
-
if (
|
|
9575
|
-
|
|
9576
|
-
return
|
|
9606
|
+
if (error2.code === "not_actionable") return true;
|
|
9607
|
+
if (error2.code !== "stale") return false;
|
|
9608
|
+
return this.options.op === "click" || this.staleRefusals++ === 0;
|
|
9577
9609
|
}
|
|
9578
9610
|
async perform() {
|
|
9579
9611
|
try {
|
|
@@ -9619,39 +9651,16 @@ var LocateRetryError = class extends Error {
|
|
|
9619
9651
|
}
|
|
9620
9652
|
priorCalls;
|
|
9621
9653
|
};
|
|
9622
|
-
function
|
|
9623
|
-
if (
|
|
9624
|
-
|
|
9625
|
-
|
|
9626
|
-
async function retryStaleResolution(page, resolved, locate, enabled) {
|
|
9627
|
-
if (!shouldRetryStale2(resolved, enabled)) return resolved;
|
|
9628
|
-
const priorCalls = resolved.calls;
|
|
9629
|
-
const settled = await quietPage(page, 1e3, 4e3).catch(() => ({
|
|
9630
|
-
quiet: false
|
|
9631
|
-
}));
|
|
9632
|
-
if (!settled.quiet) return resolved;
|
|
9633
|
-
try {
|
|
9634
|
-
const retried = await locate();
|
|
9635
|
-
return { ...retried, calls: [...priorCalls, ...retried.calls] };
|
|
9636
|
-
} catch (error2) {
|
|
9637
|
-
if (isRunWideProviderError(error2)) throw error2;
|
|
9638
|
-
throw new LocateRetryError(priorCalls);
|
|
9639
|
-
}
|
|
9640
|
-
}
|
|
9641
|
-
function hasNoCandidates(result) {
|
|
9642
|
-
if (result.kind === "resolved") return false;
|
|
9643
|
-
return result.reason === "no_candidates";
|
|
9654
|
+
function recoveryFor(result, staleRetry) {
|
|
9655
|
+
if (result.kind === "resolved") return "none";
|
|
9656
|
+
if (result.reason === "no_candidates") return "empty";
|
|
9657
|
+
return staleRetry && result.reason === "stale" ? "stale" : "none";
|
|
9644
9658
|
}
|
|
9645
9659
|
function mayRetry(deadline, signal) {
|
|
9646
9660
|
if (performance.now() >= deadline) return false;
|
|
9647
9661
|
return signal?.aborted !== true;
|
|
9648
9662
|
}
|
|
9649
|
-
async function
|
|
9650
|
-
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
9651
|
-
const settled = await quietPage(page, 80, 1e3).catch(() => ({
|
|
9652
|
-
quiet: false
|
|
9653
|
-
}));
|
|
9654
|
-
if (!settled.quiet) return void 0;
|
|
9663
|
+
async function tryLocate(locate) {
|
|
9655
9664
|
try {
|
|
9656
9665
|
return await locate();
|
|
9657
9666
|
} catch (error2) {
|
|
@@ -9659,30 +9668,34 @@ async function observeAfterDelay(page, locate) {
|
|
|
9659
9668
|
return void 0;
|
|
9660
9669
|
}
|
|
9661
9670
|
}
|
|
9662
|
-
async function
|
|
9663
|
-
|
|
9664
|
-
const fresh = await
|
|
9665
|
-
if (!fresh)
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9671
|
+
async function relocateAfterRender(page, locate, priorCalls) {
|
|
9672
|
+
await quietPage(page, 80, 1e3).catch(() => void 0);
|
|
9673
|
+
const fresh = await tryLocate(locate);
|
|
9674
|
+
if (!fresh) throw new LocateRetryError(priorCalls);
|
|
9675
|
+
return fresh;
|
|
9676
|
+
}
|
|
9677
|
+
async function relocateWhenFilled(page, locate) {
|
|
9678
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
9679
|
+
const settled = await quietPage(page, 80, 1e3).catch(() => ({
|
|
9680
|
+
quiet: false
|
|
9681
|
+
}));
|
|
9682
|
+
return settled.quiet ? tryLocate(locate) : void 0;
|
|
9683
|
+
}
|
|
9684
|
+
async function readAgain(page, recovery, locate, current) {
|
|
9685
|
+
const fresh = recovery === "stale" ? await relocateAfterRender(page, locate, current.calls) : await relocateWhenFilled(page, locate);
|
|
9686
|
+
return fresh ? { ...fresh, calls: [...current.calls, ...fresh.calls] } : current;
|
|
9677
9687
|
}
|
|
9678
9688
|
async function reobserveLocator(page, first, locate, options) {
|
|
9679
|
-
const
|
|
9680
|
-
|
|
9681
|
-
|
|
9682
|
-
|
|
9683
|
-
options.staleRetry
|
|
9684
|
-
|
|
9685
|
-
|
|
9689
|
+
const deadline = performance.now() + 8e3;
|
|
9690
|
+
let staleReads = 0;
|
|
9691
|
+
let current = first;
|
|
9692
|
+
for (; ; ) {
|
|
9693
|
+
const recovery = recoveryFor(current, options.staleRetry && staleReads < 4);
|
|
9694
|
+
if (recovery === "none" || !mayRetry(deadline, options.signal))
|
|
9695
|
+
return current;
|
|
9696
|
+
staleReads += Number(recovery === "stale");
|
|
9697
|
+
current = await readAgain(page, recovery, locate, current);
|
|
9698
|
+
}
|
|
9686
9699
|
}
|
|
9687
9700
|
function unresolvedReason(reason, op) {
|
|
9688
9701
|
if (reason === "none")
|
|
@@ -9691,6 +9704,10 @@ function unresolvedReason(reason, op) {
|
|
|
9691
9704
|
const action = op === "type" ? "type into" : op;
|
|
9692
9705
|
return `the page had nothing to ${action}`;
|
|
9693
9706
|
}
|
|
9707
|
+
if (reason === "stale")
|
|
9708
|
+
return "the page kept replacing it while it was located; wait for the page to settle first";
|
|
9709
|
+
if (reason === "provider_error")
|
|
9710
|
+
return "the model call that picks the target failed; run the test again";
|
|
9694
9711
|
return "several elements match it; name the one you mean more precisely";
|
|
9695
9712
|
}
|
|
9696
9713
|
function visionFailure(vision) {
|
|
@@ -9700,7 +9717,8 @@ function visionFallbackNote(resolved) {
|
|
|
9700
9717
|
const vision = resolved.diagnostic.vision;
|
|
9701
9718
|
if (vision?.outcome === "abstained")
|
|
9702
9719
|
return "the vision model did not find it either";
|
|
9703
|
-
if (vision || resolved.reason
|
|
9720
|
+
if (vision || ["no_candidates", "stale"].includes(resolved.reason))
|
|
9721
|
+
return void 0;
|
|
9704
9722
|
return "vision fallback could not run (it needs 2 to 40 fully visible, unobscured controls on screen)";
|
|
9705
9723
|
}
|
|
9706
9724
|
function unresolvedLocatorWhy(resolved, op, visionEnabled) {
|
|
@@ -9744,6 +9762,20 @@ function chooseOption(sentence, labels) {
|
|
|
9744
9762
|
}
|
|
9745
9763
|
|
|
9746
9764
|
// src/flow-runner/sentence-execution.ts
|
|
9765
|
+
var FAILED_LOCATOR_REASONS = [
|
|
9766
|
+
"none",
|
|
9767
|
+
"ambiguous",
|
|
9768
|
+
"no_candidates",
|
|
9769
|
+
"stale",
|
|
9770
|
+
// Run-wide provider failures are thrown before this; what reaches here is
|
|
9771
|
+
// one failed model call, which a retry can get past.
|
|
9772
|
+
"provider_error"
|
|
9773
|
+
];
|
|
9774
|
+
var FAILED_ACTION_CODES = [
|
|
9775
|
+
"not_actionable",
|
|
9776
|
+
"stale",
|
|
9777
|
+
"invalid_input"
|
|
9778
|
+
];
|
|
9747
9779
|
async function executeSentence(page, step, dependencies, data, opaqueEntries, presentation = {}) {
|
|
9748
9780
|
const started = performance.now();
|
|
9749
9781
|
const report = dependencies.report;
|
|
@@ -9892,24 +9924,18 @@ async function executeSentence(page, step, dependencies, data, opaqueEntries, pr
|
|
|
9892
9924
|
});
|
|
9893
9925
|
return error2;
|
|
9894
9926
|
};
|
|
9895
|
-
const
|
|
9927
|
+
const settleMs = Math.max(4e3, dependencies.verifyGraceMs ?? 0);
|
|
9928
|
+
const quiet = await quietPage(page, 80, settleMs).catch(() => ({
|
|
9896
9929
|
quiet: false
|
|
9897
9930
|
}));
|
|
9898
9931
|
const waits = step.op === "verify" && waitUntilTimeoutMs(step.text) !== null;
|
|
9899
9932
|
if (!quiet.quiet && !waits)
|
|
9900
|
-
return record(
|
|
9901
|
-
|
|
9902
|
-
|
|
9903
|
-
step.
|
|
9904
|
-
"The page did not settle before this step could be resolved."
|
|
9905
|
-
),
|
|
9906
|
-
{
|
|
9907
|
-
error: {
|
|
9908
|
-
code: "observation_timeout",
|
|
9909
|
-
message: "The page did not settle before this step could be resolved."
|
|
9910
|
-
}
|
|
9933
|
+
return record("failed", {
|
|
9934
|
+
error: {
|
|
9935
|
+
code: "observation_timeout",
|
|
9936
|
+
message: "The page did not settle before this step could be resolved."
|
|
9911
9937
|
}
|
|
9912
|
-
);
|
|
9938
|
+
});
|
|
9913
9939
|
let typeValue;
|
|
9914
9940
|
if (step.op === "type") {
|
|
9915
9941
|
const operand = validateTypeOperand(step);
|
|
@@ -10280,7 +10306,7 @@ async function executeSentence(page, step, dependencies, data, opaqueEntries, pr
|
|
|
10280
10306
|
}
|
|
10281
10307
|
);
|
|
10282
10308
|
if (resolved.kind !== "resolved") {
|
|
10283
|
-
if (
|
|
10309
|
+
if (FAILED_LOCATOR_REASONS.includes(resolved.reason))
|
|
10284
10310
|
return record("failed", {
|
|
10285
10311
|
locator: resolved,
|
|
10286
10312
|
error: {
|
|
@@ -10342,6 +10368,9 @@ async function executeSentence(page, step, dependencies, data, opaqueEntries, pr
|
|
|
10342
10368
|
let observation = 1;
|
|
10343
10369
|
await performWithRecovery({
|
|
10344
10370
|
op: step.op,
|
|
10371
|
+
// A target can stay disabled while the app works; wait as long as the
|
|
10372
|
+
// step's grace allows, never less than the default action budget.
|
|
10373
|
+
timeoutMs: Math.max(DEFAULT_ACTION_BUDGET_MS, actionGraceMs),
|
|
10345
10374
|
...dependencies.signal ? { signal: dependencies.signal } : {},
|
|
10346
10375
|
perform: performAction,
|
|
10347
10376
|
allowed: () => !visionAttempted,
|
|
@@ -10420,7 +10449,7 @@ async function executeSentence(page, step, dependencies, data, opaqueEntries, pr
|
|
|
10420
10449
|
} catch (error2) {
|
|
10421
10450
|
if (isRunWideProviderError(error2)) throw await runWide(error2);
|
|
10422
10451
|
const actionError2 = error2 instanceof StepExecutionError ? error2 : null;
|
|
10423
|
-
const failed = actionError2 && (actionError2.code
|
|
10452
|
+
const failed = actionError2 && FAILED_ACTION_CODES.includes(actionError2.code);
|
|
10424
10453
|
const facts = {
|
|
10425
10454
|
locator: resolved,
|
|
10426
10455
|
replayFrame,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sedum-dev/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.20",
|
|
4
4
|
"repository": "https://github.com/sedum-dev/sedum",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"playwright-core": "1.63.0",
|
|
33
33
|
"sharp": "0.35.5",
|
|
34
34
|
"yaml": "2.9.1",
|
|
35
|
-
"zod": "4.6.
|
|
35
|
+
"zod": "4.6.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@hegeldev/hegel": "0.4.7"
|