@boldare/askdare 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +14 -4
  3. package/dist/cli.js +111 -26
  4. package/dist/define-tool.js +1006 -8
  5. package/dist/embed.d.ts +19 -0
  6. package/dist/embed.js +250 -0
  7. package/dist/{store.d.ts → events.d.ts} +163 -54
  8. package/dist/index.d.ts +28 -2
  9. package/dist/index.js +74 -158
  10. package/dist/next.d.ts +70 -9
  11. package/dist/next.js +767 -169
  12. package/dist/react-marked.js +648 -624
  13. package/dist/react.d.ts +63 -77
  14. package/dist/react.js +148 -1854
  15. package/dist/root.js +2254 -0
  16. package/dist/tool-results.d.ts +140 -0
  17. package/dist/ui/askdare.css +21 -1
  18. package/dist/ui/avatar.tsx +1 -1
  19. package/dist/ui/chat.tsx +1 -1
  20. package/dist/ui/confirm.tsx +1 -1
  21. package/dist/ui/context.ts +1 -1
  22. package/dist/ui/feedback.tsx +1 -1
  23. package/dist/ui/footer.tsx +3 -15
  24. package/dist/ui/header.tsx +1 -1
  25. package/dist/ui/icons.tsx +1 -1
  26. package/dist/ui/index.ts +1 -1
  27. package/dist/ui/message.tsx +6 -4
  28. package/dist/ui/panel.tsx +17 -6
  29. package/dist/ui/welcome.tsx +1 -1
  30. package/docs/accessibility.md +83 -0
  31. package/docs/cli.md +5 -3
  32. package/docs/compliance.md +160 -0
  33. package/docs/configuration.md +58 -2
  34. package/docs/costs.md +8 -1
  35. package/docs/custom-store.md +2 -0
  36. package/docs/embedding.md +104 -0
  37. package/docs/events.md +1 -1
  38. package/docs/feedback.md +1 -1
  39. package/docs/going-public.md +15 -3
  40. package/docs/guardrails.md +128 -0
  41. package/docs/migrating-from-openai-assistant.md +1 -1
  42. package/docs/privacy.md +27 -3
  43. package/docs/protocol.md +15 -1
  44. package/docs/react.md +57 -3
  45. package/docs/styling.md +4 -3
  46. package/docs/support.md +3 -3
  47. package/docs/texts.md +127 -98
  48. package/docs/tools.md +20 -0
  49. package/docs/troubleshooting.md +30 -3
  50. package/llms.txt +14 -11
  51. package/package.json +10 -6
  52. package/skills/askdare/SKILL.md +12 -2
package/dist/index.js CHANGED
@@ -1,166 +1,82 @@
1
- import { _ as TEXT_KEYS, a as PROTOCOL_VERSION, b as textsFor, f as defineTheme, g as PRESET_NAMES, h as themeWarnings, m as themeDefinitionSchema, o as SUGGEST_REPLIES, p as resolveTheme, t as defineTool, x as canonicalLocale } from "./define-tool.js";
1
+ import { P as defineTheme, S as defineBot, d as AskdareError, l as TURNSTILE_ORIGIN, n as defineTool, u as turnstileAction, v as PROTOCOL_VERSION, y as ERROR_CODES } from "./define-tool.js";
2
2
  import { z } from "zod";
