@boldare/askdare 0.3.0 → 0.5.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +14 -4
  3. package/dist/cli.js +111 -26
  4. package/dist/define-tool.js +1006 -8
  5. package/dist/embed.d.ts +19 -0
  6. package/dist/embed.js +250 -0
  7. package/dist/{store.d.ts → events.d.ts} +163 -54
  8. package/dist/index.d.ts +28 -2
  9. package/dist/index.js +74 -158
  10. package/dist/next.d.ts +70 -9
  11. package/dist/next.js +767 -169
  12. package/dist/react-marked.js +648 -624
  13. package/dist/react.d.ts +63 -77
  14. package/dist/react.js +148 -1854
  15. package/dist/root.js +2254 -0
  16. package/dist/tool-results.d.ts +140 -0
  17. package/dist/ui/askdare.css +21 -1
  18. package/dist/ui/avatar.tsx +1 -1
  19. package/dist/ui/chat.tsx +1 -1
  20. package/dist/ui/confirm.tsx +1 -1
  21. package/dist/ui/context.ts +1 -1
  22. package/dist/ui/feedback.tsx +1 -1
  23. package/dist/ui/footer.tsx +3 -15
  24. package/dist/ui/header.tsx +1 -1
  25. package/dist/ui/icons.tsx +1 -1
  26. package/dist/ui/index.ts +1 -1
  27. package/dist/ui/message.tsx +6 -4
  28. package/dist/ui/panel.tsx +17 -6
  29. package/dist/ui/welcome.tsx +1 -1
  30. package/docs/accessibility.md +83 -0
  31. package/docs/cli.md +5 -3
  32. package/docs/compliance.md +160 -0
  33. package/docs/configuration.md +58 -2
  34. package/docs/costs.md +8 -1
  35. package/docs/custom-store.md +2 -0
  36. package/docs/embedding.md +104 -0
  37. package/docs/events.md +1 -1
  38. package/docs/feedback.md +1 -1
  39. package/docs/going-public.md +15 -3
  40. package/docs/guardrails.md +128 -0
  41. package/docs/migrating-from-openai-assistant.md +1 -1
  42. package/docs/privacy.md +27 -3
  43. package/docs/protocol.md +15 -1
  44. package/docs/react.md +57 -3
  45. package/docs/styling.md +4 -3
  46. package/docs/support.md +3 -3
  47. package/docs/texts.md +127 -98
  48. package/docs/tools.md +20 -0
  49. package/docs/troubleshooting.md +30 -3
  50. package/llms.txt +14 -11
  51. package/package.json +10 -6
  52. package/skills/askdare/SKILL.md +12 -2
package/docs/texts.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Texts
2
2
 
