dp-worker 0.1.24 → 0.1.26

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 (117) hide show
  1. package/dist/bird/sidecar-entry.js +16 -2
  2. package/dist/bird/sidecar-entry.js.map +1 -1
  3. package/dist/chrome-extension/omni-flow/manifest.json +1 -1
  4. package/node_modules/dp-shared/dist/bird-contracts.d.ts +94 -0
  5. package/node_modules/dp-shared/dist/bird-contracts.d.ts.map +1 -1
  6. package/node_modules/dp-shared/dist/bird-contracts.js +108 -0
  7. package/node_modules/dp-shared/dist/bird-contracts.js.map +1 -1
  8. package/node_modules/dp-shared/dist/task-history-contracts.d.ts +2 -2
  9. package/package.json +4 -2
  10. package/vendor/bird/LICENSE +21 -0
  11. package/vendor/bird/README.md +116 -0
  12. package/vendor/bird/dist/cli/pagination.d.ts +35 -0
  13. package/vendor/bird/dist/cli/pagination.js +43 -0
  14. package/vendor/bird/dist/cli/program.d.ts +5 -0
  15. package/vendor/bird/dist/cli/program.js +113 -0
  16. package/vendor/bird/dist/cli/shared.d.ts +77 -0
  17. package/vendor/bird/dist/cli/shared.js +327 -0
  18. package/vendor/bird/dist/cli.d.ts +12 -0
  19. package/vendor/bird/dist/cli.js +29 -0
  20. package/vendor/bird/dist/commands/bookmarks.d.ts +4 -0
  21. package/vendor/bird/dist/commands/bookmarks.js +189 -0
  22. package/vendor/bird/dist/commands/check.d.ts +4 -0
  23. package/vendor/bird/dist/commands/check.js +43 -0
  24. package/vendor/bird/dist/commands/follow.d.ts +4 -0
  25. package/vendor/bird/dist/commands/follow.js +91 -0
  26. package/vendor/bird/dist/commands/help.d.ts +4 -0
  27. package/vendor/bird/dist/commands/help.js +19 -0
  28. package/vendor/bird/dist/commands/home.d.ts +4 -0
  29. package/vendor/bird/dist/commands/home.js +43 -0
  30. package/vendor/bird/dist/commands/lists.d.ts +4 -0
  31. package/vendor/bird/dist/commands/lists.js +125 -0
  32. package/vendor/bird/dist/commands/news.d.ts +4 -0
  33. package/vendor/bird/dist/commands/news.js +131 -0
  34. package/vendor/bird/dist/commands/post.d.ts +4 -0
  35. package/vendor/bird/dist/commands/post.js +101 -0
  36. package/vendor/bird/dist/commands/query-ids.d.ts +4 -0
  37. package/vendor/bird/dist/commands/query-ids.js +80 -0
  38. package/vendor/bird/dist/commands/read.d.ts +4 -0
  39. package/vendor/bird/dist/commands/read.js +152 -0
  40. package/vendor/bird/dist/commands/search.d.ts +4 -0
  41. package/vendor/bird/dist/commands/search.js +115 -0
  42. package/vendor/bird/dist/commands/unbookmark.d.ts +4 -0
  43. package/vendor/bird/dist/commands/unbookmark.js +36 -0
  44. package/vendor/bird/dist/commands/user-tweets.d.ts +4 -0
  45. package/vendor/bird/dist/commands/user-tweets.js +109 -0
  46. package/vendor/bird/dist/commands/users.d.ts +4 -0
  47. package/vendor/bird/dist/commands/users.js +295 -0
  48. package/vendor/bird/dist/index.d.ts +2 -0
  49. package/vendor/bird/dist/index.js +2 -0
  50. package/vendor/bird/dist/lib/cli-args.d.ts +7 -0
  51. package/vendor/bird/dist/lib/cli-args.js +25 -0
  52. package/vendor/bird/dist/lib/cookies.d.ts +31 -0
  53. package/vendor/bird/dist/lib/cookies.js +81 -0
  54. package/vendor/bird/dist/lib/extract-bookmark-folder-id.d.ts +2 -0
  55. package/vendor/bird/dist/lib/extract-bookmark-folder-id.js +20 -0
  56. package/vendor/bird/dist/lib/extract-list-id.d.ts +2 -0
  57. package/vendor/bird/dist/lib/extract-list-id.js +19 -0
  58. package/vendor/bird/dist/lib/extract-tweet-id.d.ts +2 -0
  59. package/vendor/bird/dist/lib/extract-tweet-id.js +14 -0
  60. package/vendor/bird/dist/lib/features.json +17 -0
  61. package/vendor/bird/dist/lib/index.d.ts +10 -0
  62. package/vendor/bird/dist/lib/index.js +4 -0
  63. package/vendor/bird/dist/lib/normalize-handle.d.ts +6 -0
  64. package/vendor/bird/dist/lib/normalize-handle.js +31 -0
  65. package/vendor/bird/dist/lib/output.d.ts +29 -0
  66. package/vendor/bird/dist/lib/output.js +88 -0
  67. package/vendor/bird/dist/lib/paginate-cursor.d.ts +27 -0
  68. package/vendor/bird/dist/lib/paginate-cursor.js +37 -0
  69. package/vendor/bird/dist/lib/query-ids.json +20 -0
  70. package/vendor/bird/dist/lib/runtime-features.d.ts +19 -0
  71. package/vendor/bird/dist/lib/runtime-features.js +151 -0
  72. package/vendor/bird/dist/lib/runtime-query-ids.d.ts +33 -0
  73. package/vendor/bird/dist/lib/runtime-query-ids.js +264 -0
  74. package/vendor/bird/dist/lib/thread-filters.d.ts +8 -0
  75. package/vendor/bird/dist/lib/thread-filters.js +124 -0
  76. package/vendor/bird/dist/lib/twitter-client-base.d.ts +38 -0
  77. package/vendor/bird/dist/lib/twitter-client-base.js +129 -0
  78. package/vendor/bird/dist/lib/twitter-client-bookmarks.d.ts +7 -0
  79. package/vendor/bird/dist/lib/twitter-client-bookmarks.js +61 -0
  80. package/vendor/bird/dist/lib/twitter-client-constants.d.ts +43 -0
  81. package/vendor/bird/dist/lib/twitter-client-constants.js +50 -0
  82. package/vendor/bird/dist/lib/twitter-client-engagement.d.ts +16 -0
  83. package/vendor/bird/dist/lib/twitter-client-engagement.js +81 -0
  84. package/vendor/bird/dist/lib/twitter-client-features.d.ts +14 -0
  85. package/vendor/bird/dist/lib/twitter-client-features.js +347 -0
  86. package/vendor/bird/dist/lib/twitter-client-follow.d.ts +8 -0
  87. package/vendor/bird/dist/lib/twitter-client-follow.js +178 -0
  88. package/vendor/bird/dist/lib/twitter-client-home.d.ts +13 -0
  89. package/vendor/bird/dist/lib/twitter-client-home.js +138 -0
  90. package/vendor/bird/dist/lib/twitter-client-lists.d.ts +11 -0
  91. package/vendor/bird/dist/lib/twitter-client-lists.js +321 -0
  92. package/vendor/bird/dist/lib/twitter-client-media.d.ts +11 -0
  93. package/vendor/bird/dist/lib/twitter-client-media.js +136 -0
  94. package/vendor/bird/dist/lib/twitter-client-news.d.ts +47 -0
  95. package/vendor/bird/dist/lib/twitter-client-news.js +283 -0
  96. package/vendor/bird/dist/lib/twitter-client-posting.d.ts +8 -0
  97. package/vendor/bird/dist/lib/twitter-client-posting.js +218 -0
  98. package/vendor/bird/dist/lib/twitter-client-search.d.ts +19 -0
  99. package/vendor/bird/dist/lib/twitter-client-search.js +157 -0
  100. package/vendor/bird/dist/lib/twitter-client-timelines.d.ts +23 -0
  101. package/vendor/bird/dist/lib/twitter-client-timelines.js +471 -0
  102. package/vendor/bird/dist/lib/twitter-client-tweet-detail.d.ts +25 -0
  103. package/vendor/bird/dist/lib/twitter-client-tweet-detail.js +295 -0
  104. package/vendor/bird/dist/lib/twitter-client-types.d.ts +407 -0
  105. package/vendor/bird/dist/lib/twitter-client-types.js +2 -0
  106. package/vendor/bird/dist/lib/twitter-client-user-lookup.d.ts +16 -0
  107. package/vendor/bird/dist/lib/twitter-client-user-lookup.js +224 -0
  108. package/vendor/bird/dist/lib/twitter-client-user-tweets.d.ts +22 -0
  109. package/vendor/bird/dist/lib/twitter-client-user-tweets.js +154 -0
  110. package/vendor/bird/dist/lib/twitter-client-users.d.ts +9 -0
  111. package/vendor/bird/dist/lib/twitter-client-users.js +358 -0
  112. package/vendor/bird/dist/lib/twitter-client-utils.d.ts +173 -0
  113. package/vendor/bird/dist/lib/twitter-client-utils.js +511 -0
  114. package/vendor/bird/dist/lib/twitter-client.d.ts +23 -0
  115. package/vendor/bird/dist/lib/twitter-client.js +21 -0
  116. package/vendor/bird/dist/lib/version.d.ts +6 -0
  117. package/vendor/bird/dist/lib/version.js +174 -0
