@promptbook/fake-llm 0.105.0-20 → 0.105.0-23

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 (55) hide show
  1. package/esm/index.es.js +121 -4731
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +9 -13
  6. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/types.index.d.ts +24 -2
  8. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -1
  9. package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
  10. package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
  11. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +15 -0
  12. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +68 -0
  13. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
  14. package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
  15. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +8 -0
  16. package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
  17. package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
  18. package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
  19. package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
  20. package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
  21. package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
  22. package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
  23. package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
  24. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
  25. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
  26. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
  27. package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
  28. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +21 -0
  29. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +21 -0
  30. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
  31. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
  32. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
  33. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +16 -2
  34. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
  35. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
  36. package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +47 -0
  37. package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
  38. package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
  39. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +10 -0
  40. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +14 -0
  41. package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
  42. package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
  43. package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
  44. package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
  45. package/esm/typings/src/commitments/index.d.ts +3 -64
  46. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
  47. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
  48. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
  49. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
  50. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
  51. package/esm/typings/src/version.d.ts +1 -1
  52. package/esm/typings/src/wizard/wizard.d.ts +1 -4
  53. package/package.json +2 -4
  54. package/umd/index.umd.js +123 -4734
  55. package/umd/index.umd.js.map +1 -1
@@ -21,14 +21,12 @@ import { pipelineCollectionToJson } from '../collection/pipeline-collection/pipe
21
21
  import { createEmptyAgentModelRequirements } from '../commitments/_base/createEmptyAgentModelRequirements';
22
22
  import { createBasicAgentModelRequirements } from '../commitments/_base/createEmptyAgentModelRequirements';
23
23
  import { NotYetImplementedCommitmentDefinition } from '../commitments/_base/NotYetImplementedCommitmentDefinition';
24
- import { getCommitmentDefinition } from '../commitments/index';
25
- import { getAllCommitmentDefinitions } from '../commitments/index';
26
- import { getAllCommitmentTypes } from '../commitments/index';
27
- import { isCommitmentSupported } from '../commitments/index';
28
- import type { GroupedCommitmentDefinition } from '../commitments/index';
29
- import { getGroupedCommitmentDefinitions } from '../commitments/index';
30
- import { getAllCommitmentsToolFunctions } from '../commitments/index';
31
- import { getAllCommitmentsToolTitles } from '../commitments/index';
24
+ import { getAllCommitmentDefinitions } from '../commitments/_common/getAllCommitmentDefinitions';
25
+ import { getAllCommitmentsToolTitles } from '../commitments/_common/getAllCommitmentsToolTitles';
26
+ import { getAllCommitmentTypes } from '../commitments/_common/getAllCommitmentTypes';
27
+ import { getCommitmentDefinition } from '../commitments/_common/getCommitmentDefinition';
28
+ import { getGroupedCommitmentDefinitions } from '../commitments/_common/getGroupedCommitmentDefinitions';
29
+ import { isCommitmentSupported } from '../commitments/_common/isCommitmentSupported';
32
30
  import { NAME } from '../config';
33
31
  import { ADMIN_EMAIL } from '../config';
34
32
  import { PROMPTBOOK_LEGAL_ENTITY } from '../config';
@@ -226,14 +224,12 @@ export { pipelineCollectionToJson };
226
224
  export { createEmptyAgentModelRequirements };
227
225
  export { createBasicAgentModelRequirements };
228
226
  export { NotYetImplementedCommitmentDefinition };
229
- export { getCommitmentDefinition };
230
227
  export { getAllCommitmentDefinitions };
228
+ export { getAllCommitmentsToolTitles };
231
229
  export { getAllCommitmentTypes };
232
- export { isCommitmentSupported };
233
- export type { GroupedCommitmentDefinition };
230
+ export { getCommitmentDefinition };
234
231
  export { getGroupedCommitmentDefinitions };
235
- export { getAllCommitmentsToolFunctions };
236
- export { getAllCommitmentsToolTitles };
232
+ export { isCommitmentSupported };
237
233
  export { NAME };