3
- Every text the chat shows has a key, such as `composer.placeholder`. The library ships each text in English and Polish, and you can replace any of them per bot. The keys are public API ([ADR-0006](https://github.com/boldare/askdare/blob/main/docs/adr/0006-support-matrix-and-versioning.md)), so you can rely on them in your configuration.
3
+ Every text the chat shows has a key, such as `composer.placeholder`. The library ships each text in English, Czech, German, Spanish, French, Italian and Polish, and you can replace any of them per bot. The keys are public API ([ADR-0006](https://github.com/boldare/askdare/blob/main/docs/adr/0006-support-matrix-and-versioning.md)), so you can rely on them in your configuration.
4
4
 
5
5
  The keys cover the chat and the launcher on your page: `launcher.*`, and `header.title`, which also names the chat dialog. A key named after an error code, such as `error.rate_limited`, is the text the widget shows for that code; some errors have a more specific key, such as `error.conversationTooLong`. The server sends these keys with its errors ([Wire protocol](protocol.md#error-keys-and-parameters)).
6
6
 
@@ -24,7 +24,7 @@ defineBot({
24
24
 
25
25
  - **Keys.** Only the keys in the table below are accepted. An unknown key, or a text that is empty or longer than 300 characters, makes `defineBot` throw at startup.
26
26
  - **Shortcuts.** `title`, `greeting`, `placeholder` and `launcherLabel` set `header.title`, `welcome.greeting`, `composer.placeholder` and `launcher.label`. If you set a shortcut and the same key in `texts`, the shortcut wins.
27
- - **Every language.** An override replaces the text in every language. With `locale: 'auto'`, Polish visitors see your override too.
27
+ - **Every language.** An override replaces the text in every language. With `locale: 'auto'`, visitors in every language see your override too. For different texts in each language, use [texts per language](#texts-per-language).
28
28
  - **Placeholders.** Words in braces, such as `{count}`, `{name}`, `{size}` and `{max}`, are filled in by the widget. Keep the ones the default text has. A placeholder the widget doesn't fill for that key is shown as typed.
29
29
  - **Bold.** In `welcome.greeting`, `**words**` are shown in bold.
30
30
 
@@ -37,14 +37,37 @@ A page can still set its own greeting with `askdare('configure', { greeting })`;
37
37
  | Value | Texts |
38
38
  | --- | --- |
39
39
  | `'en'` (default) | English |
40
- | A Polish tag, such as `'pl'` or `'pl-PL'` | Polish |
41
- | Any other BCP 47 tag, such as `'de'` | English, unless you set `texts` |
40
+ | A tag of a built-in language (`cs`, `de`, `es`, `fr`, `it`, `pl`), such as `'de'` or `'pl-PL'` | That language |
41
+ | Any other BCP 47 tag, such as `'nl'` | English, unless you set `texts` |
42
42
  | `'auto'` | The language of the page that embeds the chat (its `lang` attribute), else the visitor's browser language, else English |
43
43
 
44
44
  `defineBot` throws on a value that is neither `'auto'` nor a valid BCP 47 tag. The language part of the tag picks the dictionary, and the full tag picks the plural rules.
45
45
 
46
46
  With `'auto'`, the launcher on your page follows the same order. Your `instructions` function receives the chosen tag as `context.locale`, so you can tell the model which language to answer in.
47
47
 
48
+ ### Texts per language
49
+
50
+ With `locale: 'auto'`, give `widget.texts` one set of overrides per language instead:
51
+
52
+ ```ts
53
+ defineBot({
54
+ // …
55
+ widget: {
56
+ locale: 'auto',
57
+ texts: {
58
+ en: { 'launcher.label': 'Questions?', 'welcome.greeting': 'Hi! How can I help?' },
59
+ pl: { 'launcher.label': 'Pytania?', 'welcome.greeting': 'Cześć! W czym pomóc?' },
60
+ },
61
+ },
62
+ });
63
+ ```
64
+
65
+ - **Which set a visitor gets.** The set for their language tag (`pl-PL`), else one for the same language (`pl`, or another `pl-…` set). A language without a built-in dictionary, such as Dutch, shows English, so it gets the `en` set. A language with a dictionary but no set of yours, such as Polish without `pl`, shows the built-in Polish texts.
66
+ - **The launcher on your page** follows the same sets, by language: a Dutch page shows your `nl` launcher texts, the rest in English.
67
+ - **Shortcuts.** `title`, `greeting`, `placeholder` and `launcherLabel` still apply in every language, but a set that gives the same key wins for its language.
68
+ - **Keys and tags.** The keys are checked as in the flat form. Each language must be a valid BCP 47 tag, once (`pl` and `PL` are the same language), and at most 20 languages are allowed.
69
+ - **One form or the other.** `texts` is either one set for every language or one set per language, not both.
70
+
48
71
  ### Switching the language on the page
49
72
 
50
73
  A site that switches its language without a page load, such as a single-page app with a language menu, can switch the chat too:
@@ -52,7 +75,9 @@ A site that switches its language without a page load, such as a single-page app
52
75
  - **`data-follow-lang`** on the script tag makes the chat follow the page's `<html lang>` whenever it changes.
53
76
  - **`askdare('configure', { locale: 'pl' })`** switches it from your own code. It wins over `data-follow-lang` until the page's `lang` changes again.
54
77
 
55
- The launcher's texts change at once, and the chat reloads in the new language. The visitor keeps their conversation: earlier answers stay in the language they were written in, and new answers and the interface follow the switch. Your `instructions` function gets the new tag as `context.locale` from the next message on. The reload loads the conversation again, which takes about as long as opening the chat. An answer still streaming disappears from view, and the page hears `message.received` with `outcome: 'stopped'` ([Chat events](events.md)); the server still finishes and stores it.
78
+ The launcher's texts change at once, and the chat switches in place, without reloading. The visitor keeps their conversation, their unsent message and an answer still streaming, which finishes as usual. Earlier answers stay in the language they were written in; new answers and the interface follow the switch. Your `instructions` function gets the new tag as `context.locale` from the next message on.
79
+
80
+ If the chat can't load the new texts, or the switch happens before the chat has connected, it reloads in the new language instead and keeps the conversation. An answer still streaming then disappears from view, and the page hears `message.received` with `outcome: 'stopped'` ([Chat events](events.md)); the server still finishes and stores it.
56
81
 
57
82
  Only a bot with `locale: 'auto'` switches. A bot with a fixed locale keeps its language, and the console says once that it ignored the change. The value is a BCP 47 tag; anything else is ignored with a console warning.
58
83
 
@@ -90,7 +115,7 @@ Setting the same language again does nothing.
90
115
 
91
116
  A call with only `locale` keeps the greeting, starters and page context of earlier `configure` calls. Next to `data-follow-lang`, your call wins until the page's `lang` changes again.
92
117
 
93
- **In React.** `Root` starts the chat again when the `locale` of its config changes, and the conversation stays ([React](react.md#good-to-know)). Read the language in a Server Component, for example from a `[lang]` segment:
118
+ **In React.** When only the `locale` of its config changes, `Root` switches the same chat to the new texts, and the conversation, the unsent message and an answer under way stay ([React](react.md#good-to-know)). Read the language in a Server Component, for example from a `[lang]` segment:
94
119
 
95
120
  ```tsx
96
121
  // app/[lang]/help/page.tsx
@@ -151,12 +176,14 @@ Each language uses only some categories:
151
176
 
152
177
  - **English** uses `one` and `other`. Zero is `other` in English, so `message.attachments.zero` has no effect there.
153
178
  - **Polish** uses `one`, `few`, `many` and `other` (fractions): 1 załącznik, 3 załączniki, 5 załączników.
179
+ - **Czech** uses `one`, `few`, `many` (fractions) and `other`: 1 příloha, 3 přílohy, 5 příloh.
180
+ - **French, Spanish and Italian** also have `many`, for very large round numbers. The built-in texts leave it to `other`.
154
181
 
155
- To see the categories of another language, run `new Intl.PluralRules('cs').resolvedOptions().pluralCategories` in a browser console. Override every category the language uses: if you set only `one` and `other` on a Polish bot, `few` and `many` keep their Polish defaults.
182
+ To see the categories of another language, run `new Intl.PluralRules('nl').resolvedOptions().pluralCategories` in a browser console. Override every category the language uses: if you set only `one` and `other` on a Polish bot, `few` and `many` keep their Polish defaults.
156
183
 
157
184
  ## Add a language
158
185
 
159
- The library has dictionaries for English and Polish only, and `widget.texts` has no per-language form. For another language, set a fixed `locale` and translate every key:
186
+ The library has dictionaries for English, Czech, German, Spanish, French, Italian and Polish. For another language, translate every key, either for a bot with a fixed `locale`:
160
187
 
161
188
  ```ts
162
189
  defineBot({
@@ -176,8 +203,8 @@ defineBot({
176
203
 
177
204
  - Keys you leave out show English.
178
205
  - Plurals follow the rules of the tag you set, so translate each category the language uses.
179
- - Keep `locale` fixed. With `'auto'`, your translations would show to every visitor, whatever their language. For a site in several languages without a dictionary, define one bot per language, each with its own `locale` and `texts`.
180
- - The chat document's `lang` attribute is your `locale` as soon as `widget.texts` has any key, so screen readers read your translation in the right language. Without your texts, a language without a built-in dictionary shows English, and `lang` says `en`.
206
+ - With `'auto'`, put the translation in its own set (`texts: { de: { … } }`, see [texts per language](#texts-per-language)). Flat texts would show to every visitor, whatever their language.
207
+ - The chat document's `lang` attribute is the visitor's language when a set of yours exists for it, or your fixed `locale` as soon as flat `widget.texts` has any key, so screen readers read your translation in the right language. Without your texts, a language without a built-in dictionary shows English, and `lang` says `en`.
181
208
 
182
209
  ## All texts
183
210
 
@@ -186,94 +213,96 @@ The table is generated from the library's dictionaries with `pnpm --filter @bold
186
213
  <!-- BEGIN:generated-texts -->
187
214
  <!-- Generated by `pnpm --filter @boldare/askdare docs:texts` from the dictionaries. Do not edit by hand. -->
188
215
 
189
- | Key | English | Polish |
190
- | --- | --- | --- |
191
- | `header.title` | Assistant | Asystent |
192
- | `header.newConversation` | Start a new conversation | Zacznij nową rozmowę |
193
- | `header.close` | Close chat | Zamknij czat |
194
- | `confirm.newConversation` | Start a new conversation? The current one will be deleted. | Zacząć nową rozmowę? Obecna zostanie usunięta. |
195
- | `confirm.cancel` | Cancel | Anuluj |
196
- | `confirm.accept` | Start new | Zacznij nową |
197
- | `welcome.label` | Welcome | Powitanie |
198
- | `welcome.greeting` | Hi! How can I help? | Cześć! W czym mogę pomóc? |
199
- | `welcome.online` | Online | Online |
200
- | `welcome.suggestions` | Suggested questions | Proponowane pytania |
201
- | `composer.placeholder` | Type your message… | Napisz wiadomość… |
202
- | `composer.send` | Send | Wyślij |
203
- | `composer.attach` | Attach files | Dołącz pliki |
204
- | `composer.dictate` | Dictate a message | Podyktuj wiadomość |
205
- | `status.loading` | Loading the conversation… | Wczytuję rozmowę… |
206
- | `status.thinking` | Thinking… | Myślę… |
207
- | `status.searching` | Searching documents… | Przeszukuję dokumenty… |
208
- | `status.tool` | Using {name}… | Korzystam z narzędzia {name}… |
209
- | `status.typing` | The assistant is typing | Asystent pisze |
210
- | `message.sources` | Sources | Źródła |
211
- | `message.replies` | Suggested replies | Proponowane odpowiedzi |
212
- | `feedback.label` | Rate this answer | Oceń tę odpowiedź |
213
- | `feedback.up` | Helpful | Pomocna |
214
- | `feedback.down` | Not helpful | Niepomocna |
215
- | `feedback.comment` | What went wrong? | Co było nie tak? |
216
- | `feedback.send` | Send feedback | Wyślij opinię |
217
- | `feedback.skip` | Skip | Pomiń |
218
- | `message.attachments.zero` | — | — |
219
- | `message.attachments.one` | {count} attachment | {count} załącznik |
220
- | `message.attachments.two` | — | — |
221
- | `message.attachments.few` | — | {count} załączniki |
222
- | `message.attachments.many` | — | {count} załączników |
223
- | `message.attachments.other` | {count} attachments | {count} załącznika |
224
- | `attachment.list` | Attachments | Załączniki |
225
- | `attachment.uploading` | Uploading… | Wysyłam… |
226
- | `attachment.remove` | Remove {name} | Usuń {name} |
227
- | `attachment.unsupported` | This file type is not supported. | Ten typ pliku nie jest obsługiwany. |
228
- | `attachment.tooLarge` | Too large (max {size}). | Za duży (maks. {size}). |
229
- | `attachment.tooMany` | You can attach up to {count} files per message. | Limit plików w jednej wiadomości: {count}. |
230
- | `dictation.listening` | Listening… | Słucham… |
231
- | `dictation.transcribing` | Transcribing… | Przepisuję… |
232
- | `dictation.cancel` | Cancel dictation | Anuluj dyktowanie |
233
- | `dictation.done` | Done | Gotowe |
234
- | `dictation.empty` | Nothing was recorded. Please try again. | Nic się nie nagrało. Spróbuj ponownie. |
235
- | `microphone.blocked` | Microphone access is blocked. Allow it in your browser to dictate. | Dostęp do mikrofonu jest zablokowany. Zezwól na niego w przeglądarce. |
236
- | `microphone.missing` | No microphone was found. | Nie znaleziono mikrofonu. |
237
- | `microphone.failed` | The microphone could not be started. | Nie udało się włączyć mikrofonu. |
238
- | `disclosure.text` | You’re chatting with an AI assistant. It can make mistakes. | Rozmawiasz z asystentem AI. Może popełniać błędy. |
239
- | `disclosure.privacy` | Privacy policy | Polityka prywatności |
240
- | `launcher.label` | Ask us | Zapytaj nas |
241
- | `launcher.open` | Open chat | Otwórz czat |
242
- | `launcher.close` | Close chat | Zamknij czat |
243
- | `launcher.unavailable` | The chat couldn’t load. Please try again later. | Nie udało się załadować czatu. Spróbuj ponownie później. |
244
- | `error.connection` | Connection problem. Please try again. | Problem z połączeniem. Spróbuj ponownie. |
245
- | `error.history` | Could not load the previous conversation. | Nie udało się wczytać poprzedniej rozmowy. |
246
- | `error.updated` | The assistant was updated. Please reload the page. | Asystent został zaktualizowany. Odśwież stronę. |
247
- | `error.stalled` | The connection stalled. Please try again. | Połączenie zostało przerwane. Spróbuj ponownie. |
248
- | `error.uploadFailed` | The file could not be uploaded. | Nie udało się wysłać pliku. |
249
- | `error.transcriptionFailed` | The recording could not be transcribed. | Nie udało się przepisać nagrania. |
250
- | `error.invalid_input` | The request was invalid. | Nieprawidłowe żądanie. |
251
- | `error.unauthorized` | Authentication is required. | Wymagane jest uwierzytelnienie. |
252
- | `error.session_expired` | Your session has expired. Please try again. | Sesja wygasła. Spróbuj ponownie. |
253
- | `error.not_found` | Not found. | Nie znaleziono. |
254
- | `error.content_blocked` | This message cannot be processed. | Nie możemy przetworzyć tej wiadomości. |
255
- | `error.rate_limited` | Too many messages. Please wait a moment. | Zbyt wiele wiadomości. Poczekaj chwilę. |
256
- | `error.budget_exceeded` | The assistant is unavailable for the rest of the day. | Asystent jest niedostępny do końca dnia. |
257
- | `error.internal_error` | Something went wrong. Please try again. | Coś poszło nie tak. Spróbuj ponownie. |
258
- | `error.upstream_error` | The assistant is temporarily unavailable. Please try again. | Asystent jest chwilowo niedostępny. Spróbuj ponownie. |
259
- | `error.bot_unavailable` | The assistant is currently unavailable. | Asystent jest obecnie niedostępny. |
260
- | `error.timeout` | The assistant took too long to respond. Please try again. | Odpowiedź trwała zbyt długo. Spróbuj ponownie. |
261
- | `error.conversationTooLong` | This conversation is too long. Please start a new one. | Ta rozmowa jest zbyt długa. Zacznij nową. |
262
- | `error.conversationGone` | This conversation is no longer available. | Ta rozmowa nie jest już dostępna. |
263
- | `error.messageLength` | Messages can be up to {max} characters. | Wiadomość może mieć maksymalnie {max} znaków. |
264
- | `error.attachmentExpired` | An attachment expired or is invalid. Please attach it again. | Załącznik wygasł lub jest nieprawidłowy. Dołącz go ponownie. |
265
- | `error.filesNotAccepted` | This assistant does not accept files. | Ten asystent nie przyjmuje plików. |
266
- | `error.tooManyFiles` | Attach up to {count} files per message. | Limit plików w jednej wiadomości: {count}. |
267
- | `error.fileType.images` | Only images (PNG, JPEG, WebP, GIF) are supported. | Obsługujemy tylko obrazy (PNG, JPEG, WebP, GIF). |
268
- | `error.fileType.pdf` | Only PDF files are supported. | Obsługujemy tylko pliki PDF. |
269
- | `error.fileType.both` | Only images (PNG, JPEG, WebP, GIF) and PDF files are supported. | Obsługujemy tylko obrazy (PNG, JPEG, WebP, GIF) i pliki PDF. |
270
- | `error.fileTooLarge` | Files can be up to {size}. | Plik może mieć maksymalnie {size}. |
271
- | `error.pdfPages` | PDFs can have up to {max} pages. | PDF może mieć maksymalnie {max} stron. |
272
- | `error.voiceNotAccepted` | This assistant does not accept voice input. | Ten asystent nie przyjmuje nagrań głosowych. |
273
- | `error.recordingFormat` | This recording format is not supported. | Ten format nagrania nie jest obsługiwany. |
274
- | `error.recordingTooLong` | This recording is too long. | To nagranie jest zbyt długie. |
275
- | `error.dictationBusy` | Another dictation is still being transcribed. Please try again in a moment. | Poprzednie nagranie jest jeszcze przepisywane. Spróbuj za chwilę. |
276
- | `error.dictationBudget` | Dictation is unavailable for the rest of the day. You can still type. | Dyktowanie jest niedostępne do końca dnia. Wiadomość możesz nadal wpisać. |
216
+ | Key | English | Czech | German | Spanish | French | Italian | Polish |
217
+ | --- | --- | --- | --- | --- | --- | --- | --- |
218
+ | `header.title` | Assistant | Asistent | Assistent | Asistente | Assistant | Assistente | Asystent |
219
+ | `header.newConversation` | Start a new conversation | Začít novou konverzaci | Neues Gespräch beginnen | Empezar una conversación nueva | Nouvelle conversation | Inizia una nuova conversazione | Zacznij nową rozmowę |
220
+ | `header.close` | Close chat | Zavřít chat | Chat schließen | Cerrar el chat | Fermer le chat | Chiudi la chat | Zamknij czat |
221
+ | `confirm.newConversation` | Start a new conversation? The current one will be deleted. | Začít novou konverzaci? Současná bude smazána. | Neues Gespräch beginnen? Das aktuelle wird gelöscht. | ¿Empezar una conversación nueva? La actual se eliminará. | Commencer une nouvelle conversation ? La conversation actuelle sera supprimée. | Iniziare una nuova conversazione? Quella attuale verrà eliminata. | Zacząć nową rozmowę? Obecna zostanie usunięta. |
222
+ | `confirm.cancel` | Cancel | Zrušit | Abbrechen | Cancelar | Annuler | Annulla | Anuluj |
223
+ | `confirm.accept` | Start new | Začít znovu | Neu beginnen | Empezar de nuevo | Recommencer | Ricomincia | Zacznij nową |
224
+ | `welcome.label` | Welcome | Vítejte | Willkommen | Bienvenida | Bienvenue | Benvenuto | Powitanie |
225
+ | `welcome.greeting` | Hi! How can I help? | Dobrý den! Jak vám mohu pomoci? | Hallo! Wie kann ich helfen? | ¡Hola! ¿En qué puedo ayudarte? | Bonjour ! Comment puis-je vous aider ? | Ciao! Come posso aiutarti? | Cześć! W czym mogę pomóc? |
226
+ | `welcome.online` | Online | Online | Online | En línea | En ligne | Online | Online |
227
+ | `welcome.suggestions` | Suggested questions | Navrhované otázky | Vorgeschlagene Fragen | Preguntas sugeridas | Questions suggérées | Domande suggerite | Proponowane pytania |
228
+ | `composer.placeholder` | Type your message… | Napište zprávu… | Nachricht eingeben… | Escribe tu mensaje… | Écrivez votre message… | Scrivi un messaggio… | Napisz wiadomość… |
229
+ | `composer.send` | Send | Odeslat | Senden | Enviar | Envoyer | Invia | Wyślij |
230
+ | `composer.attach` | Attach files | Přiložit soubory | Dateien anhängen | Adjuntar archivos | Joindre des fichiers | Allega file | Dołącz pliki |
231
+ | `composer.dictate` | Dictate a message | Nadiktovat zprávu | Nachricht diktieren | Dictar un mensaje | Dicter un message | Detta un messaggio | Podyktuj wiadomość |
232
+ | `status.loading` | Loading the conversation… | Načítám konverzaci… | Gespräch wird geladen… | Cargando la conversación… | Chargement de la conversation… | Caricamento della conversazione… | Wczytuję rozmowę… |
233
+ | `status.thinking` | Thinking… | Přemýšlím… | Denke nach… | Pensando… | Réflexion… | Sto pensando… | Myślę… |
234
+ | `status.searching` | Searching documents… | Prohledávám dokumenty… | Durchsuche Dokumente… | Buscando en los documentos… | Recherche dans les documents… | Cerco nei documenti… | Przeszukuję dokumenty… |
235
+ | `status.tool` | Using {name}… | Používám {name}… | Verwende {name}… | Usando {name}… | Utilisation de {name}… | Uso {name}… | Korzystam z narzędzia {name}… |
236
+ | `status.typing` | The assistant is typing | Asistent píše | Der Assistent schreibt | El asistente está escribiendo | L’assistant écrit | L’assistente sta scrivendo | Asystent pisze |
237
+ | `message.sources` | Sources | Zdroje | Quellen | Fuentes | Sources | Fonti | Źródła |
238
+ | `message.replies` | Suggested replies | Navrhované odpovědi | Vorgeschlagene Antworten | Respuestas sugeridas | Réponses suggérées | Risposte suggerite | Proponowane odpowiedzi |
239
+ | `feedback.label` | Rate this answer | Ohodnoťte tuto odpověď | Diese Antwort bewerten | Valora esta respuesta | Évaluer cette réponse | Valuta questa risposta | Oceń tę odpowiedź |
240
+ | `feedback.up` | Helpful | Užitečná | Hilfreich | Útil | Utile | Utile | Pomocna |
241
+ | `feedback.down` | Not helpful | Neužitečná | Nicht hilfreich | No es útil | Pas utile | Non utile | Niepomocna |
242
+ | `feedback.comment` | What went wrong? | Co bylo špatně? | Was war nicht in Ordnung? | ¿Qué salió mal? | Qu’est-ce qui n’allait pas ? | Cosa non andava? | Co było nie tak? |
243
+ | `feedback.send` | Send feedback | Odeslat hodnocení | Feedback senden | Enviar comentario | Envoyer l’avis | Invia feedback | Wyślij opinię |
244
+ | `feedback.skip` | Skip | Přeskočit | Überspringen | Omitir | Passer | Salta | Pomiń |
245
+ | `message.attachments.zero` | — | — | — | — | — | — | — |
246
+ | `message.attachments.one` | {count} attachment | {count} příloha | {count} Anhang | {count} archivo adjunto | {count} pièce jointe | {count} allegato | {count} załącznik |
247
+ | `message.attachments.two` | — | — | — | — | — | — | — |
248
+ | `message.attachments.few` | — | {count} přílohy | — | — | — | — | {count} załączniki |
249
+ | `message.attachments.many` | — | {count} přílohy | — | — | — | — | {count} załączników |
250
+ | `message.attachments.other` | {count} attachments | {count} příloh | {count} Anhänge | {count} archivos adjuntos | {count} pièces jointes | {count} allegati | {count} załącznika |
251
+ | `attachment.list` | Attachments | Přílohy | Anhänge | Archivos adjuntos | Pièces jointes | Allegati | Załączniki |
252
+ | `attachment.uploading` | Uploading… | Nahrávám… | Wird hochgeladen… | Subiendo… | Envoi… | Caricamento… | Wysyłam… |
253
+ | `attachment.remove` | Remove {name} | Odebrat {name} | {name} entfernen | Quitar {name} | Retirer {name} | Rimuovi {name} | Usuń {name} |
254
+ | `attachment.unsupported` | This file type is not supported. | Tento typ souboru není podporován. | Dieser Dateityp wird nicht unterstützt. | Este tipo de archivo no es compatible. | Ce type de fichier n’est pas pris en charge. | Questo tipo di file non è supportato. | Ten typ pliku nie jest obsługiwany. |
255
+ | `attachment.tooLarge` | Too large (max {size}). | Příliš velký (max. {size}). | Zu groß (max. {size}). | Demasiado grande (máx. {size}). | Trop volumineux (max. {size}). | Troppo grande (max {size}). | Za duży (maks. {size}). |
256
+ | `attachment.tooMany` | You can attach up to {count} files per message. | K jedné zprávě můžete přiložit nejvýše {count} souborů. | Du kannst bis zu {count} Dateien pro Nachricht anhängen. | Puedes adjuntar hasta {count} archivos por mensaje. | Vous pouvez joindre jusqu’à {count} fichiers par message. | Puoi allegare fino a {count} file per messaggio. | Limit plików w jednej wiadomości: {count}. |
257
+ | `dictation.listening` | Listening… | Poslouchám… | Ich höre zu… | Escuchando… | Écoute… | In ascolto… | Słucham… |
258
+ | `dictation.transcribing` | Transcribing… | Přepisuji… | Wird transkribiert… | Transcribiendo… | Transcription… | Trascrizione… | Przepisuję… |
259
+ | `dictation.cancel` | Cancel dictation | Zrušit diktování | Diktat abbrechen | Cancelar el dictado | Annuler la dictée | Annulla la dettatura | Anuluj dyktowanie |
260
+ | `dictation.done` | Done | Hotovo | Fertig | Listo | Terminé | Fatto | Gotowe |
261
+ | `dictation.empty` | Nothing was recorded. Please try again. | Nic se nenahrálo. Zkuste to znovu. | Es wurde nichts aufgenommen. Bitte versuche es erneut. | No se grabó nada. Inténtalo de nuevo. | Rien n’a été enregistré. Veuillez réessayer. | Non è stato registrato nulla. Riprova. | Nic się nie nagrało. Spróbuj ponownie. |
262
+ | `microphone.blocked` | Microphone access is blocked. Allow it in your browser to dictate. | Přístup k mikrofonu je zablokovaný. Povolte ho v prohlížeči, abyste mohli diktovat. | Der Zugriff auf das Mikrofon ist blockiert. Erlaube ihn im Browser, um zu diktieren. | El acceso al micrófono está bloqueado. Permítelo en tu navegador para dictar. | L’accès au micro est bloqué. Autorisez-le dans votre navigateur pour dicter. | L’accesso al microfono è bloccato. Consentilo nel browser per poter dettare. | Dostęp do mikrofonu jest zablokowany. Zezwól na niego w przeglądarce. |
263
+ | `microphone.missing` | No microphone was found. | Nebyl nalezen žádný mikrofon. | Kein Mikrofon gefunden. | No se encontró ningún micrófono. | Aucun micro trouvé. | Nessun microfono trovato. | Nie znaleziono mikrofonu. |
264
+ | `microphone.failed` | The microphone could not be started. | Mikrofon se nepodařilo spustit. | Das Mikrofon konnte nicht gestartet werden. | No se pudo iniciar el micrófono. | Le micro n’a pas pu démarrer. | Impossibile avviare il microfono. | Nie udało się włączyć mikrofonu. |
265
+ | `disclosure.text` | You’re chatting with an AI assistant. It can make mistakes. | Píšete si s asistentem s umělou inteligencí. Může dělat chyby. | Du chattest mit einem KI-Assistenten. Er kann Fehler machen. | Estás hablando con un asistente de IA. Puede cometer errores. | Vous discutez avec un assistant IA. Il peut faire des erreurs. | Stai chattando con un assistente IA. Può commettere errori. | Rozmawiasz z asystentem AI. Może popełniać błędy. |
266
+ | `disclosure.privacy` | Privacy policy | Zásady ochrany osobních údajů | Datenschutzerklärung | Política de privacidad | Politique de confidentialité | Informativa sulla privacy | Polityka prywatności |
267
+ | `launcher.label` | Ask us | Zeptejte se nás | Frag uns | Pregúntanos | Une question ? | Chiedi a noi | Zapytaj nas |
268
+ | `launcher.open` | Open chat | Otevřít chat | Chat öffnen | Abrir el chat | Ouvrir le chat | Apri la chat | Otwórz czat |
269
+ | `launcher.close` | Close chat | Zavřít chat | Chat schließen | Cerrar el chat | Fermer le chat | Chiudi la chat | Zamknij czat |
270
+ | `launcher.unavailable` | The chat couldn’t load. Please try again later. | Chat se nepodařilo načíst. Zkuste to prosím později. | Der Chat konnte nicht geladen werden. Bitte versuche es später erneut. | No se pudo cargar el chat. Inténtalo de nuevo más tarde. | Le chat n’a pas pu se charger. Veuillez réessayer plus tard. | Impossibile caricare la chat. Riprova più tardi. | Nie udało się załadować czatu. Spróbuj ponownie później. |
271
+ | `humanCheck.label` | Checking that you’re human | Ověřujeme, že jste člověk | Wir prüfen, ob du ein Mensch bist | Comprobando que eres una persona | Vérification que vous êtes humain | Verifichiamo che tu sia una persona | Sprawdzamy, czy jesteś człowiekiem |
272
+ | `error.humanCheck` | We couldn’t confirm you’re human. Please try again. | Nepodařilo se ověřit, že jste člověk. Zkuste to prosím znovu. | Wir konnten nicht bestätigen, dass du ein Mensch bist. Bitte versuche es erneut. | No pudimos confirmar que eres una persona. Inténtalo de nuevo. | Nous n’avons pas pu confirmer que vous êtes humain. Veuillez réessayer. | Non è stato possibile verificare che tu sia una persona. Riprova. | Nie udało się potwierdzić, że jesteś człowiekiem. Spróbuj ponownie. |
273
+ | `error.connection` | Connection problem. Please try again. | Problém s připojením. Zkuste to znovu. | Verbindungsproblem. Bitte versuche es erneut. | Problema de conexión. Inténtalo de nuevo. | Problème de connexion. Veuillez réessayer. | Problema di connessione. Riprova. | Problem z połączeniem. Spróbuj ponownie. |
274
+ | `error.history` | Could not load the previous conversation. | Předchozí konverzaci se nepodařilo načíst. | Das vorherige Gespräch konnte nicht geladen werden. | No se pudo cargar la conversación anterior. | Impossible de charger la conversation précédente. | Impossibile caricare la conversazione precedente. | Nie udało się wczytać poprzedniej rozmowy. |
275
+ | `error.updated` | The assistant was updated. Please reload the page. | Asistent byl aktualizován. Načtěte stránku znovu. | Der Assistent wurde aktualisiert. Bitte lade die Seite neu. | El asistente se ha actualizado. Recarga la página. | L’assistant a été mis à jour. Veuillez recharger la page. | L’assistente è stato aggiornato. Ricarica la pagina. | Asystent został zaktualizowany. Odśwież stronę. |
276
+ | `error.stalled` | The connection stalled. Please try again. | Připojení se zastavilo. Zkuste to znovu. | Die Verbindung ist ins Stocken geraten. Bitte versuche es erneut. | La conexión se detuvo. Inténtalo de nuevo. | La connexion s’est interrompue. Veuillez réessayer. | La connessione si è interrotta. Riprova. | Połączenie zostało przerwane. Spróbuj ponownie. |
277
+ | `error.uploadFailed` | The file could not be uploaded. | Soubor se nepodařilo nahrát. | Die Datei konnte nicht hochgeladen werden. | No se pudo subir el archivo. | Le fichier n’a pas pu être envoyé. | Impossibile caricare il file. | Nie udało się wysłać pliku. |
278
+ | `error.transcriptionFailed` | The recording could not be transcribed. | Nahrávku se nepodařilo přepsat. | Die Aufnahme konnte nicht transkribiert werden. | No se pudo transcribir la grabación. | L’enregistrement n’a pas pu être transcrit. | Impossibile trascrivere la registrazione. | Nie udało się przepisać nagrania. |
279
+ | `error.invalid_input` | The request was invalid. | Požadavek je neplatný. | Die Anfrage war ungültig. | La solicitud no es válida. | La requête n’est pas valide. | La richiesta non è valida. | Nieprawidłowe żądanie. |
280
+ | `error.unauthorized` | Authentication is required. | Je vyžadováno přihlášení. | Eine Anmeldung ist erforderlich. | Es necesario autenticarse. | Une authentification est requise. | È necessaria l’autenticazione. | Wymagane jest uwierzytelnienie. |
281
+ | `error.session_expired` | Your session has expired. Please try again. | Platnost relace vypršela. Zkuste to znovu. | Deine Sitzung ist abgelaufen. Bitte versuche es erneut. | Tu sesión ha caducado. Inténtalo de nuevo. | Votre session a expiré. Veuillez réessayer. | La sessione è scaduta. Riprova. | Sesja wygasła. Spróbuj ponownie. |
282
+ | `error.not_found` | Not found. | Nenalezeno. | Nicht gefunden. | No encontrado. | Introuvable. | Non trovato. | Nie znaleziono. |
283
+ | `error.content_blocked` | This message cannot be processed. | Tuto zprávu nelze zpracovat. | Diese Nachricht kann nicht verarbeitet werden. | Este mensaje no se puede procesar. | Ce message ne peut pas être traité. | Questo messaggio non può essere elaborato. | Nie możemy przetworzyć tej wiadomości. |
284
+ | `error.rate_limited` | Too many messages. Please wait a moment. | Příliš mnoho zpráv. Chvíli počkejte. | Zu viele Nachrichten. Bitte warte einen Moment. | Demasiados mensajes. Espera un momento. | Trop de messages. Veuillez patienter un instant. | Troppi messaggi. Attendi un momento. | Zbyt wiele wiadomości. Poczekaj chwilę. |
285
+ | `error.budget_exceeded` | The assistant is unavailable for the rest of the day. | Asistent je do konce dne nedostupný. | Der Assistent ist für den Rest des Tages nicht verfügbar. | El asistente no está disponible durante el resto del día. | L’assistant n’est plus disponible pour aujourd’hui. | L’assistente non è disponibile per il resto della giornata. | Asystent jest niedostępny do końca dnia. |
286
+ | `error.internal_error` | Something went wrong. Please try again. | Něco se pokazilo. Zkuste to znovu. | Etwas ist schiefgelaufen. Bitte versuche es erneut. | Algo salió mal. Inténtalo de nuevo. | Une erreur s’est produite. Veuillez réessayer. | Qualcosa è andato storto. Riprova. | Coś poszło nie tak. Spróbuj ponownie. |
287
+ | `error.upstream_error` | The assistant is temporarily unavailable. Please try again. | Asistent je dočasně nedostupný. Zkuste to znovu. | Der Assistent ist vorübergehend nicht verfügbar. Bitte versuche es erneut. | El asistente no está disponible temporalmente. Inténtalo de nuevo. | L’assistant est momentanément indisponible. Veuillez réessayer. | L’assistente è temporaneamente non disponibile. Riprova. | Asystent jest chwilowo niedostępny. Spróbuj ponownie. |
288
+ | `error.bot_unavailable` | The assistant is currently unavailable. | Asistent je momentálně nedostupný. | Der Assistent ist derzeit nicht verfügbar. | El asistente no está disponible en este momento. | L’assistant est actuellement indisponible. | L’assistente al momento non è disponibile. | Asystent jest obecnie niedostępny. |
289
+ | `error.timeout` | The assistant took too long to respond. Please try again. | Odpověď trvala příliš dlouho. Zkuste to znovu. | Der Assistent hat zu lange gebraucht. Bitte versuche es erneut. | El asistente tardó demasiado en responder. Inténtalo de nuevo. | L’assistant a mis trop de temps à répondre. Veuillez réessayer. | L’assistente ha impiegato troppo tempo a rispondere. Riprova. | Odpowiedź trwała zbyt długo. Spróbuj ponownie. |
290
+ | `error.conversationTooLong` | This conversation is too long. Please start a new one. | Tato konverzace je příliš dlouhá. Začněte novou. | Dieses Gespräch ist zu lang. Bitte beginne ein neues. | Esta conversación es demasiado larga. Empieza una nueva. | Cette conversation est trop longue. Veuillez en commencer une nouvelle. | Questa conversazione è troppo lunga. Iniziane una nuova. | Ta rozmowa jest zbyt długa. Zacznij nową. |
291
+ | `error.conversationGone` | This conversation is no longer available. | Tato konverzace už není k dispozici. | Dieses Gespräch ist nicht mehr verfügbar. | Esta conversación ya no está disponible. | Cette conversation n’est plus disponible. | Questa conversazione non è più disponibile. | Ta rozmowa nie jest już dostępna. |
292
+ | `error.messageLength` | Messages can be up to {max} characters. | Zpráva může mít nejvýše {max} znaků. | Nachrichten dürfen höchstens {max} Zeichen lang sein. | Los mensajes pueden tener hasta {max} caracteres. | Les messages peuvent contenir jusqu’à {max} caractères. | I messaggi possono contenere fino a {max} caratteri. | Wiadomość może mieć maksymalnie {max} znaków. |
293
+ | `error.attachmentExpired` | An attachment expired or is invalid. Please attach it again. | Platnost přílohy vypršela nebo je neplatná. Přiložte ji znovu. | Ein Anhang ist abgelaufen oder ungültig. Bitte hänge ihn erneut an. | Un archivo adjunto caducó o no es válido. Vuelve a adjuntarlo. | Une pièce jointe a expiré ou n’est pas valide. Veuillez la joindre à nouveau. | Un allegato è scaduto o non è valido. Allegalo di nuovo. | Załącznik wygasł lub jest nieprawidłowy. Dołącz go ponownie. |
294
+ | `error.filesNotAccepted` | This assistant does not accept files. | Tento asistent nepřijímá soubory. | Dieser Assistent nimmt keine Dateien an. | Este asistente no acepta archivos. | Cet assistant n’accepte pas de fichiers. | Questo assistente non accetta file. | Ten asystent nie przyjmuje plików. |
295
+ | `error.tooManyFiles` | Attach up to {count} files per message. | K jedné zprávě přiložte nejvýše {count} souborů. | Hänge bis zu {count} Dateien pro Nachricht an. | Adjunta hasta {count} archivos por mensaje. | Joignez jusqu’à {count} fichiers par message. | Allega fino a {count} file per messaggio. | Limit plików w jednej wiadomości: {count}. |
296
+ | `error.fileType.images` | Only images (PNG, JPEG, WebP, GIF) are supported. | Podporovány jsou jen obrázky (PNG, JPEG, WebP, GIF). | Nur Bilder (PNG, JPEG, WebP, GIF) werden unterstützt. | Solo se admiten imágenes (PNG, JPEG, WebP, GIF). | Seules les images (PNG, JPEG, WebP, GIF) sont prises en charge. | Sono supportate solo immagini (PNG, JPEG, WebP, GIF). | Obsługujemy tylko obrazy (PNG, JPEG, WebP, GIF). |
297
+ | `error.fileType.pdf` | Only PDF files are supported. | Podporovány jsou jen soubory PDF. | Nur PDF-Dateien werden unterstützt. | Solo se admiten archivos PDF. | Seuls les fichiers PDF sont pris en charge. | Sono supportati solo file PDF. | Obsługujemy tylko pliki PDF. |
298
+ | `error.fileType.both` | Only images (PNG, JPEG, WebP, GIF) and PDF files are supported. | Podporovány jsou jen obrázky (PNG, JPEG, WebP, GIF) a soubory PDF. | Nur Bilder (PNG, JPEG, WebP, GIF) und PDF-Dateien werden unterstützt. | Solo se admiten imágenes (PNG, JPEG, WebP, GIF) y archivos PDF. | Seules les images (PNG, JPEG, WebP, GIF) et les fichiers PDF sont pris en charge. | Sono supportati solo immagini (PNG, JPEG, WebP, GIF) e file PDF. | Obsługujemy tylko obrazy (PNG, JPEG, WebP, GIF) i pliki PDF. |
299
+ | `error.fileTooLarge` | Files can be up to {size}. | Soubor může mít nejvýše {size}. | Dateien dürfen höchstens {size} groß sein. | Los archivos pueden ocupar hasta {size}. | Les fichiers peuvent faire jusqu’à {size}. | I file possono pesare fino a {size}. | Plik może mieć maksymalnie {size}. |
300
+ | `error.pdfPages` | PDFs can have up to {max} pages. | PDF může mít nejvýše {max} stran. | PDFs dürfen höchstens {max} Seiten haben. | Los PDF pueden tener hasta {max} páginas. | Les PDF peuvent compter jusqu’à {max} pages. | I PDF possono avere fino a {max} pagine. | PDF może mieć maksymalnie {max} stron. |
301
+ | `error.voiceNotAccepted` | This assistant does not accept voice input. | Tento asistent nepřijímá hlasový vstup. | Dieser Assistent nimmt keine Spracheingabe an. | Este asistente no acepta entrada de voz. | Cet assistant n’accepte pas la saisie vocale. | Questo assistente non accetta input vocali. | Ten asystent nie przyjmuje nagrań głosowych. |
302
+ | `error.recordingFormat` | This recording format is not supported. | Tento formát nahrávky není podporován. | Dieses Aufnahmeformat wird nicht unterstützt. | Este formato de grabación no es compatible. | Ce format d’enregistrement n’est pas pris en charge. | Questo formato di registrazione non è supportato. | Ten format nagrania nie jest obsługiwany. |
303
+ | `error.recordingTooLong` | This recording is too long. | Tato nahrávka je příliš dlouhá. | Diese Aufnahme ist zu lang. | Esta grabación es demasiado larga. | Cet enregistrement est trop long. | Questa registrazione è troppo lunga. | To nagranie jest zbyt długie. |
304
+ | `error.dictationBusy` | Another dictation is still being transcribed. Please try again in a moment. | Jiné diktování se ještě přepisuje. Zkuste to za chvíli. | Ein anderes Diktat wird noch transkribiert. Bitte versuche es gleich noch einmal. | Todavía se está transcribiendo otro dictado. Inténtalo en un momento. | Une autre dictée est en cours de transcription. Réessayez dans un instant. | Un’altra dettatura è ancora in trascrizione. Riprova tra un momento. | Poprzednie nagranie jest jeszcze przepisywane. Spróbuj za chwilę. |
305
+ | `error.dictationBudget` | Dictation is unavailable for the rest of the day. You can still type. | Diktování je do konce dne nedostupné. Psát můžete i nadále. | Diktieren ist für den Rest des Tages nicht verfügbar. Du kannst weiterhin tippen. | El dictado no está disponible durante el resto del día. Puedes seguir escribiendo. | La dictée n’est plus disponible pour aujourd’hui. Vous pouvez toujours écrire. | La dettatura non è disponibile per il resto della giornata. Puoi comunque scrivere. | Dyktowanie jest niedostępne do końca dnia. Wiadomość możesz nadal wpisać. |
277
306
 
278
307
  A dash (—) means the language has no text of its own for that plural category, so the widget shows the `other` text.
279
308
  <!-- END:generated-texts -->
package/docs/tools.md CHANGED
@@ -63,6 +63,26 @@ export const orderStatus = defineTool({
63
63
 
64
64
  [Reply options](reply-options.md) has more flows, options in several languages, and when to let the model suggest options instead.
65
65
 
66
+ ## Cards for the visitor
67
+
68
+ A tool can also pick what the visitor may see of its result, for a card, a list or a table that your own React component draws under the answer ([ADR-0017](https://github.com/boldare/askdare/blob/main/docs/adr/0017-tool-renderers.md)):
69
+
70
+ ```ts
71
+ export const findSlots = defineTool({
72
+ name: 'find_slots',
73
+ description: 'Free consultation slots on a day.',
74
+ input: z.object({ day: z.string() }),
75
+ execute: async ({ day }) => calendar.freeSlots(day),
76
+ ui: (result) => ({ day: result.day, slots: result.slots.map((slot) => slot.start) }),
77
+ });
78
+ ```
79
+
80
+ - **Only what `ui` returns reaches the browser,** never the result itself. Pick the fields a visitor may see: no internal IDs, costs or notes, nothing about other customers. The visitor can read the payload in their browser even where no component shows it.
81
+ - **Keep `ui` pure.** It gets the result as the model received it, parsed back from JSON (a `Date` is a string by then), and runs again on every reload to bring the card back. The same result must give the same payload; a reload after a deploy shows what your current `ui` returns.
82
+ - **Limits.** Return plain JSON of at most 8 KB and 8 levels of arrays and objects, or `undefined` or `null` for no card. A payload over a limit is dropped whole and the tool's name is logged. An answer shows at most 4, in call order. A call that failed, timed out or returned too much data shows none. If `ui` throws, the answer comes without that card and the error is logged.
83
+ - **The model still sees the whole result** and writes about it as usual. If the card should speak for itself, say so in the tool's description or the bot's instructions.
84
+ - **Drawing the card** is your React component, registered with `Root`'s `toolRenderers` in the chat inside your page ([Tool cards](react.md#tool-cards)). The payload's type comes from `ui`, and the tool's name stays a literal, so a page types its components from the tool with `import type`. In the script-tag widget, a bot draws them when its iframe shows your own page (`embedPath`, [Embedding](embedding.md#your-own-page-in-the-iframe)); askdare's own iframe page has no components to draw them with.
85
+
66
86
  ## Rules
67
87
 
68
88
  - **Every field is required.** OpenAI's strict mode demands it: use `.nullable()` instead of `.optional()`. `defineTool` fails at startup otherwise.
@@ -23,10 +23,10 @@ The codes are stable. The texts are the English defaults; the widget shows them
23
23
  | Code | HTTP | The chat says | See |
24
24
  | --- | --- | --- | --- |
25
25
  | `invalid_input` | 400 | "The request was invalid.", or a specific text such as "Messages can be up to {max} characters." | [Attachments are rejected](#attachments-are-rejected) |
26
- | `unauthorized` | 401 | "Authentication is required." | [Session expired](#session-expired) |
26
+ | `unauthorized` | 401 | "Authentication is required.", or "We couldn’t confirm you’re human. Please try again." | [Session expired](#session-expired), [The human check fails](#the-human-check-fails) |
27
27
  | `session_expired` | 401 | "Your session has expired. Please try again." | [Session expired](#session-expired) |
28
28
  | `not_found` | 404 | "Not found.", or "This conversation is no longer available." | [The conversation is gone](#the-conversation-is-gone) |
29
- | `content_blocked` | 422 | "This message cannot be processed." | askdare doesn't send this code in this version |
29
+ | `content_blocked` | 422 | "This message cannot be processed.", or your own text | [Guardrails](guardrails.md): moderation or a hook blocked the message or the answer |
30
30
  | `rate_limited` | 429 | "Too many messages. Please wait a moment.", or a specific text | [Too many messages](#too-many-messages) |
31
31
  | `budget_exceeded` | 429 | "The assistant is unavailable for the rest of the day." | [Unavailable for the rest of the day](#unavailable-for-the-rest-of-the-day) |
32
32
  | `internal_error` | 500 | "Something went wrong. Please try again." | The server log; also [In-memory rate limits](#in-memory-rate-limits) |
@@ -94,6 +94,19 @@ The same check reports every invalid setting as `Invalid bot "<id>": <setting> <
94
94
 
95
95
  Problems with `CHAT_SECRET` and `IDENTITY_SECRET` are also `bot_unavailable`: they stop the chat from opening a session. In development the chat shows the reason; the table in the next entry lists them.
96
96
 
97
+ ## A model is shutting down
98
+
99
+ **You see** a warning from `npx @boldare/askdare doctor`:
100
+
101
+ ```text
102
+ ! Model <model> is scheduled to shut down on 2026-12-11.
103
+ → Change model in defineBot to the replacement OpenAI recommends: https://developers.openai.com/api/docs/deprecations
104
+ ```
105
+
106
+ **Why:** OpenAI has announced a shutdown date for the bot's model, or for the transcription model of a bot with `voice` (then the fix names `voice.model`). The model still works, so this is a warning and `doctor` still exits with `0`. The date comes from the OpenAI API; askdare keeps no list of models. After that date the model stops working and the chat answers with [The assistant is unavailable](#the-assistant-is-unavailable).
107
+
108
+ **Fix:** look up the model on OpenAI's [deprecations page](https://developers.openai.com/api/docs/deprecations), which names its recommended replacement. Set the new model (for example in `ASKDARE_MODEL`, or `voice.model` in `defineBot`), test the bot, and redeploy before the date. Run `doctor` against each deployed app, since every environment may use a different model.
109
+
97
110
  ## Connection problem
98
111
 
99
112
  **You see** "Connection problem. Please try again." when sending a message, or "Could not load the previous conversation." when the chat opens.
@@ -161,9 +174,11 @@ If the console says "Load the widget as widget.js?bot=<bot id>.", the script tag
161
174
  Every limit is in [Configuration](configuration.md#limits). Some are fixed: 12 session renewals per returning visitor per hour, 20 history loads or deletions per visitor per minute, and 2 dictations per IP and 10 per bot being transcribed at once. Windows start with the first request, so a limit of one hour lasts one hour from then.
162
175
 
163
176
  Two limits have their own text:
164
- - "This conversation is too long. Please start a new one." means the conversation reached `maxTurns`.
177
+ - "This conversation is too long. Please start a new one." means the conversation reached `maxTurns`, or outgrew the model's context window (OpenAI answered `context_length_exceeded`).
165
178
  - "Another dictation is still being transcribed. Please try again in a moment." means too many dictations are being transcribed at once.
166
179
 
180
+ For a bot that checks answers (`onOutput`, or `moderation` of output), a conversation takes one turn at a time: a message sent while the previous answer is still being written or checked, such as from a second tab, gets `rate_limited` ([Guardrails](guardrails.md#streaming-while-answers-are-checked)).
181
+
167
182
  **Fix:**
168
183
  - Wait for the window to pass, or restart `next dev`: the default counters live in the server's memory.
169
184
  - Raise the limits in development only:
@@ -229,6 +244,18 @@ When a whole bot's budget or the global one runs out, the server log says so onc
229
244
 
230
245
  **Fix:** use the same `CHAT_SECRET` on every instance. When you change it, move the old value to `CHAT_SECRET_PREVIOUS` first ([Going public](going-public.md#2-secrets-and-environment)). Then reload the page.
231
246
 
247
+ ## The human check fails
248
+
249
+ Only for a bot with `security.humanVerifier` ([Configuration](configuration.md#human-check)).
250
+
251
+ **You see** "We couldn’t confirm you’re human. Please try again." (`unauthorized`), the check never appears, or every session is refused with `upstream_error` or `bot_unavailable`.
252
+
253
+ **Why and fix:**
254
+ - **The token failed**, expired or was used before: the visitor gets a new challenge with the next message. A token solved for another bot or another widget on the same site key is refused too, since its `action` differs.
255
+ - **The widget doesn't load:** a chat inside your page needs `https://challenges.cloudflare.com` in `script-src` and `frame-src` of your page's Content Security Policy. The widget's iframe adds it by itself ([Embedding](embedding.md#what-your-app-sends-back)). Check also that your domain is in the widget's hostname list in the Cloudflare dashboard.
256
+ - **Every session is refused:** `TURNSTILE_SECRET_KEY` is missing or wrong, or Cloudflare can't be reached. The check fails closed, and `onError` (or the server log) says which.
257
+ - **With `hostnames`:** an app behind a proxy that serves it under another name fails every check. Add that name, or leave `hostnames` out.
258
+
232
259
  ## The conversation is gone
233
260
 
234
261
  **You see** "This conversation is no longer available." (`not_found`), or "Could not load the previous conversation." when the chat opens.
package/llms.txt CHANGED
@@ -2,33 +2,36 @@
2
2
 
3
3
  > `@boldare/askdare` adds an AI chatbot to any website. A Next.js 16 app (App Router, Node.js runtime) serves the chat from one catch-all route; other sites embed it with one `<script>` tag. Built on the official `openai` SDK (Responses and Conversations APIs); no database.
4
4
 
5
- Set it up with `npx @boldare/askdare init` and verify it with `npx @boldare/askdare doctor`. The public API is `defineBot`, `defineTool` and `defineTheme` from `@boldare/askdare`; `createChatHandler` (with `onError`, `onUsage` and `onFeedback`) and `getChatConfig` from `@boldare/askdare/next`; `Root`, `DefaultChat`, the hooks and the primitives from `@boldare/askdare/react`; the CLI commands (`init`, `doctor`, `kb sync`, `add ui`); `upstashStore` from `@boldare/askdare-upstash` and `otelUsage` from `@boldare/askdare-otel`; the `data-*` attributes of the script tag, `askdare(…)` on the page, the `--ask-*` CSS tokens, the `data-ask-part` names and the text keys. Everything else is internal.
5
+ Set it up with `npx @boldare/askdare init` and verify it with `npx @boldare/askdare doctor`. The public API is `defineBot` (which returns a `BotHandle`), `defineTool`, `defineTheme`, `turnstile` and `ERROR_CODES` from `@boldare/askdare`; `createChatHandler` (with `onError`, `onUsage` and `onFeedback`) and `getChatConfig` from `@boldare/askdare/next`; `Root`, `DefaultChat`, the hooks and the primitives (including `Disclosure` and `HumanCheck`) from `@boldare/askdare/react`; the CLI commands (`init`, `doctor`, `kb sync`, `add ui`); `upstashStore` from `@boldare/askdare-upstash` and `otelUsage` from `@boldare/askdare-otel`; the `data-*` attributes of the script tag, `askdare(…)` on the page, the `--ask-*` CSS tokens, the `data-ask-part` names and the text keys. Everything else is internal.
6
6
 
7
7
  ## Docs
8
8
 
9
9
  - [Getting started](docs/getting-started.md): install, `init`, `.env.local`, `doctor`, embedding on other sites
10
- - [Configuration](docs/configuration.md): every `defineBot` and `createChatHandler` option, limits with defaults, environment variables
11
- - [Embedding](docs/embedding.md): the script tag and its `data-*` attributes, several bots, the host page's CSP, staging and production
12
- - [CLI](docs/cli.md): `init`, `doctor`, `kb sync`, `add ui` and `usage`, with every flag
13
- - [Troubleshooting](docs/troubleshooting.md): symptoms, causes and fixes, by error code
14
- - [Tools](docs/tools.md): `defineTool`, Zod schemas, what a tool may trust
10
+ - [Configuration](docs/configuration.md): every `defineBot` and `createChatHandler` option, limits with defaults, the human check (`security.humanVerifier: turnstile({ siteKey })`, `TURNSTILE_SECRET_KEY`), `limits.requireSharedStore`, environment variables
11
+ - [Embedding](docs/embedding.md): the script tag and its `data-*` attributes, several bots, the host page's CSP, your own page in the widget's iframe (`embedPath`, `EmbedRoot`, `embedPageHeaders`), staging and production
12
+ - [CLI](docs/cli.md): `init`, `doctor` (including model shutdown dates and bots with the AI notice off), `kb sync`, `add ui` and `usage`, with every flag
13
+ - [Troubleshooting](docs/troubleshooting.md): symptoms, causes and fixes, by error code (`ERROR_CODES`)
14
+ - [Tools](docs/tools.md): `defineTool`, Zod schemas, what a tool may trust, and `ui`: what the visitor sees of a result as a card
15
15
  - [Reply options](docs/reply-options.md): clickable answers under the latest reply, suggested by the model (`widget.replies: 'suggest'`) or defined by a tool (`defineTool({ replies })`), limits, placement, cost
16
16
  - [Signed-in visitors](docs/identity.md): `askdare('identify')`, IDENTITY_SECRET, `context.identity`
17
17
  - [Knowledge base](docs/knowledge-base.md): `npx @boldare/askdare kb sync`, vector stores, citations
18
18
  - [Attachments](docs/attachments.md): images and PDFs from visitors
19
19
  - [Voice input](docs/voice-input.md): dictation and its limits
20
- - [Styling](docs/styling.md): texts, languages, AI disclosure, custom CSS, `askdare('open' | 'configure')`, inline mode
21
- - [React](docs/react.md): the chat inside a page of your own app with `@boldare/askdare/react`: `getChatConfig`, `Root`, `DefaultChat`, hooks and primitives, CSS resets, CSP, `add ui`
22
- - [Texts](docs/texts.md): every text key with its English and Polish default, plurals, adding a language, switching the chat's language on the page (`askdare('configure', { locale })`, `data-follow-lang`)
20
+ - [Styling](docs/styling.md): texts, languages, AI disclosure, custom CSS and the `data-ask-part` names, `askdare('open' | 'configure')`, inline mode
21
+ - [React](docs/react.md): the chat inside a page of your own app with `@boldare/askdare/react`: `getChatConfig`, `Root`, `DefaultChat`, hooks and primitives, tool cards (`toolRenderers`, `ToolResults`, `Link`), the AI notice in your own markup (`Disclosure`), the human check (`HumanCheck`), CSS resets, CSP, `add ui`
22
+ - [Texts](docs/texts.md): every text key with its default in each built-in language (en, cs, de, es, fr, it, pl), plurals, adding a language, switching the chat's language on the page (`askdare('configure', { locale })`, `data-follow-lang`)
23
23
  - [Themes](docs/themes.md): Halo, Aura, Sage and Care, tokens and variants
24
24
  - [Deployment](docs/deployment.md): Vercel, Heroku, proxies, shared limits
25
25
  - [Going public](docs/going-public.md): OpenAI project, secrets, limits, privacy checklist
26
+ - [Guardrails](docs/guardrails.md): opt-in OpenAI moderation (`moderation`), your own `onInput` and `onOutput` rules to allow, block or redact, answers held back while they are checked, `toolResults: 'untrusted'`
26
27
  - [Costs](docs/costs.md): the worst case under the default limits, and how to keep it bounded
27
28
  - [Observability](docs/observability.md): `onUsage` and `onError`, cost per turn, OpenTelemetry spans with `@boldare/askdare-otel`
28
29
  - [Chat events](docs/events.md): what the chat reports to the page, for analytics
29
30
  - [Answer ratings](docs/feedback.md): 👍/👎 with an optional comment, `onFeedback`, what the report holds
30
- - [Privacy](docs/privacy.md): what is stored where, for your privacy policy
31
- - [Support](docs/support.md): Node.js, Next.js, React, zod and TypeScript versions, browsers, sizes
31
+ - [Privacy](docs/privacy.md): what is stored where and sent to whom (OpenAI, its moderation endpoint, Cloudflare for the human check), for your privacy policy
32
+ - [Compliance](docs/compliance.md): AI Act disclosure (`widget.disclosure`, the `Disclosure` primitive), GDPR (DPA, retention, deletion), data residency, the resume token in inline mode, hosts other than Vercel and Heroku, no Edge runtime
33
+ - [Accessibility](docs/accessibility.md): the WCAG 2.2 AA conformance statement: scope, how it is tested, finished answers announced to screen readers, focus kept in a full-screen chat, known limitations
34
+ - [Support](docs/support.md): Node.js (22, 24 and 26), Next.js, React, zod and TypeScript versions, browsers, sizes
32
35
  - [Migrating from @boldare/openai-assistant](docs/migrating-from-openai-assistant.md): what maps to what
33
36
 
34
37
  ## Optional
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boldare/askdare",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Embeddable AI chatbot for Next.js, as a script-tag widget or React components, built on the official OpenAI SDK.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -49,6 +49,10 @@
49
49
  "types": "./dist/react.d.ts",
50
50
  "default": "./dist/react.js"
51
51
  },
52
+ "./embed": {
53
+ "types": "./dist/embed.d.ts",
54
+ "default": "./dist/embed.js"
55
+ },
52
56
  "./package.json": "./package.json"
53
57
  },
54
58
  "types": "./dist/index.d.ts",
@@ -75,14 +79,14 @@
75
79
  "@types/react": "^19.3.0",
76
80
  "@types/react-dom": "^19.3.0",
77
81
  "happy-dom": "^21.0.4",
78
- "marked": "18.1.3",
79
- "next": "^16.4.5",
82
+ "marked": "18.2.0",
83
+ "next": "^16.4.6",
80
84
  "preact": "11.2.0",
81
85
  "publint": "^0.3.25",
82
86
  "react": "^19.3.1",
83
87
  "react-dom": "^19.3.1",
84
88
  "tsdown": "^0.23.7",
85
- "vite": "^8.3.6",
89
+ "vite": "^8.3.8",
86
90
  "zod": "^4.6.7"
87
91
  },
88
92
  "peerDependencies": {
@@ -99,8 +103,8 @@
99
103
  }
100
104
  },
101
105
  "dependencies": {
102
- "jose": "^6.2.15",
103
- "openai": "^7.52.0"
106
+ "jose": "^6.2.17",
107
+ "openai": "^7.56.0"
104
108
  },
105
109
  "scripts": {
106
110
  "build:assets": "vite build -c vite.widget.config.ts && vite build -c vite.skin.config.ts && vite build -c vite.loader.config.ts && node scripts/inline-assets.mjs",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: askdare
3
- description: Add, configure or troubleshoot the @boldare/askdare AI chat in a Next.js app (defineBot, defineTool, createChatHandler, the widget script, the React chat inside a page, themes, knowledge base, reply options, the chat's language, answer ratings, usage reports, deployment). Use when the project depends on @boldare/askdare or the user asks for a website chatbot built on it.
3
+ description: Add, configure or troubleshoot the @boldare/askdare AI chat in a Next.js app (defineBot, defineTool, createChatHandler, the widget script, the React chat inside a page, tool cards, your own page in the widget's iframe, themes, knowledge base, reply options, the chat's language, answer ratings, usage reports, guardrails and moderation, the Turnstile human check, the AI notice, accessibility, deployment). Use when the project depends on @boldare/askdare or the user asks for a website chatbot built on it.
4
4
  ---
5
5
 
6
6
  # askdare
@@ -17,11 +17,17 @@ description: Add, configure or troubleshoot the @boldare/askdare AI chat in a Ne
17
17
 
18
18
  ## Public API: use only this
19
19
 
20
- - `defineBot`, `defineTool`, `defineTheme` from `@boldare/askdare`; `createChatHandler` from `@boldare/askdare/next`, with its `onError`, `onUsage` and `onFeedback` options; `otelUsage()` from `@boldare/askdare-otel`.
20
+ - `defineBot`, `defineTool`, `defineTheme`, `turnstile` and `ERROR_CODES` from `@boldare/askdare`; `defineBot` returns a `BotHandle` (only `id` and `embedPath`): pass it to `createChatHandler`, `getChatConfig` and `getEmbedConfig`, and type it as `BotHandle` (or `BotDefinition` for the input), never as `Bot`; `createChatHandler` from `@boldare/askdare/next`, with its `onError`, `onUsage` and `onFeedback` options; `otelUsage()` from `@boldare/askdare-otel`.
21
21
  - On pages: `<script src="…/api/chat/widget.js?bot=<id>" async>` with `data-launcher="none"` or `data-mode="inline" data-target="…"`, and `askdare('open' | 'close' | 'toggle' | 'configure', …)`.
22
22
  - The chat's language on the page, for a bot with `locale: 'auto'`: `askdare('configure', { locale: 'pl' })`, or `data-follow-lang` on the script tag to follow `<html lang>`. The chat reloads in the new language and keeps the conversation; your `instructions` get it as `context.locale`. See `docs/texts.md`.
23
23
  - Reply options (clickable answers under the latest reply): `widget.replies: 'suggest'` lets the model suggest them; `defineTool({ replies: (result) => [...] })` derives them from a tool's result. See `docs/reply-options.md`.
24
24
  - The chat inside a page of the same Next.js app (React 19): `getChatConfig` from `@boldare/askdare/next` in a Server Component, then `Root`, `DefaultChat`, the hooks (`useChat`, `useChatState`, `useMessage`) and the primitives from `@boldare/askdare/react` (see `docs/react.md`). To change the default components, run `npx @boldare/askdare add ui`; don't copy them from `node_modules` by hand.
25
+ - Tool cards: `defineTool({ ui: (result) => data })` picks what the visitor may see of a result (plain JSON, at most 8 KB; only that reaches the browser), and `Root`'s `toolRenderers={{ tool_name: Component }}` draws it, typed with `Chat.ToolRendererProps<typeof tool>` and `import type`. Render `data` as text and URLs through `Chat.Link`. See `docs/react.md#tool-cards`.
26
+ - Your own page in the widget's iframe: `defineBot({ embedPath: '/askdare/support' })`; the page lives in its own route group and root layout, renders `<EmbedRoot config={getEmbedConfig({ bots, bot, searchParams })}>` from `@boldare/askdare/embed` with `DefaultChat` inside, and gets `embedPageHeaders({ bots, bot })` from `proxy.ts` (not `next.config.ts` headers, which are fixed at build). Check with `askdare doctor --origin <site>`. See `docs/embedding.md#your-own-page-in-the-iframe`.
27
+ - Guardrails, all opt-in in `defineBot` (see `docs/guardrails.md`): `moderation: { model, check?, categories?, message? }` runs OpenAI moderation on messages (`check: 'input'`, the default), answers (`'output'`) or both; `onInput(text, context)` and `onOutput(text, context)` return `{ action: 'allow' }`, `{ action: 'block', message? }` or `{ action: 'redact', text }`; `toolResults: 'untrusted'` marks tool results as third-party data. While answers are checked, they arrive whole at the end of the turn, and a conversation takes one turn at a time.
28
+ - Human check (see `docs/configuration.md#human-check`): `security: { humanVerifier: turnstile({ siteKey }) }`, with `TURNSTILE_SECRET_KEY` in the environment. A chat inside your page must allow `https://challenges.cloudflare.com` in its CSP, and a headless chat renders the `HumanCheck` primitive. `createChatHandler({ limits: { requireSharedStore: true } })` refuses to load without a shared store.
29
+ - The AI notice: on by default (`widget.disclosure`). In your own markup, or your own page in the iframe, render the `Disclosure` primitive; in development the console notes a chat without one.
30
+ - Built-in texts in en, cs, de, es, fr, it and pl; `widget.texts` overrides them per language (see `docs/texts.md`).
25
31
  - Styling: `widget.texts`, `widget.theme`, `widget.css` with `[data-ask-part="…"]` selectors and `--ask-*` tokens (see `docs/styling.md`).
26
32
 
27
33
  Never import from `@boldare/askdare/dist/…` or other internal paths.
@@ -37,7 +43,11 @@ Never import from `@boldare/askdare/dist/…` or other internal paths.
37
43
  - With `@boldare/askdare/react`: never render `message.text` as HTML (use `MessageText` or `Markdown`); sign a visitor out with `identity={null}`, since `undefined` keeps the current one; a page that passes `identity` must not be cached; on pages with third-party scripts, prefer the script-tag widget.
38
44
  - Tools: every Zod field is required (use `.nullable()`, not `.optional()`). Never take user IDs, emails or permissions from tool arguments; use the verified `context` (`visitorId`, `botId`, `locale`, `identity`, `signal`). Keep tools read-only.
39
45
  - Signed-in users: the site's backend signs an HS256 JWT with `IDENTITY_SECRET` (`sub`, `aud` = bot ID, `iat`, `exp`), and the page calls `askdare('identify', token)` (`null` on sign-out). See `docs/identity.md`.
46
+ - Tool cards: `ui` must be pure (it runs again on every reload) and must return only fields a visitor may see; never render its `data` as HTML, and load images only from URLs the tool builds itself.
40
47
  - Reply options: at most 4, up to 80 characters each, plain text without links; anything else is dropped. A click only sends the option's text as the visitor's message, so write options the way a visitor would say them ("Cancel the order"), never as commands or IDs, and never treat a clicked option as more trusted than typed text.
41
48
  - More than one server instance (Vercel, several dynos) needs shared limits: `@boldare/askdare-upstash`.
42
49
  - Answer ratings (👍/👎) show only with `createChatHandler({ onFeedback })`; `widget.feedback: false` hides them for one bot. askdare stores no ratings: save the report in `onFeedback`. A rating's `comment` is visitor text: escape it wherever it is shown, and cover it in the privacy notice. See `docs/feedback.md`.
50
+ - Guardrail hooks must not throw to block: a hook that throws lets the text through (fail open) and logs one line. Moderation and hooks don't check attached files; keep `attachments` off where that matters. Never log the text a hook receives.
51
+ - Accessibility: keep `Messages` and its `announcement` part, and don't add your own live region for answers; screen readers hear each finished answer once (see `docs/accessibility.md`).
52
+ - Compliance and privacy: `docs/compliance.md` and `docs/privacy.md`. Name Cloudflare in the privacy notice when the human check is on, and OpenAI's moderation when `moderation` is.
43
53
  - Costs and tracing: `onUsage` (or `onUsage: otelUsage()` from `@boldare/askdare-otel`). Its reports hold pseudonyms and counts, never message text; don't add any. See `docs/observability.md`.