3
- // src/bot/define-bot.ts
4
- const DEFAULT_LIMITS = {
5
- maxOutputTokens: 1024,
6
- maxInputChars: 4e3,
7
- maxSteps: 5,
8
- turnTimeoutMs: 12e4,
9
- dailyTokens: 2e6,
10
- dailyTokensPerIp: 2e5,
11
- sessionsPerIpPerHour: 30,
12
- conversationsPerIpPerHour: 20,
13
- messagesPerVisitorPerMinute: 10,
14
- messagesPerIpPerMinute: 30,
15
- maxTurns: 50,
16
- uploadsPerVisitorPerHour: 20,
17
- uploadsPerIpPerHour: 60,
18
- uploadsPerDay: 500,
19
- transcriptionsPerVisitorPerHour: 30,
20
- voiceSecondsPerDay: 3600,
21
- voiceSecondsPerIpPerDay: 600
22
- };
23
- /** An https URL or a path on your app (no protocol-relative URLs). */
24
- const LINK = /^(https:\/\/[^\s"'<>\\]{1,500}|\/(?![/\\])[^\s"'<>\\]{0,500})$/;
25
- /** A same-origin path (served by your app, allowed by the iframe CSP) or a small raster data URL. */
26
- const AVATAR = /^(\/(?!\/)[\w\-./%]{1,200}|data:image\/(png|jpeg|webp|gif);base64,[A-Za-z0-9+/=]{1,90000})$/;
27
- const origin = z.string().refine((value) => {
28
- try {
29
- const url = new URL(value);
30
- return (url.protocol === "https:" || url.protocol === "http:" && /^(localhost|127\.0\.0\.1|\[::1\]|.+\.localhost)$/.test(url.hostname)) && url.origin === value && /^[a-z0-9.-]+$|^\[[0-9a-f:]+\]$/i.test(url.hostname);
31
- } catch {
32
- return false;
33
- }
34
- }, "must be an https origin like https://www.example.com (no path or wildcard; http only for localhost)");
35
- const definitionSchema = z.object({
36
- id: z.string().regex(/^[a-z0-9][a-z0-9-]{0,47}$/, "use 1-48 lowercase letters, digits or dashes"),
37
- model: z.string().trim().min(1, "is required"),
38
- instructions: z.union([z.string().trim().min(1, "must not be empty"), z.function()]),
39
- limits: z.object({
40
- maxOutputTokens: z.number().int().min(16).max(128e3).optional(),
41
- maxInputChars: z.number().int().min(1).max(1e5).optional(),
42
- maxSteps: z.number().int().min(1).max(20).optional(),
43
- turnTimeoutMs: z.number().int().min(1e3).max(9e5).optional(),
44
- dailyTokens: z.number().int().min(1e3).optional(),
45
- dailyTokensPerIp: z.number().int().min(100).optional(),
46
- sessionsPerIpPerHour: z.number().int().min(1).max(1e4).optional(),
47
- conversationsPerIpPerHour: z.number().int().min(1).max(1e4).optional(),
48
- messagesPerVisitorPerMinute: z.number().int().min(1).max(1e3).optional(),
49
- messagesPerIpPerMinute: z.number().int().min(1).max(1e4).optional(),
50
- maxTurns: z.number().int().min(1).max(1e3).optional(),
51
- uploadsPerVisitorPerHour: z.number().int().min(1).max(1e3).optional(),
52
- uploadsPerIpPerHour: z.number().int().min(1).max(1e4).optional(),
53
- uploadsPerDay: z.number().int().min(1).max(1e6).optional(),
54
- transcriptionsPerVisitorPerHour: z.number().int().min(1).max(1e3).optional(),
55
- voiceSecondsPerDay: z.number().int().min(60).optional(),
56
- voiceSecondsPerIpPerDay: z.number().int().min(60).optional()
57
- }).optional(),
58
- tools: z.array(z.custom((value) => typeof value === "object" && value !== null && "execute" in value, "must be created with defineTool()")).max(64).refine((tools) => new Set(tools.map((tool) => tool.name)).size === tools.length, "must have unique names").refine((tools) => tools.every((tool) => tool.name !== "file_search"), "must not use the reserved name file_search").refine((tools) => tools.every((tool) => tool.name !== SUGGEST_REPLIES), `must not use the reserved name ${SUGGEST_REPLIES}`).optional(),
59
- pageContext: z.boolean().optional(),
60
- knowledge: z.object({
61
- vectorStoreId: z.string().regex(/^vs_[A-Za-z0-9_-]+$/, "must be a vector store ID like vs_…"),
62
- maxResults: z.number().int().min(1).max(50).optional()
63
- }).optional(),
64
- attachments: z.object({
65
- images: z.boolean().optional(),
66
- pdf: z.boolean().optional(),
67
- maxBytes: z.number().int().min(1e3).max(2e7).optional(),
68
- maxPerMessage: z.number().int().min(1).max(10).optional(),
69
- maxPdfPages: z.number().int().min(1).max(500).optional()
70
- }).refine((value) => value.images !== false || value.pdf !== false, "must allow images or pdf").optional(),
71
- voice: z.object({
72
- model: z.string().trim().min(1, "is required"),
73
- maxSeconds: z.number().int().min(5).max(300).optional()
74
- }).optional(),
75
- security: z.object({ allowedOrigins: z.array(origin).max(50).optional() }).optional(),
76
- widget: z.object({
77
- title: z.string().trim().min(1).max(80).optional(),
78
- greeting: z.string().trim().min(1).max(500).optional(),
79
- placeholder: z.string().trim().min(1).max(120).optional(),
80
- locale: z.string().refine((value) => value === "auto" || canonicalLocale(value) !== void 0, "must be auto or a BCP 47 tag like en or pl-PL").optional(),
81
- texts: z.partialRecord(z.enum(TEXT_KEYS), z.string().trim().min(1).max(300)).optional(),
82
- disclosure: z.union([z.literal(false), z.object({ privacyUrl: z.string().regex(LINK, "must be an https URL or a path like /privacy").optional() }).strict()]).optional(),
83
- css: z.string().max(5e4).optional(),
84
- subtitle: z.string().trim().min(1).max(120).optional(),
85
- starters: z.array(z.string().trim().min(1).max(80)).max(4).optional(),
86
- feedback: z.boolean().optional(),
87
- replies: z.enum(["suggest", "off"]).optional(),
88
- avatar: z.string().regex(AVATAR, "must be a path like /avatar.png or a PNG, JPEG, WebP or GIF data URL").optional(),
89
- launcherLabel: z.string().trim().min(1).max(40).optional(),
90
- theme: z.union([z.enum(PRESET_NAMES), themeDefinitionSchema]).optional(),
91
- colorScheme: z.enum([
92
- "auto",
93
- "light",
94
- "dark"
95
- ]).optional()
96
- }).optional()
3
+ // src/security/turnstile.ts
4
+ const SITEVERIFY = `${TURNSTILE_ORIGIN}/turnstile/v0/siteverify`;
5
+ const SITE_KEY = /^[A-Za-z0-9_-]{1,100}$/;
6
+ /** The fields of Cloudflare's siteverify response that the decision needs. */
7
+ const siteverifyResponse = z.object({
8
+ success: z.boolean(),
9
+ "error-codes": z.array(z.string()).optional(),
10
+ hostname: z.string().optional(),
11
+ action: z.string().optional()
97
12
  });
98
13
  /**
99
- * Declares a chatbot. Validates eagerly so misconfiguration fails at startup, not on the first
100
- * visitor's message.
14
+ * Cloudflare's published test secret keys: they answer for a dummy token, always with the
15
+ * hostname example.com and without an action, so those two checks can't apply.
101
16
  */
102
- function defineBot(definition) {
103
- const parsed = definitionSchema.safeParse(definition);
104
- if (!parsed.success) {
105
- const issues = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"} ${issue.message}`).join("; ");
106
- const hint = parsed.error.issues.some((issue) => issue.path.join(".") === "model") ? " Set the model in the bot definition, usually as model: process.env.ASKDARE_MODEL with ASKDARE_MODEL in .env.local and in every environment that builds or runs the app (on Vercel: Production and Preview)." : "";
107
- throw new TypeError(`[askdare] Invalid bot "${String(definition.id)}": ${issues}.${hint}`);
108
- }
109
- const { instructions } = definition;
110
- const widget = definition.widget ?? {};
111
- const locale = widget.locale ?? "en";
112
- const overrides = Object.freeze({
113
- ...widget.texts,
114
- ...widget.title ? { "header.title": widget.title } : {},
115
- ...widget.greeting ? { "welcome.greeting": widget.greeting } : {},
116
- ...widget.placeholder ? { "composer.placeholder": widget.placeholder } : {},
117
- ...widget.launcherLabel ? { "launcher.label": widget.launcherLabel } : {}
118
- });
119
- const texts = textsFor(locale === "auto" ? "en" : locale, overrides);
120
- const theme = resolveTheme(definition.widget?.theme, definition.widget?.colorScheme ?? "auto");
121
- 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}.`);
17
+ const TEST_SECRETS = /* @__PURE__ */ new Set([
18
+ "1x0000000000000000000000000000000AA",
19
+ "2x0000000000000000000000000000000AA",
20
+ "3x0000000000000000000000000000000AA"
21
+ ]);
22
+ /** Codes that mean the operator's setup is wrong, not the visitor's token. */
23
+ const SETUP_ERRORS = /* @__PURE__ */ new Set(["missing-input-secret", "invalid-input-secret"]);
24
+ const processEnv = (name) => globalThis.process?.env?.[name];
25
+ /**
26
+ * A `HumanVerifier` backed by Cloudflare Turnstile: the chat shows the Turnstile widget before a
27
+ * new session starts, and the server checks its token with Cloudflare's siteverify endpoint.
28
+ *
29
+ * ```ts
30
+ * // The site key is public; the secret key comes from TURNSTILE_SECRET_KEY.
31
+ * security: { humanVerifier: turnstile({ siteKey: '0x4AAAAAAA…' }) }
32
+ * ```
33
+ */
34
+ function turnstile(options) {
35
+ const siteKey = typeof options.siteKey === "string" ? options.siteKey.trim() : "";
36
+ if (!SITE_KEY.test(siteKey)) throw new TypeError("[askdare] turnstile() needs the siteKey of a Turnstile widget (letters, digits, - and _).");
37
+ const hostnames = options.hostnames?.map((host) => host.trim().toLowerCase());
122
38
  return Object.freeze({
123
- id: definition.id,
124
- model: definition.model.trim(),
125
- instructions: typeof instructions === "string" ? () => instructions : instructions,
126
- limits: Object.freeze({
127
- ...DEFAULT_LIMITS,
128
- ...definition.limits
39
+ challenge: Object.freeze({
40
+ provider: "turnstile",
41
+ siteKey
129
42
  }),
130
- tools: Object.freeze([...definition.tools ?? []]),
131
- pageContext: definition.pageContext ?? false,
132
- knowledge: definition.knowledge ? Object.freeze({
133
- vectorStoreId: definition.knowledge.vectorStoreId,
134
- maxResults: definition.knowledge.maxResults ?? 5
135
- }) : void 0,
136
- attachments: definition.attachments ? Object.freeze({
137
- images: definition.attachments.images ?? true,
138
- pdf: definition.attachments.pdf ?? true,
139
- maxBytes: definition.attachments.maxBytes ?? 4e6,
140
- maxPerMessage: definition.attachments.maxPerMessage ?? 3,
141
- maxPdfPages: definition.attachments.maxPdfPages ?? 50
142
- }) : void 0,
143
- voice: definition.voice ? Object.freeze({
144
- model: definition.voice.model.trim(),
145
- maxSeconds: definition.voice.maxSeconds ?? 60
146
- }) : void 0,
147
- security: Object.freeze({ allowedOrigins: Object.freeze([...new Set(definition.security?.allowedOrigins ?? [])]) }),
148
- widget: Object.freeze({
149
- title: texts["header.title"] ?? "",
150
- subtitle: widget.subtitle ?? "",
151
- greeting: texts["welcome.greeting"] ?? "",
152
- placeholder: texts["composer.placeholder"] ?? "",
153
- locale,
154
- starters: Object.freeze([...widget.starters ?? []]),
155
- feedback: widget.feedback ?? true,
156
- replies: widget.replies ?? "off",
157
- avatar: widget.avatar,
158
- launcherLabel: texts["launcher.label"] ?? "",
159
- texts: overrides,
160
- disclosure: widget.disclosure === false ? false : Object.freeze({ privacyUrl: widget.disclosure?.privacyUrl }),
161
- css: widget.css ?? "",
162
- theme
163
- })
43
+ verify: async (token, context) => {
44
+ const secret = options.secretKey ?? processEnv("TURNSTILE_SECRET_KEY");
45
+ if (!secret) throw new AskdareError("bot_unavailable", { cause: "TURNSTILE_SECRET_KEY is not configured." });
46
+ if (token.length === 0 || token.length > 2048) return false;
47
+ let response;
48
+ try {
49
+ response = await fetch(SITEVERIFY, {
50
+ method: "POST",
51
+ headers: { "content-type": "application/json" },
52
+ body: JSON.stringify({
53
+ secret,
54
+ response: token
55
+ }),
56
+ signal: context.signal
57
+ });
58
+ } catch (error) {
59
+ throw new AskdareError(context.signal.aborted ? "timeout" : "upstream_error", { cause: new Error("Cloudflare Turnstile siteverify could not be reached.", { cause: error }) });
60
+ }
61
+ let body;
62
+ try {
63
+ body = await response.json();
64
+ } catch {
65
+ body = void 0;
66
+ }
67
+ const parsed = siteverifyResponse.safeParse(body);
68
+ if (!parsed.success) throw new AskdareError("upstream_error", { cause: `Cloudflare Turnstile siteverify answered ${response.status} without a result.` });
69
+ if (parsed.data.success) {
70
+ if (TEST_SECRETS.has(secret)) return true;
71
+ if (parsed.data.action !== turnstileAction(context.botId)) return false;
72
+ const hostname = parsed.data.hostname?.toLowerCase();
73
+ return hostnames === void 0 || hostname !== void 0 && hostnames.includes(hostname);
74
+ }
75
+ const codes = parsed.data["error-codes"] ?? [];
76
+ if (codes.some((code) => SETUP_ERRORS.has(code))) throw new AskdareError("bot_unavailable", { cause: `Cloudflare rejected the Turnstile secret key (${codes.join(", ")}). Check TURNSTILE_SECRET_KEY.` });
77
+ if (codes.includes("internal-error")) throw new AskdareError("upstream_error", { cause: "Cloudflare Turnstile siteverify reported an internal error." });
78
+ return false;
79
+ }
164
80
  });
165
81
  }
166
- export { PROTOCOL_VERSION, defineBot, defineTheme, defineTool };
82
+ export { ERROR_CODES, PROTOCOL_VERSION, defineBot, defineTheme, defineTool, turnstile };
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as VisitorIdentity, S as ThemeVariants, b as PresetName, i as Bot, n as RateLimitStore } from "./store.js";
1
+ import { A as ThemeVariants, O as PresetName, a as RateLimitStore, j as VisitorIdentity, l as BotHandle, n as ErrorCode, r as MessageEndReason } from "./events.js";
2
2
  /** What a visitor may attach, as the bot allows it. */
3
3
  interface ChatAttachments {
4
4
  readonly images: boolean;
@@ -56,6 +56,23 @@ interface ChatConfig {
56
56
  };
57
57
  /** From `getChatConfig`, for a chat inside a page. The iframe links its own stylesheets. */
58
58
  readonly styles?: ChatStyles;
59
+ /**
60
+ * Absent unless the bot has `security.humanVerifier`: the challenge the chat shows before a new
61
+ * session starts, rendered by `HumanCheck`.
62
+ */
63
+ readonly humanCheck?: ChatHumanCheck;
64
+ }
65
+ /** A human check the chat must pass before it connects; public, the site key only. */
66
+ interface ChatHumanCheck {
67
+ readonly provider: "turnstile";
68
+ readonly siteKey: string;
69
+ }
70
+ /** What `EmbedRoot` from `@boldare/askdare/embed` needs; `getEmbedConfig` builds it (ADR-0018). */
71
+ interface EmbedChatConfig extends ChatConfig {
72
+ /** Origins whose pages may hand the chat its connection to the loader (ADR-0005). */
73
+ readonly allowedOrigins: readonly string[];
74
+ /** `inline` inside an element of the host page, `floating` in the widget's panel. */
75
+ readonly mode: "floating" | "inline";
59
76
  }
60
77
  /**
61
78
  * Which proxy to trust when reading the client IP:
@@ -87,11 +104,6 @@ interface ChatFeedbackReport {
87
104
  /** The OpenAI ID of the rated answer within the conversation. */
88
105
  readonly itemId: string;
89
106
  }
90
- /** Stable error codes sent to clients. The accompanying message never contains internals. */
91
- declare const ERROR_CODES: readonly ["invalid_input", "unauthorized", "session_expired", "not_found", "rate_limited", "budget_exceeded", "bot_unavailable", "content_blocked", "timeout", "upstream_error", "internal_error"];
92
- type ErrorCode = (typeof ERROR_CODES)[number];
93
- declare const MESSAGE_END_REASONS: readonly ["completed", "max_steps", "max_output_tokens", "timeout", "content_filter", "aborted"];
94
- type MessageEndReason = (typeof MESSAGE_END_REASONS)[number];
95
107
  /** Tokens one turn used, summed over its model calls, as OpenAI reports them. */
96
108
  interface ChatTokenUsage {
97
109
  readonly inputTokens: number;
@@ -142,7 +154,7 @@ interface ChatUsageReport {
142
154
  readonly tools: readonly ChatToolCallReport[];
143
155
  }
144
156
  interface ChatHandlerOptions {
145
- readonly bots: readonly Bot[];
157
+ readonly bots: readonly BotHandle[];
146
158
  /** Path of the catch-all route. Default `/api/chat` (route file `app/api/chat/[...path]/route.ts`). */
147
159
  readonly basePath?: string;
148
160
  /** Default `process.env.OPENAI_API_KEY`. */
@@ -204,6 +216,12 @@ interface ChatHandlerLimitsOptions {
204
216
  readonly trustProxy?: TrustProxy;
205
217
  /** Input plus output tokens per UTC day across all bots. Unlimited by default. */
206
218
  readonly globalDailyTokens?: number;
219
+ /**
220
+ * Refuse to start without a shared `store`, instead of warning in production that limits are
221
+ * per instance (ADR-0019). For example `process.env.NODE_ENV === 'production'`, so development
222
+ * keeps the in-memory store. Default `false`.
223
+ */
224
+ readonly requireSharedStore?: boolean;
207
225
  }
208
226
  type RouteHandler = (request: Request) => Promise<Response>;
209
227
  interface ChatHandlers {
@@ -226,7 +244,7 @@ interface ChatHandlers {
226
244
  export declare function createChatHandler(options: ChatHandlerOptions): ChatHandlers;
227
245
  interface ChatConfigOptions {
228
246
  /** The same bots as in `createChatHandler`. */
229
- readonly bots: readonly Bot[];
247
+ readonly bots: readonly BotHandle[];
230
248
  /** The id of the bot to show. */
231
249
  readonly bot: string;
232
250
  /** Path of the chat route, the same as in `createChatHandler`. Default `/api/chat`. */
@@ -248,4 +266,47 @@ interface ChatConfigOptions {
248
266
  * ```
249
267
  */
250
268
  export declare function getChatConfig(options: ChatConfigOptions): ChatConfig;
251
- export type { ChatAttachments, ChatConfig, ChatConfigOptions, ChatErrorReport, ChatFeedbackReport, ChatHandlerLimitsOptions, ChatHandlerOptions, ChatHandlers, ChatStyles, ChatTokenUsage, ChatToolCallReport, ChatUsageReport, ChatWidget, RouteHandler, TrustProxy };
269
+ /** A page's search parameters, as Next.js hands them to it or as `URLSearchParams`. */
270
+ type EmbedSearchParams = URLSearchParams | Readonly<Record<string, string | readonly string[] | undefined>>;
271
+ interface EmbedConfigOptions {
272
+ /** The same bots as in `createChatHandler`. */
273
+ readonly bots: readonly BotHandle[];
274
+ /** The id of the bot whose `embedPath` this page is. */
275
+ readonly bot: string;
276
+ /** Path of the chat route, the same as in `createChatHandler`. Default `/api/chat`. */
277
+ readonly basePath?: string;
278
+ /** The page's search parameters: the chat route passes the language and the mode in them. */
279
+ readonly searchParams: EmbedSearchParams;
280
+ }
281
+ /**
282
+ * The configuration for the page at a bot's `embedPath` (ADR-0018), read in its Server Component
283
+ * from the language and the mode that the chat route passes in the URL:
284
+ *
285
+ * ```tsx
286
+ * // app/(askdare)/askdare/support/page.tsx
287
+ * const config = getEmbedConfig({ bots, bot: 'support', searchParams: await searchParams });
288
+ * return <Frame config={config} />; // a client component with <EmbedRoot> and <DefaultChat>
289
+ * ```
290
+ */
291
+ export declare function getEmbedConfig(options: EmbedConfigOptions): EmbedChatConfig;
292
+ /** One response header, in the shape of `headers()` in `next.config.ts`. */
293
+ interface EmbedPageHeader {
294
+ readonly key: string;
295
+ readonly value: string;
296
+ }
297
+ /**
298
+ * The headers the page at a bot's `embedPath` must send, as askdare's own iframe page does
299
+ * (ADR-0018): who may frame it, the microphone only with voice input, and the referrer policy.
300
+ * Set them for the page's path in `next.config.ts`:
301
+ *
302
+ * ```ts
303
+ * async headers() {
304
+ * return [{ source: '/askdare/support', headers: embedPageHeaders({ bots, bot: 'support' }) }];
305
+ * }
306
+ * ```
307
+ */
308
+ export declare function embedPageHeaders(options: {
309
+ readonly bots: readonly BotHandle[];
310
+ readonly bot: string;
311
+ }): EmbedPageHeader[];
312
+ export type { ChatAttachments, ChatConfig, ChatConfigOptions, ChatErrorReport, ChatFeedbackReport, ChatHandlerLimitsOptions, ChatHandlerOptions, ChatHandlers, ChatHumanCheck, ChatStyles, ChatTokenUsage, ChatToolCallReport, ChatUsageReport, ChatWidget, EmbedChatConfig, EmbedConfigOptions, EmbedPageHeader, EmbedSearchParams, RouteHandler, TrustProxy };