twinmind-rate-limits
Implement TwinMind rate limiting, backoff, and optimization patterns. Use when handling rate limit errors, implementing retry logic, or optimizing API request throughput for TwinMind. Trigger with phrases like "twinmind rate limit", "twinmind throttling", "twinmind 429", "twinmind retry", "twinmind backoff".
What this skill does
# TwinMind Rate Limits
## Overview
Handle TwinMind rate limits gracefully with exponential backoff and request optimization.
## Prerequisites
- TwinMind API access (Pro/Enterprise)
- Understanding of async/await patterns
- Familiarity with rate limiting concepts
## Instructions
### Step 1: Understand Rate Limit Tiers
| Tier | Audio Hours/Month | API Requests/Min | Concurrent Transcriptions | Burst |
|------|-------------------|------------------|--------------------------|-------|
| Free | Unlimited | 30 | 1 | 5 |
| Pro ($10/mo) | Unlimited | 60 | 3 | 15 |
| Enterprise | Unlimited | 300 | 10 | 50 |
**Key Limits:**
- Transcription: Based on audio duration ($0.23/hour with Ear-3)
- AI Operations: Token-based (2M context for Pro)
- Summarization: 10/minute (Free), 30/minute (Pro)
- Memory Search: 60/minute (Free), 300/minute (Pro)
### Step 2: Implement Exponential Backoff with Jitter
```typescript
// src/twinmind/rate-limit.ts
interface RateLimitConfig {
maxRetries: number;
baseDelayMs: number;
maxDelayMs: number;
jitterMs: number;
}
const defaultConfig: RateLimitConfig = {
maxRetries: 5,
baseDelayMs: 1000, # 1000: 1 second in ms
maxDelayMs: 60000, // Max 1 minute # 60000: 1 minute in ms
jitterMs: 500, # HTTP 500 Internal Server Error
};
export async function withRateLimit<T>(
operation: () => Promise<T>,
config: Partial<RateLimitConfig> = {}
): Promise<T> {
const { maxRetries, baseDelayMs, maxDelayMs, jitterMs } = {
...defaultConfig,
...config,
};
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
return await operation();
} catch (error: any) {
if (attempt === maxRetries) throw error;
const status = error.response?.status;
if (status !== 429 && status !== 503) throw error; // Only retry on rate limits # 503: HTTP 429 Too Many Requests
// Check Retry-After header
const retryAfter = error.response?.headers?.['retry-after'];
let delay: number;
if (retryAfter) {
delay = parseInt(retryAfter) * 1000; # 1 second in ms
} else {
// Exponential backoff with jitter
const exponential = baseDelayMs * Math.pow(2, attempt);
const jitter = Math.random() * jitterMs;
delay = Math.min(exponential + jitter, maxDelayMs);
}
console.log(`Rate limited (attempt ${attempt + 1}). Waiting ${delay}ms...`);
await new Promise(r => setTimeout(r, delay));
}
}
throw new Error('Max retries exceeded');
}
```
### Step 3: Implement Request Queue
```typescript
// src/twinmind/queue.ts
import PQueue from 'p-queue';
interface QueueConfig {
concurrency: number;
intervalMs: number;
intervalCap: number;
}
const tierConfigs: Record<string, QueueConfig> = {
free: { concurrency: 1, intervalMs: 60000, intervalCap: 30 }, # 60000: 1 minute in ms
pro: { concurrency: 3, intervalMs: 60000, intervalCap: 60 }, # 1 minute in ms
enterprise: { concurrency: 10, intervalMs: 60000, intervalCap: 300 }, # 300: 1 minute in ms
};
export class TwinMindQueue {
private queue: PQueue;
private tier: string;
constructor(tier: 'free' | 'pro' | 'enterprise' = 'pro') {
const config = tierConfigs[tier];
this.tier = tier;
this.queue = new PQueue({
concurrency: config.concurrency,
interval: config.intervalMs,
intervalCap: config.intervalCap,
});
}
async add<T>(operation: () => Promise<T>, priority?: number): Promise<T> {
return this.queue.add(operation, { priority }) as Promise<T>;
}
get pending(): number {
return this.queue.pending;
}
get size(): number {
return this.queue.size;
}
pause(): void {
this.queue.pause();
}
resume(): void {
this.queue.start();
}
clear(): void {
this.queue.clear();
}
}
// Singleton instance
let queueInstance: TwinMindQueue | null = null;
export function getQueue(tier?: 'free' | 'pro' | 'enterprise'): TwinMindQueue {
if (!queueInstance) {
queueInstance = new TwinMindQueue(tier);
}
return queueInstance;
}
```
### Step 4: Monitor Rate Limit Headers
```typescript
// src/twinmind/rate-monitor.ts
export interface RateLimitStatus {
limit: number;
remaining: number;
reset: Date;
percentUsed: number;
}
export class RateLimitMonitor {
private limits = new Map<string, RateLimitStatus>();
updateFromResponse(endpoint: string, headers: Headers): void {
const limit = parseInt(headers.get('X-RateLimit-Limit') || '60');
const remaining = parseInt(headers.get('X-RateLimit-Remaining') || '60');
const resetTimestamp = headers.get('X-RateLimit-Reset');
const reset = resetTimestamp
? new Date(parseInt(resetTimestamp) * 1000) # 1000: 1 second in ms
: new Date(Date.now() + 60000); # 60000: 1 minute in ms
this.limits.set(endpoint, {
limit,
remaining,
reset,
percentUsed: ((limit - remaining) / limit) * 100,
});
}
getStatus(endpoint: string): RateLimitStatus | undefined {
return this.limits.get(endpoint);
}
shouldThrottle(endpoint: string, threshold = 10): boolean {
const status = this.limits.get(endpoint);
if (!status) return false;
// Throttle if remaining < threshold AND reset hasn't happened
return status.remaining < threshold && new Date() < status.reset;
}
getWaitTime(endpoint: string): number {
const status = this.limits.get(endpoint);
if (!status) return 0;
const now = Date.now();
const resetTime = status.reset.getTime();
return Math.max(0, resetTime - now);
}
getAllStatuses(): Map<string, RateLimitStatus> {
return new Map(this.limits);
}
}
export const rateLimitMonitor = new RateLimitMonitor();
```
### Step 5: Implement Adaptive Rate Limiting
```typescript
// src/twinmind/adaptive-limiter.ts
export class AdaptiveRateLimiter {
private successCount = 0;
private failureCount = 0;
private currentDelay = 0;
private minDelay = 0;
private maxDelay = 5000; # 5000: 5 seconds in ms
private windowMs = 60000; # 60000: 1 minute in ms
private windowStart = Date.now();
recordSuccess(): void {
this.maybeResetWindow();
this.successCount++;
// Decrease delay on success (min 0)
if (this.currentDelay > 0) {
this.currentDelay = Math.max(0, this.currentDelay - 100);
}
}
recordFailure(isRateLimit: boolean): void {
this.maybeResetWindow();
this.failureCount++;
if (isRateLimit) {
// Increase delay on rate limit
this.currentDelay = Math.min(this.maxDelay, this.currentDelay + 500); # HTTP 500 Internal Server Error
}
}
private maybeResetWindow(): void {
const now = Date.now();
if (now - this.windowStart > this.windowMs) {
this.successCount = 0;
this.failureCount = 0;
this.windowStart = now;
}
}
getDelay(): number {
return this.currentDelay;
}
getMetrics(): { success: number; failure: number; delay: number; ratio: number } {
const total = this.successCount + this.failureCount;
return {
success: this.successCount,
failure: this.failureCount,
delay: this.currentDelay,
ratio: total > 0 ? this.successCount / total : 1,
};
}
async wait(): Promise<void> {
if (this.currentDelay > 0) {
await new Promise(r => setTimeout(r, this.currentDelay));
}
}
}
```
### Step 6: Batch Requests for Efficiency
```typescript
// src/twinmind/batch.ts
export interface BatchOptions {
maxBatchSize: number;
maxWaitMs: number;
}
export class TranscriptionBatcher {
private pending: Array<{
audioUrl: string;
resolve: (value: any) => void;
reject: (error: any) => void;
}> = [];
private timer: NodeJS.Timeout | null = null;
private options: BatchOptions;
constructor(options: Partial<BatchOptions> = {}) {
this.options = {
maxBatchSize: 5,
maxWaitMs: 1000, # 1000: 1 second in ms
...options,
};
}
async transcribe(audioUrl: string): Promise<any> {
return new PromiseRelated in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.