@volter/twin-x 0.1.0
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/LICENSE +202 -0
- package/README.md +138 -0
- package/dist/client/x-mirror.bundle.js +321 -0
- package/dist/client/x-mirror.d.ts +45 -0
- package/dist/client/x-mirror.js +417 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +29 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +68 -0
- package/dist/src/x-budget.d.ts +54 -0
- package/dist/src/x-budget.js +123 -0
- package/dist/src/x-capabilities.d.ts +3 -0
- package/dist/src/x-capabilities.js +1106 -0
- package/dist/src/x-conformance.d.ts +8 -0
- package/dist/src/x-conformance.js +91 -0
- package/dist/src/x-connector.d.ts +125 -0
- package/dist/src/x-connector.js +546 -0
- package/dist/src/x-media.d.ts +87 -0
- package/dist/src/x-media.js +275 -0
- package/dist/src/x-mirror-ui.d.ts +61 -0
- package/dist/src/x-mirror-ui.js +253 -0
- package/dist/src/x-problems.d.ts +38 -0
- package/dist/src/x-problems.js +130 -0
- package/dist/src/x-scopes.d.ts +7 -0
- package/dist/src/x-scopes.js +62 -0
- package/dist/src/x-server.d.ts +14 -0
- package/dist/src/x-server.js +127 -0
- package/dist/src/x-twin.d.ts +21 -0
- package/dist/src/x-twin.js +1534 -0
- package/package.json +58 -0
- package/src/cli.ts +27 -0
- package/src/index.ts +132 -0
- package/src/x-budget.ts +150 -0
- package/src/x-capabilities.ts +1161 -0
- package/src/x-conformance.ts +113 -0
- package/src/x-connector.ts +546 -0
- package/src/x-media.ts +295 -0
- package/src/x-mirror-ui.ts +263 -0
- package/src/x-problems.ts +143 -0
- package/src/x-scopes.ts +67 -0
- package/src/x-server.ts +126 -0
- package/src/x-twin.ts +1545 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# `@volter/twin-x` — the X (Twitter) API v2 posting surface
|
|
2
|
+
|
|
3
|
+
> **Legacy connector helpers:** this package still has callable helpers using the retired v1
|
|
4
|
+
> `syncPull` API. Those paths require migration before use on the current kernel;
|
|
5
|
+
> older helper descriptions below do not establish current compatibility. Check the
|
|
6
|
+
> [generated index](../../../generated/INDEX.md) for protocol standing and use the
|
|
7
|
+
> [shared model](../../../docs/concepts/the-model.md) for current state semantics.
|
|
8
|
+
|
|
9
|
+
The org's **public voice**: post (with images or a video), quote, reply to a mention, retract, look a post or an
|
|
10
|
+
account back up, and read the mentions / own / home timelines and recent search — offline, against local state, with
|
|
11
|
+
X's own `tweet.fields` projection, bearer/scope gate and problem envelopes.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bun packages/twin/x/src/cli.ts serve --root /tmp/world
|
|
15
|
+
# then point any X v2 client at it: X_TWIN_URL=http://127.0.0.1:<port> node --require @volter/world-core/inject app.js
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Coverage
|
|
19
|
+
|
|
20
|
+
| Area | What the twin serves |
|
|
21
|
+
|---|---|
|
|
22
|
+
| `POST /2/tweets` | Create an **original post** — with `reply.in_reply_to_tweet_id` a **reply**, with `quote_tweet_id` a **quote**. One route, three body fields. Text over the account's limit (280, or its X Premium long-post entitlement) is refused before anything is written. `media.media_ids` attaches up to four images or one video this account uploaded; an unknown, foreign, expired or still-processing id is X's `Your media IDs are invalid.` |
|
|
23
|
+
| `POST /2/media/upload` · `…/initialize` · `…/{id}/append` · `…/{id}/finalize` · `GET /2/media/upload?command=STATUS` | **Media upload**, needing `media.write`: an image (`tweet_image`, `dm_image`) in one request, multipart or base64 JSON, typed and sized from its own bytes; a video (`tweet_video`, `amplify_video`, MP4) in chunks, whose `processing_info` goes pending → in_progress → succeeded one STATUS read at a time (a file that is not an MP4 fails as `InvalidMedia`). Bytes live on the kernel's blob seam, content-addressed; an upload is not an entry — the post that attaches it is. GIF, DM video and subtitle categories are refused by name. |
|
|
24
|
+
| media bytes | Served at X's own path shapes under the twin's base (a World's mount included): `/media/<name>.<ext>` for an image, `/ext_tw_video/<id>/pu/vid/avc1/<w>x<h>/<name>.mp4` for a video with HTTP Range, `/ext_tw_video_thumb/…` for a video's preview — a stand-in poster, since the twin decodes no frames. |
|
|
25
|
+
| `DELETE /2/tweets/:id` | Retract a post. Only your own; only once. |
|
|
26
|
+
| `GET /2/tweets/:id` · `GET /2/tweets?ids=` | Post lookup, single and bulk. The bulk form is **partial**, as X's is: the ids that exist in `data`, the ones that do not in `errors` — never a fabricated row. |
|
|
27
|
+
| `GET /2/users/:id/mentions` | The mentions timeline — posts naming this account. |
|
|
28
|
+
| `GET /2/users/:id/tweets` | The account's own posted timeline. |
|
|
29
|
+
| `GET /2/users/:id/timelines/reverse_chronological` | The home timeline — the account plus the accounts it follows; refused for anyone else's id. |
|
|
30
|
+
| `GET /2/users/:id` · `GET /2/users/by/username/:username` | User lookup (handles are case-insensitive). An unknown user is X's partial-error 200 with a `resource_type: "user"` row, never a fabricated account. `GET /2/users/me` is `xidentity`'s and is not claimed here. |
|
|
31
|
+
| `GET /2/tweets/search/recent` | Recent search over the local corpus: keywords, quoted phrases and `from:`. Grammar the twin does not model (`OR`, negation, grouping, other operators) is **refused**, never silently ignored. |
|
|
32
|
+
| projection | `tweet.fields`, `user.fields`, `media.fields` and `expansions` (`attachments.media_keys` included) + the `includes` sidecar. The default is X's three fields (`id`, `text`, `edit_history_tweet_ids`) and nothing else — a documented field the twin holds no state for is refused by name rather than quietly omitted. |
|
|
33
|
+
| paging + windows | `pagination_token` / `meta.next_token`, `max_results` (5..100 on the timelines, 10..100 on search), and `since_id` / `until_id` / `start_time` / `end_time` with X's own id-beats-time precedence. |
|
|
34
|
+
| auth | The bearer `xidentity`'s OAuth flow mints, its scope set, and X's `about:blank` 401 / `Forbidden` 403 problems. |
|
|
35
|
+
| errors | `resource-not-found`, `invalid-request`, the 429 + legacy code 88 pair, `405` under `--read-only`. |
|
|
36
|
+
| connector | Pull **both** timelines — mentions and the account's own posts — following `next_token` to the end of each; **push** a pending post/quote/reply/delete to the real vendor, confirmed under the id X minted. A post with media is **performed** by uploading each file to X first (an image in one request; a video chunked, then polled on STATUS until processed) and posting with the media ids X minted. |
|
|
37
|
+
| `/_twin/*` | Twin-only control plane: seed an account (its profile — `description`, `location`, `url`, `protected`, `verified` — and its long-post entitlement), a bearer, an inbound mention, a follow edge, or an armed rate refusal. |
|
|
38
|
+
|
|
39
|
+
`src/x-capabilities.ts` is the denominator: **114 capabilities, 74 done**. What is
|
|
40
|
+
not modelled is enumerated there as a todo — polls, hide-reply, `entities`/`public_metrics`,
|
|
41
|
+
the `user.fields` with no state behind them, full-archive search and the query grammar, likes/reposts/bookmarks, stream rules, the
|
|
42
|
+
filtered and sampled **streaming** connections, GIFs, alt text, a video's real poster frame and X's transcoded
|
|
43
|
+
variants — not omitted. One CORE todo remains and says why in its own title: `x.rate_limit.published_figures`
|
|
44
|
+
needs X's published per-endpoint posting limits, and this pack makes no X call to fetch them.
|
|
45
|
+
|
|
46
|
+
## One route, two operations, and why that is the whole point
|
|
47
|
+
|
|
48
|
+
An original post and a reply are **the same HTTP operation** at X: `POST /2/tweets`, differing
|
|
49
|
+
only by `reply.in_reply_to_tweet_id` in the body. The pinned official client proves it —
|
|
50
|
+
`tweet()` posts `{text}` to `tweets` and `reply()` posts `{text, reply:{in_reply_to_tweet_id}}` to
|
|
51
|
+
the same `tweets` (`twitter-api-v2@1.29.1`, `dist/cjs/v2/client.v2.write.js:89` and `:180`). A
|
|
52
|
+
**quote** is a third body field on that same route (`quote_tweet_id`, `:187`).
|
|
53
|
+
|
|
54
|
+
That matters beyond fidelity, because the example org **graduates the two at different times**:
|
|
55
|
+
replying to a mention is allowed before posting under the org's own name is. A census keyed by
|
|
56
|
+
method+path names ONE capability for both, and that ladder cannot be written down at all.
|
|
57
|
+
|
|
58
|
+
So `x-spec-census.json` declares `requestKey: "method+path+body-field"` and carries **two** entries
|
|
59
|
+
for that one route — `x.tweets.reply` when the field is present, `x.tweets.create` when it is
|
|
60
|
+
absent — both mapped as `operationCapability`, so a consumer that has not learned to read the body
|
|
61
|
+
**denies** rather than granting the first entry to both. Every other route in the census is an
|
|
62
|
+
ordinary method+path row: this is not a single-endpoint vendor.
|
|
63
|
+
|
|
64
|
+
A quote deliberately does **not** get a third census entry: for the split this census exists to
|
|
65
|
+
express — answering someone versus speaking under the org's own name — a quote is an *original*
|
|
66
|
+
post, so it resolves to the `x.tweets.create` side and the partition stays two-sided and total.
|
|
67
|
+
|
|
68
|
+
The discriminator is the pack's own, not a vocabulary minted for the census: `x-twin.ts` branches
|
|
69
|
+
on those exact fields to decide what it writes (`conversation_id`, `in_reply_to_user_id`,
|
|
70
|
+
`referenced_tweets`), and `x-connector.ts` sends the same fields back to the real vendor on a push.
|
|
71
|
+
`src/x-spec-census.test.ts` holds those three to each other, so a rename in one goes red.
|
|
72
|
+
|
|
73
|
+
## Relationship to `@volter/twin-xidentity`
|
|
74
|
+
|
|
75
|
+
`xidentity` owns **X's OAuth 2.0** — the x.com authorize screen, the authorization-code + PKCE
|
|
76
|
+
round trip, and `GET /2/users/me`. This pack owns the **posting surface** and consumes the user
|
|
77
|
+
access token that flow mints. It never models OAuth: X's authorization-code round trip is a
|
|
78
|
+
capability of `xidentity`, and duplicating it here would be two accounts of one vendor's auth.
|
|
79
|
+
|
|
80
|
+
The two agree about X rather than sharing code: `scripts/architecture.test.ts` (A3) forbids a
|
|
81
|
+
cross-vendor pack import, so `src/x-problems.ts` and `src/x-scopes.ts` **transcribe** xidentity's
|
|
82
|
+
problem envelopes and scope catalog — both grounded in the same X API v2 OpenAPI 2.167 document —
|
|
83
|
+
and say so at the seam. If X's error shape is ever re-grounded, both files move together.
|
|
84
|
+
|
|
85
|
+
Both packs claim `api.x.com` in the injector, path-scoped and **disjoint**: xidentity claims
|
|
86
|
+
`/2/oauth2/{token,revoke}` and `/2/users/me`; this claims `/2/tweets`, `/2/tweets/:id`,
|
|
87
|
+
`/2/tweets/search/recent`, `/2/users/{id}/{mentions,tweets,timelines/reverse_chronological}`,
|
|
88
|
+
`/2/users/{id}` and `/2/users/by/username/{username}`. The user-id rule excludes `me` by a
|
|
89
|
+
lookahead and the timeline rules need a trailing segment, so `/2/users/me` matches none of them
|
|
90
|
+
and no request is claimable by both. An unclaimed path on that claimed host is refused loudly rather than mis-routed into a
|
|
91
|
+
twin that cannot serve it.
|
|
92
|
+
|
|
93
|
+
## The mirror — x.com's view of the twin
|
|
94
|
+
|
|
95
|
+
A person doing X's core job opens a browser, so this pack ships a mirror: x.com's own look over the
|
|
96
|
+
twin's state, for judging a post as it will appear.
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bun packages/twin/x/src/cli.ts mirror --root /tmp/world --port 4700 # or: volter twin x mirror --root <state> --port <p>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- **Sign in** is x.com's two-step login: the account's `@handle`, then — in place of a password —
|
|
103
|
+
the bearer the twin issued for it through `/_twin/tokens`. The mirror checks the token is that
|
|
104
|
+
account's with X's own rule (the home timeline is served only to its own account). Handle and
|
|
105
|
+
token live in the tab's `sessionStorage`; the mirror keeps nothing else.
|
|
106
|
+
- **Screens**: the profile (header, Posts / Replies), a single post's page with its reply box and
|
|
107
|
+
the replies the account can read, Notifications → Mentions, and Home with the compose box. A
|
|
108
|
+
post's media is x.com's rounded block under its text: one image at its own aspect, two to four
|
|
109
|
+
in a grid, or a video player — its own first frame, the play button and the duration badge until
|
|
110
|
+
it plays, then the player's controls. The composer posts text only.
|
|
111
|
+
- **Reads** are the routes above — `GET /2/users/by/username/:username`, `/2/users/:id/tweets`,
|
|
112
|
+
`/2/users/:id/mentions`, `/2/users/:id/timelines/reverse_chronological`, `/2/tweets/:id`, each
|
|
113
|
+
expanding `attachments.media_keys`, and the media URLs they return —
|
|
114
|
+
on the same origin (`src/x-mirror-ui.ts` mounts the pack's own fetch adapter). **Writes** are
|
|
115
|
+
`POST /2/tweets`: a post, or a reply with `reply.in_reply_to_tweet_id`.
|
|
116
|
+
- **What it does not draw**: engagement counts and the profile's Following / Followers numbers —
|
|
117
|
+
the twin models no `public_metrics`, so the slots are empty rather than zero. The avatar is a
|
|
118
|
+
lettered placeholder; the twin serves no profile images.
|
|
119
|
+
- **Not yet readable inside a served World.** `volter world serve` has no mirror mount (only
|
|
120
|
+
`apps/cloud` mounts `/<org>/<world>/<vendor>/mirror/`), and on a World's wire an
|
|
121
|
+
`Authorization: Bearer` is read as the World's own credential ahead of the browser's session
|
|
122
|
+
cookie, so the mirror's X bearer is refused there as `token required`.
|
|
123
|
+
|
|
124
|
+
**"Drafts in an outbox" is deliberately not here.** A draft sitting until someone approves it is an
|
|
125
|
+
obligation on the posting *action* — org config — and building an outbox into a vendor pack would
|
|
126
|
+
put behavior policy one layer further from where it belongs than putting it in platform code.
|
|
127
|
+
|
|
128
|
+
## Evidence boundary
|
|
129
|
+
|
|
130
|
+
**No X call is made anywhere in this pack, by any test, ever.** X's rate limits are punitive and
|
|
131
|
+
this estate has been bitten. Every route and body shape is grounded in the pinned
|
|
132
|
+
`twitter-api-v2@1.29.1` source (see `test-fixtures/x-openapi-operations.SOURCE.md`); the error
|
|
133
|
+
envelopes and scope catalog are transcribed from `xidentity`, which grounded them in X's own
|
|
134
|
+
OpenAPI document. The **rate-budget ceiling is explicitly not a transcription**: X's published
|
|
135
|
+
per-endpoint figures in this repo cover `GET /2/users/me`, not the posting endpoints, so the
|
|
136
|
+
declaration is deliberately conservative and files `x.rate_limit.published_figures` as a pinning
|
|
137
|
+
todo. Wording for refusals X has never shown us is filed the same way (`x.errors.*_wording`)
|
|
138
|
+
rather than dressed up as vendor prose.
|