@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.
- package/CHANGELOG.md +63 -0
- package/README.md +14 -4
- package/dist/cli.js +111 -26
- package/dist/define-tool.js +1006 -8
- package/dist/embed.d.ts +19 -0
- package/dist/embed.js +250 -0
- package/dist/{store.d.ts → events.d.ts} +163 -54
- package/dist/index.d.ts +28 -2
- package/dist/index.js +74 -158
- package/dist/next.d.ts +70 -9
- package/dist/next.js +767 -169
- package/dist/react-marked.js +648 -624
- package/dist/react.d.ts +63 -77
- package/dist/react.js +148 -1854
- package/dist/root.js +2254 -0
- package/dist/tool-results.d.ts +140 -0
- package/dist/ui/askdare.css +21 -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 +6 -4
- package/dist/ui/panel.tsx +17 -6
- package/dist/ui/welcome.tsx +1 -1
- package/docs/accessibility.md +83 -0
- package/docs/cli.md +5 -3
- package/docs/compliance.md +160 -0
- package/docs/configuration.md +58 -2
- package/docs/costs.md +8 -1
- package/docs/custom-store.md +2 -0
- package/docs/embedding.md +104 -0
- package/docs/events.md +1 -1
- 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 +27 -3
- package/docs/protocol.md +15 -1
- package/docs/react.md +57 -3
- package/docs/styling.md +4 -3
- package/docs/support.md +3 -3
- package/docs/texts.md +127 -98
- package/docs/tools.md +20 -0
- package/docs/troubleshooting.md +30 -3
- package/llms.txt +14 -11
- package/package.json +10 -6
- package/skills/askdare/SKILL.md +12 -2
package/dist/index.js
CHANGED
|
@@ -1,166 +1,82 @@
|
|
|
1
|
-
import {
|
|
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/
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
*
|
|
100
|
-
*
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
limits: Object.freeze({
|
|
127
|
-
...DEFAULT_LIMITS,
|
|
128
|
-
...definition.limits
|
|
39
|
+
challenge: Object.freeze({
|
|
40
|
+
provider: "turnstile",
|
|
41
|
+
siteKey
|
|
129
42
|
}),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
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 };
|