trakt-tools 1.5.2 → 1.6.1

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.
@@ -2,7 +2,7 @@
2
2
  "id": "trakt-tools",
3
3
  "name": "Trakt",
4
4
  "description": "Track movies and TV shows using trakt.tv",
5
- "version": "1.0.0",
5
+ "version": "1.6.1",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "properties": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trakt-tools",
3
- "version": "1.5.2",
3
+ "version": "1.6.1",
4
4
  "description": "OpenClaw plugin for Trakt.tv - track movies and TV shows",
5
5
  "type": "module",
6
6
  "openclaw": {
package/src/index.ts CHANGED
@@ -278,10 +278,17 @@ export default definePluginEntry({
278
278
 
279
279
  try {
280
280
  const args = buildCliArgs(tool.command, tool.subcommand, params, config);
281
+ // 30s was too tight for `progress`, which iterates ~50 API calls
282
+ // (watchlist + watched + N× GetShowProgress) and empirically runs
283
+ // 35-45s for users with substantial watch history. 120s gives
284
+ // generous headroom. maxBuffer bumped to 4MB to fit the full
285
+ // progress --all response (completed + in_progress + not_started).
286
+ // Follow-up: parallelize GetShowProgress loop or add a --filter
287
+ // flag so per-show progress checks don't hammer 50 API calls.
281
288
  const { stdout } = await execFileAsync(cliPath, args, {
282
289
  encoding: 'utf8',
283
- timeout: 30_000,
284
- maxBuffer: 1024 * 1024,
290
+ timeout: 120_000,
291
+ maxBuffer: 4 * 1024 * 1024,
285
292
  });
286
293
 
287
294
  let result: unknown;
@@ -300,6 +307,37 @@ export default definePluginEntry({
300
307
  : '';
301
308
  const errorOutput = stderr ? `${message}\n\nstderr: ${stderr}` : message;
302
309
 
310
+ // Detect rate-limit markers emitted by the Go CLI's RateLimitError
311
+ // (see api/api.go). The CLI formats the error as:
312
+ // rate limited by trakt api: <status> (path=<path> retry_after=<N>)
313
+ // Either stdout or stderr may carry it depending on how the CLI
314
+ // exited. Surface it as a structured response so the agent can
315
+ // back off instead of retrying.
316
+ const rateLimitMatch = errorOutput.match(
317
+ /rate limited by trakt api[^\n]*?retry_after=(\d+)/i
318
+ ) || errorOutput.match(/rate limited by trakt api/i);
319
+ if (rateLimitMatch) {
320
+ const retryAfter = rateLimitMatch[1]
321
+ ? parseInt(rateLimitMatch[1], 10)
322
+ : null;
323
+ return toolResult(
324
+ JSON.stringify(
325
+ {
326
+ success: false,
327
+ rate_limited: true,
328
+ retry_after_seconds: retryAfter,
329
+ error:
330
+ 'Trakt API rate-limited this request' +
331
+ (retryAfter != null ? ` (retry after ~${retryAfter}s)` : '') +
332
+ '. Do NOT retry immediately — wait out the window before calling any trakt_* tool again, and avoid falling back to other trakt tools (they share the same rate limit bucket).',
333
+ raw: errorOutput,
334
+ },
335
+ null,
336
+ 2
337
+ )
338
+ );
339
+ }
340
+
303
341
  return toolResult(
304
342
  JSON.stringify({ success: false, error: errorOutput }, null, 2)
305
343
  );