@promptbook/types 0.105.0-3 → 0.105.0-30
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/README.md +36 -77
- package/esm/typings/src/_packages/browser.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +20 -0
- package/esm/typings/src/_packages/core.index.d.ts +19 -11
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/openai.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +44 -2
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-2.0/agent-source/parseTeamCommitment.d.ts +28 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
- package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +33 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +89 -11
- package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
- package/esm/typings/src/book-components/Chat/Chat/ClockIcon.d.ts +9 -0
- package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
- package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
- package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
- package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
- package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
- package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
- package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
- package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +37 -0
- package/esm/typings/src/book-components/Chat/utils/createTeamToolNameFromUrl.d.ts +12 -0
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +40 -0
- package/esm/typings/src/book-components/Chat/utils/loadAgentProfile.d.ts +69 -0
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
- package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +64 -0
- package/esm/typings/src/book-components/icons/EmailIcon.d.ts +15 -0
- package/esm/typings/src/commitments/NOTE/NOTE.d.ts +2 -2
- package/esm/typings/src/commitments/TEAM/TEAM.d.ts +45 -0
- package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
- package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +19 -1
- package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
- package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
- package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +48 -0
- package/esm/typings/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +11 -0
- package/esm/typings/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +18 -0
- package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
- package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +11 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +6 -0
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
- package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +6 -0
- package/esm/typings/src/commitments/_base/formatOptionalInstructionBlock.d.ts +6 -0
- package/esm/typings/src/commitments/_common/commitmentToolFunctions.d.ts +26 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +9 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +13 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
- package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
- package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
- package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
- package/esm/typings/src/commitments/index.d.ts +5 -58
- package/esm/typings/src/constants.d.ts +129 -0
- package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/execution/PromptResult.d.ts +2 -19
- package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +7 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +43 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +4 -2
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -1
- package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
- package/esm/typings/src/pipeline/prompt-notation.d.ts +27 -2
- package/esm/typings/src/pipeline/prompt-notation.test.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
- package/esm/typings/src/search-engines/SearchEngine.d.ts +1 -1
- package/esm/typings/src/search-engines/_index.d.ts +6 -0
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
- package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
- package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
- package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
- package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +35 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +6 -0
- package/esm/typings/src/types/Prompt.d.ts +12 -0
- package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
- package/esm/typings/src/types/ToolCall.d.ts +37 -0
- package/esm/typings/src/types/typeAliases.d.ts +4 -0
- package/esm/typings/src/utils/misc/linguisticHash.d.ts +6 -0
- package/esm/typings/src/utils/misc/linguisticHash.test.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +1 -4
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -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
|
|
@@ -33,11 +34,42 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
|
|
|
33
34
|
* Called when the create agent button is pressed for book code blocks.
|
|
34
35
|
*/
|
|
35
36
|
onCreateAgent?: (bookContent: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Optional mapping of technical tool names to human-readable titles.
|
|
39
|
+
* e.g., { "web_search": "Searching the web..." }
|
|
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?: TeammatesMap;
|
|
47
|
+
/**
|
|
48
|
+
* Called when a tool call chiplet is clicked.
|
|
49
|
+
*/
|
|
50
|
+
onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Called when a source citation chip is clicked.
|
|
53
|
+
*/
|
|
54
|
+
onCitationClick?: (citation: ParsedCitation) => void;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Metadata for a teammate agent tool.
|
|
58
|
+
*/
|
|
59
|
+
type TeammateMetadata = {
|
|
60
|
+
url: string;
|
|
61
|
+
label?: string;
|
|
62
|
+
instructions?: string;
|
|
63
|
+
toolName: string;
|
|
36
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Lookup map of teammate metadata by tool name.
|
|
67
|
+
*/
|
|
68
|
+
type TeammatesMap = Record<string, TeammateMetadata>;
|
|
37
69
|
/**
|
|
38
70
|
* Renders a single chat message item with avatar, content, buttons, and rating.
|
|
39
71
|
*
|
|
40
72
|
* @private internal subcomponent of `<Chat>` component
|
|
41
73
|
*/
|
|
42
|
-
export declare const ChatMessageItem: import("react").MemoExoticComponent<(
|
|
74
|
+
export declare const ChatMessageItem: import("react").MemoExoticComponent<(props: ChatMessageItemProps) => import("react/jsx-runtime").JSX.Element>;
|
|
43
75
|
export {};
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { Promisable } from 'type-fest';
|
|
3
|
+
import { Color } from '../../../_packages/color.index';
|
|
4
|
+
import { SpeechRecognition } from '../../../types/SpeechRecognition';
|
|
5
|
+
import { string_color } from '../../../types/typeAliases';
|
|
3
6
|
import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
|
|
4
7
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
5
8
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
};
|
|
8
24
|
/**
|
|
9
25
|
* @public exported from `@promptbook/components`
|
|
10
26
|
*/
|
|
@@ -47,13 +63,9 @@ export type ChatProps = {
|
|
|
47
63
|
*/
|
|
48
64
|
readonly isVoiceRecognitionButtonShown?: boolean;
|
|
49
65
|
/**
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
onVoiceInput?(): void;
|
|
53
|
-
/**
|
|
54
|
-
* The language code to use for voice recognition
|
|
66
|
+
* Speech recognition provider
|
|
55
67
|
*/
|
|
56
|
-
readonly
|
|
68
|
+
readonly speechRecognition?: SpeechRecognition;
|
|
57
69
|
/**
|
|
58
70
|
* Optional placeholder message for the textarea
|
|
59
71
|
*
|
|
@@ -152,6 +164,26 @@ export type ChatProps = {
|
|
|
152
164
|
* Keys should match ChatMessage.from values (e.g., 'USER', 'AGENT_{id}', etc.)
|
|
153
165
|
*/
|
|
154
166
|
readonly participants?: ReadonlyArray<ChatParticipant>;
|
|
167
|
+
/**
|
|
168
|
+
* Optional mapping of technical tool names to human-readable titles.
|
|
169
|
+
* e.g., { "web_search": "Searching the web..." }
|
|
170
|
+
*/
|
|
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
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Optional callback to create a new agent from the template.
|
|
184
|
+
* If provided, renders the [Create Agent] button for book code blocks.
|
|
185
|
+
*/
|
|
186
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
155
187
|
/**
|
|
156
188
|
* Optional callback for handling user feedback on messages
|
|
157
189
|
* When provided, star rating buttons (1-5 stars) will be displayed next to each message
|
|
@@ -188,10 +220,56 @@ export type ChatProps = {
|
|
|
188
220
|
*/
|
|
189
221
|
isCopyButtonEnabled?: boolean;
|
|
190
222
|
/**
|
|
191
|
-
*
|
|
192
|
-
* When provided, "Create Agent" buttons will be shown for book code blocks.
|
|
223
|
+
* Called when a tool call chiplet is clicked.
|
|
193
224
|
*/
|
|
194
|
-
|
|
225
|
+
onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
|
|
226
|
+
/**
|
|
227
|
+
* Visual style of the chat component
|
|
228
|
+
*/
|
|
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;
|
|
195
273
|
};
|
|
196
274
|
/**
|
|
197
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
|
+
};
|
|
@@ -57,4 +57,17 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
|
|
|
57
57
|
* This is useful for seamless transitions from other pages.
|
|
58
58
|
*/
|
|
59
59
|
readonly autoExecuteMessage?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Optional mapping of technical tool names to human-readable titles.
|
|
62
|
+
* e.g., { "web_search": "Searching the web..." }
|
|
63
|
+
*/
|
|
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;
|
|
60
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,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,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,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[];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Message } from '../../../types/Message';
|
|
2
|
+
import type { ToolCall } from '../../../types/ToolCall';
|
|
2
3
|
import type { id, string_markdown } from '../../../types/typeAliases';
|
|
4
|
+
export type ChatToolCall = ToolCall;
|
|
3
5
|
/**
|
|
4
6
|
* Represents a single message within a chat interface.
|
|
5
7
|
*
|
|
@@ -33,6 +35,20 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
|
|
|
33
35
|
* Indicates if the message was sent via a voice call
|
|
34
36
|
*/
|
|
35
37
|
isVoiceCall?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Optional tool calls made during the execution
|
|
40
|
+
*/
|
|
41
|
+
readonly ongoingToolCalls?: ReadonlyArray<ChatToolCall>;
|
|
42
|
+
/**
|
|
43
|
+
* Optional tool calls used to produce this message.
|
|
44
|
+
*/
|
|
45
|
+
readonly toolCalls?: ReadonlyArray<ChatToolCall>;
|
|
46
|
+
/**
|
|
47
|
+
* Optional tool calls that have been completed
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Use `toolCalls` instead.
|
|
50
|
+
*/
|
|
51
|
+
readonly completedToolCalls?: ReadonlyArray<ChatToolCall>;
|
|
36
52
|
/**
|
|
37
53
|
* Optional file attachments
|
|
38
54
|
*/
|
|
@@ -50,6 +66,27 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
|
|
|
50
66
|
*/
|
|
51
67
|
url: string;
|
|
52
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
|
+
}>;
|
|
53
90
|
};
|
|
54
91
|
/**
|
|
55
92
|
* TODO: Make all fields readonly
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds a TEAM tool name from a teammate agent URL.
|
|
3
|
+
*
|
|
4
|
+
* @private utility of chat components
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTeamToolNameFromUrl(url: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Checks whether a tool name belongs to a TEAM tool.
|
|
9
|
+
*
|
|
10
|
+
* @private utility of chat components
|
|
11
|
+
*/
|
|
12
|
+
export declare function isTeamToolName(name: string): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ToolCall } from '../../../types/ToolCall';
|
|
2
|
+
import type { AgentChipData } from '../AgentChip';
|
|
3
|
+
/**
|
|
4
|
+
* Utility to format tool call information for user-friendly display.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Tool call chiplet information including agent data for team tools
|
|
8
|
+
*/
|
|
9
|
+
export type ToolCallChipletInfo = {
|
|
10
|
+
/**
|
|
11
|
+
* Display text for the chiplet
|
|
12
|
+
*/
|
|
13
|
+
text: string;
|
|
14
|
+
/**
|
|
15
|
+
* Agent data for team tools (if applicable)
|
|
16
|
+
*/
|
|
17
|
+
agentData?: AgentChipData;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Technical to user-friendly tool names and emojis
|
|
21
|
+
*
|
|
22
|
+
* @private [🧠] Maybe public?
|
|
23
|
+
*/
|
|
24
|
+
export declare const TOOL_TITLES: Record<string, {
|
|
25
|
+
title: string;
|
|
26
|
+
emoji: string;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the user-friendly text for a tool call chiplet.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated Use getToolCallChipletInfo instead which returns both text and agent data
|
|
32
|
+
* @private [🧠] Maybe public?
|
|
33
|
+
*/
|
|
34
|
+
export declare function getToolCallChipletText(toolCall: ToolCall): string;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the chiplet information including text and agent data (for team tools).
|
|
37
|
+
*
|
|
38
|
+
* @private [🧠] Maybe public?
|
|
39
|
+
*/
|
|
40
|
+
export declare function getToolCallChipletInfo(toolCall: ToolCall): ToolCallChipletInfo;
|