@ohos-perf/core 0.22.2 → 0.22.4

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 CHANGED
@@ -4917,12 +4917,19 @@ declare function writeRunFiles(outDir: string, result: RunResult): void;
4917
4917
  * completion claim carries an expectation, the expectation is evaluated
4918
4918
  * against a fresh dump, and a claim the screen contradicts is recorded as
4919
4919
  * `unverified` — a failure with the clause that failed named.
4920
- * 2. **The safety rule lives only in the prompt.** HapRay tells the model to
4921
- * avoid payment, ordering and transfers; a model that ignores the sentence
4922
- * acts anyway. Here the guard reads the node the tap lands on and refuses
4923
- * the gesture outright. An irreversible action stops the run: a model that
4924
- * reached for a payment button has lost the thread of the task, and asking
4925
- * it again spends steps on the one thing that must not happen.
4920
+ * 2. **The safety rule is mostly in the prompt.** HapRay adds one sentence to
4921
+ * the task prompt — avoid login, payment, ordering, transfer, posting — and
4922
+ * that is the only layer that applies to every gesture. `phone_agent` does
4923
+ * ship a `confirmation_callback`, but it fires only when the model itself
4924
+ * labels the tap (`do(action="Tap", element=[x,y], message="重要操作")`), so
4925
+ * a plain `Tap` is performed with no check; it covers `Tap` alone, leaving
4926
+ * long press, double tap, swipe and text entry unguarded; and HapRay passes
4927
+ * no callback, so the default is a blocking `input()` that raises `EOFError`
4928
+ * in a batch run and is recorded as a failed step with the run continuing.
4929
+ * Here the guard reads the node the tap lands on and refuses the gesture
4930
+ * outright. An irreversible action stops the run: a model that reached for
4931
+ * a payment button has lost the thread of the task, and asking it again
4932
+ * spends steps on the one thing that must not happen.
4926
4933
  * 3. **The log cannot be replayed.** HapRay records `{action, thinking,
4927
4934
  * message}` as prose, so two runs of the same task are two unrelated logs.
4928
4935
  * Here every step records the gesture and the screen hash either side of
package/dist/index.js CHANGED
@@ -8756,6 +8756,38 @@ function targetOf(tree, x, y) {
8756
8756
  };
8757
8757
  return containing.slice().sort((a, b) => Number(b.clickable) - Number(a.clickable) || area(a) - area(b))[0];
8758
8758
  }
8759
+ function rectOf2(node) {
8760
+ return node.boundsRect ?? parseBounds(node.bounds);
8761
+ }
8762
+ function gapTo(rect, x, y) {
8763
+ return Math.max(rect.left - x, 0, x - rect.right, rect.top - y, 0, y - rect.bottom);
8764
+ }
8765
+ function containsRect(outer, inner) {
8766
+ return outer.left <= inner.left && outer.top <= inner.top && outer.right >= inner.right && outer.bottom >= inner.bottom;
8767
+ }
8768
+ var NEAR_MISS_PX = 24;
8769
+ function nearMissOf(tree, x, y, landedOn) {
8770
+ let best;
8771
+ for (const node of tree) {
8772
+ if (irreversibleReason(node) === void 0) continue;
8773
+ const rect = rectOf2(node);
8774
+ if (rect === void 0) continue;
8775
+ const gap = gapTo(rect, x, y);
8776
+ if (gap > NEAR_MISS_PX) continue;
8777
+ if (landedOn !== void 0 && landedOn !== node && landedOn.clickable) {
8778
+ const landing = rectOf2(landedOn);
8779
+ if (landing === void 0 || !containsRect(landing, rect)) continue;
8780
+ }
8781
+ if (best === void 0 || gap < best.gap) best = { node, gap };
8782
+ }
8783
+ return best;
8784
+ }
8785
+ function refusalFor(tree, x, y, landedOn) {
8786
+ const direct = landedOn === void 0 ? void 0 : irreversibleReason(landedOn);
8787
+ if (direct !== void 0) return direct;
8788
+ const near = nearMissOf(tree, x, y, landedOn);
8789
+ return near === void 0 ? void 0 : irreversibleReason(near.node);
8790
+ }
8759
8791
  function unmetExpectation(expect, tree, app) {
8760
8792
  const outcomes = evaluateExpectation(expect, tree, app);
8761
8793
  const failed = outcomes.filter((outcome) => !outcome.ok);
@@ -8825,7 +8857,7 @@ async function runAgent(device, model, options) {
8825
8857
  const gesture = decision.action;
8826
8858
  const point = gesture.action === "click" || gesture.action === "inputText" ? { x: gesture.x, y: gesture.y } : void 0;
8827
8859
  const target = point === void 0 ? void 0 : targetOf(tree, point.x, point.y);
8828
- const refused = target === void 0 ? void 0 : irreversibleReason(target);
8860
+ const refused = point === void 0 ? void 0 : refusalFor(tree, point.x, point.y, target);
8829
8861
  if (refused !== void 0 && options.allowIrreversible !== true) {
8830
8862
  status = "refused";
8831
8863
  steps.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohos-perf/core",
3
- "version": "0.22.2",
3
+ "version": "0.22.4",
4
4
  "description": "HarmonyOS performance analysis: capability probing, nine collectors, trace ingest, typed queries, twenty-one analyzers with provenance and fidelity, reports and a scenario runner",
5
5
  "keywords": [
6
6
  "harmonyos",