@promptbook/utils 0.112.0-22 → 0.112.0-24

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 (41) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/src/_packages/components.index.d.ts +6 -0
  3. package/esm/src/_packages/types.index.d.ts +6 -0
  4. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  5. package/esm/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +2 -0
  6. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  7. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +14 -2
  8. package/esm/src/book-components/Chat/Chat/ChatRatingModal.d.ts +5 -0
  9. package/esm/src/book-components/Chat/SourceChip/SourceChip.d.ts +5 -1
  10. package/esm/src/book-components/Chat/hooks/useChatRatings.d.ts +5 -1
  11. package/esm/src/book-components/Chat/types/ChatMessage.d.ts +54 -0
  12. package/esm/src/book-components/Chat/utils/createCitationFootnoteRenderModel.d.ts +53 -0
  13. package/esm/src/book-components/Chat/utils/createCitationFootnoteRenderModel.test.d.ts +1 -0
  14. package/esm/src/cli/$runPromptbookCli.d.ts +9 -0
  15. package/esm/src/cli/cli-commands/coder/init.d.ts +14 -0
  16. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  17. package/esm/src/cli/main.d.ts +2 -2
  18. package/esm/src/cli/test/ptbk.d.ts +1 -1
  19. package/esm/src/commitments/_common/toolRuntimeContext.d.ts +4 -0
  20. package/esm/src/version.d.ts +1 -1
  21. package/package.json +1 -1
  22. package/umd/index.umd.js +1 -1
  23. package/umd/src/_packages/components.index.d.ts +6 -0
  24. package/umd/src/_packages/types.index.d.ts +6 -0
  25. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
  26. package/umd/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +2 -0
  27. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +4 -0
  28. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +14 -2
  29. package/umd/src/book-components/Chat/Chat/ChatRatingModal.d.ts +5 -0
  30. package/umd/src/book-components/Chat/SourceChip/SourceChip.d.ts +5 -1
  31. package/umd/src/book-components/Chat/hooks/useChatRatings.d.ts +5 -1
  32. package/umd/src/book-components/Chat/types/ChatMessage.d.ts +54 -0
  33. package/umd/src/book-components/Chat/utils/createCitationFootnoteRenderModel.d.ts +53 -0
  34. package/umd/src/book-components/Chat/utils/createCitationFootnoteRenderModel.test.d.ts +1 -0
  35. package/umd/src/cli/$runPromptbookCli.d.ts +9 -0
  36. package/umd/src/cli/cli-commands/coder/init.d.ts +14 -0
  37. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  38. package/umd/src/cli/main.d.ts +2 -2
  39. package/umd/src/cli/test/ptbk.d.ts +1 -1
  40. package/umd/src/commitments/_common/toolRuntimeContext.d.ts +4 -0
  41. package/umd/src/version.d.ts +1 -1
package/esm/index.es.js CHANGED
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
18
18
  * @generated
19
19
  * @see https://github.com/webgptorg/promptbook
20
20
  */
