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.
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +31 -0
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
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
|
);
|