238
234
  export { ADMIN_EMAIL };
239
235
  export { PROMPTBOOK_LEGAL_ENTITY };
@@ -1,5 +1,6 @@
1
1
  import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { createPipelineCollectionFromDirectory } from '../collection/pipeline-collection/constructors/createPipelineCollectionFromDirectory';
3
+ import { getAllCommitmentsToolFunctionsForNode } from '../commitments/_common/getAllCommitmentsToolFunctionsForNode';
3
4
  import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
4
5
  import { $provideExecutionToolsForNode } from '../execution/utils/$provideExecutionToolsForNode';
5
6
  import { $provideLlmToolsConfigurationFromEnv } from '../llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv';
@@ -12,6 +13,7 @@ import { $execCommand } from '../utils/execCommand/$execCommand';
12
13
  import { $execCommands } from '../utils/execCommand/$execCommands';
13
14
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
14
15
  export { createPipelineCollectionFromDirectory };
16
+ export { getAllCommitmentsToolFunctionsForNode };
15
17
  export { $provideExecutablesForNode };
16
18
  export { $provideExecutionToolsForNode };
17
19
  export { $provideLlmToolsConfigurationFromEnv };
@@ -9,17 +9,29 @@ import type { AvatarProfileProps } from '../book-components/AvatarProfile/Avatar
9
9
  import type { AvatarProfileFromSourceProps } from '../book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource';
10
10
  import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
11
11
  import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
12
+ import type { AgentChipData } from '../book-components/Chat/AgentChip/AgentChip';
13
+ import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip';
14
+ import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
12
15
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
16
+ import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
17
+ import type { ChatEffect } from '../book-components/Chat/effects/types/ChatEffect';
18
+ import type { ChatEffectConfig } from '../book-components/Chat/effects/types/ChatEffectConfig';
19
+ import type { ChatEffectsSystemProps } from '../book-components/Chat/effects/types/ChatEffectsSystemProps';
20
+ import type { ChatEffectType } from '../book-components/Chat/effects/types/ChatEffectType';
13
21
  import type { ChatAutoScrollConfig } from '../book-components/Chat/hooks/useChatAutoScroll';
14
22
  import type { SendMessageToLlmChatFunction } from '../book-components/Chat/hooks/useSendMessageToLlmChat';
23
+ import type { FriendlyErrorMessage } from '../book-components/Chat/LlmChat/FriendlyErrorMessage';
15
24
  import type { LlmChatProps } from '../book-components/Chat/LlmChat/LlmChatProps';
16
25
  import type { MockedChatDelayConfig } from '../book-components/Chat/MockedChat/MockedChat';
17
26
  import type { MockedChatProps } from '../book-components/Chat/MockedChat/MockedChat';
18
27
  import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_common/ChatSaveFormatDefinition';
19
28
  import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
29
+ import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceChip';
20
30
  import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
21
31
  import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
22
32
  import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
33
+ import type { ToolCallChipletInfo } from '../book-components/Chat/utils/getToolCallChipletText';
34
+ import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
23
35
  import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
24
36
  import type { TeamToolResult } from '../book-components/Chat/utils/toolCallParsing';
25
37
  import type { QrCodeOptions } from '../book-components/Qr/useQrCode';
@@ -60,7 +72,6 @@ import type { InstrumentCommand } from '../commands/X_INSTRUMENT/InstrumentComma
60
72
  import type { BookCommitment } from '../commitments/_base/BookCommitment';
61
73
  import type { CommitmentDefinition } from '../commitments/_base/CommitmentDefinition';
62
74
  import type { ParsedCommitment } from '../commitments/_base/ParsedCommitment';
63
- import type { GroupedCommitmentDefinition } from '../commitments/index';
64
75
  import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
65
76
  import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
66
77
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
@@ -392,17 +403,29 @@ export type { AvatarProfileProps };
392
403
  export type { AvatarProfileFromSourceProps };