21
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-22';
21
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-24';
22
22
  /**
23
23
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
24
24
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -16,6 +16,7 @@ import { AgentChat } from '../book-components/Chat/AgentChat/AgentChat';
16
16
  import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
17
17
  import { Chat } from '../book-components/Chat/Chat/Chat';
18
18
  import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
19
+ import type { ChatFeedbackMode } from '../book-components/Chat/Chat/ChatProps';
19
20
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
20
21
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
21
22
  import { ChatSoundToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
@@ -54,6 +55,8 @@ import { mdSaveFormatDefinition } from '../book-components/Chat/save/markdown/md
54
55
  import { pdfSaveFormatDefinition } from '../book-components/Chat/save/pdf/pdfSaveFormatDefinition';
55
56
  import { reactSaveFormatDefinition } from '../book-components/Chat/save/react/reactSaveFormatDefinition';
56
57
  import { txtSaveFormatDefinition } from '../book-components/Chat/save/text/txtSaveFormatDefinition';
58
+ import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
59
+ import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
57
60
  import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
58
61
  import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
59
62
  import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
@@ -90,6 +93,7 @@ export { AgentChat };
90
93
  export type { AgentChatProps };
91
94
  export { Chat };
92
95
  export type { ChatFeedbackResponse };
96
+ export type { ChatFeedbackMode };
93
97
  export type { ChatSoundSystem };
94
98
  export type { ChatProps };
95
99
  export { ChatSoundToggle };
@@ -128,6 +132,8 @@ export { mdSaveFormatDefinition };
128
132
  export { pdfSaveFormatDefinition };
129
133
  export { reactSaveFormatDefinition };
130
134
  export { txtSaveFormatDefinition };
135
+ export type { ChatProgressItem };
136
+ export type { ChatProgressCard };
131
137
  export type { ChatMessage };
132
138
  export type { ChatParticipant };
133
139
  export type { MessageButton };
@@ -17,6 +17,7 @@ import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChat
17
17
  import type { AgentChipData } from '../book-components/Chat/AgentChip/AgentChip';
18
18
  import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip';
19
19
  import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
20
+ import type { ChatFeedbackMode } from '../book-components/Chat/Chat/ChatProps';
20
21
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
21
22
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
22
23
  import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
@@ -37,6 +38,8 @@ import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_com
37
38
  import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
38
39
  import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceChip';
39
40
  import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
41
+ import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
42
+ import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
40
43
  import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
41
44
  import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
42
45
  import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
@@ -438,6 +441,7 @@ export type { AgentChatProps };
438
441
  export type { AgentChipData };
439
442
  export type { AgentChipProps };
440
443
  export type { ChatFeedbackResponse };
444
+ export type { ChatFeedbackMode };
441
445
  export type { ChatSoundSystem };
442
446
  export type { ChatProps };
443
447
  export type { ChatSoundToggleProps };
@@ -458,6 +462,8 @@ export type { ChatSaveFormatDefinition };
458
462
  export type { string_chat_format_name };
459
463
  export type { SourceChipProps };
460
464
  export type { ChatToolCall };
465
+ export type { ChatProgressItem };
466
+ export type { ChatProgressCard };
461
467
  export type { ChatMessage };
462
468
  export type { ChatParticipant };
463
469
  export type { ParsedCitation };
@@ -26,6 +26,10 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'onActionButton' | 'pa
26
26
  * Enables the feedback (rating) UI for this message bubble.
27
27
  */
28
28
  isFeedbackEnabled?: boolean;
29
+ /**
30
+ * Chooses which feedback controls should be rendered.
31
+ */
32
+ feedbackMode?: ChatProps['feedbackMode'];
29
33
  /**
30
34
  * Called when the copy button is pressed.
31
35
  */
