@promptbook/vercel 0.101.0-0 β†’ 0.101.0-10

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 (60) hide show
  1. package/esm/index.es.js +4 -1
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/components.index.d.ts +18 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +41 -3
  7. package/esm/typings/src/book-2.0/agent-source/parseParameters.d.ts +13 -0
  8. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +8 -2
  9. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +59 -0
  10. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +8 -2
  11. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +45 -0
  12. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +1 -1
  13. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +46 -0
  14. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +47 -0
  15. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +62 -0
  16. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +8 -2
  17. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +8 -2
  18. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +8 -2
  19. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +46 -0
  20. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +8 -2
  21. package/esm/typings/src/book-2.0/commitments/index.d.ts +7 -3
  22. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +46 -0
  23. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +3 -0
  24. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +10 -0
  25. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +3 -0
  26. package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +0 -5
  27. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +28 -2
  28. package/esm/typings/src/book-components/Chat/Chat/constants.d.ts +8 -0
  29. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +16 -0
  30. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +21 -0
  31. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.test.d.ts +1 -0
  32. package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +9 -0
  33. package/esm/typings/src/book-components/icons/ResetIcon.d.ts +6 -0
  34. package/esm/typings/src/book-components/icons/SendIcon.d.ts +8 -0
  35. package/esm/typings/src/book-components/icons/TemplateIcon.d.ts +8 -0
  36. package/esm/typings/src/utils/markdown/escapeMarkdownBlock.d.ts +2 -0
  37. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +2 -0
  38. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -0
  39. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -0
  40. package/esm/typings/src/utils/markdown/humanizeAiTextQuotes.d.ts +1 -0
  41. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -0
  42. package/esm/typings/src/utils/markdown/prettifyMarkdown.d.ts +8 -0
  43. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +1 -0
  44. package/esm/typings/src/utils/normalization/capitalize.d.ts +2 -0
  45. package/esm/typings/src/utils/normalization/decapitalize.d.ts +3 -1
  46. package/esm/typings/src/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +2 -0
  47. package/esm/typings/src/utils/normalization/normalizeTo_snake_case.d.ts +2 -0
  48. package/esm/typings/src/utils/normalization/normalizeWhitespaces.d.ts +2 -0
  49. package/esm/typings/src/utils/normalization/removeDiacritics.d.ts +2 -0
  50. package/esm/typings/src/utils/parseNumber.d.ts +1 -0
  51. package/esm/typings/src/utils/removeEmojis.d.ts +2 -0
  52. package/esm/typings/src/utils/removeQuotes.d.ts +1 -0
  53. package/esm/typings/src/utils/serialization/deepClone.d.ts +1 -0
  54. package/esm/typings/src/utils/trimCodeBlock.d.ts +1 -0
  55. package/esm/typings/src/utils/validators/url/isValidUrl.d.ts +1 -0
  56. package/esm/typings/src/utils/validators/uuid/isValidUuid.d.ts +2 -0
  57. package/esm/typings/src/version.d.ts +1 -1
  58. package/package.json +2 -2
  59. package/umd/index.umd.js +4 -1
  60. package/umd/index.umd.js.map +1 -1
@@ -0,0 +1,62 @@
1
+ import type { AgentModelRequirements } from '../../agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * META commitment definition
5
+ *
6
+ * The META commitment handles all meta-information about the agent such as:
7
+ * - META IMAGE: Sets the agent's avatar/profile image URL
8
+ * - META LINK: Provides profile/source links for the person the agent models
9
+ * - META TITLE: Sets the agent's display title
10
+ * - META DESCRIPTION: Sets the agent's description
11
+ * - META [ANYTHING]: Any other meta information in uppercase format
12
+ *
13
+ * These commitments are special because they don't affect the system message,
14
+ * but are handled separately in the parsing logic for profile display.
15
+ *
16
+ * Example usage in agent source:
17
+ *
18
+ * ```book
19
+ * META IMAGE https://example.com/avatar.jpg
20
+ * META LINK https://twitter.com/username
21
+ * META TITLE Professional Assistant
22
+ * META DESCRIPTION An AI assistant specialized in business tasks
23
+ * META AUTHOR John Doe
24
+ * META VERSION 1.0
25
+ * ```
26
+ *
27
+ * @private [πŸͺ”] Maybe export the commitments through some package
28
+ */
29
+ export declare class MetaCommitmentDefinition extends BaseCommitmentDefinition<`META${string}`> {
30
+ constructor();
31
+ /**
32
+ * Short one-line description of META commitments.
33
+ */
34
+ get description(): string;
35
+ /**
36
+ * Markdown documentation for META commitment.
37
+ */
38
+ get documentation(): string;
39
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
40
+ /**
41
+ * Extracts meta information from the content based on the meta type
42
+ * This is used by the parsing logic
43
+ */
44
+ extractMetaValue(metaType: string, content: string): string | null;
45
+ /**
46
+ * Validates if the provided content is a valid URL (for IMAGE and LINK types)
47
+ */
48
+ isValidUrl(content: string): boolean;
49
+ /**
50
+ * Checks if this is a known meta type
51
+ */
52
+ isKnownMetaType(metaType: string): boolean;
53
+ }
54
+ /**
55
+ * Singleton instance of the META commitment definition
56
+ *
57
+ * @private [πŸͺ”] Maybe export the commitments through some package
58
+ */
59
+ export declare const MetaCommitment: MetaCommitmentDefinition;
60
+ /**
61
+ * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
62
+ */
@@ -16,8 +16,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
16
16
  *
