birdclaw 0.5.1 → 0.6.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.
Files changed (89) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/README.md +50 -5
  3. package/package.json +3 -2
  4. package/scripts/browser-perf.mjs +1 -0
  5. package/scripts/start-test-server.mjs +16 -3
  6. package/src/cli.ts +376 -13
  7. package/src/components/AccountSwitcher.tsx +186 -0
  8. package/src/components/AppNav.tsx +27 -7
  9. package/src/components/AvatarChip.tsx +9 -3
  10. package/src/components/DmWorkspace.tsx +18 -8
  11. package/src/components/LinkPreviewCard.tsx +40 -18
  12. package/src/components/MarkdownViewer.tsx +452 -0
  13. package/src/components/SyncNowButton.tsx +57 -25
  14. package/src/components/ThemeSlider.tsx +55 -50
  15. package/src/components/TimelineCard.tsx +225 -93
  16. package/src/components/TimelineRouteFrame.tsx +22 -8
  17. package/src/components/TweetMediaGrid.tsx +87 -38
  18. package/src/components/TweetRichText.tsx +15 -11
  19. package/src/components/account-selection.ts +64 -0
  20. package/src/components/useTimelineRouteData.ts +23 -7
  21. package/src/lib/account-sync-job.ts +654 -0
  22. package/src/lib/actions-transport.ts +216 -146
  23. package/src/lib/api-client.ts +128 -53
  24. package/src/lib/archive-finder.ts +78 -63
  25. package/src/lib/archive-import.ts +1364 -1300
  26. package/src/lib/authored-live.ts +261 -204
  27. package/src/lib/avatar-cache.ts +159 -44
  28. package/src/lib/backup.ts +1532 -951
  29. package/src/lib/bird-actions.ts +139 -57
  30. package/src/lib/bird-command.ts +101 -28
  31. package/src/lib/bird.ts +549 -194
  32. package/src/lib/blocklist.ts +40 -23
  33. package/src/lib/blocks-write.ts +129 -80
  34. package/src/lib/blocks.ts +165 -97
  35. package/src/lib/bookmark-sync-job.ts +250 -160
  36. package/src/lib/conversation-surface.ts +79 -48
  37. package/src/lib/db.ts +33 -3
  38. package/src/lib/dms-live.ts +720 -66
  39. package/src/lib/effect-runtime.ts +45 -0
  40. package/src/lib/follow-graph.ts +224 -180
  41. package/src/lib/http-effect.ts +222 -0
  42. package/src/lib/inbox.ts +74 -43
  43. package/src/lib/link-index.ts +88 -76
  44. package/src/lib/link-insights.ts +24 -0
  45. package/src/lib/link-preview-metadata.ts +472 -52
  46. package/src/lib/media-fetch.ts +286 -213
  47. package/src/lib/mention-threads-live.ts +352 -288
  48. package/src/lib/mentions-live.ts +390 -342
  49. package/src/lib/moderation-target.ts +102 -65
  50. package/src/lib/moderation-write.ts +77 -18
  51. package/src/lib/mutes-write.ts +129 -80
  52. package/src/lib/mutes.ts +8 -1
  53. package/src/lib/openai.ts +84 -53
  54. package/src/lib/period-digest.ts +953 -0
  55. package/src/lib/profile-affiliation-hydration.ts +93 -54
  56. package/src/lib/profile-hydration.ts +124 -72
  57. package/src/lib/profile-replies.ts +60 -43
  58. package/src/lib/profile-resolver.ts +402 -294
  59. package/src/lib/queries.ts +969 -199
  60. package/src/lib/research.ts +165 -120
  61. package/src/lib/sqlite.ts +1 -0
  62. package/src/lib/timeline-collections-live.ts +204 -167
  63. package/src/lib/timeline-live.ts +60 -39
  64. package/src/lib/tweet-lookup.ts +30 -19
  65. package/src/lib/types.ts +38 -1
  66. package/src/lib/ui.ts +30 -7
  67. package/src/lib/url-expansion.ts +226 -55
  68. package/src/lib/url-safety.ts +220 -0
  69. package/src/lib/web-sync.ts +216 -148
  70. package/src/lib/whois.ts +166 -147
  71. package/src/lib/x-web.ts +102 -71
  72. package/src/lib/xurl.ts +681 -411
  73. package/src/routeTree.gen.ts +42 -0
  74. package/src/routes/__root.tsx +25 -5
  75. package/src/routes/api/action.tsx +127 -78
  76. package/src/routes/api/avatar.tsx +39 -30
  77. package/src/routes/api/blocks.tsx +26 -23
  78. package/src/routes/api/conversation.tsx +25 -14
  79. package/src/routes/api/inbox.tsx +27 -21
  80. package/src/routes/api/link-insights.tsx +31 -25
  81. package/src/routes/api/link-preview.tsx +25 -21
  82. package/src/routes/api/period-digest.tsx +123 -0
  83. package/src/routes/api/profile-hydrate.tsx +31 -28
  84. package/src/routes/api/query.tsx +79 -55
  85. package/src/routes/api/status.tsx +18 -10
  86. package/src/routes/api/sync.tsx +75 -29
  87. package/src/routes/dms.tsx +95 -28
  88. package/src/routes/inbox.tsx +32 -19
  89. package/src/routes/today.tsx +441 -0
