@nextclaw/x-harness 0.0.0-stage → 0.1.1

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.
Files changed (110) hide show
  1. package/LICENSE +10 -0
  2. package/README.md +41 -2
  3. package/cli/main.js +219 -0
  4. package/dist/api.d.ts +10 -0
  5. package/dist/api.js +308 -0
  6. package/dist/boundary.d.ts +2 -0
  7. package/dist/browser-common.d.ts +4 -0
  8. package/dist/browser-common.js +29 -0
  9. package/dist/browser-dom-capabilities.d.ts +4 -0
  10. package/dist/browser-dom-capabilities.js +110 -0
  11. package/dist/browser-dom-dependencies.d.ts +16 -0
  12. package/dist/browser-dom-editing.d.ts +148 -0
  13. package/dist/browser-dom-editing.js +386 -0
  14. package/dist/browser-dom-navigation.d.ts +9 -0
  15. package/dist/browser-dom-navigation.js +165 -0
  16. package/dist/browser-dom-network.d.ts +1 -0
  17. package/dist/browser-dom-network.js +128 -0
  18. package/dist/browser-dom-submission.d.ts +2 -0
  19. package/dist/browser-dom-submission.js +82 -0
  20. package/dist/browser-dom.d.ts +2 -0
  21. package/dist/browser-dom.js +103 -0
  22. package/dist/browser-native.d.ts +1 -0
  23. package/dist/browser-native.js +215 -0
  24. package/dist/browser.d.ts +4 -0
  25. package/dist/browser.js +147 -0
  26. package/dist/creator.d.ts +29 -0
  27. package/dist/creator.js +164 -0
  28. package/dist/growth-batch.d.ts +5 -0
  29. package/dist/growth-batch.js +168 -0
  30. package/dist/growth-constants.d.ts +5 -0
  31. package/dist/growth-constants.js +13 -0
  32. package/dist/growth-dependencies.d.ts +33 -0
  33. package/dist/growth-execution.d.ts +11 -0
  34. package/dist/growth-execution.js +315 -0
  35. package/dist/growth-parallel.d.ts +4 -0
  36. package/dist/growth-parallel.js +301 -0
  37. package/dist/growth-plan.d.ts +4 -0
  38. package/dist/growth-plan.js +207 -0
  39. package/dist/growth-policy.d.ts +9 -0
  40. package/dist/growth-policy.js +181 -0
  41. package/dist/growth-publishing.d.ts +5 -0
  42. package/dist/growth-publishing.js +240 -0
  43. package/dist/growth-reading.d.ts +4 -0
  44. package/dist/growth-reading.js +135 -0
  45. package/dist/growth-recovery.d.ts +6 -0
  46. package/dist/growth-recovery.js +158 -0
  47. package/dist/growth-state.d.ts +8 -0
  48. package/dist/growth-state.js +183 -0
  49. package/dist/growth-tasks.d.ts +17 -0
  50. package/dist/growth-tasks.js +101 -0
  51. package/dist/growth.d.ts +2 -0
  52. package/dist/growth.js +138 -0
  53. package/dist/index.d.ts +4 -0
  54. package/dist/index.js +22 -0
  55. package/dist/observation.d.ts +1 -0
  56. package/dist/observation.js +2 -0
  57. package/dist/platform-capabilities.d.ts +4 -0
  58. package/dist/platform-capabilities.js +19 -0
  59. package/dist/platform-collections.d.ts +7 -0
  60. package/dist/platform-collections.js +223 -0
  61. package/dist/platform-dependencies.d.ts +43 -0
  62. package/dist/platform-diagnostics.d.ts +9 -0
  63. package/dist/platform-diagnostics.js +51 -0
  64. package/dist/platform-observation.d.ts +8 -0
  65. package/dist/platform-observation.js +75 -0
  66. package/dist/platform-rules.d.ts +17 -0
  67. package/dist/platform-rules.js +41 -0
  68. package/dist/platform-targets.d.ts +7 -0
  69. package/dist/platform-targets.js +129 -0
  70. package/dist/platform-writing.d.ts +8 -0
  71. package/dist/platform-writing.js +171 -0
  72. package/dist/platform.d.ts +2 -0
  73. package/dist/platform.js +60 -0
  74. package/dist/readers-actions.d.ts +2 -0
  75. package/dist/readers-actions.js +66 -0
  76. package/dist/readers-ax-host.d.ts +2 -0
  77. package/dist/readers-ax-host.js +125 -0
  78. package/dist/readers-ax-parser.d.ts +1 -0
  79. package/dist/readers-ax-parser.js +69 -0
  80. package/dist/readers-ax-program.d.ts +1 -0
  81. package/dist/readers-ax-tree.d.ts +19 -0
  82. package/dist/readers-ax-tree.js +110 -0
  83. package/dist/readers-ax-views.d.ts +87 -0
  84. package/dist/readers-ax-views.js +247 -0
  85. package/dist/readers-cli.d.ts +6 -0
  86. package/dist/readers-composer.d.ts +2 -0
  87. package/dist/readers-composer.js +131 -0
  88. package/dist/readers-navigation.d.ts +2 -0
  89. package/dist/readers-navigation.js +66 -0
  90. package/dist/readers-posts.d.ts +2 -0
  91. package/dist/readers-posts.js +141 -0
  92. package/dist/readers-profile.d.ts +3 -0
  93. package/dist/readers-profile.js +157 -0
  94. package/dist/readers.d.ts +9 -0
  95. package/dist/results.d.ts +6 -0
  96. package/dist/results.js +233 -0
  97. package/dist/round-state.d.ts +3 -0
  98. package/dist/round-state.js +155 -0
  99. package/dist/store.d.ts +30 -0
  100. package/dist/store.js +175 -0
  101. package/dist/types.d.ts +407 -0
  102. package/generated/observation.d.mts +1 -0
  103. package/generated/observation.mjs +515 -0
  104. package/package.json +29 -3
  105. package/skill/SKILL.md +33 -0
  106. package/skill/references/api.md +10 -0
  107. package/skill/references/reads.md +23 -0
  108. package/skill/references/recovery.md +25 -0
  109. package/skill/references/setup.md +23 -0
  110. package/skill/references/writes.md +51 -0