17
17
  * @private [πŸͺ”] Maybe export the commitments through some package
18
18
  */
19
- export declare class ModelCommitmentDefinition extends BaseCommitmentDefinition<'MODEL'> {
20
- constructor();
19
+ export declare class ModelCommitmentDefinition extends BaseCommitmentDefinition<'MODEL' | 'MODELS'> {
20
+ constructor(type?: 'MODEL' | 'MODELS');
21
21
  /**
22
22
  * Short one-line description of MODEL.
23
23
  */
@@ -34,6 +34,12 @@ export declare class ModelCommitmentDefinition extends BaseCommitmentDefinition<
34
34
  * @private [πŸͺ”] Maybe export the commitments through some package
35
35
  */
36
36
  export declare const ModelCommitment: ModelCommitmentDefinition;
37
+ /**
38
+ * Singleton instance of the MODELS commitment definition
39
+ *
40
+ * @private [πŸͺ”] Maybe export the commitments through some package
41
+ */
42
+ export declare const ModelsCommitment: ModelCommitmentDefinition;
37
43
  /**
38
44
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
39
45
  */
@@ -26,8 +26,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
26
26
  *
27
27
  * @private [πŸͺ”] Maybe export the commitments through some package
28
28
  */
29
- export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'NOTE'> {
30
- constructor();
29
+ export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'NOTE' | 'NOTES'> {
30
+ constructor(type?: 'NOTE' | 'NOTES');
31
31
  /**
32
32
  * Short one-line description of NOTE.
33
33
  */
@@ -44,6 +44,12 @@ export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'
44
44
  * @private [πŸͺ”] Maybe export the commitments through some package
45
45
  */
46
46
  export declare const NoteCommitment: NoteCommitmentDefinition;
47
+ /**
48
+ * Singleton instance of the NOTES commitment definition
49
+ *
50
+ * @private [πŸͺ”] Maybe export the commitments through some package
51
+ */
52
+ export declare const NotesCommitment: NoteCommitmentDefinition;
47
53
  /**
48
54
  * [πŸ’ž] Ignore a discrepancy between file name and entity name
49
55
  */
@@ -23,8 +23,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
23
23
  *
24
24
  * @private [πŸͺ”] Maybe export the commitments through some package
25
25
  */
26
- export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinition<'PERSONA'> {
27
- constructor();
26
+ export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinition<'PERSONA' | 'PERSONAE'> {
27
+ constructor(type?: 'PERSONA' | 'PERSONAE');
28
28
  /**
29
29
  * Short one-line description of PERSONA.
30
30
  */
@@ -41,6 +41,12 @@ export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinitio
41
41
  * @private [πŸͺ”] Maybe export the commitments through some package
42
42
  */
43
43
  export declare const PersonaCommitment: PersonaCommitmentDefinition;
44
+ /**
45
+ * Singleton instance of the PERSONAE commitment definition
46
+ *
47
+ * @private [πŸͺ”] Maybe export the commitments through some package
48
+ */
49
+ export declare const PersonaeCommitment: PersonaCommitmentDefinition;
44
50
  /**
45
51
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
46
52
  */
@@ -0,0 +1,46 @@
1
+ import type { AgentModelRequirements } from '../../agent-source/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
3
+ /**
4
+ * SCENARIO commitment definition
5
+ *
6
+ * The SCENARIO commitment defines a specific situation or context in which the AI
7
+ * assistant should operate. It helps to set the scene for the AI's responses.
8
+ * Later scenarios are more important than earlier scenarios.
9
+ *
10
+ * Example usage in agent source:
11
+ *
12
+ * ```book
13
+ * SCENARIO You are in a customer service call center during peak hours
14
+ * SCENARIO The customer is frustrated and has been on hold for 20 minutes
15
+ * SCENARIO This is the customer's third call about the same issue
16
+ * ```
17
+ *
18
+ * @private [πŸͺ”] Maybe export the commitments through some package
19
+ */
20
+ export declare class ScenarioCommitmentDefinition extends BaseCommitmentDefinition<'SCENARIO' | 'SCENARIOS'> {
21
+ constructor(type?: 'SCENARIO' | 'SCENARIOS');
22
+ /**
23
+ * Short one-line description of SCENARIO.
24
+ */
25
+ get description(): string;
26
+ /**
27
+ * Markdown documentation for SCENARIO commitment.
28
+ */
29
+ get documentation(): string;
30
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
31
+ }
32
+ /**
33
+ * Singleton instance of the SCENARIO commitment definition
34
+ *
35
+ * @private [πŸͺ”] Maybe export the commitments through some package
36
+ */
37
+ export declare const ScenarioCommitment: ScenarioCommitmentDefinition;
38
+ /**
39
+ * Singleton instance of the SCENARIOS commitment definition
40
+ *
41
+ * @private [πŸͺ”] Maybe export the commitments through some package
42
+ */
43
+ export declare const ScenariosCommitment: ScenarioCommitmentDefinition;
44
+ /**
45
+ * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
46
+ */
@@ -15,8 +15,8 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
15
15
  *
16
16
  * @private [πŸͺ”] Maybe export the commitments through some package
17
17
  */
18
- export declare class StyleCommitmentDefinition extends BaseCommitmentDefinition<'STYLE'> {
19
- constructor();
18
+ export declare class StyleCommitmentDefinition extends BaseCommitmentDefinition<'STYLE' | 'STYLES'> {
19
+ constructor(type?: 'STYLE' | 'STYLES');
20
20
  /**
21
21
  * Short one-line description of STYLE.
22
22
  */
@@ -33,6 +33,12 @@ export declare class StyleCommitmentDefinition extends BaseCommitmentDefinition<
33
33
  * @private [πŸͺ”] Maybe export the commitments through some package
34
34
  */
35
35
  export declare const StyleCommitment: StyleCommitmentDefinition;
36
+ /**
37
+ * Singleton instance of the STYLES commitment definition
38
+ *
39
+ * @private [πŸͺ”] Maybe export the commitments through some package
40
+ */
41
+ export declare const StylesCommitment: StyleCommitmentDefinition;
36
42
  /**
37
43
  * [πŸ’ž] Ignore a discrepancy between file name and entity name
38
44
  */
@@ -1,15 +1,19 @@
1
1
  import type { BookCommitment } from './_base/BookCommitment';
2
2
  import type { CommitmentDefinition } from './_base/CommitmentDefinition';
3
3
  import { ActionCommitmentDefinition } from './ACTION/ACTION';
4
+ import { DeleteCommitmentDefinition } from './DELETE/DELETE';
4
5
  import { FormatCommitmentDefinition } from './FORMAT/FORMAT';
6
+ import { GoalCommitmentDefinition } from './GOAL/GOAL';
5
7
  import { KnowledgeCommitmentDefinition } from './KNOWLEDGE/KNOWLEDGE';
6
- import { MetaImageCommitmentDefinition } from './META_IMAGE/META_IMAGE';
7
- import { MetaLinkCommitmentDefinition } from './META_LINK/META_LINK';
8
+ import { MemoryCommitmentDefinition } from './MEMORY/MEMORY';
9
+ import { MessageCommitmentDefinition } from './MESSAGE/MESSAGE';
10
+ import { MetaCommitmentDefinition } from './META/META';
8
11
  import { ModelCommitmentDefinition } from './MODEL/MODEL';
9
12
  import { NoteCommitmentDefinition } from './NOTE/NOTE';
10
13
  import { PersonaCommitmentDefinition } from './PERSONA/PERSONA';
11
14
  import { RuleCommitmentDefinition } from './RULE/RULE';
12
15
  import { SampleCommitmentDefinition } from './SAMPLE/SAMPLE';
16
+ import { ScenarioCommitmentDefinition } from './SCENARIO/SCENARIO';
13
17
  import { StyleCommitmentDefinition } from './STYLE/STYLE';
14
18
  import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplementedCommitmentDefinition';
15
19
  /**
@@ -19,7 +23,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
19
23
  *
20
24
  * @private Use functions to access commitments instead of this array directly
21
25
  */
22
- export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, MetaImageCommitmentDefinition, MetaLinkCommitmentDefinition, NoteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"SCENARIO">, NotYetImplementedCommitmentDefinition<"SCENARIOS">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"GOAL">, NotYetImplementedCommitmentDefinition<"GOALS">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
26
+ export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
23
27
  /**
24
28
  * Gets a commitment definition by its type
25
29
  * @param type The commitment type to look up
@@ -0,0 +1,46 @@
1
+ import type { ChatProps } from '../../Chat/Chat/ChatProps';
2
+ /**
3
+ * Delay configuration for the MockedChat component
4
+ *
5
+ * @public exported from `@promptbook/components`
6
+ */
7
+ export type MockedChatDelayConfig = {
8
+ /**
9
+ * Delay before showing the first message (in milliseconds)
10
+ * @default 1000
11
+ */
12
+ beforeFirstMessage?: number;
13
+ /**
14
+ * Emulated thinking time between messages (in milliseconds)
15
+ * @default 2000
16
+ */
17
+ thinkingBetweenMessages?: number;
18
+ /**
19
+ * Wait time after each written word (in milliseconds)
20
+ * @default 100
21
+ */
22
+ waitAfterWord?: number;
23
+ /**
24
+ * Extra delay on top of the word waiting (in milliseconds)
25
+ * @default 50
26
+ */
27
+ extraWordDelay?: number;
28
+ };
29
+ /**
30
+ * Props for MockedChat component
31
+ *
32
+ * @public exported from `@promptbook/components`
33
+ */
34
+ export type MockedChatProps = ChatProps & {
35
+ /**
36
+ * Optional delays configuration for emulating typing behavior
37
+ */
38
+ delayConfig?: MockedChatDelayConfig;
39
+ };
40
+ /**
41
+ * MockedChat component that shows the same chat as Chat but emulates ongoing discussion
42
+ * with realistic typing delays and thinking pauses.
43
+ *
44
+ * @public exported from `@promptbook/components`
45
+ */
46
+ export declare function MockedChat(props: MockedChatProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export * from './AvatarProfile';
2
+ export * from './AvatarProfileFromSource';
3
+ export * from './MockedChat';
@@ -1,5 +1,7 @@
1
1
  import type { CSSProperties } from 'react';
2
+ import type { Promisable } from 'type-fest';
2
3
  import type { string_book } from '../../book-2.0/agent-source/string_book';
4
+ import { string_knowledge_source_content } from '../../types/typeAliases';
3
5
  /**
4
6
  * Props of `BookEditor`
5
7
  *
@@ -27,10 +29,18 @@ export type BookEditorProps = {
27
29
  * Callback function to handle changes in the book content.
28
30
  */
29
31
  onChange?(value: string_book): void;
32
+ /**
33
+ * returns the URL of the uploaded file on CDN or storage
34
+ */
35
+ onFileUpload?(file: File): Promisable<string_knowledge_source_content>;
30
36
  /**
31
37
  * If true, logs verbose debug info to the console and shows additional visual cues
32
38
  */
33
39
  readonly isVerbose?: boolean;
40
+ /**
41
+ * If true, disables border radius making the editor have sharp corners
42
+ */
43
+ readonly isBorderRadiusDisabled?: boolean;
34
44
  };
35
45
  /**
36
46
  * Renders a book editor
@@ -1,3 +1,4 @@
1
+ import { Promisable } from 'type-fest';
1
2
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
3
  /**
3
4
  * @private util of `<BookEditor />`
@@ -7,7 +8,9 @@ export type BookEditorInnerProps = {
7
8
  fontClassName?: string;
8
9
  value?: string_book;
9
10
  onChange?(value: string_book): void;
11
+ onFileUpload?(file: File): Promisable<string>;
10
12
  isVerbose?: boolean;
13
+ isBorderRadiusDisabled?: boolean;
11
14
  };
12
15
  /**
13
16
  * @private util of `<BookEditor />`
@@ -1,9 +1,4 @@
1
1
  import type { ChatProps } from './ChatProps';
2
- /**
3
- * @deprecated use `isComplete` instead
4
- * @private util of `<Chat />`
5
- */
6
- export declare const LOADING_INTERACTIVE_IMAGE = "Loading...";
7
2
  /**
8
3
  * Renders a chat with messages and input for new messages
9
4
  *
@@ -23,10 +23,16 @@ export type ChatProps = {
23
23
  * Called when user sends a message
24
24
  *
25
25
  * Note: You must handle the message yourself and add it to the `messages` array
26
+ *
27
+ * - When set, the send textarea and button will be shown
28
+ * - When undefined, the chat has no input and is read-only showing only the messages
26
29
  */
27
- onMessage(messageContent: string): Promisable<void>;
30
+ onMessage?(messageContent: string): Promisable<void>;
28
31
  /**
29
- * Optional callback, when set, button for resetting chat will be shown
32
+ * Optional callback
33
+ *
34
+ * - When set, button for resetting chat will be shown
35
+ * - When undefined, no reset button will be shown
30
36
  */
31
37
  onReset?(): Promisable<void>;
32
38
  /**
@@ -113,4 +119,24 @@ export type ChatProps = {
113
119
  * Keys should match ChatMessage.from values (e.g., 'USER', 'AGENT_{id}', etc.)
114
120
  */
115
121
  readonly participants?: ReadonlyArray<ChatParticipant>;
122
+ /**
123
+ * Optional callback for handling user feedback on messages
124
+ * When provided, star rating buttons (1-5 stars) will be displayed next to each message
125
+ *
126
+ * @param feedback - Object containing the feedback data
127
+ * @param feedback.message - The message being rated
128
+ * @param feedback.rating - Star rating from 1 to 5
129
+ * @param feedback.textRating - Optional text feedback/note from user
130
+ * @param feedback.chatThread - Complete chat thread as string
131
+ * @param feedback.expectedAnswer - Optional expected answer provided by user
132
+ * @param feedback.url - Current page URL where feedback was given
133
+ */
134
+ onFeedback?(feedback: {
135
+ message: ChatMessage;
136
+ rating: number;
137
+ textRating: string;
138
+ chatThread: string;
139
+ expectedAnswer: string | null;
140
+ url: string;
141
+ }): Promisable<void>;
116
142
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @deprecated use `isComplete` instead
3
+ * @private util of `<Chat />`
4
+ */
5
+ export declare const LOADING_INTERACTIVE_IMAGE = "Loading...";
6
+ /**
7
+ * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
8
+ */
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Demo component showing Chat with markdown rendering capabilities
3
+ *
4
+ * This example demonstrates various markdown features supported by the Chat component:
5
+ * - Headers
6
+ * - Bold and italic text
7
+ * - Code blocks and inline code
8
+ * - Lists (ordered and unordered)
9
+ * - Links
10
+ * - Blockquotes
11
+ * - Tables
12
+ * - Strikethrough text
13
+ *
14
+ * @private temporary for testing purposes
15
+ */
16
+ export declare function ChatMarkdownDemo(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import type { string_html, string_markdown } from '../../../types/typeAliases';
2
+ /**
3
+ * Convert markdown content to HTML for display in chat messages
4
+ *
5
+ * @param markdown - The markdown content to convert
6
+ * @returns HTML string ready for rendering
7
+ *
8
+ * @public exported from `@promptbook/components`
9
+ * <- TODO: [🧠] Maybe export from `@promptbook/markdown-utils`
10
+ */
11
+ export declare function renderMarkdown(markdown: string_markdown): string_html;
12
+ /**
13
+ * Check if content appears to be markdown (contains markdown syntax)
14
+ *
15
+ * @param content - Content to check
16
+ * @returns true if content appears to contain markdown syntax
17
+ *
18
+ * @public exported from `@promptbook/components`
19
+ * <- TODO: [🧠] Maybe export from `@promptbook/markdown-utils`
20
+ */
21
+ export declare function isMarkdownContent(content: string): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shows simple arrow icon pointing up or down
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const ArrowIcon: ({ direction, size }: {
7
+ direction: string;
8
+ size: number;
9
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Shows simple reset icon
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const ResetIcon: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shows simple send icon
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const SendIcon: ({ size }: {
7
+ size: number;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shows simple template icon
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const TemplateIcon: ({ size }: {
7
+ size: number;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,8 @@ import type { string_markdown_text } from '../../types/typeAliases';
3
3
  * Function escapeMarkdownBlock will escape markdown block if needed
4
4
  * It is useful when you want have block in block
5
5
  *
6
+ * Note: [πŸ”‚] This function is idempotent.
7
+ *
6
8
  * @public exported from `@promptbook/markdown-utils`
7
9
  */
8
10
  export declare function escapeMarkdownBlock(value: string_markdown_text): string_markdown_text;
@@ -2,11 +2,13 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Function `humanizeAiText` will remove traces of AI text generation artifacts
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want more control, look for other functions for example `humanizeAiTextEmdashed` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
8
9
  */
9
10
  export declare function humanizeAiText(aiText: string_markdown): string_markdown;
10
11
  /**
12
+ * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
11
13
  * TODO: [πŸ…ΎοΈ] !!! Use this across the project where AI text is involved
12
14
  */
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change ellipsis character to three dots `…` -> `...`
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change em-dashes to regular dashes `β€”` -> `-`
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change smart quotes to regular quotes
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -2,6 +2,7 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Change unprintable hard spaces to regular spaces
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
5
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
6
7
  *
7
8
  * @public exported from `@promptbook/markdown-utils`
@@ -7,3 +7,11 @@ import type { string_html } from '../../types/typeAliases';
7
7
  * @private withing the package because of HUGE size of prettier dependency
8
8
  */
9
9
  export declare function prettifyMarkdown<TContent extends string_html>(content: TContent): TContent;
10
+ /**
11
+ * Async version of prettifyMarkdown using dynamic imports
12
+ *
13
+ * @param content raw html code
14
+ * @returns formatted html code
15
+ * @private withing the package because of HUGE size of prettier dependency
16
+ */
17
+ export declare function prettifyMarkdownAsync<TContent extends string_html>(content: TContent): Promise<TContent>;
@@ -6,6 +6,7 @@ import { string_markdown } from '../../types/typeAliases';
6
6
  */
7
7
  export declare function promptbookifyAiText(text: string_markdown): string_markdown;
8
8
  /**
9
+ * TODO: !!!!! Make the function idempotent and add "Note: [πŸ”‚] This function is idempotent."
9
10
  * TODO: [πŸ…ΎοΈ]!!! Use this across the project where AI text is involved
10
11
  * TODO: [🧠][✌️] Make some Promptbook-native token system
11
12
  */
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Makes first letter of a string uppercase
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
6
8
  export declare function capitalize(word: string): string;
@@ -1,5 +1,7 @@
1
1
  /**
2
- * Makes first letter of a string uppercase
2
+ * Makes first letter of a string lowercase
3
+ *
4
+ * Note: [πŸ”‚] This function is idempotent.
3
5
  *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
@@ -9,6 +9,8 @@ export type string_SCREAMING_CASE = string;
9
9
  /**
10
10
  * Normalizes a text string to SCREAMING_CASE (all uppercase with underscores).
11
11
  *
12
+ * Note: [πŸ”‚] This function is idempotent.
13
+ *
12
14
  * @param text The text string to be converted to SCREAMING_CASE format.
13
15
  * @returns The normalized text in SCREAMING_CASE format.
14
16
  * @example 'HELLO_WORLD'
@@ -8,6 +8,8 @@ export type string_snake_case = string;
8
8
  /**
9
9
  * Normalizes a text string to snake_case format.
10
10
  *
11
+ * Note: [πŸ”‚] This function is idempotent.
12
+ *
11
13
  * @param text The text string to be converted to snake_case format.
12
14
  * @returns The normalized text in snake_case format.
13
15
  * @example 'hello_world'
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Take every whitespace (space, new line, tab) and replace it with a single space
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @public exported from `@promptbook/utils`
5
7
  */
6
8
  export declare function normalizeWhitespaces(sentence: string): string;
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Removes diacritic marks (accents) from characters in a string.
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @param input The string containing diacritics to be normalized.
5
7
  * @returns The string with diacritics removed or normalized.
6
8
  * @public exported from `@promptbook/utils`
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Function parseNumber will parse number from string
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
4
5
  * Unlike Number.parseInt, Number.parseFloat it will never ever result in NaN
5
6
  * Note: it also works only with decimal numbers
6
7
  *
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Removes emojis from a string and fix whitespaces
3
3
  *
4
+ * Note: [πŸ”‚] This function is idempotent.
5
+ *
4
6
  * @param text with emojis
5
7
  * @returns text without emojis
6
8
  * @public exported from `@promptbook/utils`