@nextclaw/x-harness 0.2.59 → 0.2.61

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.59, commit e0c324f79b77f50662ea2969c68ade82a31cb0b5.
3
+ Version 0.2.61, commit 56f3c8a87df442687670edc9526d13d74e7e101c.
4
4
 
5
- Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/e0c324f79b77f50662ea2969c68ade82a31cb0b5
5
+ Complete source, build scripts and dependencies: https://github.com/Peiiii/x-harness/tree/56f3c8a87df442687670edc9526d13d74e7e101c
6
6
 
7
7
  Clone this revision, run npm ci, npm run bootstrap and npm run release:build.
8
8
 
@@ -1,5 +1,6 @@
1
1
  import { DraftSchedule } from "./draft-schedule.js";
2
2
  import { xURL } from "./platform-rules.js";
3
+ import { replyAuthorReason } from "./reply-author-policy.js";
3
4
  import { replyRootAgeReason } from "./reply-root-policy.js";
4
5
  import { kinds, followWindows, operations, same } from "./growth-constants.js";
5
6
  import { followObservationAuthorized } from "./follow-observation-policy.js";
@@ -131,6 +132,9 @@ export class GrowthPolicy {
131
132
  if (!independentExecution && !this.handleScope(state).includes(action.kind))
132
133
  return "kind-outside-round-scope";
133
134
  if (action.kind === "reply") {
135
+ const authorReason = replyAuthorReason(state, action, this.#evidenceExists);
136
+ if (authorReason)
137
+ return authorReason;
134
138
  const reason = replyRootAgeReason(action, executor?.replyMaxRootAgeHours, this.#clock());
135
139
  if (reason)
136
140
  return reason;
@@ -9,10 +9,11 @@ export declare const source: (post: any, page: any) => {
9
9
  datetime: any;
10
10
  url: string | null;
11
11
  body: any;
12
+ replyToId: any;
12
13
  images: any;
13
14
  media: any;
14
15
  links: any;
15
- metrics: any;
16
+ metrics: any[];
16
17
  needsExpansion: any;
17
18
  missing: any[];
18
19
  };
@@ -30,10 +30,11 @@ export const source = (post, page) => ({
30
30
  datetime: post.datetime,
31
31
  url: post.primary ? new URL(post.primary, page).href : null,
32
32
  body: post.body,
33
+ replyToId: post.replyToId,
33
34
  images: post.images ?? [],
34
35
  media: post.media ?? [],
35
36
  links: post.links ?? [],
36
- metrics: post.metrics ?? post.buttons ?? [],
37
+ metrics: [...(post.buttons ?? []), ...(post.metrics ?? [])],
37
38
  needsExpansion: post.needsExpansion,
38
39
  missing: [
39
40
  ...(post.missing ?? []),
@@ -0,0 +1,3 @@
1
+ import type { BoundaryRecord } from "./boundary.js";
2
+ /** Account policy counts distinct original actions, including unresolved submissions. */
3
+ export declare function replyAuthorReason(state: BoundaryRecord, action: BoundaryRecord, evidenceExists: (path: string) => boolean): string | null;
@@ -0,0 +1,33 @@
1
+ /** Account policy counts distinct original actions, including unresolved submissions. */
2
+ export function replyAuthorReason(state, action, evidenceExists) {
3
+ const policy = state.replyAuthorPolicy;
4
+ if (action.kind !== "reply" ||
5
+ !policy ||
6
+ !(action.followGapContribution ||
7
+ ["mutual", "casual"].includes(action.sourceCategory)))
8
+ return null;
9
+ if (policy.userAuthorized !== true ||
10
+ policy.max !== 2 ||
11
+ !evidenceExists(policy.evidenceRef ?? ""))
12
+ return "reply-author-policy-unconfirmed";
13
+ const handle = action.conversation?.recipientHandle
14
+ ?.replace(/^@/, "")
15
+ .toLowerCase();
16
+ if (!/^[a-z0-9_]{1,15}$/.test(handle ?? ""))
17
+ return "reply-author-identity-required";
18
+ const history = state.replyAuthorHistory;
19
+ if (!history?.complete || !evidenceExists(history.evidenceRef ?? ""))
20
+ return "reply-author-history-unconfirmed";
21
+ const ids = new Set();
22
+ for (const a of [...(history.entries ?? []), ...(state.actions ?? [])]) {
23
+ const author = (a.author ?? a.conversation?.recipientHandle)
24
+ ?.replace(/^@/, "")
25
+ .toLowerCase();
26
+ if (a.id !== action.id &&
27
+ a.kind === "reply" &&
28
+ author === handle &&
29
+ ["intent", "unknown", "verified", "preexisting"].includes(a.status))
30
+ ids.add(a.id);
31
+ }
32
+ return ids.size >= policy.max ? "reply-author-limit" : null;
33
+ }
@@ -12,7 +12,7 @@ export function replyRootAgeReason(action, maximumHours, now) {
12
12
  return "reply-root-identity-required";
13
13
  try {
14
14
  const observation = JSON.parse(readFileSync(action.evidenceRef, "utf8")).observation;
15
- const nodes = ["posts", "context", "threadPosts"].flatMap((key) => Array.isArray(observation?.[key]) ? observation[key] : []);
15
+ const nodes = ["posts", "context", "threadPosts", "sources"].flatMap((key) => (Array.isArray(observation?.[key]) ? observation[key] : []));
16
16
  const root = nodes.find((node) => node?.id === rootId);
17
17
  if (!nodes.some((node) => node?.id === action.postId) || !root)
18
18
  return "reply-root-publication-proof-required";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/x-harness",
3
- "version": "0.2.59",
3
+ "version": "0.2.61",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Typed X task harness with compact business results and explicit diagnostics.",