@@ -0,0 +1,407 @@
1
+ /** Public business contract. Raw browser observations never cross this interface. */
2
+ export type OperationKind = "follow" | "original" | "reply";
3
+ export type ReadMode = "receipt" | "decision" | "delta";
4
+ export type EvidenceRef = string;
5
+ export interface PostTarget {
6
+ postId: string;
7
+ url: string;
8
+ evidenceRef: EvidenceRef;
9
+ }
10
+ export interface PersonTarget {
11
+ handle: string;
12
+ url: string;
13
+ evidenceRef: EvidenceRef;
14
+ }
15
+ export interface ImageEvidence {
16
+ src?: string | null;
17
+ alt?: string | null;
18
+ }
19
+ export interface MediaEvidence {
20
+ kind?: string;
21
+ src?: string | null;
22
+ poster?: string | null;
23
+ label?: string | null;
24
+ duration?: string | number;
25
+ requiresViewing?: boolean;
26
+ }
27
+ export interface LinkEvidence {
28
+ href: string;
29
+ text?: string;
30
+ label?: string;
31
+ }
32
+ export interface PostEvidence {
33
+ id: string | null;
34
+ author?: string | null;
35
+ datetime?: string | null;
36
+ url?: string | null;
37
+ body?: string | null;
38
+ images?: ImageEvidence[];
39
+ media?: MediaEvidence[];
40
+ links?: (string | LinkEvidence)[];
41
+ metrics?: string[];
42
+ quoted?: boolean;
43
+ videoElements?: number;
44
+ needsExpansion?: boolean;
45
+ missing?: string[];
46
+ }
47
+ export interface CounterEvidence {
48
+ value?: number | null;
49
+ raw?: string | null;
50
+ text?: string | string[] | null;
51
+ precision?: string;
52
+ url?: string | null;
53
+ }
54
+ export interface PersonEvidence {
55
+ handle: string;
56
+ url?: string;
57
+ blue?: boolean | null;
58
+ relationship?: string;
59
+ biography?: string | null;
60
+ following?: CounterEvidence | null;
61
+ followers?: CounterEvidence | null;
62
+ }
63
+ export interface FeedbackEvidence {
64
+ id: string;
65
+ metrics?: (string | {
66
+ label?: string;
67
+ value?: string | number;
68
+ })[];
69
+ replies?: PostEvidence[];
70
+ unconfirmedReplyIds?: string[];
71
+ pageComplete?: boolean;
72
+ missing?: string[];
73
+ }
74
+ export interface Diagnostic {
75
+ operation?: string;
76
+ category?: string;
77
+ code: string;
78
+ next?: "inspect-local-proof" | "restore-proof-store";
79
+ evidenceRef?: EvidenceRef;
80
+ }
81
+ export interface ReadResult {
82
+ status: "observed" | "needsDecision" | "needsCapability";
83
+ fresh?: boolean;
84
+ complete?: boolean;
85
+ pageComplete?: boolean;
86
+ evidenceRef?: EvidenceRef;
87
+ ids?: string[];
88
+ missing?: string[];
89
+ reason?: string;
90
+ diagnostic?: Diagnostic;
91
+ accountHandle?: string | null;
92
+ accountURL?: string | null;
93
+ sources?: PostEvidence[];
94
+ post?: PostEvidence;
95
+ person?: PersonEvidence;
96
+ feedback?: FeedbackEvidence[];
97
+ unchangedIds?: string[];
98
+ creator?: CreatorEvidence;
99
+ }
100
+ export interface WindowOptions {
101
+ mode?: ReadMode;
102
+ limit?: number;
103
+ maxPages?: number;
104
+ processedIds?: string[];
105
+ }
106
+ export interface BookmarkOptions extends WindowOptions {
107
+ folder: string;
108
+ }
109
+ export interface SearchOptions extends WindowOptions {
110
+ query: string;
111
+ }
112
+ export interface CreatorOptions {
113
+ handle: string;
114
+ target?: number;
115
+ maxScrolls?: number;
116
+ navigate?: boolean;
117
+ expand?: boolean;
118
+ mode?: ReadMode;
119
+ }
120
+ export interface CreatorEvidence {
121
+ name?: string | null;
122
+ joined?: string | null;
123
+ totalPostsText?: string | null;
124
+ externalLinks?: string[];
125
+ scrolls?: number;
126
+ observedAt?: string;
127
+ }
128
+ export interface FeedbackOptions {
129
+ targets: PostTarget[];
130
+ replyLimit?: number;
131
+ mode?: ReadMode;
132
+ }
133
+ export interface QualityReview {
134
+ approved: boolean;
135
+ evidenceRef: EvidenceRef;
136
+ approvedText?: string;
137
+ draftFingerprint?: string;
138
+ handle?: string;
139
+ blue?: boolean;
140
+ chinese?: boolean;
141
+ }
142
+ interface PreparedActionBase {
143
+ id: string;
144
+ status: "prepared";
145
+ accountHandle: string;
146
+ accountURL: string;
147
+ accountEvidenceRef: EvidenceRef;
148
+ quality: QualityReview;
149
+ }
150
+ export type PreparedAction = PreparedActionBase & ({
151
+ kind: "follow";
152
+ handle: string;
153
+ url: string;
154
+ evidenceRef: EvidenceRef;
155
+ } | {
156
+ kind: "original";
157
+ draftPath: string;
158
+ text: string;
159
+ composeURL: string;
160
+ composeEvidenceRef: EvidenceRef;
161
+ assets?: {
162
+ path: string;
163
+ alt: string;
164
+ }[];
165
+ activation?: "click" | "keyboard";
166
+ } | {
167
+ kind: "reply";
168
+ postId: string;
169
+ url: string;
170
+ evidenceRef: EvidenceRef;
171
+ text: string;
172
+ assets?: {
173
+ path: string;
174
+ alt: string;
175
+ }[];
176
+ activation?: "click" | "keyboard";
177
+ });
178
+ export interface ExecutionDecision {
179
+ actionId?: string;
180
+ kind?: OperationKind;
181
+ status?: string;
182
+ reason?: string;
183
+ missing?: string[];
184
+ resumeAt?: string;
185
+ owner?: string;
186
+ evidenceRef?: EvidenceRef;
187
+ }
188
+ export interface ActionResult {
189
+ status: "verified" | "unknown" | "prepared" | "skipped" | "preexisting" | "waiting" | "needsDecision" | "needsCapability";
190
+ taskId: string;
191
+ actionId?: string;
192
+ publicId?: string;
193
+ publicURL?: string;
194
+ evidenceRef?: EvidenceRef;
195
+ reason?: string;
196
+ missing?: string[];
197
+ resumeAt?: string;
198
+ diagnostic?: Diagnostic;
199
+ }
200
+ export interface RoundResult {
201
+ diagnostic?: Diagnostic;
202
+ status: string;
203
+ taskId: string;
204
+ mayEnd: boolean;
205
+ scopeKinds?: OperationKind[];
206
+ actual?: Partial<Record<OperationKind, {
207
+ verified: number;
208
+ unknown: number;
209
+ }>>;
210
+ gaps?: {
211
+ kind: OperationKind;
212
+ remaining: number;
213
+ unknown: number;
214
+ }[];
215
+ decision?: ExecutionDecision[];
216
+ evidenceRef?: EvidenceRef;
217
+ settlementErrors?: string[];
218
+ checkpoint?: {
219
+ taskId: string;
220
+ executorId: string;
221
+ completed: number;
222
+ resume: string;
223
+ };
224
+ }
225
+ export interface BatchResult {
226
+ diagnostic?: Diagnostic;
227
+ status: string;
228
+ taskId: string;
229
+ batchId?: string;
230
+ planned: number;
231
+ attempted: number;
232
+ verified: number;
233
+ unknown: number;
234
+ remaining: number;
235
+ mayEnd: boolean;
236
+ evidenceRef?: EvidenceRef;
237
+ decision?: ExecutionDecision[];
238
+ }
239
+ export type RoundDecision = {
240
+ type: "prepareActions";
241
+ accountHandle: string;
242
+ ownershipEvidenceRef: EvidenceRef;
243
+ actions: PreparedAction[];
244
+ attemptsCoverage?: {
245
+ complete: boolean;
246
+ since: string;
247
+ evidenceRef: EvidenceRef;
248
+ };
249
+ sharedAttempts?: {
250
+ kind: OperationKind;
251
+ at: string;
252
+ }[];
253
+ nextScheduledCheckAt?: string;
254
+ } | {
255
+ actionId: string;
256
+ approved: boolean;
257
+ evidenceRef: EvidenceRef;
258
+ approvedText?: string;
259
+ draftFingerprint?: string;
260
+ blue?: boolean;
261
+ chinese?: boolean;
262
+ };
263
+ export interface RoundOptions {
264
+ taskId: string;
265
+ decision?: RoundDecision;
266
+ maxActions?: number;
267
+ }
268
+ export interface IndependentExecution {
269
+ tabId: string;
270
+ evidenceRef: EvidenceRef;
271
+ scopeEvidenceRef: EvidenceRef;
272
+ windowAuthorization?: {
273
+ actionId: string;
274
+ userAuthorized: true;
275
+ expiresAt: string;
276
+ evidenceRef: EvidenceRef;
277
+ };
278
+ }
279
+ export interface PublishOptions {
280
+ taskId: string;
281
+ draftPath: string;
282
+ preparedAction?: Extract<PreparedAction, {
283
+ kind: "original";
284
+ }>;
285
+ independentExecution?: IndependentExecution;
286
+ }
287
+ export interface ReplyOptions {
288
+ taskId: string;
289
+ postId: string;
290
+ text: string;
291
+ preparedAction?: Extract<PreparedAction, {
292
+ kind: "reply";
293
+ }>;
294
+ }
295
+ export interface FollowOptions {
296
+ taskId: string;
297
+ handles: string[];
298
+ preparedActions?: Extract<PreparedAction, {
299
+ kind: "follow";
300
+ }>[];
301
+ }
302
+ export interface SourceLinkEvidence {
303
+ href: string;
304
+ resolvedURL: string;
305
+ evidenceRef: EvidenceRef;
306
+ renderedText?: string;
307
+ }
308
+ export interface Executor {
309
+ id: string;
310
+ scopeKinds: OperationKind[];
311
+ evidenceRef: EvidenceRef;
312
+ }
313
+ /** Structural host ports: the package reuses the provided CUA connection. */
314
+ export interface LocatorPort {
315
+ count(): Promise<number>;
316
+ click(options?: unknown): Promise<unknown>;
317
+ fill(value: string): Promise<unknown>;
318
+ first(): LocatorPort;
319
+ waitFor(options: unknown): Promise<unknown>;
320
+ press?(key: string, options?: unknown): Promise<unknown>;
321
+ all?(): Promise<LocatorPort[]>;
322
+ getByRole?(role: string, options?: unknown): LocatorPort;
323
+ }
324
+ export interface CuaTab {
325
+ id?: string;
326
+ url(): Promise<string>;
327
+ goto?(url: string): Promise<unknown>;
328
+ reload?(): Promise<unknown>;
329
+ screenshot?(): Promise<unknown>;
330
+ getAXState?(options: unknown): Promise<unknown>;
331
+ scroll?(target: number | [number, number], direction: string, pages?: number): Promise<unknown>;
332
+ playwright: {
333
+ evaluate<T, A>(fn: (arg: A) => T, arg: A): Promise<T>;
334
+ getByRole?(role: string, options?: unknown): LocatorPort;
335
+ getByText?(text: string, options?: unknown): LocatorPort;
336
+ locator?(selector: string): LocatorPort;
337
+ waitForURL?(url: unknown, options?: unknown): Promise<unknown>;
338
+ waitForLoadState?(options: unknown): Promise<unknown>;
339
+ };
340
+ }
341
+ export interface CuaApp {
342
+ getAXState(options: unknown): Promise<unknown>;
343
+ click?(index: number): Promise<unknown>;
344
+ pressKey?(key: string): Promise<unknown>;
345
+ paste?(value: string): Promise<unknown>;
346
+ }
347
+ export type HarnessOptions = ({
348
+ tab: CuaTab;
349
+ app?: never;
350
+ } | {
351
+ app: CuaApp;
352
+ tab?: never;
353
+ }) & {
354
+ ledgerPath: string;
355
+ proofDirectory: string;
356
+ clock?: () => number;
357
+ executor?: Executor;
358
+ };
359
+ export interface XGrowthHarness {
360
+ readCreator(args: CreatorOptions): Promise<ReadResult>;
361
+ readBookmarks(args: BookmarkOptions): Promise<ReadResult>;
362
+ searchSources(args: SearchOptions): Promise<ReadResult>;
363
+ readPost(args: {
364
+ target: PostTarget;
365
+ mode?: ReadMode;
366
+ }): Promise<ReadResult>;
367
+ readPerson(args: {
368
+ target: PersonTarget;
369
+ mode?: ReadMode;
370
+ }): Promise<ReadResult>;
371
+ readFeedback(args: FeedbackOptions): Promise<ReadResult>;
372
+ inspectAccount(args?: {
373
+ mode?: ReadMode;
374
+ }): Promise<ReadResult>;
375
+ inspectRound(args: {
376
+ taskId: string;
377
+ }): Promise<RoundResult>;
378
+ runGrowthRound(args: RoundOptions): Promise<RoundResult>;
379
+ followBatch(args: FollowOptions): Promise<BatchResult>;
380
+ followOne(args: {
381
+ taskId: string;
382
+ handle: string;
383
+ }): Promise<ActionResult>;
384
+ publishPost(args: PublishOptions): Promise<ActionResult>;
385
+ replyToPost(args: ReplyOptions): Promise<ActionResult>;
386
+ verifySubmission(args: {
387
+ taskId: string;
388
+ actionId: string;
389
+ }): Promise<ActionResult>;
390
+ verifyPublishedPost(args: {
391
+ taskId: string;
392
+ draftPath: string;
393
+ publicURL: string;
394
+ evidenceRef: EvidenceRef;
395
+ sourceLink?: SourceLinkEvidence;
396
+ }): Promise<ActionResult>;
397
+ verifyFollow(args: {
398
+ handle: string;
399
+ url?: string;
400
+ evidenceRef?: EvidenceRef;
401
+ mode?: "receipt" | "decision";
402
+ }): Promise<ReadResult & {
403
+ handle: string;
404
+ verified: boolean;
405
+ }>;
406
+ }
407
+ export {};
@@ -0,0 +1 @@
1
+ export declare const readXObservation: (query: unknown) => Record<string, unknown>;