@nextclaw/x-harness 0.2.49 → 0.2.51
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 +2 -2
- package/dist/browser-dom-capabilities.js +1 -0
- package/dist/browser-dom-navigation.js +12 -5
- package/dist/browser.js +3 -0
- package/dist/platform-quote.js +26 -5
- package/dist/results.js +1 -1
- package/dist/types.d.ts +1 -0
- package/generated/observation.mjs +3 -0
- package/package.json +2 -2
package/SOURCE.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Corresponding source
|
|
2
2
|
|
|
3
|
-
Version 0.2.
|
|
3
|
+
Version 0.2.51, commit 4fcb5b63209a99a05a176cc9a7242c1f7de614ea.
|
|
4
4
|
|
|
5
|
-
Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/
|
|
5
|
+
Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/4fcb5b63209a99a05a176cc9a7242c1f7de614ea
|
|
6
6
|
|
|
7
7
|
Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
|
|
8
8
|
|
|
@@ -30,16 +30,23 @@ export class DOMNavigation {
|
|
|
30
30
|
posts?.length !== 1 ||
|
|
31
31
|
posts[0].quoteCards?.length !== 1 ||
|
|
32
32
|
posts[0].quoteCards[0].text !== command.cardText)
|
|
33
|
-
throw Error(
|
|
33
|
+
throw Error(`unique-observed-quote-required:snapshot:${posts?.length ?? 0}:${posts?.[0]?.quoteCards?.length ?? 0}`);
|
|
34
34
|
const article = this.#tab.playwright.getByRole("article").filter({
|
|
35
35
|
has: this.#tab.playwright.locator(`a[href=${JSON.stringify(posts[0].primary)}]`),
|
|
36
36
|
});
|
|
37
|
-
const
|
|
37
|
+
const cards = article
|
|
38
38
|
.locator('[role="link"][tabindex="0"]')
|
|
39
39
|
.filter({ visible: true });
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const count = await cards.count();
|
|
41
|
+
const matches = [];
|
|
42
|
+
for (let i = 0; i < count; i++) {
|
|
43
|
+
const candidate = cards.nth(i);
|
|
44
|
+
if ((await candidate.innerText()) === command.cardText)
|
|
45
|
+
matches.push(candidate);
|
|
46
|
+
}
|
|
47
|
+
if (matches.length !== 1)
|
|
48
|
+
throw Error(`unique-observed-quote-required:controls:${count}:matches:${matches.length}`);
|
|
49
|
+
const card = matches[0];
|
|
43
50
|
this.#session.current = null;
|
|
44
51
|
await this.#tab.playwright.expectNavigation(() => card.click(), {
|
|
45
52
|
waitUntil: "commit",
|
package/dist/browser.js
CHANGED
|
@@ -132,10 +132,13 @@ export function readXSurface({ view, posts = [], targetId, replyTargetId, } = {}
|
|
|
132
132
|
.filter(visible)
|
|
133
133
|
.map((card) => ({
|
|
134
134
|
text: card.innerText,
|
|
135
|
+
body: card.querySelector?.('[data-testid="tweetText"]')
|
|
136
|
+
?.innerText,
|
|
135
137
|
datetime: card
|
|
136
138
|
.querySelector?.("time")
|
|
137
139
|
?.getAttribute("datetime"),
|
|
138
140
|
}))
|
|
141
|
+
.filter((card) => card.text?.trim())
|
|
139
142
|
: [],
|
|
140
143
|
};
|
|
141
144
|
}),
|
package/dist/platform-quote.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { xURL } from "./platform-rules.js";
|
|
2
2
|
export async function resolveQuotedSource(target, initial, { browser, ready, open }) {
|
|
3
|
+
const incomplete = (value) => ({
|
|
4
|
+
...value,
|
|
5
|
+
complete: false,
|
|
6
|
+
missing: [
|
|
7
|
+
...new Set([...(value.missing ?? []), "quoted-source-unconfirmed"]),
|
|
8
|
+
],
|
|
9
|
+
});
|
|
3
10
|
const parent = initial.posts?.find((p) => p.id === target.postId);
|
|
4
11
|
if (initial.needsStateCheck ||
|
|
5
12
|
initial.alerts?.length ||
|
|
6
13
|
!parent ||
|
|
7
14
|
parent.quoteCards?.length !== 1)
|
|
8
|
-
return initial;
|
|
15
|
+
return parent?.quoteCards?.length ? incomplete(initial) : initial;
|
|
9
16
|
const card = parent.quoteCards[0];
|
|
10
17
|
const destination = await browser.act({
|
|
11
18
|
operation: "openQuote",
|
|
@@ -13,15 +20,29 @@ export async function resolveQuotedSource(target, initial, { browser, ready, ope
|
|
|
13
20
|
cardText: card.text,
|
|
14
21
|
});
|
|
15
22
|
const id = xURL(destination.url).pathname.match(/\/status\/(\d+)$/)?.[1];
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
let source = await ready({ view: "posts", targetId: id });
|
|
24
|
+
let quoted = source.posts?.find((p) => p.id === id);
|
|
25
|
+
if (!source.needsStateCheck &&
|
|
26
|
+
!source.alerts?.length &&
|
|
27
|
+
quoted?.needsExpansion) {
|
|
28
|
+
await browser.act({ operation: "expandPost", postId: id });
|
|
29
|
+
source = await ready({ view: "posts", targetId: id });
|
|
30
|
+
quoted = source.posts?.find((p) => p.id === id);
|
|
31
|
+
}
|
|
32
|
+
const normalize = (text) => text.replace(/\s/g, "");
|
|
33
|
+
const excerpt = typeof card.body === "string" && /(?:…|\.\.\.)\s*$/.test(card.body)
|
|
34
|
+
? normalize(card.body.replace(/(?:…|\.\.\.)\s*$/, ""))
|
|
35
|
+
: "";
|
|
36
|
+
const bodyBound = quoted?.body &&
|
|
37
|
+
(card.text.endsWith(quoted.body) ||
|
|
38
|
+
(excerpt.length >= 32 && normalize(quoted.body).startsWith(excerpt)));
|
|
18
39
|
const confirmed = !source.needsStateCheck &&
|
|
19
40
|
!source.alerts?.length &&
|
|
20
41
|
quoted?.body &&
|
|
21
42
|
!quoted.needsExpansion &&
|
|
22
43
|
quoted.datetime === card.datetime &&
|
|
23
44
|
card.text.includes(`@${quoted.author}`) &&
|
|
24
|
-
|
|
45
|
+
bodyBound;
|
|
25
46
|
const back = await open({
|
|
26
47
|
url: target.url,
|
|
27
48
|
evidenceRef: {
|
|
@@ -43,5 +64,5 @@ export async function resolveQuotedSource(target, initial, { browser, ready, ope
|
|
|
43
64
|
parentId: target.postId,
|
|
44
65
|
cardText: card.text,
|
|
45
66
|
};
|
|
46
|
-
return back;
|
|
67
|
+
return fresh?.quoteSource ? back : incomplete(back);
|
|
47
68
|
}
|
package/dist/results.js
CHANGED
|
@@ -47,7 +47,7 @@ export function source(value, page) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
if (raw.quoteCards)
|
|
50
|
-
out.quoteCards = list(raw.quoteCards).map((v) => pick(v, ["text", "datetime"]));
|
|
50
|
+
out.quoteCards = list(raw.quoteCards).map((v) => pick(v, ["text", "datetime", "body"]));
|
|
51
51
|
if (raw.quoteSource)
|
|
52
52
|
out.quoteSource = pick(raw.quoteSource, [
|
|
53
53
|
"id",
|
package/dist/types.d.ts
CHANGED
|
@@ -634,10 +634,13 @@ export const readXObservation = (query) => {
|
|
|
634
634
|
.filter(visible)
|
|
635
635
|
.map((card) => ({
|
|
636
636
|
text: card.innerText,
|
|
637
|
+
body: card.querySelector?.('[data-testid="tweetText"]')
|
|
638
|
+
?.innerText,
|
|
637
639
|
datetime: card
|
|
638
640
|
.querySelector?.("time")
|
|
639
641
|
?.getAttribute("datetime"),
|
|
640
642
|
}))
|
|
643
|
+
.filter((card) => card.text?.trim())
|
|
641
644
|
: [],
|
|
642
645
|
};
|
|
643
646
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextclaw/x-harness",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.51",
|
|
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": "
|
|
45
|
+
"gitHead": "4fcb5b63209a99a05a176cc9a7242c1f7de614ea"
|
|
46
46
|
}
|