@boldare/askdare 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/README.md +14 -4
- package/dist/cli.js +19 -6
- package/dist/define-tool.js +677 -7
- package/dist/embed.d.ts +1 -1
- package/dist/embed.js +2 -1
- package/dist/{store.d.ts → events.d.ts} +127 -52
- package/dist/index.d.ts +28 -2
- package/dist/index.js +82 -1
- package/dist/next.d.ts +22 -11
- package/dist/next.js +537 -139
- package/dist/react-marked.js +883 -810
- package/dist/react.d.ts +24 -4
- package/dist/react.js +126 -18
- package/dist/root.js +170 -38
- package/dist/tool-results.d.ts +11 -1
- package/dist/ui/askdare.css +9 -1
- package/dist/ui/avatar.tsx +1 -1
- package/dist/ui/chat.tsx +1 -1
- package/dist/ui/confirm.tsx +1 -1
- package/dist/ui/context.ts +1 -1
- package/dist/ui/feedback.tsx +1 -1
- package/dist/ui/footer.tsx +3 -15
- package/dist/ui/header.tsx +1 -1
- package/dist/ui/icons.tsx +1 -1
- package/dist/ui/index.ts +1 -1
- package/dist/ui/message.tsx +1 -1
- package/dist/ui/panel.tsx +3 -1
- package/dist/ui/welcome.tsx +1 -1
- package/docs/accessibility.md +83 -0
- package/docs/cli.md +4 -3
- package/docs/compliance.md +160 -0
- package/docs/configuration.md +47 -2
- package/docs/costs.md +8 -1
- package/docs/custom-store.md +2 -0
- package/docs/embedding.md +2 -0
- package/docs/feedback.md +1 -1
- package/docs/going-public.md +15 -3
- package/docs/guardrails.md +128 -0
- package/docs/migrating-from-openai-assistant.md +1 -1
- package/docs/privacy.md +26 -2
- package/docs/react.md +7 -1
- package/docs/styling.md +2 -2
- package/docs/support.md +3 -3
- package/docs/texts.md +100 -96
- package/docs/troubleshooting.md +30 -3
- package/llms.txt +12 -9
- package/package.json +4 -4
- package/skills/askdare/SKILL.md +9 -2
package/dist/ui/feedback.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import { FeedbackButton, useChat, useChatState, useMessage } from '@boldare/askdare/react';
|
|
3
3
|
import { type FormEvent, type ReactElement, useEffect, useId, useRef, useState } from 'react';
|
|
4
4
|
import { useSkin } from './context';
|
package/dist/ui/footer.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import {
|
|
3
3
|
AttachButton,
|
|
4
4
|
Composer,
|
|
5
5
|
DictateButton,
|
|
6
|
+
Disclosure,
|
|
6
7
|
Files,
|
|
7
8
|
Input,
|
|
8
9
|
QuickReplies,
|
|
@@ -46,20 +47,7 @@ export function DefaultFooter(): ReactElement {
|
|
|
46
47
|
)}
|
|
47
48
|
</div>
|
|
48
49
|
</Composer>
|
|
49
|
-
|
|
50
|
-
// The AI notice (EU AI Act, art. 50).
|
|
51
|
-
<p data-ask-part="disclosure">
|
|
52
|
-
{t('disclosure.text')}
|
|
53
|
-
{bot.disclosure.privacyUrl && (
|
|
54
|
-
<>
|
|
55
|
-
{' '}
|
|
56
|
-
<a href={bot.disclosure.privacyUrl} target="_blank" rel="noopener noreferrer">
|
|
57
|
-
{t('disclosure.privacy')}
|
|
58
|
-
</a>
|
|
59
|
-
</>
|
|
60
|
-
)}
|
|
61
|
-
</p>
|
|
62
|
-
)}
|
|
50
|
+
<Disclosure />
|
|
63
51
|
</>
|
|
64
52
|
);
|
|
65
53
|
}
|
package/dist/ui/header.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import { useChat } from '@boldare/askdare/react';
|
|
3
3
|
import type { ReactElement } from 'react';
|
|
4
4
|
import { Avatar } from './avatar';
|
package/dist/ui/icons.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import type { ReactElement, ReactNode } from 'react';
|
|
3
3
|
|
|
4
4
|
/** Line icons on a 24px grid, drawn with the current text color. */
|
package/dist/ui/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
4
|
// The default look of the chat (ADR-0011): what `npx @boldare/askdare add ui` copies into an app.
|
package/dist/ui/message.tsx
CHANGED
package/dist/ui/panel.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import {
|
|
3
3
|
ErrorMessage,
|
|
4
|
+
HumanCheck,
|
|
4
5
|
MessageList,
|
|
5
6
|
Messages,
|
|
6
7
|
Panel,
|
|
@@ -128,6 +129,7 @@ export function DefaultPanel({
|
|
|
128
129
|
<MessageList>{message}</MessageList>
|
|
129
130
|
<Status />
|
|
130
131
|
</Messages>
|
|
132
|
+
<HumanCheck />
|
|
131
133
|
<ErrorMessage />
|
|
132
134
|
<Footer />
|
|
133
135
|
</Panel>
|
package/dist/ui/welcome.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.1 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import { useChat } from '@boldare/askdare/react';
|
|
3
3
|
import type { ReactElement, ReactNode } from 'react';
|
|
4
4
|
import { Avatar } from './avatar';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Accessibility
|
|
2
|
+
|
|
3
|
+
This is askdare's accessibility conformance statement. It says what the widget and its default look aim for, how that was checked, and what is known not to work yet. Why askdare cares, and what the European Accessibility Act asks of your site, is in [Compliance](compliance.md#5-accessibility).
|
|
4
|
+
|
|
5
|
+
**Last reviewed: 2026-11-21**, against the 0.5 development line (after 0.4.0). The statement is updated whenever the chat's markup changes.
|
|
6
|
+
|
|
7
|
+
## Status
|
|
8
|
+
|
|
9
|
+
askdare targets [WCAG 2.2](https://www.w3.org/TR/WCAG22/) Level AA, the level that [ETSI EN 301 549 V4.1.1](https://www.etsi.org/deliver/etsi_en/301500_301599/301549/04.01.01_60/en_301549v040101p.pdf) asks for web content.
|
|
10
|
+
|
|
11
|
+
- **Automated checks:** no failures (axe-core, every built-in theme and state, five browser setups including Safari's engine on an iPhone viewport).
|
|
12
|
+
- **Manual review of the WCAG 2.2 criteria axe can't check:** no failures in the chat. One known limitation, with a fix for full-screen chats; see [2.4.11](#manual-review).
|
|
13
|
+
- **Screen readers:** not tested by hand. askdare doesn't run manual checks with VoiceOver or NVDA; the tests check what screen readers rely on instead (roles, names, live regions, and the finished answer announced once).
|
|
14
|
+
|
|
15
|
+
With the known limitations below and no screen-reader testing, the status is **partially conformant**.
|
|
16
|
+
|
|
17
|
+
## Scope
|
|
18
|
+
|
|
19
|
+
What this statement covers:
|
|
20
|
+
|
|
21
|
+
- the launcher and the chat in its iframe, as `widget.js` adds them to a page;
|
|
22
|
+
- the default look (`DefaultChat`, `DefaultPanel`) in all four built-in themes (Halo, Aura, Sage, Care), light and dark;
|
|
23
|
+
- the same look inside your page with `@boldare/askdare/react` ([React](react.md));
|
|
24
|
+
- the built-in texts in every built-in language ([Texts](texts.md)).
|
|
25
|
+
|
|
26
|
+
What it doesn't cover, so it is yours to check:
|
|
27
|
+
|
|
28
|
+
- **Your page around the chat**, including where you put the launcher and on which pages.
|
|
29
|
+
- **Your own markup**: headless primitives, an ejected skin (`add ui`), your own components in `components`, and tool cards from `toolRenderers`. The primitives keep their roles, names and live regions; how you lay them out and style them is up to you.
|
|
30
|
+
- **Your theme and CSS**: a custom theme's colors, `widget.css`, and `::part()` rules. In development, askdare warns when a theme's colors miss AA contrast.
|
|
31
|
+
- **What the model writes.** Answers are rendered from Markdown into real headings, lists, tables and links, but their wording, heading order, link text and language come from the model and your instructions.
|
|
32
|
+
- The askdare website.
|
|
33
|
+
|
|
34
|
+
## Method
|
|
35
|
+
|
|
36
|
+
### Automated, on every change
|
|
37
|
+
|
|
38
|
+
- **axe-core** (4.14, through `@axe-core/playwright`) with the rules tagged `wcag2a`, `wcag2aa`, `wcag21a`, `wcag21aa`, `wcag22aa` and `best-practice`. Selecting by tag also runs the rules axe leaves off by default, such as `target-size` (2.5.8). It runs on:
|
|
39
|
+
- every built-in theme in both schemes, in every state of the gallery: welcome, conversation, streaming, attachments, error, dictation, rating, reply options under the answer and above the message field;
|
|
40
|
+
- the launcher on a third-party page, and the open chat after a real answer;
|
|
41
|
+
- the chat inside a page.
|
|
42
|
+
- **Browsers:** Chromium, Firefox and WebKit on a desktop viewport, and Chromium emulating a phone (Pixel 7: a 412 px wide touch screen).
|
|
43
|
+
- **Contrast:** axe can't measure text over the themes' gradients (it reports those as "needs review"), so unit tests check every built-in theme's colors instead: AA for all, and AAA for text in Care.
|
|
44
|
+
- **Behaviour tests:**
|
|
45
|
+
- a finished answer is announced once, as rendered text, and not while it streams;
|
|
46
|
+
- a restored conversation is not read out;
|
|
47
|
+
- no control is covered by the rest of the chat when it has focus (2.4.11);
|
|
48
|
+
- focus doesn't go behind a full-screen chat (2.4.11);
|
|
49
|
+
- Escape closes the chat and returns focus to what opened it.
|
|
50
|
+
|
|
51
|
+
### Manual review
|
|
52
|
+
|
|
53
|
+
The WCAG 2.2 criteria that automated tools can't decide were reviewed by hand on 2026-11-21, against the markup and behaviour of the chat:
|
|
54
|
+
|
|
55
|
+
| Criterion | Result | What was checked |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| 2.4.11 Focus Not Obscured (Minimum) | Passes in the chat; one limitation on the page | Inside the chat, the header and the message field sit outside the scrolling message list, so they never cover what has focus (also a test). A chat that fills the screen (on a phone, or a desktop page zoomed to 400%) keeps focus inside it until it is closed. On a wider screen, the open chat floats over a corner of your page and isn't modal: see [Known limitations](#known-limitations). |
|
|
58
|
+
| 2.5.7 Dragging Movements | Passes | Nothing needs dragging. Files can be dropped onto the chat, and the attach button does the same with a single click or tap. |
|
|
59
|
+
| 2.5.8 Target Size (Minimum) | Passes | axe's `target-size` rule in every state and on a phone. The launcher is at least 56 by 56 px. |
|
|
60
|
+
| 3.2.6 Consistent Help | Passes for the chat; the rest is your site's | The launcher sits in the same corner of every page that loads `widget.js`, and the chat is the same on each. Which pages load it, and any `::part(launcher)` rule that moves it, are your choice: to meet 3.2.6 on your site, keep it in the same place on every page that has it. |
|
|
61
|
+
| 3.3.8 Accessible Authentication (Minimum) | Passes | The chat asks for no password or code. Signed-in visitors are identified by your backend, without anything for them to type. The optional human check (Cloudflare Turnstile) is not a puzzle: it usually passes without interaction, and at most asks for one click on a checkbox. |
|
|
62
|
+
|
|
63
|
+
## How the chat works with assistive technology
|
|
64
|
+
|
|
65
|
+
- **The conversation** is a `log`, but not a live region: text that grows inside a message is read in fragments or not at all, so the chat doesn't rely on it. When an answer finishes, its rendered text is announced **once** through a separate, visually hidden `status` region. Answers restored after a reload are not read out.
|
|
66
|
+
- **What the assistant is doing** (loading, thinking, searching, using a tool) is a polite `status`. **Errors** are an `alert`.
|
|
67
|
+
- **The panel** is a labelled `region`, or `main` when the chat is the whole page. The launcher says whether the chat is open (`aria-expanded`), and its name starts with its visible label.
|
|
68
|
+
- **Keyboard:** everything works with the keyboard. Enter sends and Shift+Enter starts a new line. Escape dismisses the "Start over" question if it is open, else cancels a dictation, else closes the chat. Closing returns focus to whatever opened the chat. "Start over" asks in a dialog, and focus comes back to its button.
|
|
69
|
+
- **Motion:** the chat follows `prefers-reduced-motion`: no entrance animations, and the launcher and panel open and close without movement.
|
|
70
|
+
- **Zoom and reflow:** the widget's chat fills the screen at 480 CSS pixels and narrower, which covers phones and a desktop page zoomed to 400%.
|
|
71
|
+
|
|
72
|
+
## Known limitations
|
|
73
|
+
|
|
74
|
+
- **Screen readers aren't tested by hand.** Problems found with VoiceOver, NVDA or TalkBack are fixed as bugs; please report them.
|
|
75
|
+
- **On a wide screen, the open chat floats over your page.** It is a non-modal dialog in a corner. If a visitor tabs out of it into your page, the element that gets focus may sit behind the chat (2.4.11). Escape closes it while focus is in the chat, and the launcher closes it from the page. A chat that fills the screen doesn't have this problem, since focus stays in it.
|
|
76
|
+
- **The launcher can cover your page's content.** It is fixed to a corner of the window, so an element of your page that scrolls under it can be partly hidden when it gets focus. Leave room for it at the bottom of your page, or move it with `::part(launcher)` ([Styling](styling.md)).
|
|
77
|
+
- **The finished answer is announced in full.** A long answer is long to listen to; a screen reader's own "stop speaking" key interrupts it. Its copy stays in the hidden region until the next answer, so reading the whole page in order meets the latest answer twice.
|
|
78
|
+
- **Answers in another language** than the chat's are not marked with their own `lang`, so a screen reader may read them with the wrong voice (3.1.2).
|
|
79
|
+
- **Dictation needs a microphone.** Typing always works instead.
|
|
80
|
+
|
|
81
|
+
## Feedback
|
|
82
|
+
|
|
83
|
+
Found an accessibility problem? Please [open an issue](https://github.com/boldare/askdare/issues) with the browser, the assistive technology and what happened. Problems that block a visitor are fixed first.
|
package/docs/cli.md
CHANGED
|
@@ -113,22 +113,23 @@ Without `--env-file`, `doctor` reads the environment the way `next dev` does: va
|
|
|
113
113
|
|
|
114
114
|
| Check | Passes when | The key permission it names when it fails |
|
|
115
115
|
| --- | --- | --- |
|
|
116
|
-
| Model | The bot's model is available to the OpenAI project. A key that may not look up models gives a warning instead. | List models: Read |
|
|
116
|
+
| Model | The bot's model is available to the OpenAI project. A key that may not look up models gives a warning instead. So does a model OpenAI has announced a shutdown for: the warning gives the date from the OpenAI API and links to the [deprecations page](https://developers.openai.com/api/docs/deprecations), which names the replacement. | List models: Read |
|
|
117
117
|
| Responses | The key can create a 16-token response with the bot's model. | Responses API: Write |
|
|
118
118
|
| Conversations | The key can create and delete a conversation. | Write access to conversations |
|
|
119
119
|
| Knowledge base | Only with `knowledge`: the vector store exists in the project and hasn't expired. A store without searchable documents, or with documents still indexing or failed, gives a warning. | Vector Stores: Read |
|
|
120
|
-
| Voice input | Only with `voice`: the transcription model is available, and the key can transcribe one second of silence. | Model capabilities: Request |
|
|
120
|
+
| Voice input | Only with `voice`: the transcription model is available, and the key can transcribe one second of silence. A transcription model with an announced shutdown gives a warning with the date, like the bot's model. | Model capabilities: Request |
|
|
121
121
|
| Attachments | Only with `attachments`: the key can upload and delete a small file. | Files: Write |
|
|
122
122
|
| Headers | `widget.js?bot=<id>` answers with JavaScript, and the chat page answers without a redirect, without `X-Frame-Options` and with exactly one `frame-ancestors`. It lists the sites that may embed the chat, and warns when something sets cookies. | |
|
|
123
123
|
| `--origin` | The site is the app itself or is in the bot's `security.allowedOrigins`. | |
|
|
124
124
|
| Your own page | Only with `embedPath`: the chat page redirects to it, and the page answers without a redirect (a login or a `proxy.ts` rewrite), renders `EmbedRoot`, has exactly one `frame-ancestors` that lists the app and every allowed origin and nothing more, and keeps the microphone off for a bot without voice input. The fixes name `embedPageHeaders`. | |
|
|
125
125
|
| Timeout | The route's `maxDuration` is at least the bot's `limits.turnTimeoutMs` plus 15 seconds. Otherwise it's a warning. | |
|
|
126
|
+
| AI notice | A bot with `widget.disclosure: false` gets an information line, neither a warning nor a problem: fine when your page already tells visitors they are talking to an AI ([Compliance](compliance.md#1-telling-visitors-they-talk-to-an-ai)). | |
|
|
126
127
|
|
|
127
128
|
`doctor` also says when OpenAI rejects the key, or when the project is out of credit. Each run makes a few small OpenAI requests per bot, and everything it creates is deleted straight away. The app accepts one run at a time, and at most 3 a minute.
|
|
128
129
|
|
|
129
130
|
### Output
|
|
130
131
|
|
|
131
|
-
`✓` is fine, `!` is a warning and `✗` is a problem. A line starting with `→` says what to do:
|
|
132
|
+
`✓` is fine, `i` is information, `!` is a warning and `✗` is a problem. A line starting with `→` says what to do:
|
|
132
133
|
|
|
133
134
|
```text
|
|
134
135
|
askdare doctor
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Compliance
|
|
2
|
+
|
|
3
|
+
This page lists what the law asks of a chatbot on a public website, what askdare does about each point, and which decisions stay with you. It names the laws and cites them, but **it isn't legal advice**. Whether a rule applies to you, and whether askdare's defaults are enough, depends on your role, your site and your users. Check with your legal advisers.
|
|
4
|
+
|
|
5
|
+
Legal texts and OpenAI's terms were checked on 2026-11-21 against the sources at the [end of this page](#sources). Both change: check the sources again before you rely on a date or a limit.
|
|
6
|
+
|
|
7
|
+
## At a glance
|
|
8
|
+
|
|
9
|
+
| Topic | What askdare does | What you decide |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| [Telling visitors they talk to an AI](#1-telling-visitors-they-talk-to-an-ai) (AI Act, art. 50(1)) | A note under the message field, on by default | Keep it, word it, or turn it off when your page already says so |
|
|
12
|
+
| [Personal data](#2-personal-data-gdpr) (GDPR) | Stores nothing on your server but rate-limit counters; sends a pseudonym, not an identity, to OpenAI; lets visitors delete their conversation | Your privacy notice, the DPA with OpenAI, a retention policy for conversations |
|
|
13
|
+
| [Data residency](#3-data-residency) | Uses OpenAI's global endpoints | Whether OpenAI's regional options are enough, or you wait for own storage (0.6) |
|
|
14
|
+
| [The conversation handle in the browser](#4-the-conversation-handle-in-the-browser) | Keeps it in the widget's iframe | Whether to show the chat inside your own pages |
|
|
15
|
+
| [Accessibility](#5-accessibility) (European Accessibility Act) | Targets WCAG 2.2 AA | Your site's own conformance |
|
|
16
|
+
| [Moderation and guardrails](#6-moderation-and-guardrails) | Opt-in OpenAI moderation, hooks to block or redact messages and answers, untrusted tool results | Which of them your bot needs, and what blocked visitors see |
|
|
17
|
+
| [Bot protection](#7-bot-protection) | Rate limits and daily budgets by default; an optional human check with Cloudflare Turnstile | Whether your chat needs the human check, and naming Cloudflare in your privacy notice if it does |
|
|
18
|
+
| [Hosting](#8-hosting-outside-vercel-and-heroku) | Supports the Node.js runtime only | Where it runs, and that host's logs |
|
|
19
|
+
|
|
20
|
+
## 1. Telling visitors they talk to an AI
|
|
21
|
+
|
|
22
|
+
**The rule.** Under Article 50(1) of the AI Act, AI systems that interact directly with people must be designed so that those people are informed they are interacting with an AI system, unless that is obvious to a reasonably well-informed person in the context. Article 50(5) says the information must be clear and distinguishable, given at the latest at the first interaction, and accessible. Article 50 applies from 2 August 2026 (Article 113). The Digital Omnibus on AI, Regulation (EU) 2026/1744, moved the high-risk rules to 2 December 2027 and 2 August 2028; it didn't change Article 50(1) or its date.
|
|
23
|
+
|
|
24
|
+
The duty in Article 50(1) is the provider's: whoever develops the system, or has it developed, and puts it into service under its own name. When you put a bot on your site with your instructions, your legal advisers will tell you whether that is you.
|
|
25
|
+
|
|
26
|
+
**What askdare does.** By default, the chat shows "You’re chatting with an AI assistant. It can make mistakes." under the message field, before the visitor writes anything.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
defineBot({
|
|
30
|
+
// …
|
|
31
|
+
widget: {
|
|
32
|
+
disclosure: { privacyUrl: '/privacy' }, // adds a "Privacy policy" link
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
- You can change the wording with `widget.texts` (`disclosure.text`, `disclosure.privacy`). See [Styling](styling.md#1-configuration) and [Texts](texts.md).
|
|
38
|
+
- `disclosure: false` hides it. Do that only when your page already tells visitors they are talking to an AI.
|
|
39
|
+
- **If you build your own markup** with the primitives of `@boldare/askdare/react` ([React](react.md#your-own-markup)), or show your own page in the widget's iframe ([Embedding](embedding.md#your-own-page-in-the-iframe)), place it with the `Disclosure` primitive, which follows the same `widget.disclosure` setting and texts. In development, `Root` and `EmbedRoot` note once in the console when the chat rendered without a `Disclosure`, and `askdare doctor` lists each bot with `disclosure: false` as information, not a failure. Neither forces the notice on you: `disclosure: false` silences both.
|
|
40
|
+
|
|
41
|
+
**Marking of generated content.** Article 50(2) asks providers of systems that generate synthetic text, images, audio or video to mark the outputs in a machine-readable format. askdare doesn't add such marks to answers. Systems on the market before 2 August 2026 have until 2 December 2026 (Article 111(4), added by the Digital Omnibus). Whether Article 50(2) covers a chat's answers, and who carries it, is a question for your legal advisers; the codes of practice under Article 50(7) are where the practice is being worked out.
|
|
42
|
+
|
|
43
|
+
## 2. Personal data (GDPR)
|
|
44
|
+
|
|
45
|
+
[Privacy](privacy.md) lists every piece of data the chat handles, where it goes and how long it stays. This section covers the decisions it leaves to you.
|
|
46
|
+
|
|
47
|
+
### Roles and the DPA
|
|
48
|
+
|
|
49
|
+
- For the chat on your site, you decide why and how visitors' data is processed, so you are usually the controller. OpenAI processes it on your behalf, as a processor (GDPR, Article 28).
|
|
50
|
+
- OpenAI's [Data Processing Addendum](https://openai.com/policies/data-processing-addendum/) covers API customers. For customers in the EEA or Switzerland the contracting party is OpenAI Ireland Ltd. Transfers out of the EEA rely on the EU standard contractual clauses or an adequacy decision (Articles 45 and 46). Make sure it applies to the OpenAI organization whose key the app uses.
|
|
51
|
+
- Upstash, if you use `@boldare/askdare-upstash`, and your hosting provider process data too. See [Subprocessors](privacy.md#subprocessors).
|
|
52
|
+
|
|
53
|
+
### Retention and deletion
|
|
54
|
+
|
|
55
|
+
Storage limitation (Article 5(1)(e)) means keeping data no longer than you need it. Here is what lasts how long:
|
|
56
|
+
|
|
57
|
+
| What | Kept | How it ends |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| Conversations (messages, answers, page context, tool calls and results) | Until deleted | The visitor's "Start a new conversation", which deletes it at OpenAI. Nothing else deletes it |
|
|
60
|
+
| Stored model responses | 30 days by default, according to OpenAI | OpenAI deletes them |
|
|
61
|
+
| Abuse-monitoring logs at OpenAI | Up to 30 days, longer where the law requires it | OpenAI deletes them |
|
|
62
|
+
| Uploaded images and PDFs | 30 days | They expire, or are deleted with their conversation |
|
|
63
|
+
| Rate-limit counters with IP addresses | Up to 2 days | They expire |
|
|
64
|
+
|
|
65
|
+
- **Conversations outlive the browser's handle.** When the handle expires after 30 days, or the visitor clears the browser, the conversation stays in your OpenAI project. askdare keeps no list of conversations, and OpenAI's API can't list them, so askdare has no tool to find or delete one person's conversation later (right to erasure, Article 17). Decide how you will answer such a request, and say in your notice how visitors delete a conversation themselves.
|
|
66
|
+
- **Zero Data Retention isn't available.** OpenAI lists the Conversations API as not eligible, and askdare needs it ([ADR-0003](https://github.com/boldare/askdare/blob/main/docs/adr/0003-conversation-state.md)).
|
|
67
|
+
- Own storage, planned for 0.6, will let you keep conversations in your database and set their retention yourself.
|
|
68
|
+
|
|
69
|
+
### `safety_identifier`
|
|
70
|
+
|
|
71
|
+
Every model request carries a `safety_identifier`, which OpenAI uses to trace abuse to one end user instead of your whole project. It is an HMAC of the random visitor ID, or of your user ID for a [signed-in visitor](identity.md), keyed with a secret derived from `CHAT_SECRET`. It holds no name, email or IP address. It is still a pseudonym, not anonymous data: with the secret, it can be linked back. See [Privacy](privacy.md#safety_identifier).
|
|
72
|
+
|
|
73
|
+
### Your privacy notice
|
|
74
|
+
|
|
75
|
+
Visitors must be told who processes their data, for what, and for how long (Article 13). Work through [the checklist in Privacy](privacy.md#for-your-privacy-notice), and link the notice from the AI note with `widget.disclosure.privacyUrl`.
|
|
76
|
+
|
|
77
|
+
### Storage in the visitor's browser
|
|
78
|
+
|
|
79
|
+
The chat writes one `localStorage` entry after the visitor's first message, and a second one when they rate an answer. It sets no cookies. Whether these need consent under Article 5(3) of the ePrivacy Directive, which exempts storage strictly necessary for a service the user asked for, is your call: [Consent banners](privacy.md#consent-banners) lists the facts that matter.
|
|
80
|
+
|
|
81
|
+
## 3. Data residency
|
|
82
|
+
|
|
83
|
+
OpenAI offers [data residency](https://developers.openai.com/api/docs/guides/data-residency) per project, in several regions, Europe (EEA and Switzerland) among them:
|
|
84
|
+
|
|
85
|
+
- It is available to eligible organizations after contacting OpenAI's sales team. A project's region is chosen when the project is created and can't be changed later.
|
|
86
|
+
- Requests go to a regional domain, such as `eu.api.openai.com`.
|
|
87
|
+
- Models released on or after 5 March 2026 cost 10% more on data residency endpoints.
|
|
88
|
+
- It covers Customer Content at rest for the endpoints OpenAI lists, and processing where the region supports it. System data, such as account and usage data, may still be stored and processed elsewhere.
|
|
89
|
+
|
|
90
|
+
**What that means for askdare.** askdare stores conversations with OpenAI's Conversations API (`/v1/conversations`), and OpenAI's list of endpoints eligible for data residency doesn't include it. A residency project therefore doesn't keep askdare's conversations in your region. askdare also uses OpenAI's global endpoint and isn't tested against regional ones.
|
|
91
|
+
|
|
92
|
+
If you need conversations stored in a given region, wait for own storage in 0.6: conversations kept in your own database, with only model requests going to OpenAI. The [roadmap](https://github.com/boldare/askdare/blob/main/ROADMAP.md) has the details.
|
|
93
|
+
|
|
94
|
+
## 4. The conversation handle in the browser
|
|
95
|
+
|
|
96
|
+
To show a conversation again after a reload, the chat keeps a resume token in `localStorage`. It is encrypted, the browser can't read what's inside, and it works for 30 days after the last answer. Whoever holds it can continue that conversation and see its history. A signed-in visitor's conversation also needs that user's identity token.
|
|
97
|
+
|
|
98
|
+
Where it sits decides who can read it:
|
|
99
|
+
|
|
100
|
+
| How the chat is shown | Where the token sits | Who else can read it |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| The script-tag widget, and your own page in its iframe | The iframe's storage, on your askdare app's origin | No script of the host site: the browser keeps origins apart, and the iframe's strict Content Security Policy keeps foreign scripts out of the chat |
|
|
103
|
+
| The chat inside your page (`Root`, `DefaultChat` from `@boldare/askdare/react`) | Your page's own storage, next to your other entries | Every script on that page, including an XSS on your app, tag managers and third-party tags. It can also read the conversation on screen and, for signed-in visitors, the identity token in the page |
|
|
104
|
+
|
|
105
|
+
An attacker who copies the token can continue the conversation from anywhere and read it, until the token expires or the visitor starts a new conversation. This is the trade-off of a chat inside your page: no iframe between your page's scripts and the chat. It is in the [threat model](https://github.com/boldare/askdare/blob/main/THREAT_MODEL.md) as T3 and T23.
|
|
106
|
+
|
|
107
|
+
- On pages that run scripts you don't fully trust (ads, tag managers with third-party tags), use the widget.
|
|
108
|
+
- Give pages with the chat inside them a strict Content Security Policy ([React](react.md#content-security-policy)).
|
|
109
|
+
- If you suspect a leak, rotate `CHAT_SECRET` without `CHAT_SECRET_PREVIOUS`: every resume token stops working at once, and visitors start new conversations ([Rotating secrets](privacy.md#rotating-secrets)).
|
|
110
|
+
- Mention the entry in your privacy notice either way.
|
|
111
|
+
|
|
112
|
+
## 5. Accessibility
|
|
113
|
+
|
|
114
|
+
The [European Accessibility Act](https://eur-lex.europa.eu/eli/dir/2019/882/oj/eng) (Directive (EU) 2019/882) applies from 28 June 2025. Among other services, it covers e-commerce services offered to consumers; microenterprises that provide services are exempt (Article 4(5)). The harmonised standard, ETSI EN 301 549, moved to WCAG 2.2 in version V4.1.1 (2026-09).
|
|
115
|
+
|
|
116
|
+
askdare's widget and default skin target WCAG 2.2 AA, and every change runs axe with the WCAG 2.2 AA rules in Chromium, Firefox and WebKit and on a phone viewport ([Support](support.md)). The dated conformance statement, with its scope, method, the manual review and the known limitations, is [Accessibility](accessibility.md). If you build your own markup or restyle the chat, its accessibility is yours to check.
|
|
117
|
+
|
|
118
|
+
## 6. Moderation and guardrails
|
|
119
|
+
|
|
120
|
+
OpenAI's own safety systems apply to every bot. On top of them, askdare offers three server-side controls, all off by default ([ADR-0019](https://github.com/boldare/askdare/blob/main/docs/adr/0019-compliance-and-guardrails.md)):
|
|
121
|
+
- **`moderation`:** OpenAI moderation of visitors' messages, of answers, or both, with the categories that block and the text visitors see as options.
|
|
122
|
+
- **`onInput` and `onOutput`:** your own rules, which allow, block or redact a message before the model sees it, or an answer before the visitor does. While answers are checked, they are held back until complete, so a blocked one never reaches the browser.
|
|
123
|
+
- **`toolResults: 'untrusted'`:** tool results reach the model marked as third-party data, which hardens tools that return text from outside your control against prompt injection.
|
|
124
|
+
|
|
125
|
+
A blocked turn ends with the `content_blocked` error, and nothing blocked or redacted is logged as content. Which controls a bot needs, and how strict they are, is your decision: see [Guardrails](guardrails.md).
|
|
126
|
+
|
|
127
|
+
## 7. Bot protection
|
|
128
|
+
|
|
129
|
+
By default, rate limits and daily token budgets bound what an abuser can spend ([Going public](going-public.md#3-bot-configuration), [Costs](costs.md)). Two options make that stricter, and both are off until you turn them on ([ADR-0019](https://github.com/boldare/askdare/blob/main/docs/adr/0019-compliance-and-guardrails.md)):
|
|
130
|
+
|
|
131
|
+
- **A human check.** With `security.humanVerifier: turnstile({ siteKey })`, visitors pass Cloudflare Turnstile before a chat session starts, and the server checks the token with Cloudflare ([Configuration](configuration.md#human-check)). Turnstile runs Cloudflare's script in the chat, with the chat's access to the page it runs in (the widget's iframe, or your own page for a chat inside it), and sends Cloudflare data about the visitor's browser, including the IP address, so Cloudflare becomes a processor to name in your privacy notice. Anonymous visitors meet the check at their first action (a message, an upload, or loading a stored conversation); on a page that signs visitors in with `askdare('identify')`, the check shows as the chat loads. Whether the check needs consent where you operate, for example under the ePrivacy rules on reading from a visitor's device, is for your legal advisers. askdare never sends Cloudflare the conversation or the visitor's identity.
|
|
132
|
+
- **Shared counters required.** With `limits: { requireSharedStore: true }`, the route refuses to start without a shared store, so limits can't silently become per instance ([Custom rate-limit store](custom-store.md#the-shared-flag)).
|
|
133
|
+
|
|
134
|
+
## 8. Hosting outside Vercel and Heroku
|
|
135
|
+
|
|
136
|
+
askdare is tested on Vercel and Heroku. Other hosts that run a Next.js app on Node.js should work, but aren't tested ([Support](support.md)). Whatever the host, it receives every request, with the visitor's IP address, and keeps logs by its own settings: name it in your privacy notice.
|
|
137
|
+
|
|
138
|
+
**What the host has to provide:**
|
|
139
|
+
|
|
140
|
+
- **The Node.js runtime,** Node.js 22 or 24.
|
|
141
|
+
- **Streaming without buffering.** Answers arrive as `text/event-stream`; a proxy that buffers them delivers each answer at once at the end. askdare sends `X-Accel-Buffering: no` for nginx.
|
|
142
|
+
- **Long requests.** An answer can take up to the bot's `limits.turnTimeoutMs`, 120 seconds by default. The host and every proxy in front of it must keep the connection open that long. askdare sends a byte every 15 seconds, so idle timeouts above that are enough.
|
|
143
|
+
- **A proxy that sets `X-Forwarded-For`.** Never expose `next start` directly to the internet: clients could then choose their own IP and per-IP limits stop working. Set `limits.trustProxy` to the number of proxies in front of the app ([Deployment](deployment.md#behind-another-proxy-or-cdn)).
|
|
144
|
+
- **A shared store for limits** when more than one instance serves traffic ([Going public](going-public.md#4-rate-limits-across-instances)).
|
|
145
|
+
|
|
146
|
+
**Docker or a VM with `next start`.** Run `next build` and `next start` (or the standalone output) behind nginx, Caddy or a load balancer that sets `X-Forwarded-For` and doesn't buffer the stream. One container works with the default in-memory limits; with several, use a shared store.
|
|
147
|
+
|
|
148
|
+
**OpenNext.** On AWS Lambda, the function must run on Node.js with response streaming on, and with a timeout longer than `turnTimeoutMs`, at every layer in front of it as well. Every concurrent Lambda instance has its own memory, so use a shared store. The Cloudflare adapter runs the app on Workers, which isn't Node.js: it isn't supported.
|
|
149
|
+
|
|
150
|
+
**Edge runtimes won't work.** askdare supports only the Node.js runtime. Don't set `export const runtime = 'edge'` on the chat route, and don't deploy it to a platform that runs only edge or worker functions.
|
|
151
|
+
|
|
152
|
+
## Sources
|
|
153
|
+
|
|
154
|
+
- AI Act: [Regulation (EU) 2024/1689](https://eur-lex.europa.eu/eli/reg/2024/1689/oj/eng), Articles 3(3), 50, 111 and 113; [consolidated text of 27 July 2026](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:02024R1689-20260727).
|
|
155
|
+
- Digital Omnibus on AI: [Regulation (EU) 2026/1744](https://eur-lex.europa.eu/eli/reg/2026/1744/oj/eng), in force since 27 July 2026.
|
|
156
|
+
- GDPR: [Regulation (EU) 2016/679](https://eur-lex.europa.eu/eli/reg/2016/679/oj/eng), Articles 5, 13, 17, 28, 45 and 46.
|
|
157
|
+
- ePrivacy Directive: [Directive 2002/58/EC](https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:02002L0058-20091219), Article 5(3), as amended by Directive 2009/136/EC.
|
|
158
|
+
- European Accessibility Act: [Directive (EU) 2019/882](https://eur-lex.europa.eu/eli/dir/2019/882/oj/eng), Articles 2, 4(5) and 31.
|
|
159
|
+
- [ETSI EN 301 549 V4.1.1 (2026-09)](https://www.etsi.org/deliver/etsi_en/301500_301599/301549/04.01.01_60/en_301549v040101p.pdf), Accessibility requirements for ICT products and services.
|
|
160
|
+
- OpenAI: [Data Processing Addendum](https://openai.com/policies/data-processing-addendum/), [Data controls](https://developers.openai.com/api/docs/guides/your-data), [Data residency](https://developers.openai.com/api/docs/guides/data-residency), [Safety best practices](https://developers.openai.com/api/docs/guides/safety-best-practices#implement-safety-identifiers).
|
package/docs/configuration.md
CHANGED
|
@@ -85,6 +85,10 @@ export const { GET, POST, DELETE } = createChatHandler({
|
|
|
85
85
|
| `knowledge` | `KnowledgeConfig` | off | Documents the model searches and cites. See [Knowledge](#knowledge). |
|
|
86
86
|
| `attachments` | `AttachmentConfig` | off | Images and PDFs from visitors. See [Attachments](#attachments). |
|
|
87
87
|
| `voice` | `VoiceConfig` | off | Dictation. See [Voice](#voice). |
|
|
88
|
+
| `moderation` | `ModerationConfig` | off | OpenAI moderation of messages, answers or both. See [Guardrails](guardrails.md#moderation). |
|
|
89
|
+
| `onInput` | `(text, context) => GuardVerdict \| undefined` | off | Your rule for each visitor message: allow, block or redact. See [Guardrails](guardrails.md#your-own-rules-oninput-and-onoutput). |
|
|
90
|
+
| `onOutput` | `(text, context) => GuardVerdict \| undefined` | off | Your rule for each finished answer. Answers are then held back until checked. See [Guardrails](guardrails.md#streaming-while-answers-are-checked). |
|
|
91
|
+
| `toolResults` | `'trusted' \| 'untrusted'` | `'trusted'` | `'untrusted'` marks tool results as third-party data for the model. See [Guardrails](guardrails.md#untrusted-tool-results). |
|
|
88
92
|
| `security` | `BotSecurity` | own origin only | Sites that may embed the chat. See [Security](#security). |
|
|
89
93
|
| `embedPath` | `string` | off: askdare's own page | A page of this app to show in the widget's iframe instead of askdare's, such as `/askdare/support`. A path of the app, outside the chat route, without a query, a fragment or `.`/`..` segments. See [Your own page in the iframe](#your-own-page-in-the-iframe). |
|
|
90
94
|
| `limits` | `BotLimits` | see [Limits](#limits) | Rates and budgets. |
|
|
@@ -151,6 +155,45 @@ The list holds at most 50 origins. Duplicates are dropped. A wrong entry fails w
|
|
|
151
155
|
|
|
152
156
|
To check that a site may embed the chat, run `npx @boldare/askdare doctor --origin https://www.example.com`.
|
|
153
157
|
|
|
158
|
+
#### Human check
|
|
159
|
+
|
|
160
|
+
`security.humanVerifier` asks visitors to pass a human check before a new chat session starts ([ADR-0019](https://github.com/boldare/askdare/blob/main/docs/adr/0019-compliance-and-guardrails.md), [ADR-0023](https://github.com/boldare/askdare/blob/main/docs/adr/0023-human-check-and-react-budget.md)). It is off when absent, and a bot without it works as before. askdare ships one verifier, for [Cloudflare Turnstile](https://developers.cloudflare.com/turnstile/):
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
import { defineBot, turnstile } from '@boldare/askdare';
|
|
164
|
+
|
|
165
|
+
defineBot({
|
|
166
|
+
// …
|
|
167
|
+
security: {
|
|
168
|
+
allowedOrigins,
|
|
169
|
+
// The site key is public; the secret key comes from TURNSTILE_SECRET_KEY.
|
|
170
|
+
humanVerifier: turnstile({ siteKey: '0x4AAAAAAA…' }),
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| `turnstile()` option | Type | Default | Notes |
|
|
176
|
+
| --- | --- | --- | --- |
|
|
177
|
+
| `siteKey` | `string` | required | The widget's site key from the Cloudflare dashboard. Browsers receive it. |
|
|
178
|
+
| `secretKey` | `string` | `process.env.TURNSTILE_SECRET_KEY` | The widget's secret key, read at the first check, so `next build` doesn't need it. Never commit it. |
|
|
179
|
+
| `hostnames` | `string[]` | not checked | Host names the challenge may have been solved on, compared with siteverify's `hostname`: your chat route's app, such as `['www.example.com']`. Off by default: the widget's hostname list in the Cloudflare dashboard already limits where it runs, and a proxy that serves the app under another name would be refused. |
|
|
180
|
+
|
|
181
|
+
How it works:
|
|
182
|
+
|
|
183
|
+
- When the chat needs a new session (the first message, a stored conversation to load, an upload), it shows the Turnstile widget in the chat (`HumanCheck`, part `human-check`) and waits for its token. In Turnstile's managed mode most visitors only see it for a moment. A page that calls `askdare('identify')` with a token (or `Root` with `identity`) opens the session at once, to find that user's conversation, so signed-in visitors see the check as the chat loads; anonymous visitors see it at their first action.
|
|
184
|
+
- Turnstile retries a failed challenge or a network error by itself, every 8 seconds; the chat gives up at the third error and shows `error.humanCheck`.
|
|
185
|
+
- `POST /session` sends the token to Cloudflare's siteverify endpoint, after the session rate limit. A token that fails, has expired or was already used answers `unauthorized`, with the text `error.humanCheck`; the next message shows a new challenge.
|
|
186
|
+
- The chat renders the widget with the bot's id as Turnstile's `action` (cut to 32 characters), and the server refuses a token whose `action` differs, such as one solved for another bot or another widget on the same site key. Cloudflare's test secret keys return no `action` and the hostname `example.com`, so with them neither the action nor `hostnames` is checked.
|
|
187
|
+
- Renewing a live session (an access token at most an hour past its expiry) needs no new check, for **24 hours** after the check was passed. Then, and for sessions that never passed one (such as sessions from before the bot turned the check on), the visitor passes it again and keeps their session. A visitor who comes back later with a stored conversation passes the check again.
|
|
188
|
+
- If Cloudflare can't be reached, or rejects the secret key, the session is refused (`upstream_error` or `bot_unavailable`) and `onError` receives it: the check fails closed.
|
|
189
|
+
- The iframe's Content Security Policy adds `https://challenges.cloudflare.com` to `script-src` and `frame-src`, for this bot only ([Embedding](embedding.md#what-your-app-sends-back)). The loader on the host page doesn't change.
|
|
190
|
+
- A chat inside your page (`Root`, `DefaultChat`) or your own page in the iframe (`embedPath`) runs under your page's policy: allow the same origin there. A headless chat must render `HumanCheck`, or it can't connect; the console says so.
|
|
191
|
+
- **Cloudflare's script runs with your app's access.** `api.js` is loaded from `challenges.cloudflare.com` into the chat's document: the iframe, on your app's origin, or your own page for a chat inside it. There it can do what your own scripts can, such as read the conversation on screen and the resume token in storage. Cloudflare changes the script without notice, so it can't carry Subresource Integrity, and askdare loads it without. Turning the check on means trusting Cloudflare with that.
|
|
192
|
+
|
|
193
|
+
Test it with Cloudflare's [test keys](https://developers.cloudflare.com/turnstile/troubleshooting/testing/), such as the site key `1x00000000000000000000AA` with the secret key `1x0000000000000000000000000000000AA`, which always pass.
|
|
194
|
+
|
|
195
|
+
To check tokens another way, pass your own object with the `HumanVerifier` type: `challenge` is what the chat renders (only `{ provider: 'turnstile', siteKey }` in 0.5), and `verify(token, { botId, signal })` resolves `true` for a person and `false` for a token that fails. Throw when the check can't run; the session is then refused.
|
|
196
|
+
|
|
154
197
|
### Your own page in the iframe
|
|
155
198
|
|
|
156
199
|
By default the widget's iframe shows askdare's own page, which needs nothing from you. With `embedPath`, it shows a page of your app instead, so the widget on other sites can use your own components and [tool cards](react.md#tool-cards) ([ADR-0018](https://github.com/boldare/askdare/blob/main/docs/adr/0018-embed-path.md)). The chat route redirects the iframe to that path, with the visitor's language (`lang`, for a bot with `locale: 'auto'`) and the mode (`mode=inline`) in the query; the loader on the embedding site doesn't change. The redirect goes to `embedPath` exactly as you write it, so in an app with `basePath` in `next.config.ts` include that prefix (`/help/askdare/support`).
|
|
@@ -225,7 +268,7 @@ Everything in `widget` is sent to browsers. Never put secrets in it. [Styling](s
|
|
|
225
268
|
| `colorScheme` | `'auto' \| 'light' \| 'dark'` | `'auto'` | `'auto'` follows the visitor's system setting. |
|
|
226
269
|
| `css` | `string` | none | Your own CSS, up to 50,000 characters. It loads after the theme. |
|
|
227
270
|
|
|
228
|
-
The text defaults come from the built-in dictionary of the configured language. The table shows the English ones, which `'auto'` also uses. Texts ship in English and Polish.
|
|
271
|
+
The text defaults come from the built-in dictionary of the configured language. The table shows the English ones, which `'auto'` also uses. Texts ship in English, Czech, German, Spanish, French, Italian and Polish.
|
|
229
272
|
|
|
230
273
|
## `createChatHandler`
|
|
231
274
|
|
|
@@ -233,7 +276,7 @@ The text defaults come from the built-in dictionary of the configured language.
|
|
|
233
276
|
|
|
234
277
|
| Option | Type | Default | Notes |
|
|
235
278
|
| --- | --- | --- | --- |
|
|
236
|
-
| `bots` | `readonly
|
|
279
|
+
| `bots` | `readonly BotHandle[]` | required | At least one bot from `defineBot`. IDs must be unique. |
|
|
237
280
|
| `basePath` | `string` | `'/api/chat'` | Path of the catch-all route. One or more segments of letters, digits, `.`, `_`, `~` or `-`, each after a `/`. No trailing slash. |
|
|
238
281
|
| `openaiApiKey` | `string` | `process.env.OPENAI_API_KEY` | The OpenAI API key. |
|
|
239
282
|
| `secret` | `string` | `process.env.CHAT_SECRET` | Encrypts session tokens and attachment handles. At least 32 characters, with at least 12 different ones. Use `openssl rand -base64 32`. |
|
|
@@ -256,6 +299,7 @@ A wrong `basePath`, a duplicate bot ID or an empty `bots` list throws a `TypeErr
|
|
|
256
299
|
| `store` | `RateLimitStore` | in memory, per process | Counter storage for rate limits and budgets. With more than one instance, use a shared store such as `@boldare/askdare-upstash`. See [Custom rate-limit store](custom-store.md). |
|
|
257
300
|
| `trustProxy` | `'auto' \| 'vercel' \| 'heroku' \| number` | `'auto'` | How to read the client IP behind your proxy. |
|
|
258
301
|
| `globalDailyTokens` | `number` | unlimited | Input plus output tokens per UTC day, across all bots of this handler. Reaching it answers `budget_exceeded`. |
|
|
302
|
+
| `requireSharedStore` | `boolean` | `false` | `true` makes `createChatHandler` throw as the route loads unless `store` is shared (`shared: true`), instead of only warning in production. For example `process.env.NODE_ENV === 'production'`, so development keeps the in-memory store. Note that `next build` loads the route with `NODE_ENV=production`. |
|
|
259
303
|
|
|
260
304
|
### `trustProxy`
|
|
261
305
|
|
|
@@ -394,6 +438,7 @@ It must be a literal in the route file. It is the longest a streamed answer may
|
|
|
394
438
|
| `CHAT_SECRET` | `createChatHandler`, `npx @boldare/askdare doctor` | Default for `secret`. Required. `doctor` signs its request to your app with it. |
|
|
395
439
|
| `CHAT_SECRET_PREVIOUS` | `createChatHandler`, `npx @boldare/askdare doctor` | Former secrets, comma-separated. Default for `previousSecrets`. |
|
|
396
440
|
| `IDENTITY_SECRET` | `createChatHandler`, `npx @boldare/askdare doctor` | Default for `identitySecret`. Optional: without it, identity is off. |
|
|
441
|
+
| `TURNSTILE_SECRET_KEY` | `turnstile()` | Default for `secretKey`, read at the first human check. Needed only for a bot with `security.humanVerifier: turnstile(…)`. |
|
|
397
442
|
| `ASKDARE_DISABLED` | `createChatHandler` | The kill switch. When it is exactly `true`, every bot answers `bot_unavailable`. askdare reads it on every request. |
|
|
398
443
|
| `KB_VECTOR_STORE_ID` | `npx @boldare/askdare kb sync` | The vector store to sync, unless you pass `--store`. |
|
|
399
444
|
| `ASKDARE_MODEL` | `npx @boldare/askdare doctor` | `doctor` reports it when it is missing or empty and your `askdare.config` uses it. The server doesn't read it; your config does. |
|
package/docs/costs.md
CHANGED
|
@@ -12,6 +12,7 @@ Prices change often, so this page counts tokens, seconds and files. To turn them
|
|
|
12
12
|
| Knowledge base | Retrieved chunks as input tokens, a fee per file search call, and vector store storage per GB per day above a free allowance | Only the tokens are in the budgets |
|
|
13
13
|
| Attachments | Images and PDF pages as input tokens, when they are sent | The token budgets, plus upload limits |
|
|
14
14
|
| Voice input | Transcription, per minute of audio (some models bill by tokens instead) | Daily speech budgets in seconds |
|
|
15
|
+
| Moderation | Nothing extra today: OpenAI's moderation endpoint is free. Each checked message adds one call and its latency | Only bots with `moderation` make the call |
|
|
15
16
|
| `askdare doctor` | A 16-token response, plus one second of transcription for bots with voice, per bot and run | 3 runs a minute for the whole app |
|
|
16
17
|
|
|
17
18
|
## The worst case under the default limits
|
|
@@ -154,7 +155,7 @@ The model decides most of the bill, which is why askdare never picks one for you
|
|
|
154
155
|
A conversation is stored by OpenAI, and every message sends the whole conversation to the model as input. Each message therefore costs more than the one before.
|
|
155
156
|
|
|
156
157
|
- `maxTurns` (default 50) ends a conversation: the visitor is asked to start a new one.
|
|
157
|
-
- askdare sends `truncation: 'auto'`. When a conversation outgrows the model's context window, OpenAI drops the oldest items instead of failing.
|
|
158
|
+
- askdare sends `truncation: 'auto'`. When a conversation outgrows the model's context window, OpenAI drops the oldest items instead of failing. OpenAI has deprecated the parameter but announced no shutdown date; askdare keeps sending it until then. If OpenAI ever refuses an overflowing conversation, the visitor sees "This conversation is too long. Please start a new one."
|
|
158
159
|
- askdare doesn't compact or summarize conversations. OpenAI's server-side compaction isn't planned for a release yet: in spikes [S5](https://github.com/boldare/askdare/blob/main/spikes/s5-compaction/README.md) and S5b it cut answers off, ran on every turn and lost prompt caching ([ADR-0003](https://github.com/boldare/askdare/blob/main/docs/adr/0003-conversation-state.md)).
|
|
159
160
|
- Attached files and your tools' results stay in the conversation, so every later message reads them again. Keep tool results small ([Tools](tools.md)).
|
|
160
161
|
|
|
@@ -189,6 +190,12 @@ The extra call counts against `maxSteps` and the budgets like a tool round: askd
|
|
|
189
190
|
- Every model call reads the files again. A bot with tools reserves the files once per call it actually makes, so a large PDF can mean the model answers without calling tools when the visitor's budget can't hold another call.
|
|
190
191
|
- Keep attachments off for bots that don't need them, and lower `maxPdfPages` if long PDFs aren't expected. See [Attachments](attachments.md).
|
|
191
192
|
|
|
193
|
+
## Moderation
|
|
194
|
+
|
|
195
|
+
- A bot with `moderation` makes one call to OpenAI's moderation endpoint per checked message: one before the turn for `check: 'input'`, one after the answer for `'output'`, two for `'both'`. Bots without it make none.
|
|
196
|
+
- The endpoint is free to use at the time of writing ([OpenAI's moderation guide](https://developers.openai.com/api/docs/guides/moderation)), so it adds latency, not tokens, and isn't in askdare's budgets. Check the pricing page again if that changes.
|
|
197
|
+
- Checking output holds each answer back until it is complete, so visitors wait longer before they see anything. A blocked answer has still spent its tokens, and they count against the budgets. See [Guardrails](guardrails.md).
|
|
198
|
+
|
|
192
199
|
## Voice input
|
|
193
200
|
|
|
194
201
|
- Transcription is billed per minute of audio for models that report a duration. askdare reserves `voice.maxSeconds` (default 60) per dictation and then charges the duration OpenAI reports.
|
package/docs/custom-store.md
CHANGED
|
@@ -59,6 +59,8 @@ askdare uses refunds to give back a reservation. A turn reserves an estimate aga
|
|
|
59
59
|
- When `shared` is `false` and `NODE_ENV` is `production`, `createChatHandler` logs a warning as the route loads: `[askdare] Rate limits are kept in memory, per instance. With more than one instance, use a shared store such as @boldare/askdare-upstash.`
|
|
60
60
|
- `npx @boldare/askdare doctor` warns that rate limits and budgets are kept per instance, unless the app runs in development.
|
|
61
61
|
|
|
62
|
+
With `limits: { requireSharedStore: true }`, `createChatHandler` throws instead, as the route loads, when the store's `shared` is `false` ([Handler limits](configuration.md#handler-limits)). Turn it on in production when per-instance limits would be a bug, not a trade-off.
|
|
63
|
+
|
|
62
64
|
Set `shared: true` only when every instance reaches the same counters, such as a database they all connect to. A store that keeps counters inside the process is `shared: false`, even if you wrote it.
|
|
63
65
|
|
|
64
66
|
## Example: PostgreSQL
|
package/docs/embedding.md
CHANGED
|
@@ -117,6 +117,8 @@ The chat page, `/api/chat/embed/<bot>`, answers with these headers:
|
|
|
117
117
|
| `X-Content-Type-Options` | `nosniff` |
|
|
118
118
|
| `Cache-Control` | `no-store` |
|
|
119
119
|
|
|
120
|
+
A bot with a human check (`security.humanVerifier`) also allows Cloudflare Turnstile in its own policy, and nothing else: `script-src 'self' https://challenges.cloudflare.com` and `frame-src https://challenges.cloudflare.com` ([Configuration](configuration.md#human-check)).
|
|
121
|
+
|
|
120
122
|
`frame-ancestors` decides who may embed the chat: `'self'`, which is your app, plus the bot's `security.allowedOrigins`. With `allowedOrigins: ['https://www.example.com']`, the header ends in `frame-ancestors 'self' https://www.example.com`. Browsers enforce it, so the list holds even if someone copies the snippet.
|
|
121
123
|
|
|
122
124
|
`widget.js` is served with `Cache-Control: public, max-age=300, stale-while-revalidate=86400`, or `no-cache` under `next dev`. A new button look can take a few minutes to show on other sites.
|
package/docs/feedback.md
CHANGED
|
@@ -165,6 +165,6 @@ To do several of these, call them one after another in a single `onFeedback`.
|
|
|
165
165
|
|
|
166
166
|
## Texts and styling
|
|
167
167
|
|
|
168
|
-
- **Texts:** `feedback.label`, `feedback.up`, `feedback.down`, `feedback.comment`, `feedback.send` and `feedback.skip`, in
|
|
168
|
+
- **Texts:** `feedback.label`, `feedback.up`, `feedback.down`, `feedback.comment`, `feedback.send` and `feedback.skip`, in every built-in language. Override them with `widget.texts` like any other ([Texts](texts.md)).
|
|
169
169
|
- **Parts:** `feedback` (the two buttons), `feedback-button` (with `data-rating="up"` or `"down"`, and `aria-pressed`), `feedback-comment`, `feedback-comment-input`, `feedback-comment-actions`, `feedback-skip` and `feedback-send` ([Styling](styling.md)).
|
|
170
170
|
- **In your own markup:** `FeedbackButton` from `@boldare/askdare/react`, and `actions.rate(messageId, rating, comment?)` with `state.commenting` for the question after a 👎.
|
package/docs/going-public.md
CHANGED
|
@@ -21,6 +21,7 @@ openssl rand -base64 32 # use the output as CHAT_SECRET
|
|
|
21
21
|
| `CHAT_SECRET` | yes | At least 32 random characters. Never commit it. |
|
|
22
22
|
| `CHAT_SECRET_PREVIOUS` | during rotation | Comma-separated former secrets |
|
|
23
23
|
| `IDENTITY_SECRET` | for signed-in visitors | Shared with your site's backend only; never in a page or in git |
|
|
24
|
+
| `TURNSTILE_SECRET_KEY` | for a human check | The Turnstile widget's secret key; see step 3 |
|
|
24
25
|
| `ASKDARE_DISABLED` | no | Set `true` to switch every bot off. It takes effect when the app restarts with the new value: on Vercel, redeploy; on Heroku, changing a config var restarts the dynos. |
|
|
25
26
|
|
|
26
27
|
**To rotate the secret:**
|
|
@@ -32,6 +33,8 @@ openssl rand -base64 32 # use the output as CHAT_SECRET
|
|
|
32
33
|
- **`security.allowedOrigins`:** the exact sites allowed to embed the widget, such as `https://www.example.com`. No paths and no wildcards. The app's own origin is always allowed.
|
|
33
34
|
- **`limits`:** start with the defaults and tune `dailyTokens` (per bot) and `dailyTokensPerIp` to your budget. Add `limits: { globalDailyTokens }` to `createChatHandler` to cap all bots together. These budgets are the main cost control; the OpenAI hard limit is the backstop.
|
|
34
35
|
- **Instructions:** they must contain **no secrets**. Assume visitors can make the model reveal them.
|
|
36
|
+
- **Guardrails:** decide whether the bot needs OpenAI moderation (`moderation`), your own rules for messages and answers (`onInput`, `onOutput`), or untrusted tool results (`toolResults: 'untrusted'`) for tools that return third-party text. All are off by default. See [Guardrails](guardrails.md).
|
|
37
|
+
- **Human check (optional):** limits bound what one address can spend, not what many addresses can. For a public chat that attracts scripted abuse, add `security.humanVerifier: turnstile({ siteKey })` and set `TURNSTILE_SECRET_KEY`. Visitors then pass Cloudflare Turnstile when a session starts ([Configuration](configuration.md#human-check)). Create the widget in the Cloudflare dashboard with your app's host name, not the sites that embed the chat: the challenge runs in the chat's iframe, on your app's origin. Name Cloudflare in your privacy notice.
|
|
35
38
|
|
|
36
39
|
## 4. Rate limits across instances
|
|
37
40
|
|
|
@@ -46,6 +49,12 @@ export const { GET, POST, DELETE } = createChatHandler({
|
|
|
46
49
|
});
|
|
47
50
|
```
|
|
48
51
|
|
|
52
|
+
To make sure a production deployment never runs with per-instance counters, add `requireSharedStore`. The route then refuses to load without a shared store, instead of logging a warning:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
limits: { store: upstashStore(), requireSharedStore: process.env.NODE_ENV === 'production' },
|
|
56
|
+
```
|
|
57
|
+
|
|
49
58
|
**Client IP:**
|
|
50
59
|
- The client IP comes from proxy headers. The default `trustProxy: 'auto'` detects Vercel and assumes one proxy otherwise, which matches Heroku.
|
|
51
60
|
- Behind additional proxies (a CDN in front of Heroku, for example), set `trustProxy` to the number of proxies.
|
|
@@ -67,16 +76,19 @@ export const { GET, POST, DELETE } = createChatHandler({
|
|
|
67
76
|
- Clients with data-residency or zero-retention requirements need the planned own-storage add-on.
|
|
68
77
|
- **Disclosures:**
|
|
69
78
|
- Publish a privacy notice that names OpenAI (and Upstash, if used) as processors.
|
|
70
|
-
- Tell visitors they are talking to an AI. The chat says so under the message field by default; add `widget.disclosure.privacyUrl` to link your privacy notice ([Styling](styling.md#1-configuration)).
|
|
79
|
+
- Tell visitors they are talking to an AI (EU AI Act, art. 50). The chat says so under the message field by default; add `widget.disclosure.privacyUrl` to link your privacy notice ([Styling](styling.md#1-configuration)). In your own markup, or your own page in the widget's iframe, place the `Disclosure` primitive ([React](react.md#your-own-markup)). `askdare doctor` lists bots with `disclosure: false`, so you can confirm each one is deliberate.
|
|
80
|
+
- **Compliance:** [Compliance](compliance.md) goes through the AI Act's disclosure duty, the GDPR (the DPA with OpenAI, retention and deletion), data residency, the resume token in a chat inside your page, accessibility and hosts other than Vercel and Heroku.
|
|
71
81
|
|
|
72
82
|
## 7. Final check
|
|
73
83
|
|
|
74
84
|
- [ ] Restricted key, model allowlist and a hard spend limit, with a tested alert.
|
|
75
85
|
- [ ] `CHAT_SECRET` is random, at least 32 characters, and not in git.
|
|
76
86
|
- [ ] `allowedOrigins` lists only your sites.
|
|
77
|
-
- [ ] Shared store configured if you run more than one instance.
|
|
87
|
+
- [ ] Shared store configured if you run more than one instance, and `requireSharedStore` on if that must never be forgotten.
|
|
88
|
+
- [ ] If the chat is public and anonymous, you decided whether it needs a human check, and tested it with Cloudflare's test keys.
|
|
78
89
|
- [ ] Instructions contain no secrets.
|
|
79
|
-
- [ ]
|
|
90
|
+
- [ ] Guardrails decided: moderation, `onInput`/`onOutput` and `toolResults` ([Guardrails](guardrails.md)).
|
|
91
|
+
- [ ] Privacy notice, retention decision and AI disclosure are in place, checked against [Compliance](compliance.md).
|
|
80
92
|
- [ ] If visitors rate answers, your notice covers their comments, and `onFeedback` keeps them no longer than you need.
|
|
81
93
|
- [ ] You know how to flip `ASKDARE_DISABLED=true` and redeploy or restart, and how long that takes on your host.
|
|
82
94
|
- [ ] `npx @boldare/askdare doctor --url <your app> --env-file <production env>` reports no problems ([Deployment](deployment.md)).
|