@promptbook/javascript 0.108.0-0 → 0.110.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +32 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatCitationModal.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatInputArea.d.ts +48 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +40 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatRatingModal.d.ts +30 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSelfLearningSummary.d.ts +24 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +23 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatToolCallModalComponents.d.ts +39 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +55 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +67 -0
- package/esm/typings/src/book-components/icons/TeacherIcon.d.ts +15 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +18 -1
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +40 -3
- package/esm/typings/src/types/ToolCall.d.ts +4 -0
- package/esm/typings/src/utils/linguistic-hash/linguisticHash.d.ts +1 -24
- package/esm/typings/src/utils/linguistic-hash/linguisticHashWordCount.d.ts +31 -0
- package/esm/typings/src/utils/linguistic-hash/linguisticHashWordSelection.d.ts +22 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +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.
|
|
21
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-0';
|
|
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
|
|
@@ -20,6 +20,7 @@ import type { ChatEffect } from '../book-components/Chat/effects/types/ChatEffec
|
|
|
20
20
|
import type { ChatEffectConfig } from '../book-components/Chat/effects/types/ChatEffectConfig';
|
|
21
21
|
import type { ChatEffectsSystemProps } from '../book-components/Chat/effects/types/ChatEffectsSystemProps';
|
|
22
22
|
import type { ChatEffectType } from '../book-components/Chat/effects/types/ChatEffectType';
|
|
23
|
+
import type { ChatActionsOverlapResult } from '../book-components/Chat/hooks/useChatActionsOverlap';
|
|
23
24
|
import type { ChatAutoScrollConfig } from '../book-components/Chat/hooks/useChatAutoScroll';
|
|
24
25
|
import type { SendMessageToLlmChatFunction } from '../book-components/Chat/hooks/useSendMessageToLlmChat';
|
|
25
26
|
import type { FriendlyErrorMessage } from '../book-components/Chat/LlmChat/FriendlyErrorMessage';
|
|
@@ -422,6 +423,7 @@ export type { ChatEffect };
|
|
|
422
423
|
export type { ChatEffectConfig };
|
|
423
424
|
export type { ChatEffectsSystemProps };
|
|
424
425
|
export type { ChatEffectType };
|
|
426
|
+
export type { ChatActionsOverlapResult };
|
|
425
427
|
export type { ChatAutoScrollConfig };
|
|
426
428
|
export type { SendMessageToLlmChatFunction };
|
|
427
429
|
export type { FriendlyErrorMessage };
|
|
@@ -13,7 +13,7 @@ export type AvatarProfileProps = {
|
|
|
13
13
|
*/
|
|
14
14
|
readonly agent: AgentBasicInformation;
|
|
15
15
|
/**
|
|
16
|
-
* The source of the agent,
|
|
16
|
+
* The source of the agent, used to enable profile actions in the UI.
|
|
17
17
|
*/
|
|
18
18
|
readonly agentSource?: string_book;
|
|
19
19
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type MouseEvent, type MutableRefObject, type ReactNode } from 'react';
|
|
2
|
+
import type { Promisable } from 'type-fest';
|
|
3
|
+
import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
|
|
4
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
5
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
|
+
import type { ChatSoundSystem } from './ChatProps';
|
|
7
|
+
/**
|
|
8
|
+
* Props for the Chat actions toolbar.
|
|
9
|
+
*
|
|
10
|
+
* @private component of `<Chat/>`
|
|
11
|
+
*/
|
|
12
|
+
export type ChatActionsBarProps = {
|
|
13
|
+
actionsRef: MutableRefObject<HTMLDivElement | null>;
|
|
14
|
+
actionsContainer?: HTMLElement | null;
|
|
15
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
16
|
+
participants: ReadonlyArray<ChatParticipant>;
|
|
17
|
+
title: string;
|
|
18
|
+
onReset?: () => Promisable<void>;
|
|
19
|
+
onUseTemplate?: () => void;
|
|
20
|
+
extraActions?: ReactNode;
|
|
21
|
+
saveFormats?: Array<string_chat_format_name>;
|
|
22
|
+
isSaveButtonEnabled: boolean;
|
|
23
|
+
shouldFadeActions: boolean;
|
|
24
|
+
onButtonClick: (handler?: (event: MouseEvent<HTMLButtonElement>) => void) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
25
|
+
soundSystem?: ChatSoundSystem;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Renders the action buttons row for Chat.
|
|
29
|
+
*
|
|
30
|
+
* @private component of `<Chat/>`
|
|
31
|
+
*/
|
|
32
|
+
export declare function ChatActionsBar(props: ChatActionsBarProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
2
|
+
import type { ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
3
|
+
import type { ChatSoundSystem } from './ChatProps';
|
|
4
|
+
/**
|
|
5
|
+
* Props for the citation preview modal.
|
|
6
|
+
*
|
|
7
|
+
* @private component of `<Chat/>`
|
|
8
|
+
*/
|
|
9
|
+
export type ChatCitationModalProps = {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
citation: ParsedCitation | null;
|
|
12
|
+
participants: ReadonlyArray<ChatParticipant>;
|
|
13
|
+
soundSystem?: ChatSoundSystem;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Modal that previews a citation source or excerpt.
|
|
18
|
+
*
|
|
19
|
+
* @private component of `<Chat/>`
|
|
20
|
+
*/
|
|
21
|
+
export declare function ChatCitationModal(props: ChatCitationModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type MouseEvent } from 'react';
|
|
2
|
+
import { Color } from '../../../utils/color/Color';
|
|
3
|
+
import type { WithTake } from '../../../utils/take/interfaces/ITakeChain';
|
|
4
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
5
|
+
import type { ChatProps, ChatSoundSystem } from './ChatProps';
|
|
6
|
+
/**
|
|
7
|
+
* Wrapper for consistent button-click sound handling.
|
|
8
|
+
*
|
|
9
|
+
* @private component of `<Chat/>`
|
|
10
|
+
*/
|
|
11
|
+
export type ChatInputButtonClickHandler = (handler?: (event: MouseEvent<HTMLButtonElement>) => void) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Internal representation of an uploaded file in the chat input.
|
|
14
|
+
*
|
|
15
|
+
* @private component of `<Chat/>`
|
|
16
|
+
*/
|
|
17
|
+
export type ChatInputUploadedFile = {
|
|
18
|
+
id: string;
|
|
19
|
+
file: File;
|
|
20
|
+
content: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Props for the chat input area.
|
|
24
|
+
*
|
|
25
|
+
* @private component of `<Chat/>`
|
|
26
|
+
*/
|
|
27
|
+
export type ChatInputAreaProps = {
|
|
28
|
+
onMessage?: ChatProps['onMessage'];
|
|
29
|
+
onChange?: ChatProps['onChange'];
|
|
30
|
+
onFileUpload?: ChatProps['onFileUpload'];
|
|
31
|
+
speechRecognition?: ChatProps['speechRecognition'];
|
|
32
|
+
defaultMessage?: string;
|
|
33
|
+
placeholderMessageContent?: string;
|
|
34
|
+
isFocusedOnLoad?: boolean;
|
|
35
|
+
isMobile: boolean;
|
|
36
|
+
isVoiceCalling?: boolean;
|
|
37
|
+
participants: ReadonlyArray<ChatParticipant>;
|
|
38
|
+
buttonColor: WithTake<Color>;
|
|
39
|
+
soundSystem?: ChatSoundSystem;
|
|
40
|
+
onButtonClick: ChatInputButtonClickHandler;
|
|
41
|
+
chatInputClassName?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Renders the chat input area with text, file upload, and voice controls.
|
|
45
|
+
*
|
|
46
|
+
* @private component of `<Chat/>`
|
|
47
|
+
*/
|
|
48
|
+
export declare function ChatInputArea(props: ChatInputAreaProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { UIEvent } from 'react';
|
|
2
|
+
import type { Promisable } from 'type-fest';
|
|
3
|
+
import type { id } from '../../../types/typeAliases';
|
|
4
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
5
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
|
+
import type { ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
7
|
+
import type { ChatProps } from './ChatProps';
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Chat message list container.
|
|
10
|
+
*
|
|
11
|
+
* @private component of `<Chat/>`
|
|
12
|
+
*/
|
|
13
|
+
export type ChatMessageListProps = {
|
|
14
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
15
|
+
participants: ReadonlyArray<ChatParticipant>;
|
|
16
|
+
expandedMessageId: id | null;
|
|
17
|
+
messageRatings: Map<id, number>;
|
|
18
|
+
setExpandedMessageId: (value: id | null) => void;
|
|
19
|
+
handleRating: (message: ChatMessage, rating: number) => void;
|
|
20
|
+
mode: 'LIGHT' | 'DARK';
|
|
21
|
+
isCopyButtonEnabled?: boolean;
|
|
22
|
+
isFeedbackEnabled?: boolean;
|
|
23
|
+
onCopy?: () => void;
|
|
24
|
+
onMessage?: (messageContent: string) => Promisable<void>;
|
|
25
|
+
onCreateAgent?: (bookContent: string) => void;
|
|
26
|
+
toolTitles?: Record<string, string>;
|
|
27
|
+
teammates?: ChatProps['teammates'];
|
|
28
|
+
onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
|
|
29
|
+
onCitationClick?: (citation: ParsedCitation) => void;
|
|
30
|
+
setChatMessagesElement: (element: HTMLDivElement | null) => void;
|
|
31
|
+
onScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
32
|
+
chatMessagesClassName?: string;
|
|
33
|
+
hasActions: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Renders the list of chat messages.
|
|
37
|
+
*
|
|
38
|
+
* @private component of `<Chat/>`
|
|
39
|
+
*/
|
|
40
|
+
export declare function ChatMessageList(props: ChatMessageListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { id } from '../../../types/typeAliases';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
/**
|
|
4
|
+
* Props for the rating modal used in Chat.
|
|
5
|
+
*
|
|
6
|
+
* @private component of `<Chat/>`
|
|
7
|
+
*/
|
|
8
|
+
export type ChatRatingModalProps = {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
selectedMessage: ChatMessage | null;
|
|
11
|
+
postprocessedMessages: ReadonlyArray<ChatMessage>;
|
|
12
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
13
|
+
hoveredRating: number;
|
|
14
|
+
messageRatings: Map<id, number>;
|
|
15
|
+
textRating: string;
|
|
16
|
+
mode: 'LIGHT' | 'DARK';
|
|
17
|
+
isMobile: boolean;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
setHoveredRating: (value: number) => void;
|
|
20
|
+
setMessageRatings: (value: Map<id, number> | ((previous: Map<id, number>) => Map<id, number>)) => void;
|
|
21
|
+
setSelectedMessage: (value: ChatMessage | null) => void;
|
|
22
|
+
setTextRating: (value: string) => void;
|
|
23
|
+
submitRating: () => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Modal that captures per-message rating feedback.
|
|
27
|
+
*
|
|
28
|
+
* @private component of `<Chat/>`
|
|
29
|
+
*/
|
|
30
|
+
export declare function ChatRatingModal(props: ChatRatingModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TODO_any } from '../../../utils/organization/TODO_any';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
/**
|
|
4
|
+
* Resolved summary data for self-learning tool calls.
|
|
5
|
+
*
|
|
6
|
+
* @private component of `<Chat/>`
|
|
7
|
+
*/
|
|
8
|
+
export type SelfLearningSummaryData = {
|
|
9
|
+
commitments: Array<string>;
|
|
10
|
+
commitmentsText: string;
|
|
11
|
+
commitmentsLineCount: number;
|
|
12
|
+
hasTeacherCommitments: boolean;
|
|
13
|
+
samplesLabel: string | null;
|
|
14
|
+
updatedLabel: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Builds UI-ready data for the self-learning modal from a tool call.
|
|
18
|
+
*
|
|
19
|
+
* @private component of `<Chat/>`
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildSelfLearningSummary(toolCall: NonNullable<ChatMessage['toolCalls']>[number], resultRaw: TODO_any): SelfLearningSummaryData;
|
|
22
|
+
/**
|
|
23
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name, BUT maybe rename to `buildSelfLearningSummary`
|
|
24
|
+
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Color } from '../../../utils/color/Color';
|
|
2
|
+
import type { WithTake } from '../../../utils/take/interfaces/ITakeChain';
|
|
3
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
4
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
5
|
+
/**
|
|
6
|
+
* Props for the tool call details modal.
|
|
7
|
+
*
|
|
8
|
+
* @private component of `<Chat/>`
|
|
9
|
+
*/
|
|
10
|
+
export type ChatToolCallModalProps = {
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
toolCall: NonNullable<ChatMessage['toolCalls']>[number] | null;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
toolTitles?: Record<string, string>;
|
|
15
|
+
agentParticipant?: ChatParticipant;
|
|
16
|
+
buttonColor: WithTake<Color>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Modal that renders rich tool call details for chat chiplets.
|
|
20
|
+
*
|
|
21
|
+
* @private component of `<Chat/>`
|
|
22
|
+
*/
|
|
23
|
+
export declare function ChatToolCallModal(props: ChatToolCallModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for a team modal header profile badge.
|
|
4
|
+
*
|
|
5
|
+
* @private component of `<Chat/>`
|
|
6
|
+
*/
|
|
7
|
+
export type TeamHeaderProfileProps = {
|
|
8
|
+
label: string;
|
|
9
|
+
avatarSrc?: string | null;
|
|
10
|
+
href?: string;
|
|
11
|
+
fallbackColor?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Renders a profile badge used in the TEAM modal header.
|
|
15
|
+
*
|
|
16
|
+
* @private component of `<Chat/>`
|
|
17
|
+
*/
|
|
18
|
+
export declare function TeamHeaderProfile({ label, avatarSrc, href, fallbackColor }: TeamHeaderProfileProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* Props for a self-learning modal avatar.
|
|
21
|
+
*
|
|
22
|
+
* @private component of `<Chat/>`
|
|
23
|
+
*/
|
|
24
|
+
export type SelfLearningAvatarProps = {
|
|
25
|
+
label: string;
|
|
26
|
+
avatarSrc?: string | null;
|
|
27
|
+
fallbackColor?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Renders an avatar badge for the self-learning modal header.
|
|
33
|
+
*
|
|
34
|
+
* @private component of `<Chat/>`
|
|
35
|
+
*/
|
|
36
|
+
export declare function SelfLearningAvatar({ label, avatarSrc, fallbackColor, className, children, }: SelfLearningAvatarProps): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name, BUT maybe split to multiple files
|
|
39
|
+
*/
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type MutableRefObject, type UIEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for tracking action button overlap and scroll state.
|
|
4
|
+
*
|
|
5
|
+
* @private component of `<Chat/>`
|
|
6
|
+
*/
|
|
7
|
+
export type ChatActionsOverlapConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* Provides the chat messages container ref for auto-scroll integration.
|
|
10
|
+
*/
|
|
11
|
+
chatMessagesRef: (element: HTMLDivElement | null) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Scroll handler from the auto-scroll hook.
|
|
14
|
+
*/
|
|
15
|
+
handleScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Selector used to locate message elements for overlap checks.
|
|
18
|
+
*/
|
|
19
|
+
messageSelector: string;
|
|
20
|
+
/**
|
|
21
|
+
* Messages used to trigger overlap recalculation.
|
|
22
|
+
*/
|
|
23
|
+
messages: ReadonlyArray<unknown>;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Result returned by the action overlap tracking hook.
|
|
27
|
+
*/
|
|
28
|
+
export type ChatActionsOverlapResult = {
|
|
29
|
+
/**
|
|
30
|
+
* Ref for the actions toolbar element.
|
|
31
|
+
*/
|
|
32
|
+
actionsRef: MutableRefObject<HTMLDivElement | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Combined ref setter for chat messages (auto-scroll + overlap tracking).
|
|
35
|
+
*/
|
|
36
|
+
setChatMessagesElement: (element: HTMLDivElement | null) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Scroll handler that updates both auto-scroll and overlap state.
|
|
39
|
+
*/
|
|
40
|
+
handleChatScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the actions toolbar is currently being scrolled.
|
|
43
|
+
*/
|
|
44
|
+
isActionsScrolling: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the actions toolbar overlaps the first visible message.
|
|
47
|
+
*/
|
|
48
|
+
isActionsOverlapping: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Tracks action toolbar overlap while coordinating with chat auto-scroll.
|
|
52
|
+
*
|
|
53
|
+
* @private component of `<Chat/>`
|
|
54
|
+
*/
|
|
55
|
+
export declare function useChatActionsOverlap(config: ChatActionsOverlapConfig): ChatActionsOverlapResult;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Promisable } from 'type-fest';
|
|
2
|
+
import type { id } from '../../../types/typeAliases';
|
|
3
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
4
|
+
/**
|
|
5
|
+
* Input parameters for the chat rating hook.
|
|
6
|
+
*
|
|
7
|
+
* @private component of `<Chat/>`
|
|
8
|
+
*/
|
|
9
|
+
export type UseChatRatingsOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Messages in the chat thread.
|
|
12
|
+
*/
|
|
13
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
14
|
+
/**
|
|
15
|
+
* Optional feedback handler passed to Chat.
|
|
16
|
+
*/
|
|
17
|
+
onFeedback?: (feedback: {
|
|
18
|
+
message: ChatMessage;
|
|
19
|
+
rating: number;
|
|
20
|
+
textRating: string;
|
|
21
|
+
chatThread: string;
|
|
22
|
+
expectedAnswer: string | null;
|
|
23
|
+
url: string;
|
|
24
|
+
}) => Promisable<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the UI should apply mobile-specific behavior.
|
|
27
|
+
*/
|
|
28
|
+
isMobile: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Rating state tracked for the chat UI.
|
|
32
|
+
*
|
|
33
|
+
* @private component of `<Chat/>`
|
|
34
|
+
*/
|
|
35
|
+
export type ChatRatingsState = {
|
|
36
|
+
ratingModalOpen: boolean;
|
|
37
|
+
selectedMessage: ChatMessage | null;
|
|
38
|
+
messageRatings: Map<id, number>;
|
|
39
|
+
textRating: string;
|
|
40
|
+
hoveredRating: number;
|
|
41
|
+
expandedMessageId: id | null;
|
|
42
|
+
ratingConfirmation: string | null;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Rating actions for the chat UI.
|
|
46
|
+
*
|
|
47
|
+
* @private component of `<Chat/>`
|
|
48
|
+
*/
|
|
49
|
+
export type ChatRatingsActions = {
|
|
50
|
+
setRatingModalOpen: (value: boolean) => void;
|
|
51
|
+
setSelectedMessage: (value: ChatMessage | null) => void;
|
|
52
|
+
setMessageRatings: (value: Map<id, number> | ((previous: Map<id, number>) => Map<id, number>)) => void;
|
|
53
|
+
setTextRating: (value: string) => void;
|
|
54
|
+
setHoveredRating: (value: number) => void;
|
|
55
|
+
setExpandedMessageId: (value: id | null) => void;
|
|
56
|
+
handleRating: (message: ChatMessage, newRating: number) => void;
|
|
57
|
+
submitRating: () => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Hook that centralizes rating state and handlers for Chat.
|
|
61
|
+
*
|
|
62
|
+
* @private component of `<Chat/>`
|
|
63
|
+
*/
|
|
64
|
+
export declare function useChatRatings(options: UseChatRatingsOptions): {
|
|
65
|
+
state: ChatRatingsState;
|
|
66
|
+
actions: ChatRatingsActions;
|
|
67
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the TeacherIcon component.
|
|
3
|
+
*/
|
|
4
|
+
type TeacherIconProps = {
|
|
5
|
+
size?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Renders a teacher/graduation cap icon.
|
|
10
|
+
*
|
|
11
|
+
* @param props - SVG properties augmented with an optional `size`
|
|
12
|
+
* @private internal subcomponent used by various components
|
|
13
|
+
*/
|
|
14
|
+
export declare function TeacherIcon({ size, color }: TeacherIconProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -4,6 +4,19 @@ import type { string_book } from '../../../../book-2.0/agent-source/string_book'
|
|
|
4
4
|
import type { string_agent_name, string_agent_permanent_id } from '../../../../types/typeAliases';
|
|
5
5
|
import { AgentCollectionInSupabaseOptions } from './AgentCollectionInSupabaseOptions';
|
|
6
6
|
import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
|
|
7
|
+
/**
|
|
8
|
+
* Options for creating a new agent entry.
|
|
9
|
+
*/
|
|
10
|
+
type CreateAgentOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* Folder identifier to assign the new agent to.
|
|
13
|
+
*/
|
|
14
|
+
readonly folderId?: number | null;
|
|
15
|
+
/**
|
|
16
|
+
* Sort order for the agent within its parent folder.
|
|
17
|
+
*/
|
|
18
|
+
readonly sortOrder?: number;
|
|
19
|
+
};
|
|
7
20
|
/**
|
|
8
21
|
* Agent collection stored in a Supabase table.
|
|
9
22
|
*
|
|
@@ -39,8 +52,11 @@ export declare class AgentCollectionInSupabase {
|
|
|
39
52
|
* Creates a new agent in the collection
|
|
40
53
|
*
|
|
41
54
|
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
55
|
+
*
|
|
56
|
+
* @param agentSource - Source content of the agent.
|
|
57
|
+
* @param options - Optional folder placement and ordering data.
|
|
42
58
|
*/
|
|
43
|
-
createAgent(agentSource: string_book): Promise<AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>>;
|
|
59
|
+
createAgent(agentSource: string_book, options?: CreateAgentOptions): Promise<AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>>;
|
|
44
60
|
/**
|
|
45
61
|
* Updates an existing agent in the collection
|
|
46
62
|
*/
|
|
@@ -80,6 +96,7 @@ export declare class AgentCollectionInSupabase {
|
|
|
80
96
|
*/
|
|
81
97
|
private getTableName;
|
|
82
98
|
}
|
|
99
|
+
export {};
|
|
83
100
|
/**
|
|
84
101
|
* TODO: [🐱🚀] Implement it here correctly and update JSDoc comments here, and on interface + other implementations
|
|
85
102
|
* TODO: Write unit test
|
|
@@ -11,9 +11,15 @@
|
|
|
11
11
|
* NOTE: This file intentionally omits all other tables (`Metadata`, `ChatHistory`, `ChatFeedback`, `User`, `LlmCache`, etc.)
|
|
12
12
|
* and any extra schemas (e.g. `graphql_public`) to remain a strict subset.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Supabase-style JSON helper type.
|
|
16
|
+
*/
|
|
14
17
|
export type Json = string | number | boolean | null | {
|
|
15
18
|
[key: string]: Json | undefined;
|
|
16
19
|
} | Json[];
|
|
20
|
+
/**
|
|
21
|
+
* Subset of the Agents Server database schema containing only Agent and AgentHistory tables.
|
|
22
|
+
*/
|
|
17
23
|
export type AgentsDatabaseSchema = {
|
|
18
24
|
public: {
|
|
19
25
|
Tables: {
|
|
@@ -31,13 +37,15 @@ export type AgentsDatabaseSchema = {
|
|
|
31
37
|
usage: Json | null;
|
|
32
38
|
preparedModelRequirements: Json | null;
|
|
33
39
|
preparedExternals: Json | null;
|
|
40
|
+
folderId: number | null;
|
|
41
|
+
sortOrder: number;
|
|
34
42
|
deletedAt: string | null;
|
|
35
43
|
visibility: 'PUBLIC' | 'PRIVATE';
|
|
36
44
|
};
|
|
37
45
|
Insert: {
|
|
38
46
|
id?: number;
|
|
39
47
|
agentName: string;
|
|
40
|
-
createdAt
|
|
48
|
+
createdAt?: string;
|
|
41
49
|
updatedAt?: string | null;
|
|
42
50
|
permanentId?: string | null;
|
|
43
51
|
agentHash: string;
|
|
@@ -47,6 +55,8 @@ export type AgentsDatabaseSchema = {
|
|
|
47
55
|
usage?: Json | null;
|
|
48
56
|
preparedModelRequirements?: Json | null;
|
|
49
57
|
preparedExternals?: Json | null;
|
|
58
|
+
folderId?: number | null;
|
|
59
|
+
sortOrder?: number;
|
|
50
60
|
deletedAt?: string | null;
|
|
51
61
|
visibility?: 'PUBLIC' | 'PRIVATE';
|
|
52
62
|
};
|
|
@@ -63,10 +73,19 @@ export type AgentsDatabaseSchema = {
|
|
|
63
73
|
usage?: Json | null;
|
|
64
74
|
preparedModelRequirements?: Json | null;
|
|
65
75
|
preparedExternals?: Json | null;
|
|
76
|
+
folderId?: number | null;
|
|
77
|
+
sortOrder?: number;
|
|
66
78
|
deletedAt?: string | null;
|
|
67
79
|
visibility?: 'PUBLIC' | 'PRIVATE';
|
|
68
80
|
};
|
|
69
|
-
Relationships: [
|
|
81
|
+
Relationships: [
|
|
82
|
+
{
|
|
83
|
+
foreignKeyName: 'Agent_folderId_fkey';
|
|
84
|
+
columns: ['folderId'];
|
|
85
|
+
referencedRelation: 'AgentFolder';
|
|
86
|
+
referencedColumns: ['id'];
|
|
87
|
+
}
|
|
88
|
+
];
|
|
70
89
|
};
|
|
71
90
|
AgentHistory: {
|
|
72
91
|
Row: {
|
|
@@ -81,7 +100,7 @@ export type AgentsDatabaseSchema = {
|
|
|
81
100
|
};
|
|
82
101
|
Insert: {
|
|
83
102
|
id?: number;
|
|
84
|
-
createdAt
|
|
103
|
+
createdAt?: string;
|
|
85
104
|
agentName: string;
|
|
86
105
|
permanentId: string;
|
|
87
106
|
agentHash: string;
|
|
@@ -115,7 +134,13 @@ export type AgentsDatabaseSchema = {
|
|
|
115
134
|
CompositeTypes: Record<string, never>;
|
|
116
135
|
};
|
|
117
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Public schema reference for helper types.
|
|
139
|
+
*/
|
|
118
140
|
type PublicSchema = AgentsDatabaseSchema[Extract<keyof AgentsDatabaseSchema, 'public'>];
|
|
141
|
+
/**
|
|
142
|
+
* Helper type to extract table row types from the public schema.
|
|
143
|
+
*/
|
|
119
144
|
export type Tables<PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & PublicSchema['Views']) | {
|
|
120
145
|
schema: keyof AgentsDatabaseSchema;
|
|
121
146
|
}, TableName extends PublicTableNameOrOptions extends {
|
|
@@ -127,6 +152,9 @@ export type Tables<PublicTableNameOrOptions extends keyof (PublicSchema['Tables'
|
|
|
127
152
|
} ? R : never : PublicTableNameOrOptions extends keyof (PublicSchema['Tables'] & PublicSchema['Views']) ? (PublicSchema['Tables'] & PublicSchema['Views'])[PublicTableNameOrOptions] extends {
|
|
128
153
|
Row: infer R;
|
|
129
154
|
} ? R : never : never;
|
|
155
|
+
/**
|
|
156
|
+
* Helper type to extract table insert types from the public schema.
|
|
157
|
+
*/
|
|
130
158
|
export type TablesInsert<PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | {
|
|
131
159
|
schema: keyof AgentsDatabaseSchema;
|
|
132
160
|
}, TableName extends PublicTableNameOrOptions extends {
|
|
@@ -138,6 +166,9 @@ export type TablesInsert<PublicTableNameOrOptions extends keyof PublicSchema['Ta
|
|
|
138
166
|
} ? I : never : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
|
139
167
|
Insert: infer I;
|
|
140
168
|
} ? I : never : never;
|
|
169
|
+
/**
|
|
170
|
+
* Helper type to extract table update types from the public schema.
|
|
171
|
+
*/
|
|
141
172
|
export type TablesUpdate<PublicTableNameOrOptions extends keyof PublicSchema['Tables'] | {
|
|
142
173
|
schema: keyof AgentsDatabaseSchema;
|
|
143
174
|
}, TableName extends PublicTableNameOrOptions extends {
|
|
@@ -149,6 +180,9 @@ export type TablesUpdate<PublicTableNameOrOptions extends keyof PublicSchema['Ta
|
|
|
149
180
|
} ? U : never : PublicTableNameOrOptions extends keyof PublicSchema['Tables'] ? PublicSchema['Tables'][PublicTableNameOrOptions] extends {
|
|
150
181
|
Update: infer U;
|
|
151
182
|
} ? U : never : never;
|
|
183
|
+
/**
|
|
184
|
+
* Helper type to extract enum types from the public schema.
|
|
185
|
+
*/
|
|
152
186
|
export type Enums<PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] | {
|
|
153
187
|
schema: keyof AgentsDatabaseSchema;
|
|
154
188
|
}, EnumName extends PublicEnumNameOrOptions extends {
|
|
@@ -156,6 +190,9 @@ export type Enums<PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] |
|
|
|
156
190
|
} ? keyof AgentsDatabaseSchema[PublicEnumNameOrOptions['schema']]['Enums'] : never = never> = PublicEnumNameOrOptions extends {
|
|
157
191
|
schema: keyof AgentsDatabaseSchema;
|
|
158
192
|
} ? AgentsDatabaseSchema[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] : PublicEnumNameOrOptions extends keyof PublicSchema['Enums'] ? PublicSchema['Enums'][PublicEnumNameOrOptions] : never;
|
|
193
|
+
/**
|
|
194
|
+
* Helper type to extract composite types from the public schema.
|
|
195
|
+
*/
|
|
159
196
|
export type CompositeTypes<PublicCompositeTypeNameOrOptions extends keyof PublicSchema['CompositeTypes'] | {
|
|
160
197
|
schema: keyof AgentsDatabaseSchema;
|
|
161
198
|
}, CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
|
|
@@ -72,6 +72,10 @@ export type SelfLearningTeacherSummary = {
|
|
|
72
72
|
* Commitment breakdown produced by the teacher step.
|
|
73
73
|
*/
|
|
74
74
|
readonly commitmentTypes: SelfLearningCommitmentTypeCounts;
|
|
75
|
+
/**
|
|
76
|
+
* Normalized commitment lines produced by the teacher step.
|
|
77
|
+
*/
|
|
78
|
+
readonly commitments?: ReadonlyArray<string>;
|
|
75
79
|
};
|
|
76
80
|
/**
|
|
77
81
|
* Result payload for the self-learning tool call.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LinguisticHashLanguage } from './LinguisticHashLanguage';
|
|
2
2
|
export { DEFAULT_LINGUISTIC_HASH_LANGUAGE, LINGUISTIC_HASH_LANGUAGES, normalizeLinguisticHashLanguage, } from './LinguisticHashLanguage';
|
|
3
3
|
export type { LinguisticHashLanguage } from './LinguisticHashLanguage';
|
|
4
|
+
export { DEFAULT_LINGUISTIC_HASH_WORD_COUNT, MAX_LINGUISTIC_HASH_WORD_COUNT, MIN_LINGUISTIC_HASH_WORD_COUNT, normalizeLinguisticHashWordCount, } from './linguisticHashWordCount';
|
|
4
5
|
/**
|
|
5
6
|
* Creates a human-readable hash as a short, story-like phrase.
|
|
6
7
|
*
|
|
@@ -11,27 +12,3 @@ export type { LinguisticHashLanguage } from './LinguisticHashLanguage';
|
|
|
11
12
|
* @public exported from `@promptbook/utils`
|
|
12
13
|
*/
|
|
13
14
|
export declare function linguisticHash(input: string, wordCount?: number, language?: LinguisticHashLanguage): Promise<string>;
|
|
14
|
-
/**
|
|
15
|
-
* The minimum number of words for a linguistic hash.
|
|
16
|
-
*
|
|
17
|
-
* @private utility of `linguisticHash`
|
|
18
|
-
*/
|
|
19
|
-
export declare const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
20
|
-
/**
|
|
21
|
-
* The default number of words for a linguistic hash.
|
|
22
|
-
*
|
|
23
|
-
* @private utility of `linguisticHash`
|
|
24
|
-
*/
|
|
25
|
-
export declare const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
26
|
-
/**
|
|
27
|
-
* The maximum number of words for a linguistic hash.
|
|
28
|
-
*
|
|
29
|
-
* @private utility of `linguisticHash`
|
|
30
|
-
*/
|
|
31
|
-
export declare const MAX_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
32
|
-
/**
|
|
33
|
-
* Normalizes the word count to a supported integer range.
|
|
34
|
-
*
|
|
35
|
-
* @private utility of `linguisticHash`
|
|
36
|
-
*/
|
|
37
|
-
export declare function normalizeLinguisticHashWordCount(wordCount?: number | null): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MAX_LINGUISTIC_HASH_WORD_COUNT } from './linguisticHashWordSelection';
|
|
2
|
+
/**
|
|
3
|
+
* The minimum number of words for a linguistic hash.
|
|
4
|
+
*
|
|
5
|
+
* @private utility of `linguisticHash`
|
|
6
|
+
*/
|
|
7
|
+
export declare const MIN_LINGUISTIC_HASH_WORD_COUNT = 1;
|
|
8
|
+
/**
|
|
9
|
+
* The default number of words for a linguistic hash.
|
|
10
|
+
*
|
|
11
|
+
* @private utility of `linguisticHash`
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_LINGUISTIC_HASH_WORD_COUNT = 7;
|
|
14
|
+
/**
|
|
15
|
+
* Normalizes the word count to a supported integer range.
|
|
16
|
+
*
|
|
17
|
+
* @private utility of `linguisticHash`
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeLinguisticHashWordCount(wordCount?: number | null): number;
|
|
20
|
+
export { MAX_LINGUISTIC_HASH_WORD_COUNT };
|
|
21
|
+
/**
|
|
22
|
+
* Bundled helpers for linguistic hash word count handling.
|
|
23
|
+
*
|
|
24
|
+
* @private utility of `linguisticHash`
|
|
25
|
+
*/
|
|
26
|
+
export declare const linguisticHashWordCount: {
|
|
27
|
+
DEFAULT_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
28
|
+
MAX_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
29
|
+
MIN_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
30
|
+
normalizeLinguisticHashWordCount: typeof normalizeLinguisticHashWordCount;
|
|
31
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { LinguisticHashWordLists } from './linguisticHashTypes';
|
|
2
|
+
/**
|
|
3
|
+
* The maximum number of words for a linguistic hash.
|
|
4
|
+
*
|
|
5
|
+
* @private utility of `linguisticHash`
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAX_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
8
|
+
/**
|
|
9
|
+
* Selects the requested number of words from the hash output.
|
|
10
|
+
*
|
|
11
|
+
* @private utility of `linguisticHash`
|
|
12
|
+
*/
|
|
13
|
+
export declare function createLinguisticHashWords(hash: string, wordCount: number, wordLists: LinguisticHashWordLists): string[];
|
|
14
|
+
/**
|
|
15
|
+
* Bundled helpers for the linguistic hash word selection module.
|
|
16
|
+
*
|
|
17
|
+
* @private utility of `linguisticHash`
|
|
18
|
+
*/
|
|
19
|
+
export declare const linguisticHashWordSelection: {
|
|
20
|
+
createLinguisticHashWords: typeof createLinguisticHashWords;
|
|
21
|
+
MAX_LINGUISTIC_HASH_WORD_COUNT: number;
|
|
22
|
+
};
|
|
@@ -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.
|
|
18
|
+
* It follows semantic versioning (e.g., `0.109.0-0`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/javascript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.110.0-0",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"module": "./esm/index.es.js",
|
|
95
95
|
"typings": "./esm/typings/src/_packages/javascript.index.d.ts",
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@promptbook/core": "0.
|
|
97
|
+
"@promptbook/core": "0.110.0-0"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
100
|
"crypto": "1.0.1",
|
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.
|
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-0';
|
|
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
|