birdclaw 0.5.1 → 0.7.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/CHANGELOG.md +92 -1
- package/README.md +75 -5
- package/package.json +8 -2
- package/scripts/browser-perf.mjs +1 -0
- package/scripts/start-test-server.mjs +16 -3
- package/src/cli.ts +812 -37
- package/src/components/AccountSwitcher.tsx +186 -0
- package/src/components/AppNav.tsx +37 -7
- package/src/components/AvatarChip.tsx +9 -3
- package/src/components/DmWorkspace.tsx +18 -8
- package/src/components/LinkPreviewCard.tsx +40 -18
- package/src/components/MarkdownViewer.tsx +818 -0
- package/src/components/ProfileAnalysisStream.tsx +428 -0
- package/src/components/ProfilePreview.tsx +120 -9
- package/src/components/SavedTimelineView.tsx +30 -8
- package/src/components/SyncNowButton.tsx +60 -25
- package/src/components/ThemeSlider.tsx +55 -50
- package/src/components/TimelineCard.tsx +240 -92
- package/src/components/TimelineRouteFrame.tsx +38 -8
- package/src/components/TweetMediaGrid.tsx +87 -38
- package/src/components/TweetRichText.tsx +45 -17
- package/src/components/account-selection.ts +64 -0
- package/src/components/useTimelineRouteData.ts +97 -13
- package/src/lib/account-sync-job.ts +666 -0
- package/src/lib/actions-transport.ts +216 -146
- package/src/lib/api-client.ts +128 -53
- package/src/lib/archive-finder.ts +78 -63
- package/src/lib/archive-import.ts +1593 -1291
- package/src/lib/authored-live.ts +262 -204
- package/src/lib/avatar-cache.ts +208 -43
- package/src/lib/backup.ts +1536 -954
- package/src/lib/bird-actions.ts +139 -57
- package/src/lib/bird-command.ts +101 -28
- package/src/lib/bird.ts +582 -194
- package/src/lib/blocklist.ts +40 -23
- package/src/lib/blocks-write.ts +129 -80
- package/src/lib/blocks.ts +165 -97
- package/src/lib/bookmark-sync-job.ts +250 -160
- package/src/lib/config.ts +35 -2
- package/src/lib/conversation-surface.ts +79 -48
- package/src/lib/data-sources.ts +219 -0
- package/src/lib/db.ts +95 -4
- package/src/lib/dms-live.ts +720 -66
- package/src/lib/effect-runtime.ts +45 -0
- package/src/lib/follow-graph.ts +224 -180
- package/src/lib/geocoding.ts +296 -0
- package/src/lib/http-effect.ts +222 -0
- package/src/lib/inbox.ts +74 -43
- package/src/lib/link-index.ts +88 -76
- package/src/lib/link-insights.ts +24 -0
- package/src/lib/link-preview-metadata.ts +472 -52
- package/src/lib/location.ts +137 -0
- package/src/lib/media-fetch.ts +286 -213
- package/src/lib/mention-threads-live.ts +445 -288
- package/src/lib/mentions-live.ts +549 -354
- package/src/lib/moderation-target.ts +102 -65
- package/src/lib/moderation-write.ts +77 -18
- package/src/lib/mutes-write.ts +129 -80
- package/src/lib/mutes.ts +8 -1
- package/src/lib/network-map.ts +382 -0
- package/src/lib/openai.ts +84 -53
- package/src/lib/period-digest.ts +1317 -0
- package/src/lib/profile-affiliation-hydration.ts +93 -54
- package/src/lib/profile-analysis.ts +1272 -0
- package/src/lib/profile-bio-entities.ts +1 -1
- package/src/lib/profile-hydration.ts +124 -72
- package/src/lib/profile-replies.ts +60 -43
- package/src/lib/profile-resolver.ts +402 -294
- package/src/lib/queries.ts +983 -203
- package/src/lib/research.ts +165 -120
- package/src/lib/search-discussion.ts +1016 -0
- package/src/lib/sqlite.ts +1 -0
- package/src/lib/timeline-collections-live.ts +204 -167
- package/src/lib/timeline-live.ts +325 -51
- package/src/lib/tweet-account-edges.ts +2 -0
- package/src/lib/tweet-lookup.ts +30 -19
- package/src/lib/tweet-render.ts +141 -1
- package/src/lib/tweet-search-live.ts +565 -0
- package/src/lib/types.ts +75 -3
- package/src/lib/ui.ts +31 -8
- package/src/lib/url-expansion.ts +226 -55
- package/src/lib/url-safety.ts +220 -0
- package/src/lib/web-sync.ts +222 -149
- package/src/lib/whois.ts +166 -147
- package/src/lib/x-web.ts +102 -71
- package/src/lib/xurl-rate-limits.ts +267 -0
- package/src/lib/xurl.ts +1185 -405
- package/src/routeTree.gen.ts +273 -0
- package/src/routes/__root.tsx +24 -5
- package/src/routes/api/action.tsx +127 -78
- package/src/routes/api/avatar.tsx +39 -30
- package/src/routes/api/blocks.tsx +26 -23
- package/src/routes/api/conversation.tsx +25 -14
- package/src/routes/api/data-sources.tsx +24 -0
- package/src/routes/api/inbox.tsx +27 -21
- package/src/routes/api/link-insights.tsx +31 -25
- package/src/routes/api/link-preview.tsx +25 -21
- package/src/routes/api/network-map.tsx +55 -0
- package/src/routes/api/period-digest.tsx +133 -0
- package/src/routes/api/profile-analysis.tsx +152 -0
- package/src/routes/api/profile-hydrate.tsx +31 -28
- package/src/routes/api/query.tsx +80 -55
- package/src/routes/api/search-discussion.tsx +169 -0
- package/src/routes/api/status.tsx +18 -10
- package/src/routes/api/sync.tsx +75 -29
- package/src/routes/api/xurl-rate-limits.tsx +24 -0
- package/src/routes/data-sources.tsx +255 -0
- package/src/routes/discuss.tsx +419 -0
- package/src/routes/dms.tsx +95 -28
- package/src/routes/inbox.tsx +32 -19
- package/src/routes/network-map.tsx +1035 -0
- package/src/routes/profile-analyze.tsx +112 -0
- package/src/routes/profiles.$handle.tsx +228 -0
- package/src/routes/rate-limits.tsx +309 -0
- package/src/routes/today.tsx +455 -0
- package/src/styles.css +22 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Database } from "./sqlite";
|
|
2
|
-
import {
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { lookupProfileViaBirdEffect } from "./bird";
|
|
4
|
+
import { runEffectPromise } from "./effect-runtime";
|
|
3
5
|
import { syncIdentitySearchIndexForProfileIds } from "./identity-search-index";
|
|
4
6
|
import { syncProfileBioEntitiesForProfileId } from "./profile-bio-entities";
|
|
5
7
|
import { recordProfileSnapshot } from "./profile-history";
|
|
@@ -24,6 +26,17 @@ interface SyntheticAffiliationRow {
|
|
|
24
26
|
raw_json: string;
|
|
25
27
|
}
|
|
26
28
|
|
|
29
|
+
function toError(error: unknown) {
|
|
30
|
+
return error instanceof Error ? error : new Error(String(error));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function trySync<T>(try_: () => T) {
|
|
34
|
+
return Effect.try({
|
|
35
|
+
try: try_,
|
|
36
|
+
catch: toError,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
function normalizeHandle(value: string | null) {
|
|
28
41
|
const handle = value?.trim().replace(/^@/, "");
|
|
29
42
|
return handle && handle.length > 0 ? handle : null;
|
|
@@ -112,13 +125,16 @@ function findLocalOrganizationProfileId(db: Database, handle: string) {
|
|
|
112
125
|
return row?.id ?? null;
|
|
113
126
|
}
|
|
114
127
|
|
|
115
|
-
export
|
|
128
|
+
export function hydrateProfileAffiliationOrganizationsEffect(
|
|
116
129
|
db: Database,
|
|
117
130
|
subjectProfileId: string,
|
|
118
|
-
):
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
131
|
+
): Effect.Effect<ProfileAffiliationHydrationResult, unknown> {
|
|
132
|
+
return Effect.gen(function* () {
|
|
133
|
+
const rows = yield* trySync(
|
|
134
|
+
() =>
|
|
135
|
+
db
|
|
136
|
+
.prepare(
|
|
137
|
+
`
|
|
122
138
|
select subject_profile_id, organization_profile_id, organization_name,
|
|
123
139
|
organization_handle, badge_url, url, label, source, raw_json
|
|
124
140
|
from profile_affiliations
|
|
@@ -128,62 +144,85 @@ export async function hydrateProfileAffiliationOrganizations(
|
|
|
128
144
|
and organization_handle is not null
|
|
129
145
|
order by last_seen_at desc
|
|
130
146
|
`,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const result: ProfileAffiliationHydrationResult = {
|
|
135
|
-
checked: rows.length,
|
|
136
|
-
hydrated: 0,
|
|
137
|
-
skipped: 0,
|
|
138
|
-
errors: [],
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
for (const row of rows) {
|
|
142
|
-
const handle = normalizeHandle(row.organization_handle);
|
|
143
|
-
if (!handle) {
|
|
144
|
-
result.skipped += 1;
|
|
145
|
-
continue;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
const localOrganizationProfileId = findLocalOrganizationProfileId(
|
|
149
|
-
db,
|
|
150
|
-
handle,
|
|
151
|
-
);
|
|
152
|
-
if (localOrganizationProfileId) {
|
|
153
|
-
db.transaction(() => {
|
|
154
|
-
replaceSyntheticAffiliation(db, row, localOrganizationProfileId);
|
|
155
|
-
})();
|
|
156
|
-
result.hydrated += 1;
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
147
|
+
)
|
|
148
|
+
.all(subjectProfileId) as SyntheticAffiliationRow[],
|
|
149
|
+
);
|
|
159
150
|
|
|
160
|
-
|
|
161
|
-
|
|
151
|
+
const result: ProfileAffiliationHydrationResult = {
|
|
152
|
+
checked: rows.length,
|
|
153
|
+
hydrated: 0,
|
|
154
|
+
skipped: 0,
|
|
155
|
+
errors: [],
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
for (const row of rows) {
|
|
159
|
+
const handle = normalizeHandle(row.organization_handle);
|
|
160
|
+
if (!handle) {
|
|
162
161
|
result.skipped += 1;
|
|
163
162
|
continue;
|
|
164
163
|
}
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
const hydrated = yield* Effect.gen(function* () {
|
|
165
|
+
const localOrganizationProfileId = yield* trySync(() =>
|
|
166
|
+
findLocalOrganizationProfileId(db, handle),
|
|
167
|
+
);
|
|
168
|
+
if (localOrganizationProfileId) {
|
|
169
|
+
yield* trySync(() =>
|
|
170
|
+
db.transaction(() => {
|
|
171
|
+
replaceSyntheticAffiliation(db, row, localOrganizationProfileId);
|
|
172
|
+
})(),
|
|
173
|
+
);
|
|
174
|
+
result.hydrated += 1;
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const user = yield* lookupProfileViaBirdEffect(handle);
|
|
179
|
+
if (!user) {
|
|
180
|
+
result.skipped += 1;
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
const resolved = yield* trySync(() => upsertProfileFromXUser(db, user));
|
|
184
|
+
if (resolved.profile.id === row.organization_profile_id) {
|
|
185
|
+
result.skipped += 1;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
yield* trySync(() =>
|
|
189
|
+
db.transaction(() => {
|
|
190
|
+
replaceSyntheticAffiliation(db, row, resolved.profile.id);
|
|
191
|
+
})(),
|
|
192
|
+
);
|
|
193
|
+
result.hydrated += 1;
|
|
194
|
+
return true;
|
|
195
|
+
}).pipe(
|
|
196
|
+
Effect.catchAll((error) => {
|
|
197
|
+
result.errors.push({
|
|
198
|
+
handle,
|
|
199
|
+
error: error instanceof Error ? error.message : String(error),
|
|
200
|
+
});
|
|
201
|
+
return Effect.succeed(false);
|
|
202
|
+
}),
|
|
203
|
+
);
|
|
204
|
+
if (!hydrated) {
|
|
168
205
|
continue;
|
|
169
206
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
error: error instanceof Error ? error.message : String(error),
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (result.hydrated > 0) {
|
|
210
|
+
yield* trySync(() => {
|
|
211
|
+
recordProfileSnapshot(db, subjectProfileId, "affiliation_hydration");
|
|
212
|
+
syncProfileBioEntitiesForProfileId(db, subjectProfileId);
|
|
213
|
+
syncIdentitySearchIndexForProfileIds(db, [subjectProfileId]);
|
|
178
214
|
});
|
|
179
215
|
}
|
|
180
|
-
}
|
|
181
216
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
syncIdentitySearchIndexForProfileIds(db, [subjectProfileId]);
|
|
186
|
-
}
|
|
217
|
+
return result;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
187
220
|
|
|
188
|
-
|
|
221
|
+
export function hydrateProfileAffiliationOrganizations(
|
|
222
|
+
db: Database,
|
|
223
|
+
subjectProfileId: string,
|
|
224
|
+
): Promise<ProfileAffiliationHydrationResult> {
|
|
225
|
+
return runEffectPromise(
|
|
226
|
+
hydrateProfileAffiliationOrganizationsEffect(db, subjectProfileId),
|
|
227
|
+
);
|
|
189
228
|
}
|