@boldare/askdare 0.5.0 → 0.5.2
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 +17 -0
- package/dist/events.d.ts +8 -2
- package/dist/next.d.ts +4 -1
- package/dist/next.js +91 -17
- package/dist/react-marked.js +883 -810
- package/dist/root.js +2 -2
- package/dist/ui/askdare.css +1 -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 +1 -1
- 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 +1 -1
- package/dist/ui/welcome.tsx +1 -1
- package/docs/configuration.md +4 -4
- package/docs/costs.md +9 -6
- package/docs/support.md +1 -1
- package/package.json +4 -4
package/dist/root.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { t as
|
|
2
|
+
import { t as w } from "./react-marked.js";
|
|
3
3
|
import { Component, createContext, memo, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/react/context.tsx
|
|
@@ -320,7 +320,7 @@ function block(token, key, depth) {
|
|
|
320
320
|
/** The text as paragraphs, when markdown can't be had. */
|
|
321
321
|
const plain = (text) => text.split(/\n{2,}/).map((paragraph, key) => /* @__PURE__ */ jsx("p", { children: paragraph }, key));
|
|
322
322
|
function lexAll(text) {
|
|
323
|
-
const tokens =
|
|
323
|
+
const tokens = w.lex(text, { gfm: true });
|
|
324
324
|
return {
|
|
325
325
|
text,
|
|
326
326
|
tokens,
|
package/dist/ui/askdare.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Ejected from @boldare/askdare@0.5.
|
|
1
|
+
/* Ejected from @boldare/askdare@0.5.2 with `npx @boldare/askdare add ui`. This copy is yours to change. */
|
|
2
2
|
/*
|
|
3
3
|
* Default skin of the chat (ADR-0008, ADR-0011), in the iframe and inside a page. Everything is
|
|
4
4
|
* built on the public styling API: the --ask-* tokens (set per bot by the theme stylesheet), the
|
package/dist/ui/avatar.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
3
|
import { useSkin } from './context';
|
|
4
4
|
import { SparkIcon } from './icons';
|
package/dist/ui/chat.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
4
|
// The entry of an ejected copy (`npx @boldare/askdare add ui`): the same DefaultChat as in
|
package/dist/ui/confirm.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import { useChat } from '@boldare/askdare/react';
|
|
3
3
|
import { type KeyboardEvent, type ReactElement, useEffect, useId, useRef } from 'react';
|
|
4
4
|
import { RestartIcon } from './icons';
|
package/dist/ui/context.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 with `npx @boldare/askdare add ui`. This copy is yours to change.
|
|
2
2
|
import type { ChatBot, Translate } from '@boldare/askdare/react';
|
|
3
3
|
import { type Context, createContext, type RefObject, useContext } from 'react';
|
|
4
4
|
|
package/dist/ui/feedback.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 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
package/dist/ui/header.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 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.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 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.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 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
package/dist/ui/welcome.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ejected from @boldare/askdare@0.5.
|
|
1
|
+
// Ejected from @boldare/askdare@0.5.2 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';
|
package/docs/configuration.md
CHANGED
|
@@ -219,8 +219,8 @@ Limits bound what visitors can cost ([ADR-0004](https://github.com/boldare/askda
|
|
|
219
219
|
| `messagesPerIpPerMinute` | `30` | Messages per client IP per minute, across visitors | 1–10,000 |
|
|
220
220
|
| `sessionsPerIpPerHour` | `30` | New sessions per client IP per hour. Renewals by returning visitors count separately. | 1–10,000 |
|
|
221
221
|
| `conversationsPerIpPerHour` | `20` | New conversations per client IP per hour | 1–10,000 |
|
|
222
|
-
| `dailyTokens` | `2_000_000` | Input plus output tokens per UTC day, across all visitors | 1,000 or more |
|
|
223
|
-
| `dailyTokensPerIp` | `200_000` | Input plus output tokens per client IP per UTC day | 100 or more |
|
|
222
|
+
| `dailyTokens` | `2_000_000` | Input plus output tokens per UTC day, across all visitors. Input read from the prompt cache counts as a tenth of a token. | 1,000 or more |
|
|
223
|
+
| `dailyTokensPerIp` | `200_000` | Input plus output tokens per client IP per UTC day, counted like `dailyTokens` | 100 or more |
|
|
224
224
|
| `uploadsPerVisitorPerHour` | `20` | File uploads per visitor per hour | 1–1,000 |
|
|
225
225
|
| `uploadsPerIpPerHour` | `60` | File uploads per client IP per hour, across visitors | 1–10,000 |
|
|
226
226
|
| `uploadsPerDay` | `500` | File uploads per UTC day, across all visitors | 1–1,000,000 |
|
|
@@ -231,7 +231,7 @@ Limits bound what visitors can cost ([ADR-0004](https://github.com/boldare/askda
|
|
|
231
231
|
What happens at a limit:
|
|
232
232
|
|
|
233
233
|
- **Rates** answer `rate_limited`, with a `Retry-After` header. So does `maxTurns`, which asks the visitor to start a new conversation.
|
|
234
|
-
- **Token budgets** answer `budget_exceeded` until midnight UTC. Before each model call, askdare reserves an estimate against `dailyTokens`, `dailyTokensPerIp` and the handler's `globalDailyTokens`. The estimate covers the conversation so far, the new message, `maxOutputTokens`, attached files and file search results. A bot with tools reserves the next call before each tool round, and answers without tools when a budget can't hold it. When the turn ends, the real usage replaces the estimate. A turn that fails or is cut off keeps the estimate charged.
|
|
234
|
+
- **Token budgets** answer `budget_exceeded` until midnight UTC. Before each model call, askdare reserves an estimate against `dailyTokens`, `dailyTokensPerIp` and the handler's `globalDailyTokens`. The estimate covers the conversation so far, the new message, `maxOutputTokens`, attached files and file search results. A bot with tools reserves the next call before each tool round, and answers without tools when a budget can't hold it. When the turn ends, the real usage replaces the estimate: input read from the prompt cache counts as a tenth of a token, close to its price, and everything else, cache writes included, as a whole token. The estimate counts the conversation so far as whole tokens, in case the cache has gone cold. A turn that fails or is cut off keeps the estimate charged.
|
|
235
235
|
- **Speech budgets** reserve `voice.maxSeconds` per dictation, then charge the duration OpenAI reports. When one is spent, dictation answers `budget_exceeded` until midnight UTC.
|
|
236
236
|
- **`maxInputChars`** rejects a longer message with `invalid_input`.
|
|
237
237
|
|
|
@@ -298,7 +298,7 @@ A wrong `basePath`, a duplicate bot ID or an empty `bots` list throws a `TypeErr
|
|
|
298
298
|
| --- | --- | --- | --- |
|
|
299
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). |
|
|
300
300
|
| `trustProxy` | `'auto' \| 'vercel' \| 'heroku' \| number` | `'auto'` | How to read the client IP behind your proxy. |
|
|
301
|
-
| `globalDailyTokens` | `number` | unlimited | Input plus output tokens per UTC day, across all bots of this handler
|
|
301
|
+
| `globalDailyTokens` | `number` | unlimited | Input plus output tokens per UTC day, across all bots of this handler, counted like `dailyTokens`. Reaching it answers `budget_exceeded`. |
|
|
302
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`. |
|
|
303
303
|
|
|
304
304
|
### `trustProxy`
|
package/docs/costs.md
CHANGED
|
@@ -21,8 +21,8 @@ These defaults bound spending. All of them can be changed in `limits` ([Configur
|
|
|
21
21
|
|
|
22
22
|
| Limit | Default | Counted per |
|
|
23
23
|
| --- | --- | --- |
|
|
24
|
-
| `dailyTokens` | 2,000,000 input plus output tokens | bot, per UTC day |
|
|
25
|
-
| `dailyTokensPerIp` | 200,000 input plus output tokens | client IP and bot, per UTC day |
|
|
24
|
+
| `dailyTokens` | 2,000,000 input plus output tokens (cached input counts as a tenth) | bot, per UTC day |
|
|
25
|
+
| `dailyTokensPerIp` | 200,000 input plus output tokens (cached input counts as a tenth) | client IP and bot, per UTC day |
|
|
26
26
|
| `globalDailyTokens` (in `createChatHandler`) | none | all bots, per UTC day |
|
|
27
27
|
| `maxOutputTokens` | 1,024 | model call |
|
|
28
28
|
| `maxSteps` | 5 model calls | message |
|
|
@@ -46,15 +46,18 @@ one bot, 30 days 30 × 2,000,000 = 60,000,000 tokens
|
|
|
46
46
|
three bots, one day 3 × 2,000,000 = 6,000,000 tokens (unless you set globalDailyTokens)
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
The budget counts input,
|
|
49
|
+
The budget counts input read from the prompt cache as a tenth of a token, and input, cache writes and output as whole tokens. OpenAI prices cached input at a tenth of input on most models, so one budget token never costs more than the most expensive of them. For a ceiling in money, use the highest per-token price of your model:
|
|
50
50
|
|
|
51
51
|
```text
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
highest price per 1M tokens = the highest of: input, cache writes, output, 10 × cached input
|
|
53
|
+
ceiling per bot per day = 2,000,000 / 1,000,000 × highest price per 1M tokens
|
|
54
|
+
= 2 × highest price per 1M tokens
|
|
54
55
|
ceiling per bot per 30 days = 60 × highest price per 1M tokens
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
Real spending is lower whenever some of the tokens are cheaper input or cached input. The ceiling is what an attacker with ten or more IP addresses can make you pay every day.
|
|
58
|
+
On current models the highest is usually output, and 10 × cached input equals input. Real spending is lower whenever some of the tokens are cheaper input or cached input. The ceiling is what an attacker with ten or more IP addresses can make you pay every day.
|
|
59
|
+
|
|
60
|
+
Long conversations are mostly cached input: every model call reads the whole conversation again, and the cache serves all of it but the newest part. We measured a 50-turn support conversation with knowledge searches at 97.9 % cached input. It used 3.8M input tokens, cost 0.31 USD, and counts as about 460,000 tokens against the budgets. One visitor can hold a conversation of about 25 turns like it on the default `dailyTokensPerIp`.
|
|
58
61
|
|
|
59
62
|
### Speech
|
|
60
63
|
|
package/docs/support.md
CHANGED
|
@@ -34,7 +34,7 @@ Every release is tested automatically in Chromium, Firefox and WebKit, and on tw
|
|
|
34
34
|
| --- | --- | --- |
|
|
35
35
|
| The loader (`widget.js`), on every page | about 3 KB | 5 KB |
|
|
36
36
|
| The chat itself, when the visitor opens it | about 38 KB, plus 6 KB of styles | 50 KB and 8 KB |
|
|
37
|
-
| `@boldare/askdare/react` in your app's bundle, without React itself | about 28 KB; about 8 KB with only `Root` and the hooks |
|
|
37
|
+
| `@boldare/askdare/react` in your app's bundle, without React itself | about 28 KB; about 8 KB with only `Root` and the hooks | 34 KB and 12 KB |
|
|
38
38
|
| One theme's fonts, from your app | up to 82 KB | 82 KB |
|
|
39
39
|
|
|
40
40
|
The build fails when one of these grows past its budget.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boldare/askdare",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Embeddable AI chatbot for Next.js, as a script-tag widget or React components, built on the official OpenAI SDK.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"@types/react": "^19.3.0",
|
|
80
80
|
"@types/react-dom": "^19.3.0",
|
|
81
81
|
"happy-dom": "^21.0.4",
|
|
82
|
-
"marked": "18.2.
|
|
82
|
+
"marked": "18.2.1",
|
|
83
83
|
"next": "^16.4.6",
|
|
84
84
|
"preact": "11.2.0",
|
|
85
85
|
"publint": "^0.3.25",
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"jose": "^6.2.
|
|
107
|
-
"openai": "^7.
|
|
106
|
+
"jose": "^6.2.18",
|
|
107
|
+
"openai": "^7.62.0"
|
|
108
108
|
},
|
|
109
109
|
"scripts": {
|
|
110
110
|
"build:assets": "vite build -c vite.widget.config.ts && vite build -c vite.skin.config.ts && vite build -c vite.loader.config.ts && node scripts/inline-assets.mjs",
|