@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/react.d.ts
CHANGED
|
@@ -1,76 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
import { a as ToolResults, c as ChatConfig, d as ChatWidget, i as ToolRenderers, l as ChatHumanCheck, m as ThemeVariants, n as LinkProps, o as ToolResultsProps, p as PresetName, r as ToolRendererProps, s as ChatAttachments, t as Link, u as ChatStyles } from "./tool-results.js";
|
|
2
3
|
import { ComponentProps, ComponentType, NamedExoticComponent, ReactElement, ReactNode, Ref } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
readonly
|
|
11
|
-
readonly surface: "solid" | "glass";
|
|
12
|
-
readonly density: "comfortable" | "compact";
|
|
13
|
-
readonly composer: "outline" | "gradient";
|
|
14
|
-
/** Where the latest answer's options show: under it, or in one row above the message field. */
|
|
15
|
-
readonly replies: "answer" | "composer";
|
|
16
|
-
}
|
|
17
|
-
/** What a visitor may attach, as the bot allows it. */
|
|
18
|
-
interface ChatAttachments {
|
|
19
|
-
readonly images: boolean;
|
|
20
|
-
readonly pdf: boolean;
|
|
21
|
-
readonly maxBytes: number;
|
|
22
|
-
readonly maxPerMessage: number;
|
|
23
|
-
readonly maxPdfPages: number;
|
|
24
|
-
}
|
|
25
|
-
/** A bot's public widget settings, in the visitor's language. */
|
|
26
|
-
interface ChatWidget {
|
|
27
|
-
readonly title: string;
|
|
28
|
-
readonly subtitle: string;
|
|
29
|
-
readonly greeting: string;
|
|
30
|
-
readonly placeholder: string;
|
|
31
|
-
/** The language this visitor sees. */
|
|
32
|
-
readonly locale: string;
|
|
33
|
-
readonly starters: readonly string[];
|
|
34
|
-
readonly avatar: string | undefined;
|
|
35
|
-
readonly launcherLabel: string;
|
|
36
|
-
readonly disclosure: false | {
|
|
37
|
-
readonly privacyUrl: string | undefined;
|
|
38
|
-
};
|
|
39
|
-
readonly preset: PresetName;
|
|
40
|
-
readonly variants: ThemeVariants;
|
|
41
|
-
/** `auto` follows the visitor's system setting. */
|
|
42
|
-
readonly colorScheme: "auto" | "light" | "dark";
|
|
43
|
-
/** Every text in the visitor's language, overrides applied; plural keys included. */
|
|
44
|
-
readonly texts: Readonly<Record<string, string>>;
|
|
45
|
-
}
|
|
46
|
-
/** Stylesheets of a chat inside a page, served by the chat route (ADR-0011). */
|
|
47
|
-
interface ChatStyles {
|
|
48
|
-
/** The bot's tokens for both color schemes, then its own `widget.css`. */
|
|
49
|
-
readonly theme: string;
|
|
50
|
-
/** The default look; only `DefaultChat` loads it. */
|
|
51
|
-
readonly skin: string;
|
|
52
|
-
/** `@font-face` rules of the built-in themes; browsers fetch only the fonts in use. */
|
|
53
|
-
readonly fonts: string;
|
|
54
|
-
}
|
|
55
|
-
/** What the browser needs to run one bot's chat. Public: it never holds secrets (ADR-0008). */
|
|
56
|
-
interface ChatConfig {
|
|
57
|
-
readonly protocolVersion: number;
|
|
58
|
-
/** Path of the chat route, such as `/api/chat`. Same origin only (ADR-0011). */
|
|
59
|
-
readonly basePath: string;
|
|
60
|
-
readonly botId: string;
|
|
61
|
-
readonly widget: ChatWidget;
|
|
62
|
-
/** Whether the bot accepts a description of the page it is on. */
|
|
63
|
-
readonly pageContext: boolean;
|
|
64
|
-
/** Whether the bot lets visitors rate answers. Answers carry a handle when the route takes ratings. */
|
|
65
|
-
readonly feedback: boolean;
|
|
66
|
-
/** Absent when attachments are off. */
|
|
67
|
-
readonly attachments?: ChatAttachments;
|
|
68
|
-
/** Absent when voice input is off. The model stays on the server. */
|
|
69
|
-
readonly voice?: {
|
|
70
|
-
readonly maxSeconds: number;
|
|
71
|
-
};
|
|
72
|
-
/** From `getChatConfig`, for a chat inside a page. The iframe links its own stylesheets. */
|
|
73
|
-
readonly styles?: ChatStyles;
|
|
4
|
+
/** One tool call's payload, as the `tool.ui` event and the history carry it. */
|
|
5
|
+
interface ToolUi {
|
|
6
|
+
/** The call, as in `tool.status`. Opaque. */
|
|
7
|
+
readonly callId: string;
|
|
8
|
+
/** The tool's name, which picks the renderer. */
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/** Whatever the tool's `ui` returned: plain JSON, never `null`. */
|
|
11
|
+
readonly data: unknown;
|
|
74
12
|
}
|
|
75
13
|
/** Parts of the default look you can replace. They take no props: read the chat with the hooks. */
|
|
76
14
|
interface DefaultChatComponents {
|
|
@@ -82,9 +20,12 @@ interface DefaultChatComponents {
|
|
|
82
20
|
readonly Footer?: ComponentType;
|
|
83
21
|
}
|
|
84
22
|
interface DefaultPanelProps {
|
|
85
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Level of the chat's title (default 2, or 1 inside `EmbedRoot`); 1 makes the chat the page's
|
|
25
|
+
* main landmark.
|
|
26
|
+
*/
|
|
86
27
|
readonly headingLevel?: 1 | 2 | 3 | 4 | 5;
|
|
87
|
-
/** Shows a close button, and Escape calls it too. */
|
|
28
|
+
/** Shows a close button, and Escape calls it too. Inside `EmbedRoot`, it closes the widget by default. */
|
|
88
29
|
readonly onClose?: (() => void) | undefined;
|
|
89
30
|
readonly components?: DefaultChatComponents | undefined;
|
|
90
31
|
}
|
|
@@ -156,6 +97,11 @@ interface ChatMessage {
|
|
|
156
97
|
* is the latest message; a click sends the option as the visitor's own message.
|
|
157
98
|
*/
|
|
158
99
|
readonly replies?: readonly string[] | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* What the turn's tools picked from their results for the visitor to see (ADR-0017), in call
|
|
102
|
+
* order, at most four: plain JSON for the components registered with `toolRenderers`.
|
|
103
|
+
*/
|
|
104
|
+
readonly ui?: readonly ToolUi[] | undefined;
|
|
159
105
|
}
|
|
160
106
|
type Rating = "up" | "down";
|
|
161
107
|
/** A file picked for the next message. */
|
|
@@ -195,6 +141,8 @@ interface ChatState {
|
|
|
195
141
|
readonly ratings: Readonly<Record<string, Rating>>;
|
|
196
142
|
/** The id of the answer just rated 👎, while the chat asks what went wrong. */
|
|
197
143
|
readonly commenting: string | undefined;
|
|
144
|
+
/** The chat waits for the visitor to pass the bot's human check before it connects. */
|
|
145
|
+
readonly humanCheck: boolean;
|
|
198
146
|
}
|
|
199
147
|
/**
|
|
200
148
|
* What happened in the chat, for the page's analytics and reactions (ADR-0013). Metadata only:
|
|
@@ -285,6 +233,8 @@ declare const EN: {
|
|
|
285
233
|
readonly "launcher.open": "Open chat";
|
|
286
234
|
readonly "launcher.close": "Close chat";
|
|
287
235
|
readonly "launcher.unavailable": "The chat couldn’t load. Please try again later.";
|
|
236
|
+
readonly "humanCheck.label": "Checking that you’re human";
|
|
237
|
+
readonly "error.humanCheck": "We couldn’t confirm you’re human. Please try again.";
|
|
288
238
|
readonly "error.connection": "Connection problem. Please try again.";
|
|
289
239
|
readonly "error.history": "Could not load the previous conversation.";
|
|
290
240
|
readonly "error.updated": "The assistant was updated. Please reload the page.";
|
|
@@ -417,6 +367,19 @@ interface Chat {
|
|
|
417
367
|
/** A text in the visitor's language by its key, such as `composer.send`. */
|
|
418
368
|
readonly t: Translate;
|
|
419
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* The chat is the whole document of the widget's iframe (`EmbedRoot`, ADR-0018): `close` asks the
|
|
372
|
+
* loader to close the panel; undefined when the page isn't in an iframe or in `inline` mode.
|
|
373
|
+
*/
|
|
374
|
+
interface Frame {
|
|
375
|
+
readonly close: (() => void) | undefined;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Inside `EmbedRoot`, on your own page in the widget's iframe (ADR-0018): the chat is the whole
|
|
379
|
+
* document, and `close` asks the loader to close the panel (undefined in `inline` mode or when the
|
|
380
|
+
* page isn't in the widget). Null everywhere else. Your own markup uses it for a close button.
|
|
381
|
+
*/
|
|
382
|
+
export declare function useFrame(): Frame | null;
|
|
420
383
|
/** The whole chat: its state, actions, bot settings and texts. Re-renders on every change. */
|
|
421
384
|
export declare function useChat(): Chat;
|
|
422
385
|
/**
|
|
@@ -426,6 +389,13 @@ export declare function useChat(): Chat;
|
|
|
426
389
|
export declare function useChatState<T>(select: (state: ChatState) => T): T;
|
|
427
390
|
/** The message being rendered, inside `MessageList`. */
|
|
428
391
|
export declare function useMessage(): ChatMessage;
|
|
392
|
+
type DisclosureProps = ComponentProps<"p">;
|
|
393
|
+
/**
|
|
394
|
+
* The AI notice (EU AI Act, art. 50): `disclosure.text`, with a link to the bot's
|
|
395
|
+
* `widget.disclosure.privacyUrl` when it has one. Children replace the text with your own notice.
|
|
396
|
+
* Renders nothing when the bot sets `disclosure: false`.
|
|
397
|
+
*/
|
|
398
|
+
export declare function Disclosure({ children, ...props }: DisclosureProps): ReactElement | null;
|
|
429
399
|
interface FeedbackButtonProps extends ComponentProps<"button"> {
|
|
430
400
|
/** What a click rates the answer: 👍 `up` or 👎 `down`. A second click takes the rating back. */
|
|
431
401
|
readonly rating: Rating;
|
|
@@ -436,6 +406,13 @@ interface FeedbackButtonProps extends ComponentProps<"button"> {
|
|
|
436
406
|
* be rated. After 👎 the chat's `state.commenting` names the answer to ask about.
|
|
437
407
|
*/
|
|
438
408
|
export declare function FeedbackButton({ rating, onClick, ...props }: FeedbackButtonProps): ReactElement | null;
|
|
409
|
+
type HumanCheckProps = Omit<ComponentProps<"div">, "children">;
|
|
410
|
+
/**
|
|
411
|
+
* The bot's human check (`security.humanVerifier`), shown while the chat waits for it before it
|
|
412
|
+
* connects; nothing otherwise. The default look includes it; a headless chat whose bot has a check
|
|
413
|
+
* must render it, or it can't connect.
|
|
414
|
+
*/
|
|
415
|
+
export declare function HumanCheck(props: HumanCheckProps): ReactElement | null;
|
|
439
416
|
/**
|
|
440
417
|
* Renders model output as markdown (GFM) without ever producing raw HTML: marked only tokenizes,
|
|
441
418
|
* and each token becomes an element here. HTML in the source is dropped, links are limited to
|
|
@@ -448,8 +425,10 @@ interface MarkdownProps {
|
|
|
448
425
|
export declare const Markdown: NamedExoticComponent<MarkdownProps>;
|
|
449
426
|
type MessagesProps = ComponentProps<"div">;
|
|
450
427
|
/**
|
|
451
|
-
* The conversation
|
|
452
|
-
*
|
|
428
|
+
* The conversation, following the latest message as it streams. Holds the welcome, the
|
|
429
|
+
* `MessageList` and the `Status`. It is a log but not a live region: text growing inside a node is
|
|
430
|
+
* read in fragments or not at all, so a finished answer is announced once, through a status region
|
|
431
|
+
* next to it.
|
|
453
432
|
*/
|
|
454
433
|
export declare function Messages({ ref, ...props }: MessagesProps): ReactElement;
|
|
455
434
|
interface MessageListProps {
|
|
@@ -527,11 +506,18 @@ interface RootProps {
|
|
|
527
506
|
* rating (ADR-0013). Metadata only, never the text. A new function doesn't restart the chat.
|
|
528
507
|
*/
|
|
529
508
|
readonly onEvent?: ChatEventListener | undefined;
|
|
509
|
+
/**
|
|
510
|
+
* Your components for tools' results, by tool name (ADR-0017): each gets what the tool's `ui`
|
|
511
|
+
* returned and is drawn by `ToolResults`, in `DefaultChat` under the answer. Type them with
|
|
512
|
+
* `satisfies ToolRenderers<[typeof myTool]>`. Define the map outside your component (or
|
|
513
|
+
* memoize it): a new object on every render re-renders every card.
|
|
514
|
+
*/
|
|
515
|
+
readonly toolRenderers?: ToolRenderers | undefined;
|
|
530
516
|
readonly children?: ReactNode;
|
|
531
517
|
}
|
|
532
518
|
/**
|
|
533
519
|
* Runs one bot's chat for the components inside it, without rendering any element. Its props
|
|
534
520
|
* take what `askdare('identify')` and `askdare('configure')` take, checked the same way.
|
|
535
521
|
*/
|
|
536
|
-
export declare function Root({ config, identity, context, greeting, starters, onEvent, children }: RootProps): ReactElement;
|
|
537
|
-
export type
|
|
522
|
+
export declare function Root({ config, identity, context, greeting, starters, onEvent, toolRenderers, children }: RootProps): ReactElement;
|
|
523
|
+
export { type AttachButtonProps, type Chat, type ChatActions, type ChatAttachments, type ChatBot, type ChatConfig, type ChatEvent, type ChatEventListener, type ChatEventType, type ChatHumanCheck, type ChatMessage, type ChatPhase, type ChatState, type ChatStyles, type ChatWidget, type Citation, type CitationsProps, type ComposerProps, type DefaultChatComponents, type DefaultChatProps, type DictateButtonProps, type Dictation, type DisclosureProps, type ErrorMessageProps, type FeedbackButtonProps, type FilesProps, type Frame, type HumanCheckProps, type InputProps, Link, type LinkProps, type MarkdownProps, type MessageFilesProps, type MessageListProps, type MessageProps, type MessageTextProps, type MessagesProps, type PanelProps, type PendingFile, type QuickRepliesProps, type Rating, type RecorderProps, type RootProps, type SendProps, type SentFile, type StatusProps, type ThemeProps, type ToolRendererProps, type ToolRenderers, ToolResults, type ToolResultsProps, type ToolUi, type Translate };
|