393
404
  export type { BookEditorProps };
394
405
  export type { AgentChatProps };
406
+ export type { AgentChipData };
407
+ export type { AgentChipProps };
408
+ export type { ChatSoundSystem };
395
409
  export type { ChatProps };
410
+ export type { ChatSoundToggleProps };
411
+ export type { ChatEffect };
412
+ export type { ChatEffectConfig };
413
+ export type { ChatEffectsSystemProps };
414
+ export type { ChatEffectType };
396
415
  export type { ChatAutoScrollConfig };
397
416
  export type { SendMessageToLlmChatFunction };
417
+ export type { FriendlyErrorMessage };
398
418
  export type { LlmChatProps };
399
419
  export type { MockedChatDelayConfig };
400
420
  export type { MockedChatProps };
401
421
  export type { ChatSaveFormatDefinition };
402
422
  export type { string_chat_format_name };
423
+ export type { SourceChipProps };
403
424
  export type { ChatToolCall };
404
425
  export type { ChatMessage };
405
426
  export type { ChatParticipant };
427
+ export type { ToolCallChipletInfo };
428
+ export type { ParsedCitation };
406
429
  export type { MessageButton };
407
430
  export type { TeamToolResult };
408
431
  export type { QrCodeOptions };
@@ -443,7 +466,6 @@ export type { InstrumentCommand };
443
466
  export type { BookCommitment };
444
467
  export type { CommitmentDefinition };
445
468
  export type { ParsedCommitment };
446
- export type { GroupedCommitmentDefinition };
447
469
  export type { PrettifyOptions };
448
470
  export type { renderPipelineMermaidOptions };
449
471
  export type { CallbackInterfaceToolsOptions };
