birdclaw 0.8.2 → 0.8.4

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 (247) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +10 -8
  3. package/bin/birdclaw.mjs +4 -66
  4. package/dist/cli/birdclaw.js +28165 -0
  5. package/dist/client/assets/AvatarChip-DLoqM5xD.js +1 -0
  6. package/dist/client/assets/ProfilePreview-BejAuYsJ.js +1 -0
  7. package/dist/client/assets/SavedTimelineView-BIS7HKpp.js +1 -0
  8. package/dist/client/assets/SmartTimestamp-BR0-9se2.js +1 -0
  9. package/dist/client/assets/TimelineRouteFrame-CyGPj0eM.js +1 -0
  10. package/dist/client/assets/blocks-7UDKQp8H.js +1 -0
  11. package/dist/client/assets/bookmarks-CbBkMvXk.js +1 -0
  12. package/dist/client/assets/chunk-C0phanGV.js +1 -0
  13. package/dist/client/assets/circle-check-C_Vq3ElD.js +1 -0
  14. package/dist/client/assets/client-stream-contracts-ys3XhWG4.js +5 -0
  15. package/dist/client/assets/createLucideIcon-JV8isFFR.js +1 -0
  16. package/dist/client/assets/data-sources-Cm2bpNvg.js +1 -0
  17. package/dist/client/assets/discuss-DTjaOugw.js +1 -0
  18. package/dist/client/assets/dms-CGd6Eogq.js +1 -0
  19. package/dist/client/assets/inbox-BHlGuOy2.js +1 -0
  20. package/dist/client/assets/index-CEIG7S6s.js +31 -0
  21. package/dist/client/assets/index-bpFrQ5yG.css +1 -0
  22. package/dist/client/assets/likes-cLrcAQem.js +1 -0
  23. package/dist/client/assets/links-CM9QO1LC.js +1 -0
  24. package/dist/client/assets/mapbox-BxTlqXt9.js +2 -0
  25. package/dist/client/assets/mapbox-gl-dgf_hX3a.js +3215 -0
  26. package/dist/client/assets/mentions-CxKCgzIf.js +1 -0
  27. package/dist/client/assets/network-map-B5a3whqj.js +2 -0
  28. package/dist/client/assets/profile-analyze-CRtNEwlb.js +1 -0
  29. package/dist/client/assets/profile-hydration-client-YEtJsNTv.js +1 -0
  30. package/dist/client/assets/profiles._handle-C82_HoKX.js +1 -0
  31. package/dist/client/assets/query-client-fYu2rzRC.js +17 -0
  32. package/dist/client/assets/rate-limits-ScaEwdVK.js +1 -0
  33. package/dist/client/assets/react-dom-DHl6Ug7F.js +1 -0
  34. package/dist/client/assets/react-nBylq1U5.js +1 -0
  35. package/dist/client/assets/repeat-2-xCwHM9hD.js +1 -0
  36. package/dist/client/assets/routes-q7ZaW4En.js +1 -0
  37. package/dist/client/assets/schemas-I9r6F6ya.js +64 -0
  38. package/dist/client/assets/search-Dq5kYsxA.js +1 -0
  39. package/dist/client/assets/sparkles-CQVlvHsZ.js +1 -0
  40. package/dist/client/assets/styles-B8s3tt3r.css +2 -0
  41. package/dist/client/assets/today-CeG1O7Py.js +1 -0
  42. package/dist/client/assets/triangle-alert-CBL7s2pf.js +1 -0
  43. package/dist/client/assets/useTimelineRouteData-1HsqgvUi.js +1 -0
  44. package/dist/client/assets/users-CHbKlqUr.js +1 -0
  45. package/dist/server/assets/AvatarChip-zUDAEmjL.js +105 -0
  46. package/dist/server/assets/FeedState-ntW0Q2GB.js +214 -0
  47. package/dist/server/assets/ProfileAnalysisStream-BFvhVdhn.js +198 -0
  48. package/dist/server/assets/ProfilePreview-C6gAor_j.js +752 -0
  49. package/dist/server/assets/SavedTimelineView-BG1jnBp1.js +64 -0
  50. package/dist/server/assets/SmartTimestamp-DfwE1NGf.js +45 -0
  51. package/dist/server/assets/SyncNowButton-BOn_IBXS.js +76 -0
  52. package/dist/server/assets/TimelineRouteFrame-CU7ilM7U.js +85 -0
  53. package/dist/server/assets/TweetRichText-DhCVv1-6.js +74 -0
  54. package/dist/server/assets/_tanstack-start-manifest_v-C-ZRnG_n.js +148 -0
  55. package/dist/server/assets/account-selection-CTdFGWRk.js +44 -0
  56. package/dist/server/assets/blocks-C1mgGTB3.js +299 -0
  57. package/dist/server/assets/blocks-DSgQghqP.js +17 -0
  58. package/dist/server/assets/bookmarks-BJN8tykY.js +14 -0
  59. package/dist/server/assets/client-stream-contracts-C2xbWVjm.js +769 -0
  60. package/dist/server/assets/data-sources-BnA1Q94p.js +180 -0
  61. package/dist/server/assets/discuss-CJ1dau1j.js +15 -0
  62. package/dist/server/assets/discuss-QTo08NCN.js +338 -0
  63. package/dist/server/assets/dms-BuLj4bp8.js +368 -0
  64. package/dist/server/assets/dms-DAyQrVM2.js +240 -0
  65. package/dist/server/assets/empty-plugin-adapters-DzrEkdBF.js +5 -0
  66. package/dist/server/assets/inbox-CkGOaW1q.js +214 -0
  67. package/dist/server/assets/inbox-DpWd1EzC.js +146 -0
  68. package/dist/server/assets/likes-DBOAtsJU.js +14 -0
  69. package/dist/server/assets/links-DAhSjynu.js +240 -0
  70. package/dist/server/assets/links-DmH5lxHO.js +468 -0
  71. package/dist/server/assets/mentions-BH2MzKtB.js +26 -0
  72. package/dist/server/assets/network-map-D3CzRcC4.js +224 -0
  73. package/dist/server/assets/network-map-D5DoLOwR.js +582 -0
  74. package/dist/server/assets/profile-analyze-BP65PED0.js +90 -0
  75. package/dist/server/assets/profile-analyze-C1NoM0tV.js +9 -0
  76. package/dist/server/assets/profile-hydration-client-GJ4kwJS8.js +133 -0
  77. package/dist/server/assets/profiles._handle-DjwlN_ac.js +184 -0
  78. package/dist/server/assets/profiles._handle-DsLNj2Ca.js +12 -0
  79. package/dist/server/assets/query-client-BdauHBgd.js +923 -0
  80. package/dist/server/assets/rate-limits-VAr2qzYD.js +262 -0
  81. package/dist/server/assets/route-search-BUlQ5lGM.js +117 -0
  82. package/dist/server/assets/router-DqkwSPiM.js +17026 -0
  83. package/dist/server/assets/routes-A9c9ZhwN.js +26 -0
  84. package/dist/server/assets/start-FaDOTmto.js +4 -0
  85. package/dist/server/assets/today-B5hVM57Z.js +17 -0
  86. package/dist/server/assets/today-fvGiZ7ud.js +303 -0
  87. package/dist/server/assets/ui-qbmcMSSX.js +137 -0
  88. package/{src/components/useDebouncedValue.ts → dist/server/assets/useDebouncedValue-DOnA6Xcy.js} +4 -4
  89. package/dist/server/assets/useTimelineRouteData-27cxynxa.js +1101 -0
  90. package/dist/server/server.js +5520 -0
  91. package/package.json +27 -34
  92. package/playwright.config.ts +0 -35
  93. package/scripts/browser-perf.mjs +0 -427
  94. package/scripts/build-docs-site.mjs +0 -967
  95. package/scripts/docs-site-assets.mjs +0 -311
  96. package/scripts/run-vitest.mjs +0 -21
  97. package/scripts/sanitize-node-options.mjs +0 -23
  98. package/scripts/start-test-server.mjs +0 -42
  99. package/src/cli-moderation.ts +0 -210
  100. package/src/cli.ts +0 -2336
  101. package/src/components/AccountSwitcher.tsx +0 -186
  102. package/src/components/AppNav.tsx +0 -118
  103. package/src/components/AvatarChip.tsx +0 -58
  104. package/src/components/BrandMark.tsx +0 -67
  105. package/src/components/ConversationThread.tsx +0 -131
  106. package/src/components/DmWorkspace.tsx +0 -286
  107. package/src/components/EmbeddedTweetCard.tsx +0 -55
  108. package/src/components/FeedState.tsx +0 -147
  109. package/src/components/FloatingPreview.tsx +0 -382
  110. package/src/components/InboxCard.tsx +0 -152
  111. package/src/components/LinkPreviewCard.tsx +0 -292
  112. package/src/components/MarkdownViewer.tsx +0 -777
  113. package/src/components/ProfileAnalysisStream.tsx +0 -428
  114. package/src/components/ProfilePreview.tsx +0 -129
  115. package/src/components/SavedTimelineView.tsx +0 -155
  116. package/src/components/SmartTimestamp.tsx +0 -72
  117. package/src/components/SyncNowButton.tsx +0 -140
  118. package/src/components/ThemeSlider.tsx +0 -80
  119. package/src/components/TimelineCard.tsx +0 -533
  120. package/src/components/TimelineRouteFrame.tsx +0 -186
  121. package/src/components/TweetArticleCard.tsx +0 -66
  122. package/src/components/TweetMediaGrid.tsx +0 -185
  123. package/src/components/TweetRichText.tsx +0 -159
  124. package/src/components/account-selection.ts +0 -64
  125. package/src/components/useTimelineRouteData.ts +0 -323
  126. package/src/lib/account-sync-job.ts +0 -666
  127. package/src/lib/actions-transport.ts +0 -300
  128. package/src/lib/api-client.ts +0 -419
  129. package/src/lib/archive-finder.ts +0 -185
  130. package/src/lib/archive-import.ts +0 -2764
  131. package/src/lib/authored-live.ts +0 -1072
  132. package/src/lib/avatar-cache.ts +0 -349
  133. package/src/lib/backup.ts +0 -2741
  134. package/src/lib/bird-actions.ts +0 -294
  135. package/src/lib/bird-command.ts +0 -130
  136. package/src/lib/bird.ts +0 -1140
  137. package/src/lib/blocklist.ts +0 -136
  138. package/src/lib/blocks-write.ts +0 -167
  139. package/src/lib/blocks.ts +0 -389
  140. package/src/lib/bookmark-sync-job.ts +0 -536
  141. package/src/lib/client-cache.ts +0 -109
  142. package/src/lib/config.ts +0 -224
  143. package/src/lib/conversation-surface.ts +0 -205
  144. package/src/lib/data-sources.ts +0 -219
  145. package/src/lib/db.ts +0 -1135
  146. package/src/lib/dms-live.ts +0 -933
  147. package/src/lib/effect-runtime.ts +0 -45
  148. package/src/lib/follow-graph.ts +0 -1097
  149. package/src/lib/geocoding.ts +0 -296
  150. package/src/lib/http-effect.ts +0 -222
  151. package/src/lib/identity-search-index.ts +0 -369
  152. package/src/lib/inbox.ts +0 -241
  153. package/src/lib/link-index.ts +0 -641
  154. package/src/lib/link-insights.ts +0 -860
  155. package/src/lib/link-preview-metadata.ts +0 -754
  156. package/src/lib/location.ts +0 -137
  157. package/src/lib/media-fetch.ts +0 -860
  158. package/src/lib/media-includes.ts +0 -165
  159. package/src/lib/mention-threads-live.ts +0 -917
  160. package/src/lib/mentions-export.ts +0 -147
  161. package/src/lib/mentions-live.ts +0 -1238
  162. package/src/lib/moderation-target.ts +0 -216
  163. package/src/lib/moderation-write.ts +0 -131
  164. package/src/lib/mutes-write.ts +0 -167
  165. package/src/lib/mutes.ts +0 -84
  166. package/src/lib/ndjson-stream.ts +0 -106
  167. package/src/lib/network-map.ts +0 -382
  168. package/src/lib/openai.ts +0 -117
  169. package/src/lib/period-digest.ts +0 -1552
  170. package/src/lib/present.ts +0 -118
  171. package/src/lib/profile-affiliation-hydration.ts +0 -228
  172. package/src/lib/profile-affiliations.ts +0 -262
  173. package/src/lib/profile-analysis.ts +0 -1272
  174. package/src/lib/profile-bio-entities.ts +0 -318
  175. package/src/lib/profile-history.ts +0 -164
  176. package/src/lib/profile-hydration.ts +0 -180
  177. package/src/lib/profile-replies.ts +0 -77
  178. package/src/lib/profile-resolver.ts +0 -650
  179. package/src/lib/queries.ts +0 -2381
  180. package/src/lib/research.ts +0 -652
  181. package/src/lib/search-discussion.ts +0 -1016
  182. package/src/lib/seed.ts +0 -613
  183. package/src/lib/sqlite.ts +0 -147
  184. package/src/lib/sync-cache.ts +0 -65
  185. package/src/lib/theme-transition.ts +0 -113
  186. package/src/lib/theme.tsx +0 -165
  187. package/src/lib/timeline-collections-live.ts +0 -581
  188. package/src/lib/timeline-live.ts +0 -452
  189. package/src/lib/tweet-account-edges.ts +0 -48
  190. package/src/lib/tweet-lookup.ts +0 -46
  191. package/src/lib/tweet-render.ts +0 -430
  192. package/src/lib/tweet-search-live.ts +0 -566
  193. package/src/lib/types.ts +0 -723
  194. package/src/lib/ui.ts +0 -529
  195. package/src/lib/url-expansion-store.ts +0 -110
  196. package/src/lib/url-expansion.ts +0 -343
  197. package/src/lib/url-safety.ts +0 -220
  198. package/src/lib/web-sync.ts +0 -516
  199. package/src/lib/whois.ts +0 -1079
  200. package/src/lib/x-profile.ts +0 -365
  201. package/src/lib/x-web.ts +0 -199
  202. package/src/lib/xurl-rate-limits.ts +0 -267
  203. package/src/lib/xurl.ts +0 -1677
  204. package/src/routeTree.gen.ts +0 -723
  205. package/src/router.tsx +0 -20
  206. package/src/routes/__root.tsx +0 -79
  207. package/src/routes/api/action.tsx +0 -147
  208. package/src/routes/api/avatar.tsx +0 -50
  209. package/src/routes/api/blocks.tsx +0 -35
  210. package/src/routes/api/conversation.tsx +0 -45
  211. package/src/routes/api/data-sources.tsx +0 -24
  212. package/src/routes/api/inbox.tsx +0 -43
  213. package/src/routes/api/link-insights.tsx +0 -85
  214. package/src/routes/api/link-preview.tsx +0 -47
  215. package/src/routes/api/network-map.tsx +0 -55
  216. package/src/routes/api/period-digest.tsx +0 -101
  217. package/src/routes/api/profile-analysis.tsx +0 -97
  218. package/src/routes/api/profile-hydrate.tsx +0 -54
  219. package/src/routes/api/query.tsx +0 -115
  220. package/src/routes/api/search-discussion.tsx +0 -113
  221. package/src/routes/api/status.tsx +0 -28
  222. package/src/routes/api/sync.tsx +0 -105
  223. package/src/routes/api/xurl-rate-limits.tsx +0 -24
  224. package/src/routes/blocks.tsx +0 -377
  225. package/src/routes/bookmarks.tsx +0 -18
  226. package/src/routes/data-sources.tsx +0 -257
  227. package/src/routes/discuss.tsx +0 -419
  228. package/src/routes/dms.tsx +0 -432
  229. package/src/routes/inbox.tsx +0 -226
  230. package/src/routes/index.tsx +0 -32
  231. package/src/routes/likes.tsx +0 -18
  232. package/src/routes/links.tsx +0 -994
  233. package/src/routes/mentions.tsx +0 -32
  234. package/src/routes/network-map.tsx +0 -1035
  235. package/src/routes/profile-analyze.tsx +0 -112
  236. package/src/routes/profiles.$handle.tsx +0 -228
  237. package/src/routes/rate-limits.tsx +0 -309
  238. package/src/routes/today.tsx +0 -511
  239. package/src/styles.css +0 -257
  240. package/tsconfig.json +0 -29
  241. package/vite.config.ts +0 -29
  242. /package/{public → dist/client}/birdclaw-mark.png +0 -0
  243. /package/{public → dist/client}/favicon.ico +0 -0
  244. /package/{public → dist/client}/logo192.png +0 -0
  245. /package/{public → dist/client}/logo512.png +0 -0
  246. /package/{public → dist/client}/manifest.json +0 -0
  247. /package/{public → dist/client}/robots.txt +0 -0