@@ -0,0 +1,152 @@
1
+ import { parsePaginationFlags } from '../cli/pagination.js';
2
+ import { formatStatsLine } from '../lib/output.js';
3
+ import { TwitterClient } from '../lib/twitter-client.js';
4
+ export function registerReadCommands(program, ctx) {
5
+ program
6
+ .command('read')
7
+ .description('Read/fetch a tweet by ID or URL')
8
+ .argument('<tweet-id-or-url>', 'Tweet ID or URL to read')
9
+ .option('--json', 'Output as JSON')
10
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
11
+ .action(async (tweetIdOrUrl, cmdOpts) => {
12
+ const opts = program.opts();
13
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
14
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
15
+ const tweetId = ctx.extractTweetId(tweetIdOrUrl);
16
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
17
+ for (const warning of warnings) {
18
+ console.error(`${ctx.p('warn')}${warning}`);
19
+ }
20
+ if (!cookies.authToken || !cookies.ct0) {
21
+ console.error(`${ctx.p('err')}Missing required credentials`);
22
+ process.exit(1);
23
+ }
24
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
25
+ const includeRaw = cmdOpts.jsonFull ?? false;
26
+ const result = await client.getTweet(tweetId, { includeRaw });
27
+ if (result.success && result.tweet) {
28
+ if (cmdOpts.json || cmdOpts.jsonFull) {
29
+ console.log(JSON.stringify(result.tweet, null, 2));
30
+ }
31
+ else {
32
+ ctx.printTweets([result.tweet], { showSeparator: false });
33
+ console.log(formatStatsLine(result.tweet, ctx.getOutput()));
34
+ }
35
+ }
36
+ else {
37
+ console.error(`${ctx.p('err')}Failed to read tweet: ${result.error}`);
38
+ process.exit(1);
39
+ }
40
+ });
41
+ program
42
+ .command('replies')
43
+ .description('List replies to a tweet (by ID or URL)')
44
+ .argument('<tweet-id-or-url>', 'Tweet ID or URL')
45
+ .option('--all', 'Fetch all replies (paged)')
46
+ .option('--max-pages <number>', 'Fetch N pages (implies pagination)')
47
+ .option('--delay <ms>', 'Delay in ms between page fetches', '1000')
48
+ .option('--cursor <string>', 'Resume pagination from a cursor')
49
+ .option('--json', 'Output as JSON')
50
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
51
+ .action(async (tweetIdOrUrl, cmdOpts) => {
52
+ const opts = program.opts();
53
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
54
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
55
+ const tweetId = ctx.extractTweetId(tweetIdOrUrl);
56
+ const pagination = parsePaginationFlags(cmdOpts, { maxPagesImpliesPagination: true, includeDelay: true });
57
+ if (!pagination.ok) {
58
+ console.error(`${ctx.p('err')}${pagination.error}`);
59
+ process.exit(1);
60
+ }
61
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
62
+ for (const warning of warnings) {
63
+ console.error(`${ctx.p('warn')}${warning}`);
64
+ }
65
+ if (!cookies.authToken || !cookies.ct0) {
66
+ console.error(`${ctx.p('err')}Missing required credentials`);
67
+ process.exit(1);
68
+ }
69
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
70
+ const includeRaw = cmdOpts.jsonFull ?? false;
71
+ const result = pagination.usePagination
72
+ ? await client.getRepliesPaged(tweetId, {
73
+ includeRaw,
74
+ maxPages: pagination.maxPages,
75
+ cursor: pagination.cursor,
76
+ pageDelayMs: pagination.pageDelayMs,
77
+ })
78
+ : await client.getReplies(tweetId, { includeRaw });
79
+ const isJson = Boolean(cmdOpts.json || cmdOpts.jsonFull);
80
+ if (result.tweets) {
81
+ ctx.printTweetsResult(result, {
82
+ json: isJson,
83
+ usePagination: pagination.usePagination,
84
+ emptyMessage: 'No replies found.',
85
+ });
86
+ // Show pagination hint if there's more
87
+ if (result.nextCursor && !isJson) {
88
+ console.error(`${ctx.p('info')}More replies available. Use --cursor "${result.nextCursor}" to continue.`);
89
+ }
90
+ }
91
+ if (!result.success) {
92
+ console.error(`${ctx.p('err')}Failed to fetch replies: ${result.error}`);
93
+ process.exit(1);
94
+ }
95
+ });
96
+ program
97
+ .command('thread')
98
+ .description('Show the full conversation thread containing the tweet')
99
+ .argument('<tweet-id-or-url>', 'Tweet ID or URL')
100
+ .option('--all', 'Fetch all thread tweets (paged)')
101
+ .option('--max-pages <number>', 'Fetch N pages (implies pagination)')
102
+ .option('--delay <ms>', 'Delay in ms between page fetches', '1000')
103
+ .option('--cursor <string>', 'Resume pagination from a cursor')
104
+ .option('--json', 'Output as JSON')
105
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
106
+ .action(async (tweetIdOrUrl, cmdOpts) => {
107
+ const opts = program.opts();
108
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
109
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
110
+ const tweetId = ctx.extractTweetId(tweetIdOrUrl);
111
+ const pagination = parsePaginationFlags(cmdOpts, { maxPagesImpliesPagination: true, includeDelay: true });
112
+ if (!pagination.ok) {
113
+ console.error(`${ctx.p('err')}${pagination.error}`);
114
+ process.exit(1);
115
+ }
116
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
117
+ for (const warning of warnings) {
118
+ console.error(`${ctx.p('warn')}${warning}`);
119
+ }
120
+ if (!cookies.authToken || !cookies.ct0) {
121
+ console.error(`${ctx.p('err')}Missing required credentials`);
122
+ process.exit(1);
123
+ }
124
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
125
+ const includeRaw = cmdOpts.jsonFull ?? false;
126
+ const result = pagination.usePagination
127
+ ? await client.getThreadPaged(tweetId, {
128
+ includeRaw,
129
+ maxPages: pagination.maxPages,
130
+ cursor: pagination.cursor,
131
+ pageDelayMs: pagination.pageDelayMs,
132
+ })
133
+ : await client.getThread(tweetId, { includeRaw });
134
+ const isJson = Boolean(cmdOpts.json || cmdOpts.jsonFull);
135
+ if (result.tweets) {
136
+ ctx.printTweetsResult(result, {
137
+ json: isJson,
138
+ usePagination: pagination.usePagination,
139
+ emptyMessage: 'No thread tweets found.',
140
+ });
141
+ // Show pagination hint if there's more
142
+ if (result.nextCursor && !isJson) {
143
+ console.error(`${ctx.p('info')}More thread tweets available. Use --cursor "${result.nextCursor}" to continue.`);
144
+ }
145
+ }
146
+ if (!result.success) {
147
+ console.error(`${ctx.p('err')}Failed to fetch thread: ${result.error}`);
148
+ process.exit(1);
149
+ }
150
+ });
151
+ }
152
+ //# sourceMappingURL=read.js.map
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliContext } from '../cli/shared.js';
3
+ export declare function registerSearchCommands(program: Command, ctx: CliContext): void;
4
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1,115 @@
1
+ import { parsePaginationFlags } from '../cli/pagination.js';
2
+ import { mentionsQueryFromUserOption, normalizeHandle } from '../lib/normalize-handle.js';
3
+ import { TwitterClient } from '../lib/twitter-client.js';
4
+ export function registerSearchCommands(program, ctx) {
5
+ program
6
+ .command('search')
7
+ .description('Search for tweets')
8
+ .argument('<query>', 'Search query (e.g., "@clawdbot" or "from:clawdbot")')
9
+ .option('-n, --count <number>', 'Number of tweets to fetch', '10')
10
+ .option('--all', 'Fetch all search results (paged)')
11
+ .option('--max-pages <number>', 'Stop after N pages when using --all')
12
+ .option('--cursor <string>', 'Resume pagination from a cursor')
13
+ .option('--json', 'Output as JSON')
14
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
15
+ .action(async (query, cmdOpts) => {
16
+ const opts = program.opts();
17
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
18
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
19
+ const count = Number.parseInt(cmdOpts.count || '10', 10);
20
+ const pagination = parsePaginationFlags(cmdOpts);
21
+ if (!pagination.ok) {
22
+ console.error(`${ctx.p('err')}${pagination.error}`);
23
+ process.exit(1);
24
+ }
25
+ const maxPages = pagination.maxPages;
26
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
27
+ for (const warning of warnings) {
28
+ console.error(`${ctx.p('warn')}${warning}`);
29
+ }
30
+ if (!cookies.authToken || !cookies.ct0) {
31
+ console.error(`${ctx.p('err')}Missing required credentials`);
32
+ process.exit(1);
33
+ }
34
+ const usePagination = pagination.usePagination;
35
+ if (maxPages !== undefined && !usePagination) {
36
+ console.error(`${ctx.p('err')}--max-pages requires --all or --cursor.`);
37
+ process.exit(1);
38
+ }
39
+ if (!usePagination && (!Number.isFinite(count) || count <= 0)) {
40
+ console.error(`${ctx.p('err')}Invalid --count. Expected a positive integer.`);
41
+ process.exit(1);
42
+ }
43
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
44
+ const includeRaw = cmdOpts.jsonFull ?? false;
45
+ const searchOptions = { includeRaw };
46
+ const paginationOptions = { includeRaw, maxPages, cursor: pagination.cursor };
47
+ const result = usePagination
48
+ ? await client.getAllSearchResults(query, paginationOptions)
49
+ : await client.search(query, count, searchOptions);
50
+ if (result.success) {
51
+ const isJson = Boolean(cmdOpts.json || cmdOpts.jsonFull);
52
+ ctx.printTweetsResult(result, {
53
+ json: isJson,
54
+ usePagination: Boolean(usePagination),
55
+ emptyMessage: 'No tweets found.',
56
+ });
57
+ }
58
+ else {
59
+ console.error(`${ctx.p('err')}Search failed: ${result.error}`);
60
+ process.exit(1);
61
+ }
62
+ });
63
+ program
64
+ .command('mentions')
65
+ .description('Find tweets mentioning a user (defaults to current user)')
66
+ .option('-u, --user <handle>', 'User handle (e.g. @steipete)')
67
+ .option('-n, --count <number>', 'Number of tweets to fetch', '10')
68
+ .option('--json', 'Output as JSON')
69
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
70
+ .action(async (cmdOpts) => {
71
+ const opts = program.opts();
72
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
73
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
74
+ const count = Number.parseInt(cmdOpts.count || '10', 10);
75
+ const fromUserOpt = mentionsQueryFromUserOption(cmdOpts.user);
76
+ if (fromUserOpt.error) {
77
+ console.error(`${ctx.p('err')}${fromUserOpt.error}`);
78
+ process.exit(2);
79
+ }
80
+ let query = fromUserOpt.query;
81
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
82
+ for (const warning of warnings) {
83
+ console.error(`${ctx.p('warn')}${warning}`);
84
+ }
85
+ if (!cookies.authToken || !cookies.ct0) {
86
+ console.error(`${ctx.p('err')}Missing required credentials`);
87
+ process.exit(1);
88
+ }
89
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
90
+ if (!query) {
91
+ const who = await client.getCurrentUser();
92
+ const handle = normalizeHandle(who.user?.username);
93
+ if (handle) {
94
+ query = `@${handle}`;
95
+ }
96
+ else {
97
+ console.error(`${ctx.p('err')}Could not determine current user (${who.error ?? 'Unknown error'}). Use --user <handle>.`);
98
+ process.exit(1);
99
+ }
100
+ }
101
+ const includeRaw = cmdOpts.jsonFull ?? false;
102
+ const result = await client.search(query, count, { includeRaw });
103
+ if (result.success) {
104
+ ctx.printTweets(result.tweets, {
105
+ json: cmdOpts.json || cmdOpts.jsonFull,
106
+ emptyMessage: 'No mentions found.',
107
+ });
108
+ }
109
+ else {
110
+ console.error(`${ctx.p('err')}Failed to fetch mentions: ${result.error}`);
111
+ process.exit(1);
112
+ }
113
+ });
114
+ }
115
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliContext } from '../cli/shared.js';
3
+ export declare function registerUnbookmarkCommand(program: Command, ctx: CliContext): void;
4
+ //# sourceMappingURL=unbookmark.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { TwitterClient } from '../lib/twitter-client.js';
2
+ export function registerUnbookmarkCommand(program, ctx) {
3
+ program
4
+ .command('unbookmark')
5
+ .description('Remove bookmarked tweets')
6
+ .argument('<tweet-id-or-url...>', 'Tweet IDs or URLs to remove from bookmarks')
7
+ .action(async (tweetIdOrUrls) => {
8
+ const opts = program.opts();
9
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
10
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
11
+ for (const warning of warnings) {
12
+ console.error(`${ctx.p('warn')}${warning}`);
13
+ }
14
+ if (!cookies.authToken || !cookies.ct0) {
15
+ console.error(`${ctx.p('err')}Missing required credentials`);
16
+ process.exit(1);
17
+ }
18
+ const client = new TwitterClient({ cookies, timeoutMs });
19
+ let failures = 0;
20
+ for (const input of tweetIdOrUrls) {
21
+ const tweetId = ctx.extractTweetId(input);
22
+ const result = await client.unbookmark(tweetId);
23
+ if (result.success) {
24
+ console.log(`${ctx.p('ok')}Removed bookmark for ${tweetId}`);
25
+ }
26
+ else {
27
+ failures += 1;
28
+ console.error(`${ctx.p('err')}Failed to remove bookmark for ${tweetId}: ${result.error}`);
29
+ }
30
+ }
31
+ if (failures > 0) {
32
+ process.exit(1);
33
+ }
34
+ });
35
+ }
36
+ //# sourceMappingURL=unbookmark.js.map
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliContext } from '../cli/shared.js';
3
+ export declare function registerUserTweetsCommand(program: Command, ctx: CliContext): void;
4
+ //# sourceMappingURL=user-tweets.d.ts.map
@@ -0,0 +1,109 @@
1
+ import { parseNonNegativeIntFlag, parsePositiveIntFlag } from '../cli/pagination.js';
2
+ import { normalizeHandle } from '../lib/normalize-handle.js';
3
+ import { TwitterClient } from '../lib/twitter-client.js';
4
+ export function registerUserTweetsCommand(program, ctx) {
5
+ const formatExample = (cmd, desc) => ` ${ctx.colors.command(cmd)}\n ${ctx.colors.muted(desc)}`;
6
+ program
7
+ .command('user-tweets')
8
+ .description("Get tweets from a user's profile timeline")
9
+ .argument('<handle>', 'Username to fetch tweets from (e.g., @steipete or steipete)')
10
+ .option('-n, --count <number>', 'Number of tweets to fetch', '20')
11
+ .option('--max-pages <number>', 'Stop after N pages (max: 10)')
12
+ .option('--delay <ms>', 'Delay in ms between page fetches', '1000')
13
+ .option('--cursor <string>', 'Resume pagination from a cursor')
14
+ .option('--json', 'Output as JSON')
15
+ .option('--json-full', 'Output as JSON with full raw API response in _raw field')
16
+ .addHelpText('after', () => `\n${ctx.colors.section('Command Examples')}\n${[
17
+ formatExample('bird user-tweets @steipete', 'Get recent tweets from a user'),
18
+ formatExample('bird user-tweets steipete -n 10', 'Get 10 tweets (@ is optional)'),
19
+ formatExample('bird user-tweets @steipete -n 50', 'Fetch 50 tweets (paged)'),
20
+ formatExample('bird user-tweets @steipete --max-pages 3 -n 200', 'Safety cap (max 3 pages)'),
21
+ formatExample('bird user-tweets @steipete --json', 'Output as JSON'),
22
+ formatExample('bird user-tweets @steipete --cursor "DAABCg..."', 'Resume from cursor'),
23
+ ].join('\n')}`)
24
+ .action(async (handle, cmdOpts) => {
25
+ const opts = program.opts();
26
+ const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
27
+ const quoteDepth = ctx.resolveQuoteDepthFromOptions(opts);
28
+ const count = Number.parseInt(cmdOpts.count || '20', 10);
29
+ const maxPagesParsed = parsePositiveIntFlag(cmdOpts.maxPages, '--max-pages');
30
+ if (!maxPagesParsed.ok) {
31
+ console.error(`${ctx.p('err')}${maxPagesParsed.error}`);
32
+ process.exit(2);
33
+ }
34
+ const maxPages = maxPagesParsed.value;
35
+ const delayParsed = parseNonNegativeIntFlag(cmdOpts.delay, '--delay', 1000);
36
+ if (!delayParsed.ok) {
37
+ console.error(`${ctx.p('err')}${delayParsed.error}`);
38
+ process.exit(2);
39
+ }
40
+ const pageDelayMs = delayParsed.value;
41
+ // Validate inputs
42
+ if (!Number.isFinite(count) || count <= 0) {
43
+ console.error(`${ctx.p('err')}Invalid --count. Expected a positive integer.`);
44
+ process.exit(2);
45
+ }
46
+ const pageSize = 20;
47
+ const hardMaxPages = 10;
48
+ const hardMaxTweets = pageSize * hardMaxPages;
49
+ if (count > hardMaxTweets) {
50
+ console.error(`${ctx.p('err')}Invalid --count. Max ${hardMaxTweets} tweets per run (safety cap: ${hardMaxPages} pages). Use --cursor to continue.`);
51
+ process.exit(2);
52
+ }
53
+ if (maxPages !== undefined && maxPages > hardMaxPages) {
54
+ console.error(`${ctx.p('err')}Invalid --max-pages. Expected a positive integer (max: ${hardMaxPages}).`);
55
+ process.exit(2);
56
+ }
57
+ // Normalize handle (strip @ if present)
58
+ const username = normalizeHandle(handle);
59
+ if (!username) {
60
+ console.error(`${ctx.p('err')}Invalid handle: ${handle}`);
61
+ process.exit(2);
62
+ }
63
+ const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
64
+ for (const warning of warnings) {
65
+ console.error(`${ctx.p('warn')}${warning}`);
66
+ }
67
+ if (!cookies.authToken || !cookies.ct0) {
68
+ console.error(`${ctx.p('err')}Missing required credentials`);
69
+ process.exit(1);
70
+ }
71
+ const client = new TwitterClient({ cookies, timeoutMs, quoteDepth });
72
+ // Look up user ID from username
73
+ console.error(`${ctx.p('info')}Looking up @${username}...`);
74
+ const userLookup = await client.getUserIdByUsername(username);
75
+ if (!userLookup.success || !userLookup.userId) {
76
+ console.error(`${ctx.p('err')}${userLookup.error || `Could not find user @${username}`}`);
77
+ process.exit(1);
78
+ }
79
+ const displayName = userLookup.name
80
+ ? `${userLookup.name} (@${userLookup.username})`
81
+ : `@${userLookup.username}`;
82
+ console.error(`${ctx.p('info')}Fetching tweets from ${displayName}...`);
83
+ const includeRaw = cmdOpts.jsonFull ?? false;
84
+ const wantsPaginationOutput = Boolean(cmdOpts.cursor) || maxPages !== undefined || count > pageSize;
85
+ const result = await client.getUserTweetsPaged(userLookup.userId, count, {
86
+ includeRaw,
87
+ maxPages,
88
+ cursor: cmdOpts.cursor,
89
+ pageDelayMs,
90
+ });
91
+ if (result.success) {
92
+ const isJson = Boolean(cmdOpts.json || cmdOpts.jsonFull);
93
+ ctx.printTweetsResult(result, {
94
+ json: isJson,
95
+ usePagination: wantsPaginationOutput,
96
+ emptyMessage: `No tweets found for @${username}.`,
97
+ });
98
+ // Show pagination hint if there's more
99
+ if (result.nextCursor && !cmdOpts.json && !cmdOpts.jsonFull) {
100
+ console.error(`${ctx.p('info')}More tweets available. Use --cursor "${result.nextCursor}" to continue.`);
101
+ }
102
+ }
103
+ else {
104
+ console.error(`${ctx.p('err')}Failed to fetch tweets: ${result.error}`);
105
+ process.exit(1);
106
+ }
107
+ });
108
+ }
109
+ //# sourceMappingURL=user-tweets.js.map
@@ -0,0 +1,4 @@
1
+ import type { Command } from 'commander';
2
+ import type { CliContext } from '../cli/shared.js';
3
+ export declare function registerUserCommands(program: Command, ctx: CliContext): void;
4
+ //# sourceMappingURL=users.d.ts.map