@@ -31,7 +31,7 @@ export type AgentCapability = {
31
31
  /**
32
32
  * The type of the capability
33
33
  */
34
- type: 'browser' | 'search-engine' | 'knowledge' | 'time' | 'inheritance' | 'import' | 'image-generator' | 'team';
34
+ type: 'browser' | 'search-engine' | 'knowledge' | 'time' | 'inheritance' | 'import' | 'image-generator' | 'team' | 'email';
35
35
  /**
36
36
  * The label to display for this capability
37
37
  */
@@ -0,0 +1,67 @@
1
+ /// <reference types="react" />
2
+ import type { string_url } from '../../../types/typeAliases';
3
+ /**
4
+ * Agent profile information for chip display
5
+ */
6
+ export type AgentChipData = {
7
+ /**
8
+ * Agent URL (required)
9
+ */
10
+ url: string_url;
11
+ /**
12
+ * Agent display name/label
13
+ */
14
+ label?: string;
15
+ /**
16
+ * Agent profile image URL
17
+ */
18
+ imageUrl?: string_url;
19
+ /**
20
+ * Public URL of the agents server (for generating placeholder images)
21
+ */
22
+ publicUrl?: string_url;
23
+ };
24
+ /**
25
+ * Props for AgentChip component
26
+ */
27
+ export type AgentChipProps = {
28
+ /**
29
+ * Agent data to display
30
+ */
31
+ agent: AgentChipData;
32
+ /**
33
+ * Whether this is an ongoing interaction (shows spinner)
34
+ */
35
+ isOngoing?: boolean;
36
+ /**
37
+ * Whether this is clickable (completed state)
38
+ */
39
+ isClickable?: boolean;
40
+ /**
41
+ * Click handler
42
+ */
43
+ onClick?: (event?: React.MouseEvent) => void;
44
+ /**
45
+ * Additional CSS class name
46
+ */
47
+ className?: string;
48
+ };
49
+ /**
50
+ * AgentChip component - displays a chip with agent avatar and name
51
+ *
52
+ * This component is used to display agent interactions in chat messages.
53
+ * It fetches the agent profile if needed and displays the agent's avatar and name.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * <AgentChip
58
+ * agent={{ url: 'https://agents.example.com/joe', label: 'Joe' }}
59
+ * isOngoing={false}
60
+ * isClickable={true}
61
+ * onClick={() => console.log('clicked')}
62
+ * />
63
+ * ```
64
+ *
65
+ * @private utility of `ChatMessageItem` component
66
+ */
67
+ export declare function AgentChip({ agent, isOngoing, isClickable, onClick, className }: AgentChipProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { AgentChip } from './AgentChip';
2
+ export type { AgentChipData, AgentChipProps } from './AgentChip';
@@ -2,6 +2,7 @@
2
2
  import type { id } from '../../../types/typeAliases';
3
3
  import type { ChatMessage } from '../types/ChatMessage';
4
4
  import type { ChatParticipant } from '../types/ChatParticipant';
5
+ import { type ParsedCitation } from '../utils/parseCitationsFromContent';
5
6
  import type { ChatProps } from './ChatProps';
6
7
  /**
7
8
  * Props for the `ChatMessageItem` component
@@ -38,10 +39,24 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
38
39
  * e.g., { "web_search": "Searching the web..." }
39
40
  */
40
41
  toolTitles?: Record<string, string>;
42
+ /**
43
+ * Optional metadata about teammates for team tool calls
44
+ * Maps tool name to agent information
45
+ */
46
+ teammates?: Record<string, {
47
+ url: string;
48
+ label?: string;
49
+ instructions?: string;
50
+ toolName: string;
51
+ }>;
41
52
  /**
42
53
  * Called when a tool call chiplet is clicked.
43
54
  */
44
55
  onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
56
+ /**
57
+ * Called when a source citation chip is clicked.
58
+ */
59
+ onCitationClick?: (citation: ParsedCitation) => void;
45
60
  };
46
61
  /**
47
62
  * Renders a single chat message item with avatar, content, buttons, and rating.
@@ -6,6 +6,21 @@ import { string_color } from '../../../types/typeAliases';
6
6
  import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
7
7
  import type { ChatMessage } from '../types/ChatMessage';
8
8
  import type { ChatParticipant } from '../types/ChatParticipant';
9
+ /**
10
+ * Interface for sound system that can be passed to Chat component
11
+ * This allows the chat to trigger sounds without tight coupling
12
+ *
13
+ * @public exported from `@promptbook/components`
14
+ */
15
+ export type ChatSoundSystem = {
16
+ /**
17
+ * @@@
18
+ */
19
+ play(event: string): Promise<void>;
20
+ isEnabled(): boolean;
21
+ setEnabled(enabled: boolean): void;
22
+ toggle(): boolean;
23
+ };
9
24
  /**
10
25
  * @public exported from `@promptbook/components`
11
26
  */
@@ -154,6 +169,16 @@ export type ChatProps = {
154
169
  * e.g., { "web_search": "Searching the web..." }
155
170
  */
156
171
  readonly toolTitles?: Record<string, string>;
172
+ /**
173
+ * Optional metadata about teammates for team tool calls
174
+ * Maps tool name to agent information
175
+ */
176
+ readonly teammates?: Record<string, {
177
+ url: string;
178
+ label?: string;
179
+ instructions?: string;
180
+ toolName: string;
181
+ }>;
157
182
  /**
158
183
  * Optional callback to create a new agent from the template.
159
184
  * If provided, renders the [Create Agent] button for book code blocks.
@@ -202,6 +227,49 @@ export type ChatProps = {
202
227
  * Visual style of the chat component
203
228
  */
204
229
  readonly visual: 'STANDALONE' | 'FULL_PAGE';
230
+ /**
231
+ * Optional array of effect configurations for chat animations
232
+ * When provided, enables visual effects (confetti, hearts, etc.) based on emojis in messages
233
+ *
234
+ * Example:
235
+ * ```typescript
236
+ * [
237
+ * { trigger: '🎉', effectType: 'CONFETTI' },
238
+ * { trigger: /❤️|💙|💚/, effectType: 'HEARTS' }
239
+ * ]
240
+ * ```
241
+ */
242
+ readonly effectConfigs?: ReadonlyArray<{
243
+ trigger: string | RegExp;
244
+ effectType: string;
245
+ }>;
246
+ /**
247
+ * Optional sound system for playing chat sounds
248
+ * When provided, enables sound effects for message events, button clicks, and visual effects
249
+ *
250
+ * The sound system should implement the ChatSoundSystem interface:
251
+ * - play(event: string): Plays a sound for the given event
252
+ * - isEnabled(): Returns whether sounds are enabled
253
+ * - setEnabled(enabled: boolean): Enables or disables sounds
254
+ * - toggle(): Toggles sound on/off and returns the new state
255
+ *
256
+ * Supported events:
257
+ * - 'message_send': When user sends a message
258
+ * - 'message_receive': When agent sends a message
259
+ * - 'message_typing': When agent is typing/thinking
260
+ * - 'button_click': When any button is clicked
261
+ * - 'effect_confetti': When confetti effect is triggered
262
+ * - 'effect_hearts': When hearts effect is triggered
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * import { createDefaultSoundSystem } from '@/utils/sound/createDefaultSoundSystem';
267
+ *
268
+ * const soundSystem = createDefaultSoundSystem();
269
+ * <Chat soundSystem={soundSystem} ... />
270
+ * ```
271
+ */
272
+ readonly soundSystem?: ChatSoundSystem;
205
273
  };
206
274
  /**
207
275
  * TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
@@ -0,0 +1,23 @@
1
+ import type { ChatSoundSystem } from './ChatProps';
2
+ /**
3
+ * Props for the ChatSoundToggle component
4
+ */
5
+ export type ChatSoundToggleProps = {
6
+ /**
7
+ * The sound system instance
8
+ */
9
+ soundSystem: ChatSoundSystem;
10
+ /**
11
+ * Optional CSS class name
12
+ */
13
+ className?: string;
14
+ };
15
+ /**
16
+ * ChatSoundToggle component
17
+ *
18
+ * Renders a toggle button/checkbox to enable/disable chat sounds.
19
+ * The state is persisted in localStorage via the SoundSystem.
20
+ *
21
+ * @public exported from `@promptbook/components`
22
+ */
23
+ export declare function ChatSoundToggle(props: ChatSoundToggleProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Error types for LlmChat component
3
+ *
4
+ * This is a minimal type definition for use in the Promptbook Engine component.
5
+ * The full implementation is in the Agent Server.
6
+ */
7
+ export type FriendlyErrorMessage = {
8
+ /**
9
+ * @@@
10
+ */
11
+ title: string;
12
+ /**
13
+ * @@@
14
+ */
15
+ message: string;
16
+ /**
17
+ * @@@
18
+ */
19
+ canRetry: boolean;
20
+ };
@@ -62,4 +62,12 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
62
62
  * e.g., { "web_search": "Searching the web..." }
63
63
  */
64
64
  readonly toolTitles?: Record<string, string>;
65
+ /**
66
+ * Optional custom error handler that will be called when an error occurs during chat.
67
+ * If not provided, errors will be displayed as messages in the chat.
68
+ *
69
+ * @param error - The error that occurred
70
+ * @param retry - Function to retry the last failed message
71
+ */
72
+ onError?(error: unknown, retry: () => void): void;
65
73
  };
@@ -0,0 +1,35 @@
1
+ import type { ParsedCitation } from '../utils/parseCitationsFromContent';
2
+ /**
3
+ * Props for SourceChip component
4
+ */
5
+ export type SourceChipProps = {
6
+ /**
7
+ * Citation data to display
8
+ */
9
+ citation: ParsedCitation;
10
+ /**
11
+ * Click handler
12
+ */
13
+ onClick?: (citation: ParsedCitation) => void;
14
+ /**
15
+ * Additional CSS class name
16
+ */
17
+ className?: string;
18
+ };
19
+ /**
20
+ * SourceChip component - displays a chip with source document information
21
+ *
22
+ * This component is used to display RAG source citations in chat messages.
23
+ * It displays the source document name and citation ID.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <SourceChip
28
+ * citation={{ id: '5:13', source: 'document.pdf' }}
29
+ * onClick={(citation) => console.log('clicked', citation)}
30
+ * />
31
+ * ```
32
+ *
33
+ * @private utility of `ChatMessageItem` component
34
+ */
35
+ export declare function SourceChip({ citation, onClick, className }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { SourceChip } from './SourceChip';
2
+ export type { SourceChipProps } from './SourceChip';
@@ -0,0 +1,14 @@
1
+ import type { ChatEffectsSystemProps } from './types/ChatEffectsSystemProps';
2
+ /**
3
+ * ChatEffectsSystem component
4
+ * Monitors chat messages and triggers visual effects based on emoji content
5
+ *
6
+ * This component:
7
+ * - Tracks which messages have already been processed
8
+ * - Detects emojis in new agent messages
9
+ * - Triggers appropriate effects (confetti, hearts, etc.)
10
+ * - Handles effect lifecycle (creation, completion, cleanup)
11
+ *
12
+ * @public exported from `@promptbook/components`
13
+ */
14
+ export declare function ChatEffectsSystem(props: ChatEffectsSystemProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ type ConfettiEffectProps = {
2
+ /**
3
+ * Unique identifier for this effect instance
4
+ */
5
+ effectId: string;
6
+ /**
7
+ * Callback when the effect completes
8
+ */
9
+ onComplete?: () => void;
10
+ };
11
+ /**
12
+ * Confetti effect component
13
+ * Renders falling confetti particles from the top of the screen
14
+ *
15
+ * @public exported from `@promptbook/components`
16
+ */
17
+ export declare function ConfettiEffect(props: ConfettiEffectProps): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,18 @@
1
+ type HeartsEffectProps = {
2
+ /**
3
+ * Unique identifier for this effect instance
4
+ */
5
+ effectId: string;
6
+ /**
7
+ * Callback when the effect completes
8
+ */
9
+ onComplete?: () => void;
10
+ };
11
+ /**
12
+ * Hearts effect component
13
+ * Renders floating hearts that rise from the bottom of the screen
14
+ *
15
+ * @public exported from `@promptbook/components`
16
+ */
17
+ export declare function HeartsEffect(props: HeartsEffectProps): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { ChatEffectConfig } from '../types/ChatEffectConfig';
2
+ /**
3
+ * Default effect configurations for common chat emojis
4
+ *
5
+ * @public exported from `@promptbook/components`
6
+ */
7
+ export declare const defaultEffectConfigs: ReadonlyArray<ChatEffectConfig>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Chat effects system exports
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { ChatEffectsSystem } from './ChatEffectsSystem';
7
+ export { ConfettiEffect } from './components/ConfettiEffect';
8
+ export { HeartsEffect } from './components/HeartsEffect';
9
+ export { defaultEffectConfigs } from './configs/defaultEffectConfigs';
10
+ export type { ChatEffect } from './types/ChatEffect';
11
+ export type { ChatEffectConfig } from './types/ChatEffectConfig';
12
+ export type { ChatEffectsSystemProps } from './types/ChatEffectsSystemProps';
13
+ export type { ChatEffectType } from './types/ChatEffectType';
14
+ export { detectEffects } from './utils/detectEffects';
15
+ /**
16
+ * TODO: !!!!! To rules: Do not create index files that re-ex-port from multiple files, import directly instead or use full register
17
+ * Note: [💞] Ignore a discrepancy between file name and entity name
18
+ */
@@ -0,0 +1,20 @@
1
+ import type { ChatEffectType } from './ChatEffectType';
2
+ /**
3
+ * Represents a chat effect instance
4
+ *
5
+ * @public exported from `@promptbook/components`
6
+ */
7
+ export type ChatEffect = {
8
+ /**
9
+ * Unique identifier for this effect instance
10
+ */
11
+ id: string;
12
+ /**
13
+ * Type of effect
14
+ */
15
+ type: ChatEffectType;
16
+ /**
17
+ * Timestamp when the effect was triggered
18
+ */
19
+ timestamp: number;
20
+ };
@@ -0,0 +1,21 @@
1
+ import type { ChatEffectType } from './ChatEffectType';
2
+ /**
3
+ * Configuration for a chat effect trigger
4
+ *
5
+ * @public exported from `@promptbook/components`
6
+ */
7
+ export type ChatEffectConfig = {
8
+ /**
9
+ * Emoji or pattern that triggers this effect
10
+ */
11
+ trigger: string | RegExp;
12
+ /**
13
+ * Type of effect to trigger
14
+ */
15
+ effectType: ChatEffectType;
16
+ /**
17
+ * Whether to match all heart emojis (❤️, 💙, 💚, etc.)
18
+ * Only relevant for heart effects
19
+ */
20
+ matchAllHeartEmojis?: boolean;
21
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Types of chat effects that can be triggered
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export type ChatEffectType = 'CONFETTI' | 'HEARTS';
@@ -0,0 +1,32 @@
1
+ import type { ChatSoundSystem } from '../../Chat/ChatProps';
2
+ import type { ChatMessage } from '../../types/ChatMessage';
3
+ import type { ChatEffectConfig } from './ChatEffectConfig';
4
+ /**
5
+ * Props for the ChatEffectsSystem component
6
+ *
7
+ * @public exported from `@promptbook/components`
8
+ */
9
+ export type ChatEffectsSystemProps = {
10
+ /**
11
+ * Array of chat messages to monitor for effect triggers
12
+ */
13
+ messages: ReadonlyArray<ChatMessage>;
14
+ /**
15
+ * Array of effect configurations
16
+ * Defines which emojis/patterns trigger which effects
17
+ */
18
+ effectConfigs: ReadonlyArray<ChatEffectConfig>;
19
+ /**
20
+ * Optional filter function to determine if a message should trigger effects
21
+ * By default, only agent messages trigger effects
22
+ */
23
+ shouldTriggerEffect?: (message: ChatMessage) => boolean;
24
+ /**
25
+ * CSS class name for the effects container
26
+ */
27
+ className?: string;
28
+ /**
29
+ * Optional sound system to play sounds when effects are triggered
30
+ */
31
+ soundSystem?: ChatSoundSystem;
32
+ };
@@ -0,0 +1,12 @@
1
+ import type { ChatMessage } from '../../types/ChatMessage';
2
+ import type { ChatEffectConfig } from '../types/ChatEffectConfig';
3
+ import type { ChatEffectType } from '../types/ChatEffectType';
4
+ /**
5
+ * Detects which effects should be triggered based on message content
6
+ *
7
+ * @param message - The chat message to analyze
8
+ * @param effectConfigs - Array of effect configurations
9
+ * @returns Array of unique effect types to trigger
10
+ * @private utility function of Effects system
11
+ */
12
+ export declare function detectEffects(message: ChatMessage, effectConfigs: ReadonlyArray<ChatEffectConfig>): ChatEffectType[];
@@ -66,6 +66,27 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
66
66
  */
67
67
  url: string;
68
68
  }>;
69
+ /**
70
+ * Optional source citations/annotations (from RAG systems like OpenAI Assistants)
71
+ */
72
+ readonly citations?: ReadonlyArray<{
73
+ /**
74
+ * The unique identifier for the citation (e.g., "5:13")
75
+ */
76
+ id: string;
77
+ /**
78
+ * The source document name (e.g., "document.pdf")
79
+ */
80
+ source: string;
81
+ /**
82
+ * Optional URL to the source document
83
+ */
84
+ url?: string;
85
+ /**
86
+ * Optional preview/excerpt from the source
87
+ */
88
+ excerpt?: string;
89
+ }>;
69
90
  };
70
91
  /**
71
92
  * TODO: Make all fields readonly