@@ -0,0 +1,923 @@
1
+ import { useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
+ import { Cause, Data, Effect, Exit, Option } from "effect";
5
+ import { z } from "zod";
6
+ z.enum([
7
+ "home",
8
+ "mentions",
9
+ "authored",
10
+ "search",
11
+ "dms"
12
+ ]);
13
+ var inboxKindSchema = z.enum([
14
+ "mixed",
15
+ "mentions",
16
+ "dms"
17
+ ]);
18
+ var dmDirectionSchema = z.enum(["inbound", "outbound"]);
19
+ z.enum(["likes", "bookmarks"]);
20
+ z.enum(["followers", "following"]);
21
+ var webSyncKindSchema = z.enum([
22
+ "timeline",
23
+ "mentions",
24
+ "likes",
25
+ "bookmarks",
26
+ "dms"
27
+ ]);
28
+ //#endregion
29
+ //#region src/lib/api-contracts.ts
30
+ var jsonRecordSchema = z.record(z.string(), z.unknown());
31
+ var unknownProfile = {
32
+ id: "profile_unknown",
33
+ handle: "unknown",
34
+ displayName: "Unknown",
35
+ bio: "",
36
+ followersCount: 0,
37
+ avatarHue: 0,
38
+ createdAt: ""
39
+ };
40
+ var profileAffiliationSchema = z.object({
41
+ organizationProfileId: z.string(),
42
+ organizationName: z.string().optional(),
43
+ organizationHandle: z.string().optional(),
44
+ badgeUrl: z.string().nullable().optional(),
45
+ url: z.string().nullable().optional(),
46
+ label: z.string().nullable().optional(),
47
+ source: z.string(),
48
+ firstSeenAt: z.string(),
49
+ lastSeenAt: z.string(),
50
+ isActive: z.boolean()
51
+ });
52
+ var profileRecordSchema = z.object({
53
+ id: z.string().default("profile_unknown"),
54
+ handle: z.string().default("unknown"),
55
+ displayName: z.string().default("Unknown"),
56
+ bio: z.string().default(""),
57
+ followersCount: z.number().default(0),
58
+ followingCount: z.number().optional(),
59
+ avatarHue: z.number().default(0),
60
+ avatarUrl: z.string().optional(),
61
+ location: z.string().optional(),
62
+ url: z.string().optional(),
63
+ verifiedType: z.string().optional(),
64
+ entities: jsonRecordSchema.optional(),
65
+ affiliations: z.array(profileAffiliationSchema).optional(),
66
+ primaryAffiliation: profileAffiliationSchema.optional(),
67
+ createdAt: z.string().default("")
68
+ });
69
+ var tweetEntitiesSchema = z.object({
70
+ mentions: z.array(z.object({
71
+ username: z.string(),
72
+ id: z.string().optional(),
73
+ start: z.number(),
74
+ end: z.number(),
75
+ profile: profileRecordSchema.optional()
76
+ })).optional(),
77
+ urls: z.array(z.object({
78
+ url: z.string(),
79
+ expandedUrl: z.string(),
80
+ displayUrl: z.string(),
81
+ start: z.number(),
82
+ end: z.number(),
83
+ title: z.string().optional(),
84
+ description: z.string().nullable().optional(),
85
+ imageUrl: z.string().nullable().optional(),
86
+ siteName: z.string().nullable().optional()
87
+ })).optional(),
88
+ hashtags: z.array(z.object({
89
+ tag: z.string(),
90
+ start: z.number(),
91
+ end: z.number()
92
+ })).optional(),
93
+ article: z.object({
94
+ title: z.string(),
95
+ previewText: z.string().optional(),
96
+ url: z.string(),
97
+ coverImageUrl: z.string().optional()
98
+ }).optional()
99
+ });
100
+ var tweetMediaSchema = z.object({
101
+ url: z.string(),
102
+ type: z.preprocess((value) => value === "photo" ? "image" : value === "animated_gif" ? "gif" : value, z.enum([
103
+ "image",
104
+ "video",
105
+ "gif",
106
+ "unknown"
107
+ ])),
108
+ altText: z.string().optional(),
109
+ width: z.number().optional(),
110
+ height: z.number().optional(),
111
+ thumbnailUrl: z.string().optional(),
112
+ durationMs: z.number().optional(),
113
+ variants: z.array(z.object({
114
+ url: z.string(),
115
+ contentType: z.string().optional(),
116
+ bitRate: z.number().optional()
117
+ })).optional()
118
+ });
119
+ var embeddedTweetSchema = z.object({
120
+ id: z.string(),
121
+ text: z.string(),
122
+ createdAt: z.string().default(""),
123
+ replyToId: z.string().nullable().optional(),
124
+ isReplied: z.boolean().optional(),
125
+ likeCount: z.number().optional(),
126
+ mediaCount: z.number().optional(),
127
+ bookmarked: z.boolean().optional(),
128
+ liked: z.boolean().optional(),
129
+ author: profileRecordSchema.default(unknownProfile),
130
+ entities: tweetEntitiesSchema.default({}),
131
+ media: z.array(tweetMediaSchema).default([])
132
+ });
133
+ var timelineItemSchema = z.object({
134
+ id: z.string(),
135
+ accountId: z.string().default("acct_primary"),
136
+ accountHandle: z.string().default(""),
137
+ kind: z.enum([
138
+ "home",
139
+ "mention",
140
+ "authored",
141
+ "search",
142
+ "like",
143
+ "bookmark"
144
+ ]).default("home"),
145
+ text: z.string(),
146
+ searchSnippet: z.string().optional(),
147
+ createdAt: z.string().default(""),
148
+ replyToId: z.string().nullable().optional(),
149
+ isReplied: z.boolean().default(false),
150
+ likeCount: z.number().default(0),
151
+ mediaCount: z.number().default(0),
152
+ bookmarked: z.boolean().default(false),
153
+ liked: z.boolean().default(false),
154
+ author: profileRecordSchema.default(unknownProfile),
155
+ entities: tweetEntitiesSchema.default({}),
156
+ media: z.array(tweetMediaSchema).default([]),
157
+ replyToTweet: embeddedTweetSchema.nullable().optional(),
158
+ quotedTweet: embeddedTweetSchema.nullable().optional(),
159
+ retweetedTweet: embeddedTweetSchema.nullable().optional(),
160
+ qualityReason: z.string().nullable().optional()
161
+ });
162
+ var dmMessageSchema = z.object({
163
+ id: z.string(),
164
+ conversationId: z.string().default(""),
165
+ text: z.string(),
166
+ createdAt: z.string().default(""),
167
+ direction: dmDirectionSchema.default("inbound"),
168
+ isReplied: z.boolean().default(false),
169
+ mediaCount: z.number().default(0),
170
+ sender: profileRecordSchema.default(unknownProfile)
171
+ });
172
+ var urlExpansionSchema = z.object({
173
+ url: z.string(),
174
+ expandedUrl: z.string(),
175
+ finalUrl: z.string(),
176
+ status: z.enum([
177
+ "hit",
178
+ "miss",
179
+ "error"
180
+ ]),
181
+ source: z.enum(["cache", "network"]),
182
+ title: z.string().optional(),
183
+ description: z.string().nullable().optional(),
184
+ error: z.string().optional(),
185
+ updatedAt: z.string()
186
+ });
187
+ var dmSearchMatchSchema = z.object({
188
+ message: dmMessageSchema,
189
+ before: z.array(dmMessageSchema),
190
+ after: z.array(dmMessageSchema),
191
+ urlExpansions: z.array(urlExpansionSchema).optional()
192
+ });
193
+ var dmConversationSchema = z.object({
194
+ id: z.string(),
195
+ accountId: z.string(),
196
+ accountHandle: z.string().default(""),
197
+ title: z.string(),
198
+ searchSnippet: z.string().optional(),
199
+ inboxKind: z.enum(["accepted", "request"]).optional(),
200
+ isMessageRequest: z.boolean().optional(),
201
+ lastMessageAt: z.string().default(""),
202
+ lastMessagePreview: z.string().default(""),
203
+ unreadCount: z.number().default(0),
204
+ needsReply: z.boolean().default(false),
205
+ influenceScore: z.number().default(0),
206
+ influenceLabel: z.string().default(""),
207
+ participant: profileRecordSchema.default(unknownProfile),
208
+ matches: z.array(dmSearchMatchSchema).optional()
209
+ });
210
+ var accountRecordSchema = z.object({
211
+ id: z.string(),
212
+ name: z.string().default(""),
213
+ handle: z.string().default(""),
214
+ externalUserId: z.string().nullable().optional(),
215
+ profileId: z.string().optional(),
216
+ avatarHue: z.number().optional(),
217
+ avatarUrl: z.string().optional(),
218
+ transport: z.string().default("local"),
219
+ isDefault: z.coerce.number().default(0),
220
+ createdAt: z.string().default("")
221
+ });
222
+ var archiveCandidateSchema = z.object({
223
+ path: z.string(),
224
+ name: z.string().default(""),
225
+ size: z.number().default(0),
226
+ sizeFormatted: z.string().default(""),
227
+ modifiedTime: z.string().default(""),
228
+ dateFormatted: z.string().default("")
229
+ });
230
+ var transportStatusSchema = z.object({
231
+ installed: z.boolean().default(false),
232
+ availableTransport: z.enum(["xurl", "local"]).default("local"),
233
+ statusText: z.string(),
234
+ rawStatus: z.string().optional()
235
+ });
236
+ var queryEnvelopeSchema = z.object({
237
+ accounts: z.array(accountRecordSchema),
238
+ archives: z.array(archiveCandidateSchema),
239
+ transport: transportStatusSchema,
240
+ stats: z.object({
241
+ home: z.number(),
242
+ mentions: z.number(),
243
+ dms: z.number(),
244
+ needsReply: z.number(),
245
+ inbox: z.number()
246
+ })
247
+ });
248
+ var timelineQueryResponseBaseSchema = z.object({
249
+ items: z.array(timelineItemSchema),
250
+ selectedConversation: z.undefined().optional()
251
+ });
252
+ var dmQueryResponseSchema = z.object({
253
+ resource: z.literal("dms"),
254
+ items: z.array(dmConversationSchema),
255
+ selectedConversation: z.object({
256
+ conversation: dmConversationSchema,
257
+ messages: z.array(dmMessageSchema)
258
+ }).nullable().optional()
259
+ });
260
+ var queryResponseSchema = z.discriminatedUnion("resource", [
261
+ timelineQueryResponseBaseSchema.extend({ resource: z.literal("home") }),
262
+ timelineQueryResponseBaseSchema.extend({ resource: z.literal("mentions") }),
263
+ timelineQueryResponseBaseSchema.extend({ resource: z.literal("authored") }),
264
+ timelineQueryResponseBaseSchema.extend({ resource: z.literal("search") }),
265
+ dmQueryResponseSchema
266
+ ]);
267
+ var webSyncStepSchema = z.object({
268
+ kind: z.union([webSyncKindSchema, z.literal("mention-threads")]),
269
+ label: z.string(),
270
+ count: z.number(),
271
+ source: z.string().optional(),
272
+ partial: z.boolean().optional(),
273
+ warnings: z.array(z.string()).optional()
274
+ });
275
+ var webSyncResponseSchema = z.object({
276
+ ok: z.boolean(),
277
+ kind: webSyncKindSchema,
278
+ accountId: z.string().optional(),
279
+ startedAt: z.string().default(""),
280
+ finishedAt: z.string().optional(),
281
+ summary: z.string(),
282
+ steps: z.array(webSyncStepSchema).default([]),
283
+ inProgress: z.boolean().optional(),
284
+ backup: z.custom().optional(),
285
+ error: z.string().optional()
286
+ });
287
+ var webSyncJobSchema = z.object({
288
+ id: z.string(),
289
+ kind: webSyncKindSchema,
290
+ accountId: z.string().optional(),
291
+ status: z.enum([
292
+ "running",
293
+ "succeeded",
294
+ "failed"
295
+ ]),
296
+ startedAt: z.string(),
297
+ finishedAt: z.string().optional(),
298
+ summary: z.string(),
299
+ inProgress: z.boolean(),
300
+ result: webSyncResponseSchema.optional(),
301
+ error: z.string().optional()
302
+ });
303
+ var tweetConversationResponseSchema = z.object({
304
+ ok: z.literal(true),
305
+ anchorId: z.string().default(""),
306
+ items: z.array(embeddedTweetSchema)
307
+ });
308
+ var blockItemSchema = z.object({
309
+ accountId: z.string(),
310
+ accountHandle: z.string(),
311
+ source: z.string(),
312
+ blockedAt: z.string(),
313
+ profile: profileRecordSchema
314
+ });
315
+ var blockSearchItemSchema = z.object({
316
+ profile: profileRecordSchema,
317
+ isBlocked: z.boolean(),
318
+ blockedAt: z.string().optional()
319
+ });
320
+ var blockListResponseSchema = z.object({
321
+ items: z.array(blockItemSchema),
322
+ matches: z.array(blockSearchItemSchema)
323
+ });
324
+ var inboxItemSchema = z.object({
325
+ id: z.string(),
326
+ entityId: z.string().default(""),
327
+ entityKind: z.enum(["mention", "dm"]).default("dm"),
328
+ accountId: z.string().default("acct_primary"),
329
+ accountHandle: z.string().default(""),
330
+ title: z.string(),
331
+ text: z.string().default(""),
332
+ createdAt: z.string().default(""),
333
+ needsReply: z.boolean().default(false),
334
+ influenceScore: z.number().default(0),
335
+ participant: profileRecordSchema.default(unknownProfile),
336
+ source: z.enum(["heuristic", "openai"]).default("heuristic"),
337
+ score: z.number().default(0),
338
+ summary: z.string().default(""),
339
+ reasoning: z.string().default("")
340
+ });
341
+ var inboxResponseSchema = z.object({
342
+ items: z.array(inboxItemSchema),
343
+ stats: z.object({
344
+ total: z.number(),
345
+ openai: z.number(),
346
+ heuristic: z.number()
347
+ })
348
+ });
349
+ var linkInsightMentionSchema = z.object({
350
+ id: z.string(),
351
+ sourceKind: z.enum(["dm", "tweet"]),
352
+ sourceId: z.string(),
353
+ sourceUrl: z.string().nullable().optional(),
354
+ sourceLabel: z.string(),
355
+ shortUrl: z.string(),
356
+ conversationId: z.string().nullable().optional(),
357
+ createdAt: z.string(),
358
+ text: z.string(),
359
+ rawText: z.string(),
360
+ commentText: z.string(),
361
+ sharedContentText: z.string().nullable().optional(),
362
+ hasComment: z.boolean(),
363
+ isPureShare: z.boolean(),
364
+ timelineTweetId: z.string().nullable().optional(),
365
+ contentTweetId: z.string().nullable().optional(),
366
+ contentTweetUrl: z.string().nullable().optional(),
367
+ contentAuthor: profileRecordSchema.nullable().optional(),
368
+ media: z.array(tweetMediaSchema),
369
+ direction: z.string().nullable().optional(),
370
+ accountHandle: z.string().nullable().optional(),
371
+ sharedBy: profileRecordSchema.nullable().optional(),
372
+ participant: profileRecordSchema.nullable().optional()
373
+ });
374
+ var linkInsightItemSchema = z.object({
375
+ id: z.string(),
376
+ kind: z.enum(["links", "videos"]),
377
+ url: z.string(),
378
+ canonicalKey: z.string(),
379
+ displayUrl: z.string(),
380
+ host: z.string(),
381
+ title: z.string().nullable().optional(),
382
+ description: z.string().nullable().optional(),
383
+ shareCount: z.number(),
384
+ uniqueSharers: z.number(),
385
+ totalInfluence: z.number(),
386
+ mentionCount: z.number(),
387
+ commentCount: z.number(),
388
+ pureShareCount: z.number(),
389
+ hiddenMentionCount: z.number(),
390
+ firstSeenAt: z.string(),
391
+ lastSeenAt: z.string(),
392
+ topSharer: profileRecordSchema.nullable().optional(),
393
+ sharers: z.array(profileRecordSchema),
394
+ mentions: z.array(linkInsightMentionSchema)
395
+ });
396
+ var linkInsightResponseSchema = z.object({
397
+ kind: z.enum(["links", "videos"]),
398
+ range: z.enum([
399
+ "today",
400
+ "week",
401
+ "month",
402
+ "year",
403
+ "all"
404
+ ]),
405
+ sort: z.enum([
406
+ "rank",
407
+ "recent",
408
+ "comments"
409
+ ]),
410
+ source: z.enum([
411
+ "all",
412
+ "tweet",
413
+ "dm"
414
+ ]),
415
+ since: z.string().nullable(),
416
+ until: z.string().nullable(),
417
+ items: z.array(linkInsightItemSchema),
418
+ stats: z.object({
419
+ occurrences: z.number(),
420
+ groups: z.number()
421
+ })
422
+ });
423
+ var liveDataSourceKindSchema = z.enum([
424
+ "birdclaw",
425
+ "bird",
426
+ "xurl"
427
+ ]);
428
+ var liveDataSourceAccountSchema = z.object({
429
+ id: z.string().optional(),
430
+ username: z.string().optional(),
431
+ handle: z.string().optional(),
432
+ app: z.string().optional(),
433
+ isDefault: z.boolean().optional()
434
+ });
435
+ var liveDataSourceStatusSchema = z.object({
436
+ source: liveDataSourceKindSchema,
437
+ label: z.string(),
438
+ works: z.boolean(),
439
+ installed: z.boolean().optional(),
440
+ status: z.enum([
441
+ "ok",
442
+ "warning",
443
+ "error"
444
+ ]),
445
+ detail: z.string(),
446
+ accounts: z.array(liveDataSourceAccountSchema)
447
+ });
448
+ var liveDataSourceCapabilitySchema = z.object({
449
+ key: z.string(),
450
+ label: z.string(),
451
+ primary: liveDataSourceKindSchema,
452
+ fallbacks: z.array(liveDataSourceKindSchema),
453
+ notes: z.string().optional()
454
+ });
455
+ var liveDataSourcesResponseSchema = z.object({
456
+ generatedAt: z.string(),
457
+ sources: z.array(liveDataSourceStatusSchema),
458
+ capabilities: z.array(liveDataSourceCapabilitySchema)
459
+ });
460
+ var networkMapResponseSchema = z.object({
461
+ type: z.literal("FeatureCollection"),
462
+ features: z.array(z.object({
463
+ type: z.literal("Feature"),
464
+ geometry: z.object({
465
+ type: z.literal("Point"),
466
+ coordinates: z.tuple([z.number(), z.number()])
467
+ }),
468
+ properties: z.object({
469
+ profileId: z.string(),
470
+ handle: z.string(),
471
+ name: z.string(),
472
+ avatarUrl: z.string().nullable(),
473
+ location: z.string(),
474
+ resolvedLocation: z.string().nullable(),
475
+ followersCount: z.number(),
476
+ followingCount: z.number(),
477
+ verified: z.boolean().nullable(),
478
+ relationship: z.enum([
479
+ "followers",
480
+ "following",
481
+ "mutual"
482
+ ]),
483
+ approxRadiusM: z.number().nullable()
484
+ })
485
+ })),
486
+ meta: z.object({
487
+ accountId: z.string(),
488
+ type: z.enum([
489
+ "all",
490
+ "followers",
491
+ "following",
492
+ "mutual"
493
+ ]),
494
+ totalProfiles: z.number(),
495
+ profilesWithLocation: z.number(),
496
+ meaningfulProfiles: z.number(),
497
+ locatedProfiles: z.number(),
498
+ missingGeocodes: z.number(),
499
+ geocodedThisRun: z.number(),
500
+ suppressedGeocodes: z.number(),
501
+ opencageConfigured: z.boolean(),
502
+ mapboxTokenConfigured: z.boolean()
503
+ }),
504
+ config: z.object({ mapboxToken: z.string().nullable() })
505
+ });
506
+ var xurlRateLimitEndpointKeySchema = z.enum(["tweets_search_recent", "users_id_tweets"]);
507
+ var xurlRateLimitEventSchema = z.object({
508
+ id: z.string(),
509
+ endpoint: xurlRateLimitEndpointKeySchema,
510
+ status: z.enum([
511
+ "ok",
512
+ "rate_limited",
513
+ "error"
514
+ ]),
515
+ at: z.string(),
516
+ source: z.string(),
517
+ handle: z.string().optional(),
518
+ detail: z.string().optional()
519
+ });
520
+ var xurlRateLimitEndpointSchema = z.object({
521
+ key: xurlRateLimitEndpointKeySchema,
522
+ label: z.string(),
523
+ method: z.string(),
524
+ path: z.string(),
525
+ description: z.string(),
526
+ perAppLimit: z.number(),
527
+ perUserLimit: z.number(),
528
+ windowMs: z.number(),
529
+ callsLastWindow: z.number(),
530
+ estimatedRemaining: z.number(),
531
+ usagePercent: z.number(),
532
+ rateLimitedLastWindow: z.number(),
533
+ errorsLastWindow: z.number(),
534
+ lastEventAt: z.string().nullable(),
535
+ lastRateLimitAt: z.string().nullable(),
536
+ estimatedResetAt: z.string().nullable(),
537
+ status: z.enum([
538
+ "healthy",
539
+ "warning",
540
+ "critical",
541
+ "quiet"
542
+ ])
543
+ });
544
+ var xurlRateLimitSnapshotSchema = z.object({
545
+ generatedAt: z.string(),
546
+ windowMs: z.number(),
547
+ docsUrl: z.string(),
548
+ summary: z.object({
549
+ totalCallsLastWindow: z.number(),
550
+ rateLimitedLastWindow: z.number(),
551
+ errorLastWindow: z.number(),
552
+ criticalEndpoints: z.number(),
553
+ lastEventAt: z.string().nullable()
554
+ }),
555
+ endpoints: z.array(xurlRateLimitEndpointSchema),
556
+ events: z.array(xurlRateLimitEventSchema),
557
+ throttle: z.object({
558
+ conversationDelayMs: z.number(),
559
+ rateLimitRetryMs: z.number(),
560
+ rateLimitMaxRetries: z.number()
561
+ })
562
+ });
563
+ var profileHydrationResultSchema = z.object({
564
+ handle: z.string(),
565
+ status: z.enum([
566
+ "hit",
567
+ "miss",
568
+ "error"
569
+ ]),
570
+ source: z.enum([
571
+ "cache",
572
+ "bird",
573
+ "xurl"
574
+ ]),
575
+ profile: profileRecordSchema.optional(),
576
+ error: z.string().optional()
577
+ });
578
+ var profileHydrationResponseSchema = z.object({
579
+ ok: z.literal(true),
580
+ results: z.array(profileHydrationResultSchema),
581
+ hydratedProfiles: z.number().default(0)
582
+ });
583
+ var linkPreviewMetadataSchema = z.object({
584
+ url: z.string(),
585
+ title: z.string().nullable(),
586
+ description: z.string().nullable(),
587
+ imageUrl: z.string().nullable(),
588
+ siteName: z.string().nullable(),
589
+ error: z.string().nullable().optional()
590
+ });
591
+ var linkPreviewResponseSchema = z.object({
592
+ ok: z.literal(true),
593
+ preview: linkPreviewMetadataSchema
594
+ });
595
+ var actionTransportSchema = z.looseObject({
596
+ ok: z.boolean().default(true),
597
+ output: z.string().optional(),
598
+ transport: z.enum(["bird", "xurl"]).optional()
599
+ });
600
+ var profileActionResponseBaseSchema = z.looseObject({
601
+ ok: z.boolean(),
602
+ accountId: z.string().optional(),
603
+ profile: profileRecordSchema.optional(),
604
+ transport: actionTransportSchema.optional(),
605
+ blockedAt: z.string().optional(),
606
+ mutedAt: z.string().optional()
607
+ });
608
+ var postActionResponseSchema = z.looseObject({
609
+ ok: z.literal(true),
610
+ transport: actionTransportSchema.optional(),
611
+ tweetId: z.string().default("")
612
+ });
613
+ var tweetReplyActionResponseSchema = z.looseObject({
614
+ ok: z.literal(true),
615
+ transport: actionTransportSchema.optional(),
616
+ replyId: z.string().default("")
617
+ });
618
+ var dmReplyActionResponseSchema = z.looseObject({
619
+ ok: z.literal(true),
620
+ transport: actionTransportSchema.optional(),
621
+ messageId: z.string().default("")
622
+ });
623
+ var scoreInboxActionResponseSchema = z.looseObject({
624
+ ok: z.literal(true),
625
+ scored: z.number().default(0),
626
+ items: z.array(z.object({
627
+ id: z.string(),
628
+ score: z.number(),
629
+ source: z.literal("openai")
630
+ })).default([])
631
+ });
632
+ var syncBlocksActionResponseSchema = z.looseObject({
633
+ ok: z.boolean(),
634
+ accountId: z.string().optional(),
635
+ synced: z.boolean().default(false),
636
+ syncedCount: z.number().default(0),
637
+ partial: z.boolean().optional(),
638
+ transport: actionTransportSchema.optional()
639
+ });
640
+ var actionRequestSchema = z.discriminatedUnion("kind", [
641
+ z.object({
642
+ kind: z.literal("post"),
643
+ accountId: z.string().optional(),
644
+ text: z.string().default("")
645
+ }),
646
+ z.object({
647
+ kind: z.literal("replyTweet"),
648
+ accountId: z.string().optional(),
649
+ tweetId: z.string().default(""),
650
+ text: z.string().default("")
651
+ }),
652
+ z.object({
653
+ kind: z.literal("replyDm"),
654
+ conversationId: z.string().default(""),
655
+ text: z.string().default("")
656
+ }),
657
+ z.object({
658
+ kind: z.literal("scoreInbox"),
659
+ scoreKind: inboxKindSchema.default("mixed"),
660
+ account: z.string().optional(),
661
+ limit: z.coerce.number().optional()
662
+ }),
663
+ z.object({
664
+ kind: z.literal("blockProfile"),
665
+ accountId: z.string().optional(),
666
+ query: z.string().default(""),
667
+ transport: z.enum([
668
+ "auto",
669
+ "bird",
670
+ "xurl"
671
+ ]).optional()
672
+ }),
673
+ z.object({
674
+ kind: z.literal("unblockProfile"),
675
+ accountId: z.string().optional(),
676
+ query: z.string().default(""),
677
+ transport: z.enum([
678
+ "auto",
679
+ "bird",
680
+ "xurl"
681
+ ]).optional()
682
+ }),
683
+ z.object({
684
+ kind: z.literal("muteProfile"),
685
+ accountId: z.string().optional(),
686
+ query: z.string().default(""),
687
+ transport: z.enum([
688
+ "auto",
689
+ "bird",
690
+ "xurl"
691
+ ]).optional()
692
+ }),
693
+ z.object({
694
+ kind: z.literal("unmuteProfile"),
695
+ accountId: z.string().optional(),
696
+ query: z.string().default(""),
697
+ transport: z.enum([
698
+ "auto",
699
+ "bird",
700
+ "xurl"
701
+ ]).optional()
702
+ }),
703
+ z.object({
704
+ kind: z.literal("syncBlocks"),
705
+ accountId: z.string().optional()
706
+ })
707
+ ]);
708
+ var actionResponseSchemas = {
709
+ post: postActionResponseSchema,
710
+ replyTweet: tweetReplyActionResponseSchema,
711
+ replyDm: dmReplyActionResponseSchema,
712
+ scoreInbox: scoreInboxActionResponseSchema,
713
+ blockProfile: profileActionResponseBaseSchema.extend({ action: z.literal("block").default("block") }),
714
+ unblockProfile: profileActionResponseBaseSchema.extend({ action: z.literal("unblock").default("unblock") }),
715
+ muteProfile: profileActionResponseBaseSchema.extend({ action: z.literal("mute").default("mute") }),
716
+ unmuteProfile: profileActionResponseBaseSchema.extend({ action: z.literal("unmute").default("unmute") }),
717
+ syncBlocks: syncBlocksActionResponseSchema
718
+ };
719
+ z.union([
720
+ postActionResponseSchema,
721
+ tweetReplyActionResponseSchema,
722
+ dmReplyActionResponseSchema,
723
+ scoreInboxActionResponseSchema,
724
+ profileActionResponseBaseSchema.extend({ action: z.literal("block") }),
725
+ profileActionResponseBaseSchema.extend({ action: z.literal("unblock") }),
726
+ profileActionResponseBaseSchema.extend({ action: z.literal("mute") }),
727
+ profileActionResponseBaseSchema.extend({ action: z.literal("unmute") }),
728
+ syncBlocksActionResponseSchema
729
+ ]);
730
+ function actionResponseSchemaFor(kind) {
731
+ return actionResponseSchemas[kind];
732
+ }
733
+ //#endregion
734
+ //#region src/lib/effect-runtime.ts
735
+ function toError(cause) {
736
+ return cause instanceof Error ? cause : new Error(String(cause));
737
+ }
738
+ function trySync(try_) {
739
+ return Effect.try({
740
+ try: try_,
741
+ catch: toError
742
+ });
743
+ }
744
+ function tryPromise(try_) {
745
+ return Effect.tryPromise({
746
+ try: try_,
747
+ catch: (cause) => cause
748
+ });
749
+ }
750
+ function runEffectPromise(effect) {
751
+ return Effect.runPromiseExit(effect).then((exit) => {
752
+ if (Exit.isSuccess(exit)) return exit.value;
753
+ throw effectExitError(exit);
754
+ });
755
+ }
756
+ function effectExitError(exit) {
757
+ if (Exit.isSuccess(exit)) return /* @__PURE__ */ new Error("Effect completed successfully");
758
+ const failure = Cause.failureOption(exit.cause);
759
+ if (Option.isSome(failure)) return failure.value;
760
+ const squashed = Cause.squash(exit.cause);
761
+ return squashed instanceof Error ? squashed : new Error(String(squashed));
762
+ }
763
+ function runEffectBackground(effect, handlers) {
764
+ Effect.runPromiseExit(effect).then((exit) => {
765
+ if (Exit.isSuccess(exit)) {
766
+ handlers.onSuccess(exit.value);
767
+ return;
768
+ }
769
+ handlers.onFailure(effectExitError(exit));
770
+ });
771
+ }
772
+ //#endregion
773
+ //#region src/lib/runtime-services.ts
774
+ var defaultRuntimeServices = {
775
+ fetch: (input, init) => init === void 0 ? globalThis.fetch(input) : globalThis.fetch(input, init),
776
+ now: () => /* @__PURE__ */ new Date(),
777
+ random: () => Math.random(),
778
+ env: (name) => typeof process === "undefined" ? void 0 : process.env[name]
779
+ };
780
+ //#endregion
781
+ //#region src/lib/api-client.ts
782
+ var SYNC_POLL_INTERVAL_MS = 500;
783
+ var ApiFetchError = class extends Data.TaggedError("ApiFetchError") {};
784
+ function responseMessage(data, fallback) {
785
+ if (data && typeof data === "object") {
786
+ const record = data;
787
+ if (typeof record.message === "string") return record.message;
788
+ if (typeof record.error === "string") return record.error;
789
+ if (typeof record.summary === "string") return record.summary;
790
+ }
791
+ return fallback;
792
+ }
793
+ function apiFetchErrorFromCause(cause, fallbackMessage) {
794
+ if (cause instanceof DOMException && cause.name === "AbortError") return cause;
795
+ if (cause instanceof ApiFetchError) return cause;
796
+ if (cause instanceof Error) return new ApiFetchError({
797
+ message: cause.message,
798
+ cause
799
+ });
800
+ if (typeof cause === "string") return new ApiFetchError({
801
+ message: cause,
802
+ cause
803
+ });
804
+ return new ApiFetchError({
805
+ message: fallbackMessage,
806
+ cause
807
+ });
808
+ }
809
+ function readJsonEffect(response) {
810
+ return Effect.promise(() => response.json().catch(() => null));
811
+ }
812
+ function runApiEffect(effect) {
813
+ return runEffectPromise(effect);
814
+ }
815
+ function fetchJsonEffect(input, init, schema, fallbackMessage, runtime = defaultRuntimeServices) {
816
+ return Effect.gen(function* () {
817
+ const response = yield* Effect.tryPromise({
818
+ try: () => init === void 0 ? runtime.fetch(input) : runtime.fetch(input, init),
819
+ catch: (cause) => apiFetchErrorFromCause(cause, fallbackMessage)
820
+ });
821
+ const data = yield* readJsonEffect(response);
822
+ if (!response.ok) return yield* Effect.fail(new ApiFetchError({
823
+ message: responseMessage(data, fallbackMessage),
824
+ status: response.status
825
+ }));
826
+ const parsed = schema.safeParse(data);
827
+ if (!parsed.success) return yield* Effect.fail(new ApiFetchError({
828
+ message: fallbackMessage,
829
+ cause: parsed.error
830
+ }));
831
+ return parsed.data;
832
+ });
833
+ }
834
+ function fetchJson(input, init, schema, fallbackMessage, runtime = defaultRuntimeServices) {
835
+ return runApiEffect(fetchJsonEffect(input, init, schema, fallbackMessage, runtime));
836
+ }
837
+ function fetchQueryEnvelope(init) {
838
+ return runApiEffect(fetchQueryEnvelopeEffect(init));
839
+ }
840
+ function fetchQueryEnvelopeEffect(init) {
841
+ return fetchJsonEffect("/api/status", init, queryEnvelopeSchema, "Status unavailable");
842
+ }
843
+ function fetchQueryResponse(input, init) {
844
+ return runApiEffect(fetchQueryResponseEffect(input, init));
845
+ }
846
+ function fetchQueryResponseEffect(input, init) {
847
+ return fetchJsonEffect(input, init, queryResponseSchema, "Query unavailable");
848
+ }
849
+ function postAction(body) {
850
+ return runApiEffect(postActionEffect(body));
851
+ }
852
+ function postActionEffect(body) {
853
+ return fetchJsonEffect("/api/action", {
854
+ method: "POST",
855
+ headers: { "content-type": "application/json" },
856
+ body: JSON.stringify(body)
857
+ }, actionResponseSchemaFor(body.kind), "Action failed");
858
+ }
859
+ function postSync(kind, accountId, options = {}) {
860
+ return runApiEffect(postSyncEffect(kind, accountId, options));
861
+ }
862
+ function postSyncEffect(kind, accountId, options = {}) {
863
+ return fetchJsonEffect("/api/sync", {
864
+ method: "POST",
865
+ headers: { "content-type": "application/json" },
866
+ body: JSON.stringify({
867
+ kind,
868
+ ...accountId ? { accountId } : {},
869
+ ...options
870
+ })
871
+ }, webSyncJobSchema, "Sync failed").pipe(Effect.flatMap(waitForWebSyncJobEffect));
872
+ }
873
+ function fetchSyncJobEffect(id) {
874
+ const url = new URL("/api/sync", window.location.origin);
875
+ url.searchParams.set("id", id);
876
+ return fetchJsonEffect(url, void 0, webSyncJobSchema, "Sync status unavailable");
877
+ }
878
+ function waitForWebSyncJobEffect(job) {
879
+ return Effect.gen(function* () {
880
+ let current = job;
881
+ while (current.inProgress) {
882
+ yield* Effect.sleep(SYNC_POLL_INTERVAL_MS);
883
+ current = yield* fetchSyncJobEffect(current.id);
884
+ }
885
+ if (!current.result) return yield* Effect.fail(new ApiFetchError({ message: current.error ?? current.summary }));
886
+ if (!current.result.ok) return yield* Effect.fail(new ApiFetchError({ message: current.result.error ?? current.result.summary }));
887
+ return current.result;
888
+ });
889
+ }
890
+ //#endregion
891
+ //#region src/lib/query-client.tsx
892
+ var queryKeys = {
893
+ status: ["status"],
894
+ timelines: ["timeline"],
895
+ dms: ["dms"],
896
+ conversations: ["conversation"],
897
+ linkInsights: ["link-insights"],
898
+ linkPreviews: ["link-preview"],
899
+ profileHydration: ["profile-hydration"],
900
+ networkMap: ["network-map"],
901
+ blocks: ["blocks"],
902
+ blockSync: ["block-sync"],
903
+ inbox: ["inbox"],
904
+ dataSources: ["data-sources"],
905
+ rateLimits: ["rate-limits"]
906
+ };
907
+ function createBirdclawQueryClient() {
908
+ return new QueryClient({ defaultOptions: { queries: {
909
+ gcTime: 30 * 6e4,
910
+ refetchOnWindowFocus: false,
911
+ retry: 1,
912
+ staleTime: 6e4
913
+ } } });
914
+ }
915
+ function BirdclawQueryProvider({ children }) {
916
+ const [queryClient] = useState(createBirdclawQueryClient);
917
+ return /* @__PURE__ */ jsx(QueryClientProvider, {
918
+ client: queryClient,
919
+ children
920
+ });
921
+ }
922
+ //#endregion
923
+ export { networkMapResponseSchema as C, tweetConversationResponseSchema as D, queryResponseSchema as E, webSyncJobSchema as O, liveDataSourcesResponseSchema as S, queryEnvelopeSchema as T, blockListResponseSchema as _, fetchQueryEnvelope as a, linkInsightResponseSchema as b, postSync as c, runEffectPromise as d, toError as f, actionResponseSchemaFor as g, actionRequestSchema as h, fetchJsonEffect as i, xurlRateLimitSnapshotSchema as k, defaultRuntimeServices as l, trySync as m, queryKeys as n, fetchQueryResponse as o, tryPromise as p, fetchJson as r, postAction as s, BirdclawQueryProvider as t, runEffectBackground as u, dmQueryResponseSchema as v, profileHydrationResponseSchema as w, linkPreviewResponseSchema as x, inboxResponseSchema as y };