@nextclaw/x-harness 0.2.48 → 0.2.50
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-navigation.js +1 -1
- package/dist/browser.js +3 -0
- package/dist/platform-observation.js +4 -2
- 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.50, commit 574f6379381dcf0bab9269f063474771df0067ee.
|
|
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/574f6379381dcf0bab9269f063474771df0067ee
|
|
6
6
|
|
|
7
7
|
Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
|
|
8
8
|
|
|
@@ -36,7 +36,7 @@ export class DOMNavigation {
|
|
|
36
36
|
});
|
|
37
37
|
const card = article
|
|
38
38
|
.locator('[role="link"][tabindex="0"]')
|
|
39
|
-
.filter({ visible: true });
|
|
39
|
+
.filter({ visible: true, hasText: command.cardText });
|
|
40
40
|
if ((await card.count()) !== 1 ||
|
|
41
41
|
(await card.innerText()) !== command.cardText)
|
|
42
42
|
throw Error("unique-observed-quote-required");
|
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() && card.datetime)
|
|
139
142
|
: [],
|
|
140
143
|
};
|
|
141
144
|
}),
|
|
@@ -62,9 +62,9 @@ export class PlatformObservation {
|
|
|
62
62
|
const waitingForOffset = query.view === "posts" &&
|
|
63
63
|
Number.isInteger(query.offset) &&
|
|
64
64
|
query.offset > 0 &&
|
|
65
|
-
value.renderedArticles > 0 &&
|
|
66
65
|
!value.posts?.length;
|
|
67
|
-
|
|
66
|
+
const waitingForList = query.view === "posts" && !query.targetId && !value.posts?.length;
|
|
67
|
+
if ((value.needsStateCheck || waitingForOffset || waitingForList) &&
|
|
68
68
|
!value.alerts?.length &&
|
|
69
69
|
query.view === "posts") {
|
|
70
70
|
try {
|
|
@@ -78,6 +78,8 @@ export class PlatformObservation {
|
|
|
78
78
|
throw error;
|
|
79
79
|
}
|
|
80
80
|
value = await this.handleObserved(query);
|
|
81
|
+
if (waitingForList && !query.offset && !value.posts?.length)
|
|
82
|
+
value = { ...value, needsStateCheck: true };
|
|
81
83
|
}
|
|
82
84
|
return value;
|
|
83
85
|
}
|
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() && card.datetime)
|
|
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.50",
|
|
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": "574f6379381dcf0bab9269f063474771df0067ee"
|
|
46
46
|
}
|