Docs / CrateProvider

CrateProvider

Sets labels and locale for every crate wait state, so all text can be replaced or translated.

Install

npx shadcn@latest add https://crate.onerollstudios.com/r/crate-provider.json

Import

import { CrateProvider } from "@/components/agent-wait-states/crate-provider";

Props

PropTypeRequiredDefaultNotes
labelsPartial<CrateLabels>noAny labels to replace. Missing ones fall back to English.
localestringnoBCP 47 locale for numbers, times, and plurals, e.g. "fr" or "ar-EG". Inherited when omitted.
childrenReactNodeyes

Labels

Every label key, with its English default. Labels with a number are functions that receive the value and a locale formatter (f.number, f.seconds, f.plural).

LabelEnglish default
thinking"Thinking…"
stillThinking"Still thinking…"
cancel"Cancel"
responseStreaming"Response streaming"
toolActivity"Agent tool activity"
runningTool(toolName) => `Running ${toolName}…`
runningToolUnnamed"Running a tool…"
usedTool(toolName) => `Used ${toolName}`
usedToolUnnamed"Used a tool"
stalled"Still working…"
error"Something went wrong."
retry"Retry"
done"Done"
showThinking"Show thinking"
thoughtFor(seconds, f) => `Thought for ${f.seconds(seconds)}`
thoughtDone"Done thinking"
reasoningPlaceholder"Working through the details…"
sources"Sources"
sourceFallback"source"
sourceTitle"Source"
moreSources(count, f) => `+${f.number(count)} more`
plan"Plan"
planProgress(current, total, f) => `${f.number(current)} of ${f.number(total)}`
approvalRequired"Approval required"
approvalTitle"The agent wants to send this email"
approvalPreview"Review this action before it runs."
expiresIn(seconds, f) => `Expires in ${f.seconds(seconds)}`
deny"Deny"
allow"Allow"
queuePosition(position, f) => `You’re #${f.number(position)} in line`
queueWaiting"Waiting in line…"
rateLimited(seconds, f) => `Slow down. Try again in ${f.seconds(seconds)}`
rateLimitedUnknown"Slow down. Try again shortly."
fileUploading"Upload"
fileReading"Reading"
fileChunking"Chunking"
fileReady"Ready"
fileProgress(percent, f) => `${f.number(percent)}%`

Types

export type CrateFormat = {
  locale: string;
  /** 1234 -> "1,234" (en) or "1 234" (fr). */
  number: (value: number) => string;
  /** 30 -> "30s" in en. Other locales use their own short unit format. */
  seconds: (value: number) => string;
  /** Picks a form by Intl plural rules, e.g. plural(n, { one: "source", other: "sources" }). */
  plural: (value: number, forms: Partial<Record<Intl.LDMLPluralRule, string>> & { other: string }) => string;
};

export type CrateLabels = {
  thinking: string;
  stillThinking: string;
  cancel: string;
  responseStreaming: string;
  toolActivity: string;
  runningTool: (toolName: string) => string;
  runningToolUnnamed: string;
  usedTool: (toolName: string) => string;
  usedToolUnnamed: string;
  stalled: string;
  error: string;
  retry: string;
  done: string;
  showThinking: string;
  thoughtFor: (seconds: number, format: CrateFormat) => string;
  thoughtDone: string;
  reasoningPlaceholder: string;
  sources: string;
  sourceFallback: string;
  sourceTitle: string;
  moreSources: (count: number, format: CrateFormat) => string;
  plan: string;
  planProgress: (current: number, total: number, format: CrateFormat) => string;
  approvalRequired: string;
  approvalTitle: string;
  approvalPreview: string;
  expiresIn: (seconds: number, format: CrateFormat) => string;
  deny: string;
  allow: string;
  queuePosition: (position: number, format: CrateFormat) => string;
  queueWaiting: string;
  rateLimited: (seconds: number, format: CrateFormat) => string;
  rateLimitedUnknown: string;
  fileUploading: string;
  fileReading: string;
  fileChunking: string;
  fileReady: string;
  fileProgress: (percent: number, format: CrateFormat) => string;
};

Example

"use client";

import { CrateProvider, type CrateLabels } from "@/components/agent-wait-states";

const fr: Partial<CrateLabels> = {
  thinking: "Réflexion…",
  stillThinking: "Toujours en réflexion…",
  cancel: "Annuler",
  done: "Terminé",
  retry: "Réessayer",
  error: "Une erreur est survenue.",
  showThinking: "Afficher le raisonnement",
  thoughtFor: (seconds, f) => `Réflexion pendant ${f.seconds(seconds)}`,
  moreSources: (count, f) => `+${f.number(count)} ${f.plural(count, { one: "autre", other: "autres" })}`,
  planProgress: (current, total, f) => `${f.number(current)} sur ${f.number(total)}`,
  expiresIn: (seconds, f) => `Expire dans ${f.seconds(seconds)}`,
  deny: "Refuser",
  allow: "Autoriser",
  queuePosition: (position, f) => `Vous êtes n° ${f.number(position)} dans la file`,
};

<CrateProvider locale="fr" labels={fr}>
  <AgentState status={status} />
</CrateProvider>

For coding agents: /llms/crate-provider.md, generated from the same source.