@nextclaw/x-harness 0.2.4 → 0.2.6

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/SOURCE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Corresponding source
2
2
 
3
- Version 0.2.4, commit 6dec3f53d7adf1743c1cd22857b17fc225cb4957.
3
+ Version 0.2.6, commit 7f48fb11b07a0e043cfaccfc377183d71f23eef2.
4
4
 
5
- Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/6dec3f53d7adf1743c1cd22857b17fc225cb4957
5
+ Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/7f48fb11b07a0e043cfaccfc377183d71f23eef2
6
6
 
7
7
  Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
8
8
 
@@ -367,12 +367,21 @@ export class DOMEditing {
367
367
  const submits = result.buttons.filter((b) => /^(回复|Reply|发帖|发布|Post|更新|Update)$/i.test(b.label));
368
368
  if (submits.length !== 1)
369
369
  throw new Error("编辑后提交入口不唯一");
370
- await this.#locator("button", submits[0].label)
371
- .and(this.#tab.playwright.locator(':not([disabled]):not([aria-disabled="true"])'))
372
- .waitFor({
373
- state: "visible",
374
- timeoutMs: result.videos?.length ? 60000 : 5000,
375
- });
370
+ const enabled = this.#locator("button", submits[0].label).and(this.#tab.playwright.locator(':not([disabled]):not([aria-disabled="true"])'));
371
+ // Some hosts cap each locator wait at 5s. Bound video processing to 12 waits;
372
+ // this never retries a submission and every subsequent step re-observes.
373
+ const waits = result.videos?.length ? 12 : 1;
374
+ for (let attempt = 0; attempt < waits; attempt++) {
375
+ try {
376
+ await enabled.waitFor({ state: "visible", timeoutMs: 5000 });
377
+ break;
378
+ }
379
+ catch (error) {
380
+ if (attempt + 1 === waits ||
381
+ !/timed out|deadline exceeded/i.test(error.message))
382
+ throw error;
383
+ }
384
+ }
376
385
  return { completed: true };
377
386
  return { completed: false, loc, submittedEditor };
378
387
  }
@@ -1,4 +1,4 @@
1
- import { xURL } from "./platform-rules.js";
1
+ import { xURL, matchesReviewedAssets } from "./platform-rules.js";
2
2
  import { same } from "./growth-constants.js";
3
3
  export class GrowthRecovery {
4
4
  #capability;
@@ -53,7 +53,7 @@ export class GrowthRecovery {
53
53
  url: publicURL,
54
54
  evidenceRef,
55
55
  });
56
- const trailing = action.text.match(/\n\n(https:\/\/\S+)$/);
56
+ const trailing = action.text.match(/\n+(https:\/\/\S+)$/);
57
57
  const matches = (observation.posts ?? []).filter((p) => {
58
58
  const exact = p.body === action.text;
59
59
  const card = trailing &&
@@ -69,9 +69,14 @@ export class GrowthRecovery {
69
69
  sourceLink.resolvedURL === trailing[1] &&
70
70
  p.links?.includes(sourceLink.href)) {
71
71
  try {
72
+ const displayed = new URL(sourceLink.renderedText.replace(/\s/g, "").replace(/…$/, ""));
73
+ const resolved = new URL(sourceLink.resolvedURL);
74
+ // This rendering allowance requires the observed short link's actual
75
+ // destination to equal the reviewed source URL in the guard above.
76
+ if (resolved.hostname === `www.${displayed.hostname}`)
77
+ displayed.hostname = resolved.hostname;
72
78
  renderedSource =
73
- new URL(sourceLink.renderedText.replace(/\s/g, "")).href ===
74
- sourceLink.resolvedURL &&
79
+ displayed.href === resolved.href &&
75
80
  p.body?.endsWith(sourceLink.renderedText) &&
76
81
  p.body.slice(0, -sourceLink.renderedText.length).trimEnd() ===
77
82
  action.text.slice(0, -trailing[0].length);
@@ -87,8 +92,7 @@ export class GrowthRecovery {
87
92
  !(action.beforeIds ?? []).includes(p.id) &&
88
93
  Date.parse(p.datetime) >= Date.parse(action.intentAt) &&
89
94
  Date.parse(p.datetime) <= this.#clock() + 5000 &&
90
- (!action.assets?.length ||
91
- action.assets.every((a) => p.images?.some((i) => i.alt === a.alt))));
95
+ matchesReviewedAssets(p, action.assets));
92
96
  });
93
97
  Object.assign(observation, {
94
98
  verified: !observation.needsStateCheck &&
@@ -15,3 +15,4 @@ export declare const source: (post: any, page: any) => {
15
15
  needsExpansion: any;
16
16
  missing: any[];
17
17
  };
18
+ export declare function matchesReviewedAssets(post: any, assets?: any[]): boolean;
@@ -39,3 +39,8 @@ export const source = (post, page) => ({
39
39
  ...(!post.body ? ["exact-body-unconfirmed"] : []),
40
40
  ],
41
41
  });
42
+ export function matchesReviewedAssets(post, assets = []) {
43
+ return assets.every((asset) => /\.mp4$/i.test(asset.path ?? "")
44
+ ? post.media?.some((media) => media.kind === "video")
45
+ : post.images?.some((image) => image.alt === asset.alt));
46
+ }
@@ -1,4 +1,4 @@
1
- import { xURL, sameHandle, sameText, samePublishedText, } from "./platform-rules.js";
1
+ import { xURL, sameHandle, sameText, samePublishedText, matchesReviewedAssets, } from "./platform-rules.js";
2
2
  export class PlatformWriting {
3
3
  #observed;
4
4
  #browser;
@@ -127,10 +127,7 @@ export class PlatformWriting {
127
127
  const matchesContent = (post) => sameHandle(post.author, action.accountHandle) &&
128
128
  samePublishedText(post.body, action.text) &&
129
129
  /^\d+$/.test(post.id ?? "") &&
130
- (!action.assets?.length ||
131
- action.assets.every((asset) => /\.mp4$/i.test(asset.path ?? "")
132
- ? post.media?.some((media) => media.kind === "video")
133
- : post.images?.some((image) => image.alt === asset.alt))) &&
130
+ matchesReviewedAssets(post, action.assets) &&
134
131
  !(action.beforeIds ?? []).includes(post.id) &&
135
132
  Number.isFinite(Date.parse(post.datetime)) &&
136
133
  Date.parse(post.datetime) >= Date.parse(action.intentAt) &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/x-harness",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "description": "Typed X task harness with compact business results and explicit diagnostics.",
6
6
  "main": "./dist/index.js",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "6dec3f53d7adf1743c1cd22857b17fc225cb4957"
45
+ "gitHead": "7f48fb11b07a0e043cfaccfc377183d71f23eef2"
46
46
  }