trakt-tools 1.5.2 → 1.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.
@@ -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.0",
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.0",
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
@@ -300,6 +300,37 @@ export default definePluginEntry({
300
300
  : '';
301
301
  const errorOutput = stderr ? `${message}\n\nstderr: ${stderr}` : message;
302
302
 
303
+ // Detect rate-limit markers emitted by the Go CLI's RateLimitError
304
+ // (see api/api.go). The CLI formats the error as:
305
+ // rate limited by trakt api: <status> (path=<path> retry_after=<N>)
306
+ // Either stdout or stderr may carry it depending on how the CLI
307
+ // exited. Surface it as a structured response so the agent can
308
+ // back off instead of retrying.
309
+ const rateLimitMatch = errorOutput.match(
310
+ /rate limited by trakt api[^\n]*?retry_after=(\d+)/i
311
+ ) || errorOutput.match(/rate limited by trakt api/i);
312
+ if (rateLimitMatch) {
313
+ const retryAfter = rateLimitMatch[1]
314
+ ? parseInt(rateLimitMatch[1], 10)
315
+ : null;
316
+ return toolResult(
317
+ JSON.stringify(
318
+ {
319
+ success: false,
320
+ rate_limited: true,
321
+ retry_after_seconds: retryAfter,
322
+ error:
323
+ 'Trakt API rate-limited this request' +
324
+ (retryAfter != null ? ` (retry after ~${retryAfter}s)` : '') +
325
+ '. 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).',
326
+ raw: errorOutput,
327
+ },
328
+ null,
329
+ 2
330
+ )
331
+ );
332
+ }
333
+
303
334
  return toolResult(
304
335
  JSON.stringify({ success: false, error: errorOutput }, null, 2)
305
336
  );