package/src/lib/db.ts CHANGED
@@ -131,6 +131,7 @@ export interface DmConversationsTable {
131
131
  account_id: string;
132
132
  participant_profile_id: string;
133
133
  title: string;
134
+ inbox_kind: "accepted" | "request";
134
135
  last_message_at: string;
135
136
  unread_count: number;
136
137
  needs_reply: number;
@@ -429,6 +430,7 @@ const BASE_SCHEMA_SQL = `
429
430
  account_id text not null,
430
431
  participant_profile_id text not null,
431
432
  title text not null,
433
+ inbox_kind text not null default 'accepted',
432
434
  last_message_at text not null,
433
435
  unread_count integer not null default 0,
434
436
  needs_reply integer not null default 0
@@ -678,6 +680,15 @@ function ensureAccountExternalUserIdColumn(db: Database) {
678
680
  }
679
681
  }
680
682
 
683
+ function ensureDmConversationInboxColumns(db: Database) {
684
+ const columnNames = getColumnNames(db, "dm_conversations");
685
+ if (!columnNames.has("inbox_kind")) {
686
+ db.exec(
687
+ "alter table dm_conversations add column inbox_kind text not null default 'accepted'",
688
+ );
689
+ }
690
+ }
691
+
681
692
  function ensureTweetCollectionsTable(db: Database) {
682
693
  db.exec(`
683
694
  create table if not exists tweet_collections (
@@ -941,6 +952,7 @@ function initDatabase(options: InitDatabaseOptions = {}) {
941
952
  nativeDb = new NativeSqliteDatabase(dbPath);
942
953
  nativeDb.exec(BASE_SCHEMA_SQL);
943
954
  ensureAccountExternalUserIdColumn(nativeDb);
955
+ ensureDmConversationInboxColumns(nativeDb);
944
956
  ensureTweetMetadataColumns(nativeDb);
945
957
  ensureProfileAvatarColumns(nativeDb);
946
958
  ensureTweetCollectionsTable(nativeDb);
@@ -981,11 +993,29 @@ export function getDb() {
981
993
  return kyselyDb as Kysely<BirdclawDatabase>;
982
994
  }
983
995
 
984
- export function resetDatabaseForTests() {
985
- kyselyDb?.destroy();
996
+ export async function closeDatabase() {
997
+ const db = kyselyDb;
998
+ const native = nativeDb;
986
999
  kyselyDb = undefined;
1000
+ nativeDb = undefined;
1001
+ demoSeedAttempted = false;
1002
+
1003
+ if (db) {
1004
+ await db.destroy();
1005
+ } else {
1006
+ native?.close();
1007
+ }
1008
+ }
987
1009
 
988
- nativeDb?.close();
1010
+ export function resetDatabaseForTests() {
1011
+ const db = kyselyDb;
1012
+ const native = nativeDb;
1013
+ kyselyDb = undefined;
989
1014
  nativeDb = undefined;
990
1015
  demoSeedAttempted = false;
1016
+ if (db) {
1017
+ void db.destroy();
1018
+ } else {
1019
+ native?.close();
1020
+ }
991
1021
  }