@boldare/askdare 0.4.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 (48) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +14 -4
  3. package/dist/cli.js +19 -6
  4. package/dist/define-tool.js +677 -7
  5. package/dist/embed.d.ts +1 -1
  6. package/dist/embed.js +2 -1
  7. package/dist/{store.d.ts → events.d.ts} +127 -52
  8. package/dist/index.d.ts +28 -2
  9. package/dist/index.js +82 -1
  10. package/dist/next.d.ts +22 -11
  11. package/dist/next.js +537 -139
  12. package/dist/react.d.ts +24 -4
  13. package/dist/react.js +126 -18
  14. package/dist/root.js +169 -37
  15. package/dist/tool-results.d.ts +11 -1
  16. package/dist/ui/askdare.css +9 -1
  17. package/dist/ui/avatar.tsx +1 -1
  18. package/dist/ui/chat.tsx +1 -1
  19. package/dist/ui/confirm.tsx +1 -1
  20. package/dist/ui/context.ts +1 -1
  21. package/dist/ui/feedback.tsx +1 -1
  22. package/dist/ui/footer.tsx +3 -15
  23. package/dist/ui/header.tsx +1 -1
  24. package/dist/ui/icons.tsx +1 -1
  25. package/dist/ui/index.ts +1 -1
  26. package/dist/ui/message.tsx +1 -1
  27. package/dist/ui/panel.tsx +3 -1
  28. package/dist/ui/welcome.tsx +1 -1
  29. package/docs/accessibility.md +83 -0
  30. package/docs/cli.md +4 -3
  31. package/docs/compliance.md +160 -0
  32. package/docs/configuration.md +47 -2
  33. package/docs/costs.md +8 -1
  34. package/docs/custom-store.md +2 -0
  35. package/docs/embedding.md +2 -0
  36. package/docs/feedback.md +1 -1
  37. package/docs/going-public.md +15 -3
  38. package/docs/guardrails.md +128 -0
  39. package/docs/migrating-from-openai-assistant.md +1 -1
  40. package/docs/privacy.md +26 -2
  41. package/docs/react.md +7 -1
  42. package/docs/styling.md +2 -2
  43. package/docs/support.md +3 -3
  44. package/docs/texts.md +100 -96
  45. package/docs/troubleshooting.md +30 -3
  46. package/llms.txt +12 -9
  47. package/package.json +1 -1
  48. package/skills/askdare/SKILL.md +9 -2