@@ -0,0 +1,2 @@
1
+ /** @jest-environment jsdom */
2
+ export {};
@@ -20,6 +20,10 @@ export type ChatMessageListProps = {
20
20
  mode: 'LIGHT' | 'DARK';
21
21
  isCopyButtonEnabled?: boolean;
22
22
  isFeedbackEnabled?: boolean;
23
+ /**
24
+ * Chooses which feedback controls should be rendered.
25
+ */
26
+ feedbackMode?: ChatProps['feedbackMode'];
23
27
  onCopy?: () => void;
24
28
  onMessage?: (messageContent: string) => Promisable<void>;
25
29
  onActionButton?: ChatProps['onActionButton'];
@@ -18,6 +18,12 @@ export type ChatFeedbackResponse = {
18
18
  */
19
19
  readonly message?: string;
20
20
  };
21
+ /**
22
+ * Visual mode for post-response feedback actions.
23
+ *
24
+ * @public exported from `@promptbook/components`
25
+ */
26
+ export type ChatFeedbackMode = 'off' | 'stars' | 'report_issue';
21
27
  /**
22
28
  * Interface for sound system that can be passed to Chat component
23
29
  * This allows the chat to trigger sounds without tight coupling
@@ -275,11 +281,11 @@ export type ChatProps = {
275
281
  onCreateAgent?: (bookContent: string) => void;
276
282
  /**
277
283
  * Optional callback for handling user feedback on messages
278
- * When provided, star rating buttons (1-5 stars) will be displayed next to each message
284
+ * When provided, message feedback actions are displayed according to `feedbackMode`.
279
285
  *
280
286
  * @param feedback - Object containing the feedback data
281
287
  * @param feedback.message - The message being rated
282
- * @param feedback.rating - Star rating from 1 to 5
288
+ * @param feedback.rating - Numeric feedback rating value
283
289
  * @param feedback.textRating - Optional text feedback/note from user
284
290
  * @param feedback.chatThread - Complete chat thread as string
285
291
  * @param feedback.expectedAnswer - Optional expected answer provided by user
@@ -293,6 +299,12 @@ export type ChatProps = {
293
299
  expectedAnswer: string | null;
294
300
  url: string;
295
301
  }): Promisable<void>;
302
+ /**
303
+ * Selects which feedback action UI is shown on assistant responses.
304
+ *
305
+ * @default 'stars'
306
+ */
307
+ readonly feedbackMode?: ChatFeedbackMode;
296
308
  /**
297
309
  * Optional callback for handling file uploads
298
310
  * When provided, enables file upload functionality via drag-and-drop and file button
@@ -1,5 +1,6 @@
1
1
  import type { id } from '../../../types/typeAliases';
2
2
  import type { ChatMessage } from '../types/ChatMessage';
3
+ import type { ChatFeedbackMode } from './ChatProps';
3
4
  /**
4
5
  * Props for the rating modal used in Chat.
5
6
  *
@@ -13,6 +14,10 @@ export type ChatRatingModalProps = {
13
14
  hoveredRating: number;
14
15
  messageRatings: Map<id, number>;
15
16
  textRating: string;
17
+ /**
18
+ * Chooses which feedback flow the modal should render.
19
+ */
20
+ feedbackMode: ChatFeedbackMode;
16
21
  mode: 'LIGHT' | 'DARK';
17
22
  isMobile: boolean;
18
23
  onClose: () => void;
@@ -19,6 +19,10 @@ export type SourceChipProps = {
19
19
  * Optional suffix text to display after the citation label.
20
20
  */
21
21
  suffix?: string;
22
+ /**
23
+ * Controls whether the technical citation id is shown inside the chip label.
24
+ */
25
+ isCitationIdVisible?: boolean;
22
26
  };
23
27
  /**
24
28
  * SourceChip component - displays a chip with source document information
@@ -36,4 +40,4 @@ export type SourceChipProps = {
36
40
  *
37
41
  * @private utility of `ChatMessageItem` component
38
42
  */
39
- export declare function SourceChip({ citation, onClick, className, suffix }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function SourceChip({ citation, onClick, className, suffix, isCitationIdVisible }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import type { Promisable } from 'type-fest';
2
2
  import type { id } from '../../../types/typeAliases';
3
3
  import type { ChatMessage } from '../types/ChatMessage';
4
- import type { ChatFeedbackResponse } from '../Chat/ChatProps';
4
+ import type { ChatFeedbackMode, ChatFeedbackResponse } from '../Chat/ChatProps';
5
5
  /**
6
6
  * Input parameters for the chat rating hook.
7
7
  *
@@ -23,6 +23,10 @@ export type UseChatRatingsOptions = {
23
23
  expectedAnswer: string | null;
24
24
  url: string;
25
25
  }) => Promisable<ChatFeedbackResponse | void>;
26
+ /**
27
+ * Feedback mode currently used by the chat UI.
28
+ */
29
+ feedbackMode: ChatFeedbackMode;
26
30
  /**
27
31
  * Whether the UI should apply mobile-specific behavior.
28
32
  */
@@ -2,6 +2,56 @@ import { Message } from '../../../types/Message';
2
2
  import type { ToolCall } from '../../../types/ToolCall';
3
3
  import type { id, string_date_iso8601, string_markdown } from '../../../types/typeAliases';
4
4
  export type ChatToolCall = ToolCall;
5
+ /**
6
+ * One item in a user-facing progress card shown while assistant response is still running.
7
+ *
8
+ * @public exported from `@promptbook/components`
9
+ */
10
+ export type ChatProgressItem = {
11
+ /**
12
+ * Stable item id used for incremental updates.
13
+ */
14
+ readonly id: string;
15
+ /**
16
+ * Item text in markdown.
17
+ */
18
+ readonly text: string_markdown;
19
+ /**
20
+ * Item status shown by the UI.
21
+ */
22
+ readonly status: 'pending' | 'completed';
23
+ };
24
+ /**
25
+ * Structured progress card rendered in place of generic thinking placeholders.
26
+ *
27
+ * @public exported from `@promptbook/components`
28
+ */
29
+ export type ChatProgressCard = {
30
+ /**
31
+ * Optional title shown at the top of the panel.
32
+ */
33
+ readonly title?: string_markdown;
34
+ /**
35
+ * Optional markdown section describing current work.
36
+ */
37
+ readonly now?: string_markdown;
38
+ /**
39
+ * Optional markdown section describing upcoming work.
40
+ */
41
+ readonly next?: string_markdown;
42
+ /**
43
+ * Ordered bullet items representing in-progress or completed tasks.
44
+ */
45
+ readonly items: ReadonlyArray<ChatProgressItem>;
46
+ /**
47
+ * Optional timestamp when this card was last updated.
48
+ */
49
+ readonly updatedAt?: string_date_iso8601;
50
+ /**
51
+ * Optional visibility flag allowing explicit panel hide before final answer.
52
+ */
53
+ readonly isVisible?: boolean;
54
+ };
5
55
  /**
6
56
  * Represents a single message within a chat interface.
7
57
  *
@@ -111,6 +161,10 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
111
161
  */
112
162
  excerpt?: string;
113
163
  }>;
164
+ /**
165
+ * Optional structured progress-card payload shown while a response is still in progress.
166
+ */
167
+ readonly progressCard?: ChatProgressCard;
114
168
  };
115
169
  /**
116
170
  * TODO: Make all fields readonly
@@ -0,0 +1,53 @@
1
+ import type { ChatMessage } from '../types/ChatMessage';
2
+ import { type ParsedCitation } from './parseCitationsFromContent';
3
+ /**
4
+ * Minimal message shape required to derive inline citation references and footnotes.
5
+ *
6
+ * @private utility of `<Chat/>`
7
+ */
8
+ type CitationFootnoteMessage = Pick<ChatMessage, 'content' | 'citations'>;
9
+ /**
10
+ * One rendered citation footnote entry shown below the message body.
11
+ *
12
+ * @private utility of `<Chat/>`
13
+ */
14
+ export type CitationFootnoteEntry = {
15
+ /**
16
+ * Visible footnote number assigned by first appearance in the message body.
17
+ */
18
+ readonly number: number;
19
+ /**
20
+ * Citation metadata rendered for this footnote.
21
+ */
22
+ readonly citation: ParsedCitation;
23
+ };
24
+ /**
25
+ * Render-ready message citation payload containing transformed content plus footnotes.
26
+ *
27
+ * @private utility of `<Chat/>`
28
+ */
29
+ export type CitationFootnoteRenderModel = {
30
+ /**
31
+ * Markdown/HTML content with inline citation tokens replaced by numeric superscripts.
32
+ */
33
+ readonly content: ChatMessage['content'];
34
+ /**
35
+ * Deduplicated footnotes ordered by first appearance in the message body.
36
+ */
37
+ readonly footnotes: ReadonlyArray<CitationFootnoteEntry>;
38
+ };
39
+ /**
40
+ * Creates one render model that replaces raw citation tokens with numeric footnotes.
41
+ *
42
+ * Supported input markers:
43
+ * - OpenAI-style full markers that already include the document source name.
44
+ * - Bracketed id-only tokens, for example `[0:0]` or `[8:13]`
45
+ *
46
+ * Footnotes are deduplicated by document source while preserving the first-seen order.
47
+ *
48
+ * @param message - Message content plus optional structured citation metadata.
49
+ * @returns Render-ready content and matching footnote entries.
50
+ * @private utility of `<Chat/>`
51
+ */
52
+ export declare function createCitationFootnoteRenderModel(message: CitationFootnoteMessage): CitationFootnoteRenderModel;
53
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared bootstrap for Promptbook CLI used by both local `ts-node` and packaged `npx` entrypoints.
3
+ *
4
+ * @private internal utility of Promptbook CLI bootstrap
5
+ */
6
+ export declare function $runPromptbookCli(): Promise<void>;
7
+ /**
8
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
9
+ */
@@ -0,0 +1,14 @@
1
+ import type { Command as Program } from 'commander';
2
+ import type { $side_effect } from '../../../utils/organization/$side_effect';
3
+ /**
4
+ * Initializes `coder init` command for Promptbook CLI utilities.
5
+ *
6
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
7
+ *
8
+ * @private internal function of `promptbookCli`
9
+ */
10
+ export declare function $initializeCoderInitCommand(program: Program): $side_effect;
11
+ /**
12
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
14
+ */
@@ -4,6 +4,7 @@ import type { $side_effect } from '../../utils/organization/$side_effect';
4
4
  * Initializes `coder` command with subcommands for Promptbook CLI utilities
5
5
  *
6
6
  * The coder command provides utilities for automated coding:
7
+ * - init: Initialize coder configuration in current project
7
8
  * - generate-boilerplates: Generate prompt boilerplate files
8
9
  * - find-refactor-candidates: Find files that need refactoring
9
10
  * - run: Run coding prompts with AI agents
@@ -1,4 +1,4 @@
1
- import { promptbookCli } from './promptbookCli';
1
+ import { $runPromptbookCli } from './$runPromptbookCli';
2
2
  /**
3
3
  * Note: [🔺] Purpose of this file is to export CLI for production environment
4
4
  */
@@ -8,7 +8,7 @@ import { promptbookCli } from './promptbookCli';
8
8
  * @public exported from `@promptbook/cli`
9
9
  */
10
10
  export declare const _CLI: {
11
- _initialize_promptbookCli: typeof promptbookCli;
11
+ _initialize_promptbookCli: typeof $runPromptbookCli;
12
12
  };
13
13
  /**
14
14
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2,4 +2,4 @@
2
2
  /**
3
3
  * Note: [🔺] Purpose of this file is to test and use the current CLI in development environment
4
4
  */
5
- import '../../_packages/cli.index';
5
+ export {};
@@ -104,6 +104,10 @@ export type ToolRuntimeContext = {
104
104
  userId?: number;
105
105
  agentId?: string;
106
106
  agentName?: string;
107
+ /**
108
+ * Optional assistant message id currently being generated in durable web chat.
109
+ */
110
+ assistantMessageId?: string;
107
111
  parameters?: Record<string, string>;
108
112
  attachments?: ReadonlyArray<ChatAttachment>;
109
113
  };
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-21`).
18
+ * It follows semantic versioning (e.g., `0.112.0-23`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/utils",
3
- "version": "0.112.0-22",
3
+ "version": "0.112.0-24",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-22';
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-24';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -16,6 +16,7 @@ import { AgentChat } from '../book-components/Chat/AgentChat/AgentChat';
16
16
  import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
17
17
  import { Chat } from '../book-components/Chat/Chat/Chat';
18
18
  import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
19
+ import type { ChatFeedbackMode } from '../book-components/Chat/Chat/ChatProps';
19
20
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
20
21
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
21
22
  import { ChatSoundToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
@@ -54,6 +55,8 @@ import { mdSaveFormatDefinition } from '../book-components/Chat/save/markdown/md
54
55
  import { pdfSaveFormatDefinition } from '../book-components/Chat/save/pdf/pdfSaveFormatDefinition';
55
56
  import { reactSaveFormatDefinition } from '../book-components/Chat/save/react/reactSaveFormatDefinition';
56
57
  import { txtSaveFormatDefinition } from '../book-components/Chat/save/text/txtSaveFormatDefinition';
58
+ import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
59
+ import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
57
60
  import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
58
61
  import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
59
62
  import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
@@ -90,6 +93,7 @@ export { AgentChat };
90
93
  export type { AgentChatProps };
91
94
  export { Chat };
92
95
  export type { ChatFeedbackResponse };
96
+ export type { ChatFeedbackMode };
93
97
  export type { ChatSoundSystem };
94
98
  export type { ChatProps };
95
99
  export { ChatSoundToggle };
@@ -128,6 +132,8 @@ export { mdSaveFormatDefinition };
128
132
  export { pdfSaveFormatDefinition };
129
133
  export { reactSaveFormatDefinition };
130
134
  export { txtSaveFormatDefinition };
135
+ export type { ChatProgressItem };
136
+ export type { ChatProgressCard };
131
137
  export type { ChatMessage };
132
138
  export type { ChatParticipant };
133
139
  export type { MessageButton };
@@ -17,6 +17,7 @@ import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChat
17
17
  import type { AgentChipData } from '../book-components/Chat/AgentChip/AgentChip';
18
18
  import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip';
19
19
  import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
20
+ import type { ChatFeedbackMode } from '../book-components/Chat/Chat/ChatProps';
20
21
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
21
22
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
22
23
  import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
@@ -37,6 +38,8 @@ import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_com
37
38
  import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
38
39
  import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceChip';
39
40
  import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
41
+ import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
42
+ import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
40
43
  import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
41
44
  import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
42
45
  import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
@@ -438,6 +441,7 @@ export type { AgentChatProps };
438
441
  export type { AgentChipData };
439
442
  export type { AgentChipProps };
440
443
  export type { ChatFeedbackResponse };
444
+ export type { ChatFeedbackMode };
441
445
  export type { ChatSoundSystem };
442
446
  export type { ChatProps };
443
447
  export type { ChatSoundToggleProps };
@@ -458,6 +462,8 @@ export type { ChatSaveFormatDefinition };
458
462
  export type { string_chat_format_name };
459
463
  export type { SourceChipProps };
460
464
  export type { ChatToolCall };
465
+ export type { ChatProgressItem };
466
+ export type { ChatProgressCard };
461
467
  export type { ChatMessage };
462
468
  export type { ChatParticipant };
463
469
  export type { ParsedCitation };
@@ -26,6 +26,10 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'onActionButton' | 'pa
26
26
  * Enables the feedback (rating) UI for this message bubble.
27
27
  */
28
28
  isFeedbackEnabled?: boolean;
29
+ /**
30
+ * Chooses which feedback controls should be rendered.
31
+ */
32
+ feedbackMode?: ChatProps['feedbackMode'];
29
33
  /**
30
34
  * Called when the copy button is pressed.
31
35
  */
@@ -0,0 +1,2 @@
1
+ /** @jest-environment jsdom */
2
+ export {};
@@ -20,6 +20,10 @@ export type ChatMessageListProps = {
20
20
  mode: 'LIGHT' | 'DARK';
21
21
  isCopyButtonEnabled?: boolean;
22
22
  isFeedbackEnabled?: boolean;
23
+ /**
24
+ * Chooses which feedback controls should be rendered.
25
+ */
26
+ feedbackMode?: ChatProps['feedbackMode'];
23
27
  onCopy?: () => void;
24
28
  onMessage?: (messageContent: string) => Promisable<void>;
25
29
  onActionButton?: ChatProps['onActionButton'];
@@ -18,6 +18,12 @@ export type ChatFeedbackResponse = {
18
18
  */
19
19
  readonly message?: string;
20
20
  };
21
+ /**
22
+ * Visual mode for post-response feedback actions.
23
+ *
24
+ * @public exported from `@promptbook/components`
25
+ */
26
+ export type ChatFeedbackMode = 'off' | 'stars' | 'report_issue';
21
27
  /**
22
28
  * Interface for sound system that can be passed to Chat component
23
29
  * This allows the chat to trigger sounds without tight coupling
@@ -275,11 +281,11 @@ export type ChatProps = {
275
281
  onCreateAgent?: (bookContent: string) => void;
276
282
  /**
277
283
  * Optional callback for handling user feedback on messages
278
- * When provided, star rating buttons (1-5 stars) will be displayed next to each message
284
+ * When provided, message feedback actions are displayed according to `feedbackMode`.
279
285
  *
280
286
  * @param feedback - Object containing the feedback data
281
287
  * @param feedback.message - The message being rated
282
- * @param feedback.rating - Star rating from 1 to 5
288
+ * @param feedback.rating - Numeric feedback rating value
283
289
  * @param feedback.textRating - Optional text feedback/note from user
284
290
  * @param feedback.chatThread - Complete chat thread as string
285
291
  * @param feedback.expectedAnswer - Optional expected answer provided by user
@@ -293,6 +299,12 @@ export type ChatProps = {
293
299
  expectedAnswer: string | null;
294
300
  url: string;
295
301
  }): Promisable<void>;
302
+ /**
303
+ * Selects which feedback action UI is shown on assistant responses.
304
+ *
305
+ * @default 'stars'
306
+ */
307
+ readonly feedbackMode?: ChatFeedbackMode;
296
308
  /**
297
309
  * Optional callback for handling file uploads
298
310
  * When provided, enables file upload functionality via drag-and-drop and file button
@@ -1,5 +1,6 @@
1
1
  import type { id } from '../../../types/typeAliases';
2
2
  import type { ChatMessage } from '../types/ChatMessage';
3
+ import type { ChatFeedbackMode } from './ChatProps';
3
4
  /**
4
5
  * Props for the rating modal used in Chat.
5
6
  *
@@ -13,6 +14,10 @@ export type ChatRatingModalProps = {
13
14
  hoveredRating: number;
14
15
  messageRatings: Map<id, number>;
15
16
  textRating: string;
17
+ /**
18
+ * Chooses which feedback flow the modal should render.
19
+ */
20
+ feedbackMode: ChatFeedbackMode;
16
21
  mode: 'LIGHT' | 'DARK';
17
22
  isMobile: boolean;
18
23
  onClose: () => void;
@@ -19,6 +19,10 @@ export type SourceChipProps = {
19
19
  * Optional suffix text to display after the citation label.
20
20
  */
21
21
  suffix?: string;
22
+ /**
23
+ * Controls whether the technical citation id is shown inside the chip label.
24
+ */
25
+ isCitationIdVisible?: boolean;
22
26
  };
23
27
  /**
24
28
  * SourceChip component - displays a chip with source document information
@@ -36,4 +40,4 @@ export type SourceChipProps = {
36
40
  *
37
41
  * @private utility of `ChatMessageItem` component
38
42
  */
39
- export declare function SourceChip({ citation, onClick, className, suffix }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function SourceChip({ citation, onClick, className, suffix, isCitationIdVisible }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import type { Promisable } from 'type-fest';
2
2
  import type { id } from '../../../types/typeAliases';
3
3
  import type { ChatMessage } from '../types/ChatMessage';
4
- import type { ChatFeedbackResponse } from '../Chat/ChatProps';
4
+ import type { ChatFeedbackMode, ChatFeedbackResponse } from '../Chat/ChatProps';
5
5
  /**
6
6
  * Input parameters for the chat rating hook.
7
7
  *
@@ -23,6 +23,10 @@ export type UseChatRatingsOptions = {
23
23
  expectedAnswer: string | null;
24
24
  url: string;
25
25
  }) => Promisable<ChatFeedbackResponse | void>;
26
+ /**
27
+ * Feedback mode currently used by the chat UI.
28
+ */
29
+ feedbackMode: ChatFeedbackMode;
26
30
  /**
27
31
  * Whether the UI should apply mobile-specific behavior.
28
32
  */
@@ -2,6 +2,56 @@ import { Message } from '../../../types/Message';
2
2
  import type { ToolCall } from '../../../types/ToolCall';
3
3
  import type { id, string_date_iso8601, string_markdown } from '../../../types/typeAliases';
4
4
  export type ChatToolCall = ToolCall;
5
+ /**
6
+ * One item in a user-facing progress card shown while assistant response is still running.
7
+ *
8
+ * @public exported from `@promptbook/components`
9
+ */
10
+ export type ChatProgressItem = {
11
+ /**
12
+ * Stable item id used for incremental updates.
13
+ */
14
+ readonly id: string;
15
+ /**
16
+ * Item text in markdown.
17
+ */
18
+ readonly text: string_markdown;
19
+ /**
20
+ * Item status shown by the UI.
21
+ */
22
+ readonly status: 'pending' | 'completed';
23
+ };
24
+ /**
25
+ * Structured progress card rendered in place of generic thinking placeholders.
26
+ *
27
+ * @public exported from `@promptbook/components`
28
+ */
29
+ export type ChatProgressCard = {
30
+ /**
31
+ * Optional title shown at the top of the panel.
32
+ */
33
+ readonly title?: string_markdown;
34
+ /**
35
+ * Optional markdown section describing current work.
36
+ */
37
+ readonly now?: string_markdown;
38
+ /**
39
+ * Optional markdown section describing upcoming work.
40
+ */
41
+ readonly next?: string_markdown;
42
+ /**
43
+ * Ordered bullet items representing in-progress or completed tasks.
44
+ */
45
+ readonly items: ReadonlyArray<ChatProgressItem>;
46
+ /**
47
+ * Optional timestamp when this card was last updated.
48
+ */
49
+ readonly updatedAt?: string_date_iso8601;
50
+ /**
51
+ * Optional visibility flag allowing explicit panel hide before final answer.
52
+ */
53
+ readonly isVisible?: boolean;
54
+ };
5
55
  /**
6
56
  * Represents a single message within a chat interface.
7
57
  *
@@ -111,6 +161,10 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
111
161
  */
112
162
  excerpt?: string;
113
163
  }>;
164
+ /**
165
+ * Optional structured progress-card payload shown while a response is still in progress.
166
+ */
167
+ readonly progressCard?: ChatProgressCard;
114
168
  };
115
169
  /**
116
170
  * TODO: Make all fields readonly
@@ -0,0 +1,53 @@
1
+ import type { ChatMessage } from '../types/ChatMessage';
2
+ import { type ParsedCitation } from './parseCitationsFromContent';
3
+ /**
4
+ * Minimal message shape required to derive inline citation references and footnotes.
5
+ *
6
+ * @private utility of `<Chat/>`
7
+ */
8
+ type CitationFootnoteMessage = Pick<ChatMessage, 'content' | 'citations'>;
9
+ /**
10
+ * One rendered citation footnote entry shown below the message body.
11
+ *
12
+ * @private utility of `<Chat/>`
13
+ */
14
+ export type CitationFootnoteEntry = {
15
+ /**
16
+ * Visible footnote number assigned by first appearance in the message body.
17
+ */
18
+ readonly number: number;
19
+ /**
20
+ * Citation metadata rendered for this footnote.
21
+ */
22
+ readonly citation: ParsedCitation;
23
+ };
24
+ /**
25
+ * Render-ready message citation payload containing transformed content plus footnotes.
26
+ *
27
+ * @private utility of `<Chat/>`
28
+ */
29
+ export type CitationFootnoteRenderModel = {
30
+ /**
31
+ * Markdown/HTML content with inline citation tokens replaced by numeric superscripts.
32
+ */
33
+ readonly content: ChatMessage['content'];
34
+ /**
35
+ * Deduplicated footnotes ordered by first appearance in the message body.
36
+ */
37
+ readonly footnotes: ReadonlyArray<CitationFootnoteEntry>;
38
+ };
39
+ /**
40
+ * Creates one render model that replaces raw citation tokens with numeric footnotes.
41
+ *
42
+ * Supported input markers:
43
+ * - OpenAI-style full markers that already include the document source name.
44
+ * - Bracketed id-only tokens, for example `[0:0]` or `[8:13]`
45
+ *
46
+ * Footnotes are deduplicated by document source while preserving the first-seen order.
47
+ *
48
+ * @param message - Message content plus optional structured citation metadata.
49
+ * @returns Render-ready content and matching footnote entries.
50
+ * @private utility of `<Chat/>`
51
+ */
52
+ export declare function createCitationFootnoteRenderModel(message: CitationFootnoteMessage): CitationFootnoteRenderModel;
53
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared bootstrap for Promptbook CLI used by both local `ts-node` and packaged `npx` entrypoints.
3
+ *
4
+ * @private internal utility of Promptbook CLI bootstrap
5
+ */
6
+ export declare function $runPromptbookCli(): Promise<void>;
7
+ /**
8
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
9
+ */
@@ -0,0 +1,14 @@
1
+ import type { Command as Program } from 'commander';
2
+ import type { $side_effect } from '../../../utils/organization/$side_effect';
3
+ /**
4
+ * Initializes `coder init` command for Promptbook CLI utilities.
5
+ *
6
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
7
+ *
8
+ * @private internal function of `promptbookCli`
9
+ */
10
+ export declare function $initializeCoderInitCommand(program: Program): $side_effect;
11
+ /**
12
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
14
+ */
@@ -4,6 +4,7 @@ import type { $side_effect } from '../../utils/organization/$side_effect';
4
4
  * Initializes `coder` command with subcommands for Promptbook CLI utilities
5
5
  *
6
6
  * The coder command provides utilities for automated coding:
7
+ * - init: Initialize coder configuration in current project
7
8
  * - generate-boilerplates: Generate prompt boilerplate files
8
9
  * - find-refactor-candidates: Find files that need refactoring
9
10
  * - run: Run coding prompts with AI agents
@@ -1,4 +1,4 @@
1
- import { promptbookCli } from './promptbookCli';
1
+ import { $runPromptbookCli } from './$runPromptbookCli';
2
2
  /**
3
3
  * Note: [🔺] Purpose of this file is to export CLI for production environment
4
4
  */
@@ -8,7 +8,7 @@ import { promptbookCli } from './promptbookCli';
8
8
  * @public exported from `@promptbook/cli`
9
9
  */
10
10
  export declare const _CLI: {
11
- _initialize_promptbookCli: typeof promptbookCli;
11
+ _initialize_promptbookCli: typeof $runPromptbookCli;
12
12
  };
13
13
  /**
14
14
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -2,4 +2,4 @@
2
2
  /**
3
3
  * Note: [🔺] Purpose of this file is to test and use the current CLI in development environment
4
4
  */
5
- import '../../_packages/cli.index';
5
+ export {};
@@ -104,6 +104,10 @@ export type ToolRuntimeContext = {
104
104
  userId?: number;
105
105
  agentId?: string;
106
106
  agentName?: string;
107
+ /**
108
+ * Optional assistant message id currently being generated in durable web chat.
109
+ */
110
+ assistantMessageId?: string;
107
111
  parameters?: Record<string, string>;
108
112
  attachments?: ReadonlyArray<ChatAttachment>;
109
113
  };
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-21`).
18
+ * It follows semantic versioning (e.g., `0.112.0-23`).
19
19
  *
20
20
  * @generated
21
21
  */