@@ -20,6 +20,454 @@ function isEmbedPath(value) {
20
20
  function isInside(path, basePath) {
21
21
  return path === basePath || path.startsWith(`${basePath}/`);
22
22
  }
23
+ // src/i18n/locales/cs.ts
24
+ /**
25
+ * Czech. Formal "vy", as Czech interfaces usually address users; plurals use `one`, `few`,
26
+ * `many` (fractions) and `other`. Override any text with `widget.texts`.
27
+ */
28
+ const CS = {
29
+ "header.title": "Asistent",
30
+ "header.newConversation": "Začít novou konverzaci",
31
+ "header.close": "Zavřít chat",
32
+ "confirm.newConversation": "Začít novou konverzaci? Současná bude smazána.",
33
+ "confirm.cancel": "Zrušit",
34
+ "confirm.accept": "Začít znovu",
35
+ "welcome.label": "Vítejte",
36
+ "welcome.greeting": "Dobrý den! Jak vám mohu pomoci?",
37
+ "welcome.online": "Online",
38
+ "welcome.suggestions": "Navrhované otázky",
39
+ "composer.placeholder": "Napište zprávu…",
40
+ "composer.send": "Odeslat",
41
+ "composer.attach": "Přiložit soubory",
42
+ "composer.dictate": "Nadiktovat zprávu",
43
+ "status.loading": "Načítám konverzaci…",
44
+ "status.thinking": "Přemýšlím…",
45
+ "status.searching": "Prohledávám dokumenty…",
46
+ "status.tool": "Používám {name}…",
47
+ "status.typing": "Asistent píše",
48
+ "message.sources": "Zdroje",
49
+ "message.replies": "Navrhované odpovědi",
50
+ "feedback.label": "Ohodnoťte tuto odpověď",
51
+ "feedback.up": "Užitečná",
52
+ "feedback.down": "Neužitečná",
53
+ "feedback.comment": "Co bylo špatně?",
54
+ "feedback.send": "Odeslat hodnocení",
55
+ "feedback.skip": "Přeskočit",
56
+ "message.attachments.one": "{count} příloha",
57
+ "message.attachments.few": "{count} přílohy",
58
+ "message.attachments.many": "{count} přílohy",
59
+ "message.attachments.other": "{count} příloh",
60
+ "attachment.list": "Přílohy",
61
+ "attachment.uploading": "Nahrávám…",
62
+ "attachment.remove": "Odebrat {name}",
63
+ "attachment.unsupported": "Tento typ souboru není podporován.",
64
+ "attachment.tooLarge": "Příliš velký (max. {size}).",
65
+ "attachment.tooMany": "K jedné zprávě můžete přiložit nejvýše {count} souborů.",
66
+ "dictation.listening": "Poslouchám…",
67
+ "dictation.transcribing": "Přepisuji…",
68
+ "dictation.cancel": "Zrušit diktování",
69
+ "dictation.done": "Hotovo",
70
+ "dictation.empty": "Nic se nenahrálo. Zkuste to znovu.",
71
+ "microphone.blocked": "Přístup k mikrofonu je zablokovaný. Povolte ho v prohlížeči, abyste mohli diktovat.",
72
+ "microphone.missing": "Nebyl nalezen žádný mikrofon.",
73
+ "microphone.failed": "Mikrofon se nepodařilo spustit.",
74
+ "disclosure.text": "Píšete si s asistentem s umělou inteligencí. Může dělat chyby.",
75
+ "disclosure.privacy": "Zásady ochrany osobních údajů",
76
+ "launcher.label": "Zeptejte se nás",
77
+ "launcher.open": "Otevřít chat",
78
+ "launcher.close": "Zavřít chat",
79
+ "launcher.unavailable": "Chat se nepodařilo načíst. Zkuste to prosím později.",
80
+ "humanCheck.label": "Ověřujeme, že jste člověk",
81
+ "error.humanCheck": "Nepodařilo se ověřit, že jste člověk. Zkuste to prosím znovu.",
82
+ "error.connection": "Problém s připojením. Zkuste to znovu.",
83
+ "error.history": "Předchozí konverzaci se nepodařilo načíst.",
84
+ "error.updated": "Asistent byl aktualizován. Načtěte stránku znovu.",
85
+ "error.stalled": "Připojení se zastavilo. Zkuste to znovu.",
86
+ "error.uploadFailed": "Soubor se nepodařilo nahrát.",
87
+ "error.transcriptionFailed": "Nahrávku se nepodařilo přepsat.",
88
+ "error.invalid_input": "Požadavek je neplatný.",
89
+ "error.unauthorized": "Je vyžadováno přihlášení.",
90
+ "error.session_expired": "Platnost relace vypršela. Zkuste to znovu.",
91
+ "error.not_found": "Nenalezeno.",
92
+ "error.content_blocked": "Tuto zprávu nelze zpracovat.",
93
+ "error.rate_limited": "Příliš mnoho zpráv. Chvíli počkejte.",
94
+ "error.budget_exceeded": "Asistent je do konce dne nedostupný.",
95
+ "error.internal_error": "Něco se pokazilo. Zkuste to znovu.",
96
+ "error.upstream_error": "Asistent je dočasně nedostupný. Zkuste to znovu.",
97
+ "error.bot_unavailable": "Asistent je momentálně nedostupný.",
98
+ "error.timeout": "Odpověď trvala příliš dlouho. Zkuste to znovu.",
99
+ "error.conversationTooLong": "Tato konverzace je příliš dlouhá. Začněte novou.",
100
+ "error.conversationGone": "Tato konverzace už není k dispozici.",
101
+ "error.messageLength": "Zpráva může mít nejvýše {max} znaků.",
102
+ "error.attachmentExpired": "Platnost přílohy vypršela nebo je neplatná. Přiložte ji znovu.",
103
+ "error.filesNotAccepted": "Tento asistent nepřijímá soubory.",
104
+ "error.tooManyFiles": "K jedné zprávě přiložte nejvýše {count} souborů.",
105
+ "error.fileType.images": "Podporovány jsou jen obrázky (PNG, JPEG, WebP, GIF).",
106
+ "error.fileType.pdf": "Podporovány jsou jen soubory PDF.",
107
+ "error.fileType.both": "Podporovány jsou jen obrázky (PNG, JPEG, WebP, GIF) a soubory PDF.",
108
+ "error.fileTooLarge": "Soubor může mít nejvýše {size}.",
109
+ "error.pdfPages": "PDF může mít nejvýše {max} stran.",
110
+ "error.voiceNotAccepted": "Tento asistent nepřijímá hlasový vstup.",
111
+ "error.recordingFormat": "Tento formát nahrávky není podporován.",
112
+ "error.recordingTooLong": "Tato nahrávka je příliš dlouhá.",
113
+ "error.dictationBusy": "Jiné diktování se ještě přepisuje. Zkuste to za chvíli.",
114
+ "error.dictationBudget": "Diktování je do konce dne nedostupné. Psát můžete i nadále."
115
+ };
116
+ // src/i18n/locales/de.ts
117
+ /** German. Informal "du", as most chat interfaces use; override any text with `widget.texts`. */
118
+ const DE = {
119
+ "header.title": "Assistent",
120
+ "header.newConversation": "Neues Gespräch beginnen",
121
+ "header.close": "Chat schließen",
122
+ "confirm.newConversation": "Neues Gespräch beginnen? Das aktuelle wird gelöscht.",
123
+ "confirm.cancel": "Abbrechen",
124
+ "confirm.accept": "Neu beginnen",
125
+ "welcome.label": "Willkommen",
126
+ "welcome.greeting": "Hallo! Wie kann ich helfen?",
127
+ "welcome.online": "Online",
128
+ "welcome.suggestions": "Vorgeschlagene Fragen",
129
+ "composer.placeholder": "Nachricht eingeben…",
130
+ "composer.send": "Senden",
131
+ "composer.attach": "Dateien anhängen",
132
+ "composer.dictate": "Nachricht diktieren",
133
+ "status.loading": "Gespräch wird geladen…",
134
+ "status.thinking": "Denke nach…",
135
+ "status.searching": "Durchsuche Dokumente…",
136
+ "status.tool": "Verwende {name}…",
137
+ "status.typing": "Der Assistent schreibt",
138
+ "message.sources": "Quellen",
139
+ "message.replies": "Vorgeschlagene Antworten",
140
+ "feedback.label": "Diese Antwort bewerten",
141
+ "feedback.up": "Hilfreich",
142
+ "feedback.down": "Nicht hilfreich",
143
+ "feedback.comment": "Was war nicht in Ordnung?",
144
+ "feedback.send": "Feedback senden",
145
+ "feedback.skip": "Überspringen",
146
+ "message.attachments.one": "{count} Anhang",
147
+ "message.attachments.other": "{count} Anhänge",
148
+ "attachment.list": "Anhänge",
149
+ "attachment.uploading": "Wird hochgeladen…",
150
+ "attachment.remove": "{name} entfernen",
151
+ "attachment.unsupported": "Dieser Dateityp wird nicht unterstützt.",
152
+ "attachment.tooLarge": "Zu groß (max. {size}).",
153
+ "attachment.tooMany": "Du kannst bis zu {count} Dateien pro Nachricht anhängen.",
154
+ "dictation.listening": "Ich höre zu…",
155
+ "dictation.transcribing": "Wird transkribiert…",
156
+ "dictation.cancel": "Diktat abbrechen",
157
+ "dictation.done": "Fertig",
158
+ "dictation.empty": "Es wurde nichts aufgenommen. Bitte versuche es erneut.",
159
+ "microphone.blocked": "Der Zugriff auf das Mikrofon ist blockiert. Erlaube ihn im Browser, um zu diktieren.",
160
+ "microphone.missing": "Kein Mikrofon gefunden.",
161
+ "microphone.failed": "Das Mikrofon konnte nicht gestartet werden.",
162
+ "disclosure.text": "Du chattest mit einem KI-Assistenten. Er kann Fehler machen.",
163
+ "disclosure.privacy": "Datenschutzerklärung",
164
+ "launcher.label": "Frag uns",
165
+ "launcher.open": "Chat öffnen",
166
+ "launcher.close": "Chat schließen",
167
+ "launcher.unavailable": "Der Chat konnte nicht geladen werden. Bitte versuche es später erneut.",
168
+ "humanCheck.label": "Wir prüfen, ob du ein Mensch bist",
169
+ "error.humanCheck": "Wir konnten nicht bestätigen, dass du ein Mensch bist. Bitte versuche es erneut.",
170
+ "error.connection": "Verbindungsproblem. Bitte versuche es erneut.",
171
+ "error.history": "Das vorherige Gespräch konnte nicht geladen werden.",
172
+ "error.updated": "Der Assistent wurde aktualisiert. Bitte lade die Seite neu.",
173
+ "error.stalled": "Die Verbindung ist ins Stocken geraten. Bitte versuche es erneut.",
174
+ "error.uploadFailed": "Die Datei konnte nicht hochgeladen werden.",
175
+ "error.transcriptionFailed": "Die Aufnahme konnte nicht transkribiert werden.",
176
+ "error.invalid_input": "Die Anfrage war ungültig.",
177
+ "error.unauthorized": "Eine Anmeldung ist erforderlich.",
178
+ "error.session_expired": "Deine Sitzung ist abgelaufen. Bitte versuche es erneut.",
179
+ "error.not_found": "Nicht gefunden.",
180
+ "error.content_blocked": "Diese Nachricht kann nicht verarbeitet werden.",
181
+ "error.rate_limited": "Zu viele Nachrichten. Bitte warte einen Moment.",
182
+ "error.budget_exceeded": "Der Assistent ist für den Rest des Tages nicht verfügbar.",
183
+ "error.internal_error": "Etwas ist schiefgelaufen. Bitte versuche es erneut.",
184
+ "error.upstream_error": "Der Assistent ist vorübergehend nicht verfügbar. Bitte versuche es erneut.",
185
+ "error.bot_unavailable": "Der Assistent ist derzeit nicht verfügbar.",
186
+ "error.timeout": "Der Assistent hat zu lange gebraucht. Bitte versuche es erneut.",
187
+ "error.conversationTooLong": "Dieses Gespräch ist zu lang. Bitte beginne ein neues.",
188
+ "error.conversationGone": "Dieses Gespräch ist nicht mehr verfügbar.",
189
+ "error.messageLength": "Nachrichten dürfen höchstens {max} Zeichen lang sein.",
190
+ "error.attachmentExpired": "Ein Anhang ist abgelaufen oder ungültig. Bitte hänge ihn erneut an.",
191
+ "error.filesNotAccepted": "Dieser Assistent nimmt keine Dateien an.",
192
+ "error.tooManyFiles": "Hänge bis zu {count} Dateien pro Nachricht an.",
193
+ "error.fileType.images": "Nur Bilder (PNG, JPEG, WebP, GIF) werden unterstützt.",
194
+ "error.fileType.pdf": "Nur PDF-Dateien werden unterstützt.",
195
+ "error.fileType.both": "Nur Bilder (PNG, JPEG, WebP, GIF) und PDF-Dateien werden unterstützt.",
196
+ "error.fileTooLarge": "Dateien dürfen höchstens {size} groß sein.",
197
+ "error.pdfPages": "PDFs dürfen höchstens {max} Seiten haben.",
198
+ "error.voiceNotAccepted": "Dieser Assistent nimmt keine Spracheingabe an.",
199
+ "error.recordingFormat": "Dieses Aufnahmeformat wird nicht unterstützt.",
200
+ "error.recordingTooLong": "Diese Aufnahme ist zu lang.",
201
+ "error.dictationBusy": "Ein anderes Diktat wird noch transkribiert. Bitte versuche es gleich noch einmal.",
202
+ "error.dictationBudget": "Diktieren ist für den Rest des Tages nicht verfügbar. Du kannst weiterhin tippen."
203
+ };
204
+ // src/i18n/locales/es.ts
205
+ /** Spanish. Informal "tú", neutral across regions; override any text with `widget.texts`. */
206
+ const ES = {
207
+ "header.title": "Asistente",
208
+ "header.newConversation": "Empezar una conversación nueva",
209
+ "header.close": "Cerrar el chat",
210
+ "confirm.newConversation": "¿Empezar una conversación nueva? La actual se eliminará.",
211
+ "confirm.cancel": "Cancelar",
212
+ "confirm.accept": "Empezar de nuevo",
213
+ "welcome.label": "Bienvenida",
214
+ "welcome.greeting": "¡Hola! ¿En qué puedo ayudarte?",
215
+ "welcome.online": "En línea",
216
+ "welcome.suggestions": "Preguntas sugeridas",
217
+ "composer.placeholder": "Escribe tu mensaje…",
218
+ "composer.send": "Enviar",
219
+ "composer.attach": "Adjuntar archivos",
220
+ "composer.dictate": "Dictar un mensaje",
221
+ "status.loading": "Cargando la conversación…",
222
+ "status.thinking": "Pensando…",
223
+ "status.searching": "Buscando en los documentos…",
224
+ "status.tool": "Usando {name}…",
225
+ "status.typing": "El asistente está escribiendo",
226
+ "message.sources": "Fuentes",
227
+ "message.replies": "Respuestas sugeridas",
228
+ "feedback.label": "Valora esta respuesta",
229
+ "feedback.up": "Útil",
230
+ "feedback.down": "No es útil",
231
+ "feedback.comment": "¿Qué salió mal?",
232
+ "feedback.send": "Enviar comentario",
233
+ "feedback.skip": "Omitir",
234
+ "message.attachments.one": "{count} archivo adjunto",
235
+ "message.attachments.other": "{count} archivos adjuntos",
236
+ "attachment.list": "Archivos adjuntos",
237
+ "attachment.uploading": "Subiendo…",
238
+ "attachment.remove": "Quitar {name}",
239
+ "attachment.unsupported": "Este tipo de archivo no es compatible.",
240
+ "attachment.tooLarge": "Demasiado grande (máx. {size}).",
241
+ "attachment.tooMany": "Puedes adjuntar hasta {count} archivos por mensaje.",
242
+ "dictation.listening": "Escuchando…",
243
+ "dictation.transcribing": "Transcribiendo…",
244
+ "dictation.cancel": "Cancelar el dictado",
245
+ "dictation.done": "Listo",
246
+ "dictation.empty": "No se grabó nada. Inténtalo de nuevo.",
247
+ "microphone.blocked": "El acceso al micrófono está bloqueado. Permítelo en tu navegador para dictar.",
248
+ "microphone.missing": "No se encontró ningún micrófono.",
249
+ "microphone.failed": "No se pudo iniciar el micrófono.",
250
+ "disclosure.text": "Estás hablando con un asistente de IA. Puede cometer errores.",
251
+ "disclosure.privacy": "Política de privacidad",
252
+ "launcher.label": "Pregúntanos",
253
+ "launcher.open": "Abrir el chat",
254
+ "launcher.close": "Cerrar el chat",
255
+ "launcher.unavailable": "No se pudo cargar el chat. Inténtalo de nuevo más tarde.",
256
+ "humanCheck.label": "Comprobando que eres una persona",
257
+ "error.humanCheck": "No pudimos confirmar que eres una persona. Inténtalo de nuevo.",
258
+ "error.connection": "Problema de conexión. Inténtalo de nuevo.",
259
+ "error.history": "No se pudo cargar la conversación anterior.",
260
+ "error.updated": "El asistente se ha actualizado. Recarga la página.",
261
+ "error.stalled": "La conexión se detuvo. Inténtalo de nuevo.",
262
+ "error.uploadFailed": "No se pudo subir el archivo.",
263
+ "error.transcriptionFailed": "No se pudo transcribir la grabación.",
264
+ "error.invalid_input": "La solicitud no es válida.",
265
+ "error.unauthorized": "Es necesario autenticarse.",
266
+ "error.session_expired": "Tu sesión ha caducado. Inténtalo de nuevo.",
267
+ "error.not_found": "No encontrado.",
268
+ "error.content_blocked": "Este mensaje no se puede procesar.",
269
+ "error.rate_limited": "Demasiados mensajes. Espera un momento.",
270
+ "error.budget_exceeded": "El asistente no está disponible durante el resto del día.",
271
+ "error.internal_error": "Algo salió mal. Inténtalo de nuevo.",
272
+ "error.upstream_error": "El asistente no está disponible temporalmente. Inténtalo de nuevo.",
273
+ "error.bot_unavailable": "El asistente no está disponible en este momento.",
274
+ "error.timeout": "El asistente tardó demasiado en responder. Inténtalo de nuevo.",
275
+ "error.conversationTooLong": "Esta conversación es demasiado larga. Empieza una nueva.",
276
+ "error.conversationGone": "Esta conversación ya no está disponible.",
277
+ "error.messageLength": "Los mensajes pueden tener hasta {max} caracteres.",
278
+ "error.attachmentExpired": "Un archivo adjunto caducó o no es válido. Vuelve a adjuntarlo.",
279
+ "error.filesNotAccepted": "Este asistente no acepta archivos.",
280
+ "error.tooManyFiles": "Adjunta hasta {count} archivos por mensaje.",
281
+ "error.fileType.images": "Solo se admiten imágenes (PNG, JPEG, WebP, GIF).",
282
+ "error.fileType.pdf": "Solo se admiten archivos PDF.",
283
+ "error.fileType.both": "Solo se admiten imágenes (PNG, JPEG, WebP, GIF) y archivos PDF.",
284
+ "error.fileTooLarge": "Los archivos pueden ocupar hasta {size}.",
285
+ "error.pdfPages": "Los PDF pueden tener hasta {max} páginas.",
286
+ "error.voiceNotAccepted": "Este asistente no acepta entrada de voz.",
287
+ "error.recordingFormat": "Este formato de grabación no es compatible.",
288
+ "error.recordingTooLong": "Esta grabación es demasiado larga.",
289
+ "error.dictationBusy": "Todavía se está transcribiendo otro dictado. Inténtalo en un momento.",
290
+ "error.dictationBudget": "El dictado no está disponible durante el resto del día. Puedes seguir escribiendo."
291
+ };
292
+ // src/i18n/locales/fr.ts
293
+ /**
294
+ * French. "Vous", and a narrow no-break space (U+202F) before `?`, `!`, `:` and `;` as French
295
+ * typography asks; override any text with `widget.texts`.
296
+ */
297
+ const FR = {
298
+ "header.title": "Assistant",
299
+ "header.newConversation": "Nouvelle conversation",
300
+ "header.close": "Fermer le chat",
301
+ "confirm.newConversation": "Commencer une nouvelle conversation ? La conversation actuelle sera supprimée.",
302
+ "confirm.cancel": "Annuler",
303
+ "confirm.accept": "Recommencer",
304
+ "welcome.label": "Bienvenue",
305
+ "welcome.greeting": "Bonjour ! Comment puis-je vous aider ?",
306
+ "welcome.online": "En ligne",
307
+ "welcome.suggestions": "Questions suggérées",
308
+ "composer.placeholder": "Écrivez votre message…",
309
+ "composer.send": "Envoyer",
310
+ "composer.attach": "Joindre des fichiers",
311
+ "composer.dictate": "Dicter un message",
312
+ "status.loading": "Chargement de la conversation…",
313
+ "status.thinking": "Réflexion…",
314
+ "status.searching": "Recherche dans les documents…",
315
+ "status.tool": "Utilisation de {name}…",
316
+ "status.typing": "L’assistant écrit",
317
+ "message.sources": "Sources",
318
+ "message.replies": "Réponses suggérées",
319
+ "feedback.label": "Évaluer cette réponse",
320
+ "feedback.up": "Utile",
321
+ "feedback.down": "Pas utile",
322
+ "feedback.comment": "Qu’est-ce qui n’allait pas ?",
323
+ "feedback.send": "Envoyer l’avis",
324
+ "feedback.skip": "Passer",
325
+ "message.attachments.one": "{count} pièce jointe",
326
+ "message.attachments.other": "{count} pièces jointes",
327
+ "attachment.list": "Pièces jointes",
328
+ "attachment.uploading": "Envoi…",
329
+ "attachment.remove": "Retirer {name}",
330
+ "attachment.unsupported": "Ce type de fichier n’est pas pris en charge.",
331
+ "attachment.tooLarge": "Trop volumineux (max. {size}).",
332
+ "attachment.tooMany": "Vous pouvez joindre jusqu’à {count} fichiers par message.",
333
+ "dictation.listening": "Écoute…",
334
+ "dictation.transcribing": "Transcription…",
335
+ "dictation.cancel": "Annuler la dictée",
336
+ "dictation.done": "Terminé",
337
+ "dictation.empty": "Rien n’a été enregistré. Veuillez réessayer.",
338
+ "microphone.blocked": "L’accès au micro est bloqué. Autorisez-le dans votre navigateur pour dicter.",
339
+ "microphone.missing": "Aucun micro trouvé.",
340
+ "microphone.failed": "Le micro n’a pas pu démarrer.",
341
+ "disclosure.text": "Vous discutez avec un assistant IA. Il peut faire des erreurs.",
342
+ "disclosure.privacy": "Politique de confidentialité",
343
+ "launcher.label": "Une question ?",
344
+ "launcher.open": "Ouvrir le chat",
345
+ "launcher.close": "Fermer le chat",
346
+ "launcher.unavailable": "Le chat n’a pas pu se charger. Veuillez réessayer plus tard.",
347
+ "humanCheck.label": "Vérification que vous êtes humain",
348
+ "error.humanCheck": "Nous n’avons pas pu confirmer que vous êtes humain. Veuillez réessayer.",
349
+ "error.connection": "Problème de connexion. Veuillez réessayer.",
350
+ "error.history": "Impossible de charger la conversation précédente.",
351
+ "error.updated": "L’assistant a été mis à jour. Veuillez recharger la page.",
352
+ "error.stalled": "La connexion s’est interrompue. Veuillez réessayer.",
353
+ "error.uploadFailed": "Le fichier n’a pas pu être envoyé.",
354
+ "error.transcriptionFailed": "L’enregistrement n’a pas pu être transcrit.",
355
+ "error.invalid_input": "La requête n’est pas valide.",
356
+ "error.unauthorized": "Une authentification est requise.",
357
+ "error.session_expired": "Votre session a expiré. Veuillez réessayer.",
358
+ "error.not_found": "Introuvable.",
359
+ "error.content_blocked": "Ce message ne peut pas être traité.",
360
+ "error.rate_limited": "Trop de messages. Veuillez patienter un instant.",
361
+ "error.budget_exceeded": "L’assistant n’est plus disponible pour aujourd’hui.",
362
+ "error.internal_error": "Une erreur s’est produite. Veuillez réessayer.",
363
+ "error.upstream_error": "L’assistant est momentanément indisponible. Veuillez réessayer.",
364
+ "error.bot_unavailable": "L’assistant est actuellement indisponible.",
365
+ "error.timeout": "L’assistant a mis trop de temps à répondre. Veuillez réessayer.",
366
+ "error.conversationTooLong": "Cette conversation est trop longue. Veuillez en commencer une nouvelle.",
367
+ "error.conversationGone": "Cette conversation n’est plus disponible.",
368
+ "error.messageLength": "Les messages peuvent contenir jusqu’à {max} caractères.",
369
+ "error.attachmentExpired": "Une pièce jointe a expiré ou n’est pas valide. Veuillez la joindre à nouveau.",
370
+ "error.filesNotAccepted": "Cet assistant n’accepte pas de fichiers.",
371
+ "error.tooManyFiles": "Joignez jusqu’à {count} fichiers par message.",
372
+ "error.fileType.images": "Seules les images (PNG, JPEG, WebP, GIF) sont prises en charge.",
373
+ "error.fileType.pdf": "Seuls les fichiers PDF sont pris en charge.",
374
+ "error.fileType.both": "Seules les images (PNG, JPEG, WebP, GIF) et les fichiers PDF sont pris en charge.",
375
+ "error.fileTooLarge": "Les fichiers peuvent faire jusqu’à {size}.",
376
+ "error.pdfPages": "Les PDF peuvent compter jusqu’à {max} pages.",
377
+ "error.voiceNotAccepted": "Cet assistant n’accepte pas la saisie vocale.",
378
+ "error.recordingFormat": "Ce format d’enregistrement n’est pas pris en charge.",
379
+ "error.recordingTooLong": "Cet enregistrement est trop long.",
380
+ "error.dictationBusy": "Une autre dictée est en cours de transcription. Réessayez dans un instant.",
381
+ "error.dictationBudget": "La dictée n’est plus disponible pour aujourd’hui. Vous pouvez toujours écrire."
382
+ };
383
+ // src/i18n/locales/it.ts
384
+ /** Italian. Informal "tu"; override any text with `widget.texts`. */
385
+ const IT = {
386
+ "header.title": "Assistente",
387
+ "header.newConversation": "Inizia una nuova conversazione",
388
+ "header.close": "Chiudi la chat",
389
+ "confirm.newConversation": "Iniziare una nuova conversazione? Quella attuale verrà eliminata.",
390
+ "confirm.cancel": "Annulla",
391
+ "confirm.accept": "Ricomincia",
392
+ "welcome.label": "Benvenuto",
393
+ "welcome.greeting": "Ciao! Come posso aiutarti?",
394
+ "welcome.online": "Online",
395
+ "welcome.suggestions": "Domande suggerite",
396
+ "composer.placeholder": "Scrivi un messaggio…",
397
+ "composer.send": "Invia",
398
+ "composer.attach": "Allega file",
399
+ "composer.dictate": "Detta un messaggio",
400
+ "status.loading": "Caricamento della conversazione…",
401
+ "status.thinking": "Sto pensando…",
402
+ "status.searching": "Cerco nei documenti…",
403
+ "status.tool": "Uso {name}…",
404
+ "status.typing": "L’assistente sta scrivendo",
405
+ "message.sources": "Fonti",
406
+ "message.replies": "Risposte suggerite",
407
+ "feedback.label": "Valuta questa risposta",
408
+ "feedback.up": "Utile",
409
+ "feedback.down": "Non utile",
410
+ "feedback.comment": "Cosa non andava?",
411
+ "feedback.send": "Invia feedback",
412
+ "feedback.skip": "Salta",
413
+ "message.attachments.one": "{count} allegato",
414
+ "message.attachments.other": "{count} allegati",
415
+ "attachment.list": "Allegati",
416
+ "attachment.uploading": "Caricamento…",
417
+ "attachment.remove": "Rimuovi {name}",
418
+ "attachment.unsupported": "Questo tipo di file non è supportato.",
419
+ "attachment.tooLarge": "Troppo grande (max {size}).",
420
+ "attachment.tooMany": "Puoi allegare fino a {count} file per messaggio.",
421
+ "dictation.listening": "In ascolto…",
422
+ "dictation.transcribing": "Trascrizione…",
423
+ "dictation.cancel": "Annulla la dettatura",
424
+ "dictation.done": "Fatto",
425
+ "dictation.empty": "Non è stato registrato nulla. Riprova.",
426
+ "microphone.blocked": "L’accesso al microfono è bloccato. Consentilo nel browser per poter dettare.",
427
+ "microphone.missing": "Nessun microfono trovato.",
428
+ "microphone.failed": "Impossibile avviare il microfono.",
429
+ "disclosure.text": "Stai chattando con un assistente IA. Può commettere errori.",
430
+ "disclosure.privacy": "Informativa sulla privacy",
431
+ "launcher.label": "Chiedi a noi",
432
+ "launcher.open": "Apri la chat",
433
+ "launcher.close": "Chiudi la chat",
434
+ "launcher.unavailable": "Impossibile caricare la chat. Riprova più tardi.",
435
+ "humanCheck.label": "Verifichiamo che tu sia una persona",
436
+ "error.humanCheck": "Non è stato possibile verificare che tu sia una persona. Riprova.",
437
+ "error.connection": "Problema di connessione. Riprova.",
438
+ "error.history": "Impossibile caricare la conversazione precedente.",
439
+ "error.updated": "L’assistente è stato aggiornato. Ricarica la pagina.",
440
+ "error.stalled": "La connessione si è interrotta. Riprova.",
441
+ "error.uploadFailed": "Impossibile caricare il file.",
442
+ "error.transcriptionFailed": "Impossibile trascrivere la registrazione.",
443
+ "error.invalid_input": "La richiesta non è valida.",
444
+ "error.unauthorized": "È necessaria l’autenticazione.",
445
+ "error.session_expired": "La sessione è scaduta. Riprova.",
446
+ "error.not_found": "Non trovato.",
447
+ "error.content_blocked": "Questo messaggio non può essere elaborato.",
448
+ "error.rate_limited": "Troppi messaggi. Attendi un momento.",
449
+ "error.budget_exceeded": "L’assistente non è disponibile per il resto della giornata.",
450
+ "error.internal_error": "Qualcosa è andato storto. Riprova.",
451
+ "error.upstream_error": "L’assistente è temporaneamente non disponibile. Riprova.",
452
+ "error.bot_unavailable": "L’assistente al momento non è disponibile.",
453
+ "error.timeout": "L’assistente ha impiegato troppo tempo a rispondere. Riprova.",
454
+ "error.conversationTooLong": "Questa conversazione è troppo lunga. Iniziane una nuova.",
455
+ "error.conversationGone": "Questa conversazione non è più disponibile.",
456
+ "error.messageLength": "I messaggi possono contenere fino a {max} caratteri.",
457
+ "error.attachmentExpired": "Un allegato è scaduto o non è valido. Allegalo di nuovo.",
458
+ "error.filesNotAccepted": "Questo assistente non accetta file.",
459
+ "error.tooManyFiles": "Allega fino a {count} file per messaggio.",
460
+ "error.fileType.images": "Sono supportate solo immagini (PNG, JPEG, WebP, GIF).",
461
+ "error.fileType.pdf": "Sono supportati solo file PDF.",
462
+ "error.fileType.both": "Sono supportati solo immagini (PNG, JPEG, WebP, GIF) e file PDF.",
463
+ "error.fileTooLarge": "I file possono pesare fino a {size}.",
464
+ "error.pdfPages": "I PDF possono avere fino a {max} pagine.",
465
+ "error.voiceNotAccepted": "Questo assistente non accetta input vocali.",
466
+ "error.recordingFormat": "Questo formato di registrazione non è supportato.",
467
+ "error.recordingTooLong": "Questa registrazione è troppo lunga.",
468
+ "error.dictationBusy": "Un’altra dettatura è ancora in trascrizione. Riprova tra un momento.",
469
+ "error.dictationBudget": "La dettatura non è disponibile per il resto della giornata. Puoi comunque scrivere."
470
+ };
23
471
  // src/i18n/locale.ts
24
472
  /** The canonical form of a BCP 47 tag that Intl accepts (plural rules need it), else undefined. */
25
473
  function canonicalLocale(tag) {
@@ -85,6 +533,8 @@ const EN = {
85
533
  "launcher.open": "Open chat",
86
534
  "launcher.close": "Close chat",
87
535
  "launcher.unavailable": "The chat couldn’t load. Please try again later.",
536
+ "humanCheck.label": "Checking that you’re human",
537
+ "error.humanCheck": "We couldn’t confirm you’re human. Please try again.",
88
538
  "error.connection": "Connection problem. Please try again.",
89
539
  "error.history": "Could not load the previous conversation.",
90
540
  "error.updated": "The assistant was updated. Please reload the page.",
@@ -181,6 +631,8 @@ const PL = {
181
631
  "launcher.open": "Otwórz czat",
182
632
  "launcher.close": "Zamknij czat",
183
633
  "launcher.unavailable": "Nie udało się załadować czatu. Spróbuj ponownie później.",
634
+ "humanCheck.label": "Sprawdzamy, czy jesteś człowiekiem",
635
+ "error.humanCheck": "Nie udało się potwierdzić, że jesteś człowiekiem. Spróbuj ponownie.",
184
636
  "error.connection": "Problem z połączeniem. Spróbuj ponownie.",
185
637
  "error.history": "Nie udało się wczytać poprzedniej rozmowy.",
186
638
  "error.updated": "Asystent został zaktualizowany. Odśwież stronę.",
@@ -216,9 +668,37 @@ const PL = {
216
668
  "error.dictationBudget": "Dyktowanie jest niedostępne do końca dnia. Wiadomość możesz nadal wpisać."
217
669
  };
218
670
  /** Languages with a built-in dictionary; any other locale shows English texts. */
219
- const TEXT_LOCALES = ["en", "pl"];
671
+ const TEXT_LOCALES = [
672
+ "en",
673
+ "cs",
674
+ "de",
675
+ "es",
676
+ "fr",
677
+ "it",
678
+ "pl"
679
+ ];
220
680
  const DICTIONARIES = {
221
681
  en: EN,
682
+ cs: {
683
+ ...EN,
684
+ ...CS
685
+ },
686
+ de: {
687
+ ...EN,
688
+ ...DE
689
+ },
690
+ es: {
691
+ ...EN,
692
+ ...ES
693
+ },
694
+ fr: {
695
+ ...EN,
696
+ ...FR
697
+ },
698
+ it: {
699
+ ...EN,
700
+ ...IT
701
+ },
222
702
  pl: {
223
703
  ...EN,
224
704
  ...PL
@@ -233,7 +713,7 @@ function textLocale(locale) {
233
713
  const TEXT_KEYS = [.../* @__PURE__ */ new Set([...Object.keys(EN), ...PLURAL_BASES.flatMap((base) => PLURAL_FORMS.map((form) => `${base}.${form}`))])];
234
714
  /**
235
715
  * The full dictionary for a locale with overrides applied. Plural forms beyond `one`/`other`
236
- * (Polish `few`, `many`) are kept too, so the widget can pick them.
716
+ * (Polish and Czech `few`, `many`) are kept too, so the widget can pick them.
237
717
  */
238
718
  function textsFor(locale, overrides = {}) {
239
719
  return {
@@ -721,7 +1201,47 @@ const readSuggestedReplies = (calls) => {
721
1201
  const call = calls.findLast((stored) => stored.name === "suggest_replies" && stored.output !== void 0);
722
1202
  return call && suggestedReplies(call.arguments);
723
1203
  };
1204
+ const hook = z.custom((value) => typeof value === "function", "must be a function");
1205
+ /** The guardrail keys of the bot definition schema. */
1206
+ const guardrailShape = {
1207
+ moderation: z.object({
1208
+ model: z.string().trim().min(1, "is required"),
1209
+ check: z.enum([
1210
+ "input",
1211
+ "output",
1212
+ "both"
1213
+ ]).optional(),
1214
+ categories: z.array(z.string().trim().min(1).max(64)).min(1).max(30).optional(),
1215
+ message: z.string().trim().min(1).max(300).optional()
1216
+ }).strict().optional(),
1217
+ onInput: hook.optional(),
1218
+ onOutput: hook.optional(),
1219
+ toolResults: z.enum(["trusted", "untrusted"]).optional()
1220
+ };
1221
+ /** Fills in the defaults: everything off. */
1222
+ function resolveGuardrails(options) {
1223
+ const { moderation } = options;
1224
+ const check = moderation?.check ?? "input";
1225
+ return Object.freeze({
1226
+ moderation: moderation ? Object.freeze({
1227
+ model: moderation.model.trim(),
1228
+ input: check !== "output",
1229
+ output: check !== "input",
1230
+ categories: moderation.categories ? Object.freeze(moderation.categories.map((category) => category.trim())) : void 0,
1231
+ message: moderation.message?.trim()
1232
+ }) : void 0,
1233
+ onInput: options.onInput,
1234
+ onOutput: options.onOutput,
1235
+ toolResults: options.toolResults ?? "trusted"
1236
+ });
1237
+ }
1238
+ /** Whether visitor messages are checked before the model sees them. */
1239
+ const checksInput = (guardrails) => guardrails.onInput !== void 0 || guardrails.moderation?.input === true;
1240
+ /** Whether answers are checked, and so held back until complete. */
1241
+ const checksOutput = (guardrails) => guardrails.onOutput !== void 0 || guardrails.moderation?.output === true;
724
1242
  // src/bot/define-bot.ts
1243
+ /** Marks a resolved bot; `Symbol.for`, so a second copy of this module recognises it too. */
1244
+ const BOT = Symbol.for("askdare.bot");
725
1245
  const DEFAULT_LIMITS = {
726
1246
  maxOutputTokens: 1024,
727
1247
  maxInputChars: 4e3,
@@ -832,7 +1352,10 @@ const definitionSchema = z.object({
832
1352
  model: z.string().trim().min(1, "is required"),
833
1353
  maxSeconds: z.number().int().min(5).max(300).optional()
834
1354
  }).optional(),
835
- security: z.object({ allowedOrigins: z.array(origin).max(50).optional() }).optional(),
1355
+ security: z.object({
1356
+ allowedOrigins: z.array(origin).max(50).optional(),
1357
+ humanVerifier: z.custom((value) => typeof value === "object" && value !== null && typeof value.verify === "function" && value.challenge?.provider === "turnstile" && /^[A-Za-z0-9_-]{1,100}$/.test(String(value.challenge?.siteKey)), "must be created with turnstile() or implement HumanVerifier").optional()
1358
+ }).optional(),
836
1359
  embedPath: z.string().refine(isEmbedPath, "must be a path of this app like /askdare/support").optional(),
837
1360
  widget: z.object({
838
1361
  title: z.string().trim().min(1).max(80).optional(),
@@ -854,13 +1377,26 @@ const definitionSchema = z.object({
854
1377
  "light",
855
1378
  "dark"
856
1379
  ]).optional()
857
- }).optional()
1380
+ }).optional(),
1381
+ ...guardrailShape
858
1382
  });
859
1383
  /**
860
1384
  * Declares a chatbot. Validates eagerly so misconfiguration fails at startup, not on the first
861
1385
  * visitor's message.
862
1386
  */
863
1387
  function defineBot(definition) {
1388
+ return createBot(definition);
1389
+ }
1390
+ /** The resolved bot behind a handle, or a TypeError when it didn't come from `defineBot`. */
1391
+ function botOf(handle) {
1392
+ if (!isBot(handle)) throw new TypeError(`[askdare] Bot "${handle.id}" was not made by defineBot().`);
1393
+ return handle;
1394
+ }
1395
+ function isBot(handle) {
1396
+ return BOT in handle;
1397
+ }
1398
+ /** `defineBot` for code inside the library, typed with the resolved settings. */
1399
+ function createBot(definition) {
864
1400
  const parsed = definitionSchema.safeParse(definition);
865
1401
  if (!parsed.success) {
866
1402
  const issues = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"} ${issue.message}`).join("; ");
@@ -887,6 +1423,7 @@ function defineBot(definition) {
887
1423
  const theme = resolveTheme(definition.widget?.theme, definition.widget?.colorScheme ?? "auto");
888
1424
  if (typeof definition.widget?.theme === "object" && globalThis.process?.env?.["NODE_ENV"] !== "production") for (const warning of themeWarnings(theme)) console.warn(`[askdare] Bot "${definition.id}" theme: ${warning}.`);
889
1425
  return Object.freeze({
1426
+ [BOT]: true,
890
1427
  id: definition.id,
891
1428
  model: definition.model.trim(),
892
1429
  instructions: typeof instructions === "string" ? () => instructions : instructions,
@@ -911,7 +1448,10 @@ function defineBot(definition) {
911
1448
  model: definition.voice.model.trim(),
912
1449
  maxSeconds: definition.voice.maxSeconds ?? 60
913
1450
  }) : void 0,
914
- security: Object.freeze({ allowedOrigins: Object.freeze([...new Set(definition.security?.allowedOrigins ?? [])]) }),
1451
+ security: Object.freeze({
1452
+ allowedOrigins: Object.freeze([...new Set(definition.security?.allowedOrigins ?? [])]),
1453
+ humanVerifier: definition.security?.humanVerifier
1454
+ }),
915
1455
  embedPath: definition.embedPath,
916
1456
  widget: Object.freeze({
917
1457
  title: texts["header.title"] ?? "",
@@ -929,9 +1469,38 @@ function defineBot(definition) {
929
1469
  disclosure: widget.disclosure === false ? false : Object.freeze({ privacyUrl: widget.disclosure?.privacyUrl }),
930
1470
  css: widget.css ?? "",
931
1471
  theme
932
- })
1472
+ }),
1473
+ guardrails: resolveGuardrails(definition)
933
1474
  });
934
1475
  }
1476
+ // src/protocol/events.ts
1477
+ /** Stable error codes sent to clients. The accompanying message never contains internals. */
1478
+ const ERROR_CODES = [
1479
+ "invalid_input",
1480
+ "unauthorized",
1481
+ "session_expired",
1482
+ "not_found",
1483
+ "rate_limited",
1484
+ "budget_exceeded",
1485
+ "bot_unavailable",
1486
+ "content_blocked",
1487
+ "timeout",
1488
+ "upstream_error",
1489
+ "internal_error"
1490
+ ];
1491
+ const PROTOCOL_EVENT_TYPES = [
1492
+ "conversation.created",
1493
+ "user.ack",
1494
+ "message.start",
1495
+ "reasoning",
1496
+ "text.delta",
1497
+ "citation",
1498
+ "tool.status",
1499
+ "tool.ui",
1500
+ "replies",
1501
+ "message.end",
1502
+ "error"
1503
+ ];
935
1504
  // src/protocol/version.ts
936
1505
  /**
937
1506
  * Version of the SSE wire protocol between the askdare server and its clients.
@@ -940,6 +1509,107 @@ function defineBot(definition) {
940
1509
  const PROTOCOL_VERSION = 1;
941
1510
  /** Response header carrying {@link PROTOCOL_VERSION} on every streaming response. */
942
1511
  const PROTOCOL_HEADER = "x-askdare-protocol";
1512
+ // src/errors.ts
1513
+ const HTTP_STATUS = {
1514
+ invalid_input: 400,
1515
+ unauthorized: 401,
1516
+ session_expired: 401,
1517
+ not_found: 404,
1518
+ content_blocked: 422,
1519
+ rate_limited: 429,
1520
+ budget_exceeded: 429,
1521
+ internal_error: 500,
1522
+ upstream_error: 502,
1523
+ bot_unavailable: 503,
1524
+ timeout: 504
1525
+ };
1526
+ const DEFAULT_MESSAGES = {
1527
+ invalid_input: "The request was invalid.",
1528
+ unauthorized: "Authentication is required.",
1529
+ session_expired: "Your session has expired. Please try again.",
1530
+ not_found: "Not found.",
1531
+ content_blocked: "This message cannot be processed.",
1532
+ rate_limited: "Too many messages. Please wait a moment.",
1533
+ budget_exceeded: "The assistant is unavailable for the rest of the day.",
1534
+ internal_error: "Something went wrong. Please try again.",
1535
+ upstream_error: "The assistant is temporarily unavailable. Please try again.",
1536
+ bot_unavailable: "The assistant is currently unavailable.",
1537
+ timeout: "The assistant took too long to respond. Please try again."
1538
+ };
1539
+ /** An error with a stable, client-safe code. Anything else that escapes becomes `internal_error`. */
1540
+ var AskdareError = class extends Error {
1541
+ name = "AskdareError";
1542
+ code;
1543
+ status;
1544
+ retryAfterMs;
1545
+ key;
1546
+ params;
1547
+ constructor(code, options = {}) {
1548
+ super(options.message ?? DEFAULT_MESSAGES[code], { cause: options.cause });
1549
+ this.code = code;
1550
+ this.status = HTTP_STATUS[code];
1551
+ this.retryAfterMs = options.retryAfterMs;
1552
+ this.key = options.key ?? (options.message === void 0 ? `error.${code}` : void 0);
1553
+ this.params = options.params;
1554
+ }
1555
+ };
1556
+ /** The caller's own signal aborted the work (for example, the visitor closed the chat). Not an error to report. */
1557
+ var TurnAbortedError = class extends Error {
1558
+ name = "TurnAbortedError";
1559
+ };
1560
+ /** Normalizes anything thrown into a {@link AskdareError} without exposing its details. */
1561
+ function toAskdareError(error) {
1562
+ return error instanceof AskdareError ? error : new AskdareError("internal_error", { cause: error });
1563
+ }
1564
+ /** API keys never reach a log line, a report or the chat: `sk-proj-abc…` keeps only its prefix. */
1565
+ function scrub(text) {
1566
+ return text.replace(/\b(sk|rk)-[A-Za-z0-9_-]{6,}/g, (key) => `${key.slice(0, 3)}…`);
1567
+ }
1568
+ /** Longer quoted values in an error message may be the visitor's text, not configuration. */
1569
+ const LONG_QUOTE = /(['"`])[^'"`]{33,}\1/g;
1570
+ const MAX_MESSAGE = 300;
1571
+ /**
1572
+ * An error message fit for a log line: API keys cut down to their prefix (a 401 quotes part of the
1573
+ * key), quoted values longer than 32 characters replaced (a 400 can quote the value it rejected,
1574
+ * which may be what the visitor wrote), and the whole capped. Model names, parameters and IDs stay.
1575
+ */
1576
+ function loggableMessage(message) {
1577
+ const text = scrub(message).replace(LONG_QUOTE, (_, quote) => `${quote}[…]${quote}`);
1578
+ return text.length > MAX_MESSAGE ? `${text.slice(0, MAX_MESSAGE)}…` : text;
1579
+ }
1580
+ /**
1581
+ * The cause of an error as the server logs it when no `onError` is set (ADR-0004: no content in
1582
+ * logs): an `Error` keeps its name, stack frames and status, code and request ID, with its message
1583
+ * passed through {@link loggableMessage}; a string is cleaned the same way; anything else is
1584
+ * logged as its type only.
1585
+ */
1586
+ function forLog(cause) {
1587
+ if (cause === void 0) return void 0;
1588
+ if (typeof cause === "string") return loggableMessage(cause);
1589
+ if (!(cause instanceof Error)) return `[${typeof cause}]`;
1590
+ const copy = new Error(loggableMessage(cause.message));
1591
+ copy.name = cause.name;
1592
+ const frames = (cause.stack ?? "").split("\n").filter((line) => /^\s+at /.test(line));
1593
+ copy.stack = [`${copy.name}: ${copy.message}`, ...frames].join("\n");
1594
+ const { status, code, requestId } = cause;
1595
+ return Object.assign(copy, {
1596
+ ...status === void 0 ? {} : { status },
1597
+ ...code === void 0 ? {} : { code },
1598
+ ...requestId === void 0 ? {} : { requestId }
1599
+ });
1600
+ }
1601
+ // src/security/human-verifier.ts
1602
+ /** Where Cloudflare serves Turnstile's script and frame; the iframe's CSP allows it for such bots. */
1603
+ const TURNSTILE_ORIGIN = "https://challenges.cloudflare.com";
1604
+ /** Longest token Turnstile issues. */
1605
+ const HUMAN_TOKEN_MAX_LENGTH = 2048;
1606
+ /**
1607
+ * The Turnstile `action` the chat renders for a bot and the server expects back: the bot id, cut
1608
+ * to Turnstile's 32 characters (bot ids use only characters it accepts).
1609
+ */
1610
+ const turnstileAction = (botId) => botId.slice(0, 32);
1611
+ /** The origins a challenge's script and frame come from, for the iframe's CSP. */
1612
+ const CHALLENGE_ORIGINS = { turnstile: TURNSTILE_ORIGIN };
943
1613
  /**
944
1614
  * A URL or something a browser or a chat app would turn into a link: a scheme (`https://`,
945
1615
  * `mailto:`, `javascript:` …), `www.`, an IP address or a domain name such as `example.com`.
@@ -1125,4 +1795,4 @@ function readToolUi(tools, calls, onError) {
1125
1795
  }
1126
1796
  return payloads;
1127
1797
  }
1128
- export { textLocale as C, isInside as D, isBasePath as E, TEXT_LOCALES as S, canonicalLocale as T, readSuggestedReplies as _, isToolUiList as a, resolveTheme as b, PROTOCOL_VERSION as c, primarySubtag as d, widgetTexts as f, SUGGEST_REPLIES_PARAMETERS as g, SUGGEST_REPLIES_OUTPUT as h, readToolUi as i, defineBot as l, SUGGEST_REPLIES_DESCRIPTION as m, defineTool as n, normalizeReplies as o, SUGGEST_REPLIES as p, readToolReplies as r, PROTOCOL_HEADER as s, ToolUiLimitError as t, languageTexts as u, suggestedReplies as v, textsFor as w, PRESET_NAMES as x, defineTheme as y };
1798
+ export { SUGGEST_REPLIES_OUTPUT as A, canonicalLocale as B, languageTexts as C, checksOutput as D, checksInput as E, resolveTheme as F, isInside as H, PRESET_NAMES as I, TEXT_LOCALES as L, readSuggestedReplies as M, suggestedReplies as N, SUGGEST_REPLIES as O, defineTheme as P, textLocale as R, defineBot as S, widgetTexts as T, isBasePath as V, PROTOCOL_HEADER as _, isToolUiList as a, PROTOCOL_EVENT_TYPES as b, HUMAN_TOKEN_MAX_LENGTH as c, AskdareError as d, TurnAbortedError as f, toAskdareError as g, scrub as h, readToolUi as i, SUGGEST_REPLIES_PARAMETERS as j, SUGGEST_REPLIES_DESCRIPTION as k, TURNSTILE_ORIGIN as l, loggableMessage as m, defineTool as n, normalizeReplies as o, forLog as p, readToolReplies as r, CHALLENGE_ORIGINS as s, ToolUiLimitError as t, turnstileAction as u, PROTOCOL_VERSION as v, primarySubtag as w, botOf as x, ERROR_CODES as y, textsFor as z };