@promptbook/javascript 0.110.0-8 → 0.110.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/README.md +0 -4
- package/esm/index.es.js +1 -1
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +6 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +22 -21
- package/esm/typings/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +8 -2
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.agentReferenceResolver.test.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +4 -5
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +42 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatInputArea.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +26 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +31 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +6 -0
- package/esm/typings/src/book-components/Chat/hooks/useChatRatings.d.ts +24 -2
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +2 -10
- package/esm/typings/src/book-components/Chat/utils/parseCitationMarker.d.ts +75 -0
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +3 -1
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.test.d.ts +1 -0
- package/esm/typings/src/book-components/icons/ArrowIcon.d.ts +17 -4
- package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +9 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.test.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +39 -0
- package/esm/typings/src/types/LlmToolDefinition.d.ts +1 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +9 -0
- package/esm/typings/src/utils/DEFAULT_THINKING_MESSAGES.d.ts +8 -0
- package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.d.ts +38 -0
- package/esm/typings/src/utils/knowledge/inlineKnowledgeSource.test.d.ts +1 -0
- package/esm/typings/src/utils/language/getBrowserPreferredSpeechRecognitionLanguage.d.ts +35 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1 -1
- package/umd/index.umd.js.map +1 -1
|
@@ -2,6 +2,43 @@ import { CSSProperties } from 'react';
|
|
|
2
2
|
import type { Promisable } from 'type-fest';
|
|
3
3
|
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
4
|
import type { number_percent, number_positive, string_css_value, string_knowledge_source_content } from '../../types/typeAliases';
|
|
5
|
+
/**
|
|
6
|
+
* Monaco diagnostic shown inside `BookEditor`.
|
|
7
|
+
*
|
|
8
|
+
* @private internal type of `BookEditor`
|
|
9
|
+
*/
|
|
10
|
+
type BookEditorDiagnostic = {
|
|
11
|
+
/**
|
|
12
|
+
* 1-based start line.
|
|
13
|
+
*/
|
|
14
|
+
readonly startLineNumber: number;
|
|
15
|
+
/**
|
|
16
|
+
* 1-based start column.
|
|
17
|
+
*/
|
|
18
|
+
readonly startColumn: number;
|
|
19
|
+
/**
|
|
20
|
+
* 1-based end line.
|
|
21
|
+
*/
|
|
22
|
+
readonly endLineNumber: number;
|
|
23
|
+
/**
|
|
24
|
+
* 1-based end column.
|
|
25
|
+
*/
|
|
26
|
+
readonly endColumn: number;
|
|
27
|
+
/**
|
|
28
|
+
* Diagnostic message shown by Monaco.
|
|
29
|
+
*/
|
|
30
|
+
readonly message: string;
|
|
31
|
+
/**
|
|
32
|
+
* Marker severity used for color coding in Monaco.
|
|
33
|
+
*
|
|
34
|
+
* @default 'error'
|
|
35
|
+
*/
|
|
36
|
+
readonly severity?: 'error' | 'warning' | 'info' | 'hint';
|
|
37
|
+
/**
|
|
38
|
+
* Optional source label shown in Monaco hover.
|
|
39
|
+
*/
|
|
40
|
+
readonly source?: string;
|
|
41
|
+
};
|
|
5
42
|
/**
|
|
6
43
|
* Default height of the book editor
|
|
7
44
|
*
|
|
@@ -76,6 +113,10 @@ export type BookEditorProps = {
|
|
|
76
113
|
* Callback function to handle changes in the book content.
|
|
77
114
|
*/
|
|
78
115
|
onChange?(value: string_book): void;
|
|
116
|
+
/**
|
|
117
|
+
* Optional Monaco diagnostics shown as squiggle markers in the editor.
|
|
118
|
+
*/
|
|
119
|
+
readonly diagnostics?: ReadonlyArray<BookEditorDiagnostic>;
|
|
79
120
|
/**
|
|
80
121
|
* Returns the URL of the uploaded file on CDN or storage.
|
|
81
122
|
*/
|
|
@@ -162,6 +203,7 @@ export type BookEditorProps = {
|
|
|
162
203
|
* @public exported from `@promptbook/components`
|
|
163
204
|
*/
|
|
164
205
|
export declare function BookEditor(props: BookEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
206
|
+
export {};
|
|
165
207
|
/**
|
|
166
208
|
* TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
|
|
167
209
|
*/
|
|
@@ -3,7 +3,6 @@ import type { Promisable } from 'type-fest';
|
|
|
3
3
|
import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
|
|
4
4
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
5
5
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
6
|
-
import type { ChatSoundSystem } from './ChatProps';
|
|
7
6
|
/**
|
|
8
7
|
* Props for the Chat actions toolbar.
|
|
9
8
|
*
|
|
@@ -26,7 +25,6 @@ export type ChatActionsBarProps = {
|
|
|
26
25
|
*/
|
|
27
26
|
shouldDisableActions: boolean;
|
|
28
27
|
onButtonClick: (handler?: (event: MouseEvent<HTMLButtonElement>) => void) => (event: MouseEvent<HTMLButtonElement>) => void;
|
|
29
|
-
soundSystem?: ChatSoundSystem;
|
|
30
28
|
};
|
|
31
29
|
/**
|
|
32
30
|
* Renders the action buttons row for Chat.
|
|
@@ -29,6 +29,7 @@ export type ChatInputAreaProps = {
|
|
|
29
29
|
onChange?: ChatProps['onChange'];
|
|
30
30
|
onFileUpload?: ChatProps['onFileUpload'];
|
|
31
31
|
speechRecognition?: ChatProps['speechRecognition'];
|
|
32
|
+
speechRecognitionLanguage?: ChatProps['speechRecognitionLanguage'];
|
|
32
33
|
defaultMessage?: string;
|
|
33
34
|
placeholderMessageContent?: string;
|
|
34
35
|
isFocusedOnLoad?: boolean;
|
|
@@ -52,6 +52,10 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
|
|
|
52
52
|
* Called when a source citation chip is clicked.
|
|
53
53
|
*/
|
|
54
54
|
onCitationClick?: (citation: ParsedCitation) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Optional sound system for triggering tool chip events.
|
|
57
|
+
*/
|
|
58
|
+
soundSystem?: ChatProps['soundSystem'];
|
|
55
59
|
};
|
|
56
60
|
/**
|
|
57
61
|
* Metadata for a teammate agent tool.
|
|
@@ -27,6 +27,7 @@ export type ChatMessageListProps = {
|
|
|
27
27
|
teammates?: ChatProps['teammates'];
|
|
28
28
|
onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
|
|
29
29
|
onCitationClick?: (citation: ParsedCitation) => void;
|
|
30
|
+
soundSystem?: ChatProps['soundSystem'];
|
|
30
31
|
setChatMessagesElement: (element: HTMLDivElement | null) => void;
|
|
31
32
|
onScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
32
33
|
chatMessagesClassName?: string;
|
|
@@ -6,6 +6,17 @@ import { string_color } from '../../../types/typeAliases';
|
|
|
6
6
|
import type { string_chat_format_name } from '../save/_common/string_chat_format_name';
|
|
7
7
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
8
8
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
9
|
+
/**
|
|
10
|
+
* Response data returned by the optional `onFeedback` handler.
|
|
11
|
+
*
|
|
12
|
+
* @public exported from `@promptbook/components`
|
|
13
|
+
*/
|
|
14
|
+
export type ChatFeedbackResponse = {
|
|
15
|
+
/**
|
|
16
|
+
* Optional text that should be shown to the user after the feedback is saved.
|
|
17
|
+
*/
|
|
18
|
+
readonly message?: string;
|
|
19
|
+
};
|
|
9
20
|
/**
|
|
10
21
|
* Interface for sound system that can be passed to Chat component
|
|
11
22
|
* This allows the chat to trigger sounds without tight coupling
|
|
@@ -20,6 +31,16 @@ export type ChatSoundSystem = {
|
|
|
20
31
|
isEnabled(): boolean;
|
|
21
32
|
setEnabled(enabled: boolean): void;
|
|
22
33
|
toggle(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional helpers for haptic vibration state.
|
|
36
|
+
*/
|
|
37
|
+
isVibrationEnabled?(): boolean;
|
|
38
|
+
setVibrationEnabled?(enabled: boolean): void;
|
|
39
|
+
toggleVibration?(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Optional vibration helper to stay in sync with sound events.
|
|
42
|
+
*/
|
|
43
|
+
vibrate?(event: string): void;
|
|
23
44
|
};
|
|
24
45
|
/**
|
|
25
46
|
* @public exported from `@promptbook/components`
|
|
@@ -66,6 +87,11 @@ export type ChatProps = {
|
|
|
66
87
|
* Speech recognition provider
|
|
67
88
|
*/
|
|
68
89
|
readonly speechRecognition?: SpeechRecognition;
|
|
90
|
+
/**
|
|
91
|
+
* Optional language tag (BCP 47) to force speech recognition to use a specific language.
|
|
92
|
+
* When not provided, the browser preferences are used with a fallback to `en-US`.
|
|
93
|
+
*/
|
|
94
|
+
readonly speechRecognitionLanguage?: string;
|
|
69
95
|
/**
|
|
70
96
|
* Optional placeholder message for the textarea
|
|
71
97
|
*
|
|
@@ -21,3 +21,34 @@ export type ChatSoundToggleProps = {
|
|
|
21
21
|
* @public exported from `@promptbook/components`
|
|
22
22
|
*/
|
|
23
23
|
export declare function ChatSoundToggle(props: ChatSoundToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Props for the chat vibration toggle.
|
|
26
|
+
*/
|
|
27
|
+
export type ChatVibrationToggleProps = {
|
|
28
|
+
/**
|
|
29
|
+
* The sound system instance that supports vibration helpers.
|
|
30
|
+
*/
|
|
31
|
+
soundSystem: ChatSoundSystem;
|
|
32
|
+
/**
|
|
33
|
+
* Optional CSS class name.
|
|
34
|
+
*/
|
|
35
|
+
className?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* ChatVibrationToggle component that controls haptic feedback.
|
|
39
|
+
*
|
|
40
|
+
* @public exported from `@promptbook/components`
|
|
41
|
+
*/
|
|
42
|
+
export declare function ChatVibrationToggle(props: ChatVibrationToggleProps): import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
/**
|
|
44
|
+
* Props for the combined sound and vibration control panel.
|
|
45
|
+
*/
|
|
46
|
+
export type ChatSoundAndVibrationPanelProps = {
|
|
47
|
+
readonly soundSystem: ChatSoundSystem;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Renders a compact control panel that surfaces both sound and haptic toggles with richer affordances.
|
|
51
|
+
*
|
|
52
|
+
* @public exported from `@promptbook/components`
|
|
53
|
+
*/
|
|
54
|
+
export declare function ChatSoundAndVibrationPanel(props: ChatSoundAndVibrationPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -62,6 +62,12 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
|
|
|
62
62
|
* e.g., { "web_search": "Searching the web..." }
|
|
63
63
|
*/
|
|
64
64
|
readonly toolTitles?: Record<string, string>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom variants for the placeholder thinking message shown while the agent buffers its response.
|
|
67
|
+
*
|
|
68
|
+
* @default Shared thinking message variants
|
|
69
|
+
*/
|
|
70
|
+
readonly thinkingMessages?: ReadonlyArray<string>;
|
|
65
71
|
/**
|
|
66
72
|
* Optional custom error handler that will be called when an error occurs during chat.
|
|
67
73
|
* If not provided, errors will be displayed as messages in the chat.
|
|
@@ -1,6 +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
5
|
/**
|
|
5
6
|
* Input parameters for the chat rating hook.
|
|
6
7
|
*
|
|
@@ -21,12 +22,33 @@ export type UseChatRatingsOptions = {
|
|
|
21
22
|
chatThread: string;
|
|
22
23
|
expectedAnswer: string | null;
|
|
23
24
|
url: string;
|
|
24
|
-
}) => Promisable<void>;
|
|
25
|
+
}) => Promisable<ChatFeedbackResponse | void>;
|
|
25
26
|
/**
|
|
26
27
|
* Whether the UI should apply mobile-specific behavior.
|
|
27
28
|
*/
|
|
28
29
|
isMobile: boolean;
|
|
29
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Indicates how the feedback status message should be rendered.
|
|
33
|
+
*
|
|
34
|
+
* @private component of `<Chat/>`
|
|
35
|
+
*/
|
|
36
|
+
export type FeedbackStatusVariant = 'success' | 'error';
|
|
37
|
+
/**
|
|
38
|
+
* Data used to show the transient feedback status toast.
|
|
39
|
+
*
|
|
40
|
+
* @private component of `<Chat/>`
|
|
41
|
+
*/
|
|
42
|
+
export type FeedbackStatus = {
|
|
43
|
+
/**
|
|
44
|
+
* Message displayed to the user.
|
|
45
|
+
*/
|
|
46
|
+
readonly message: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the message indicates success or failure.
|
|
49
|
+
*/
|
|
50
|
+
readonly variant: FeedbackStatusVariant;
|
|
51
|
+
};
|
|
30
52
|
/**
|
|
31
53
|
* Rating state tracked for the chat UI.
|
|
32
54
|
*
|
|
@@ -39,7 +61,7 @@ export type ChatRatingsState = {
|
|
|
39
61
|
textRating: string;
|
|
40
62
|
hoveredRating: number;
|
|
41
63
|
expandedMessageId: id | null;
|
|
42
|
-
|
|
64
|
+
feedbackStatus: FeedbackStatus | null;
|
|
43
65
|
};
|
|
44
66
|
/**
|
|
45
67
|
* Rating actions for the chat UI.
|
|
@@ -7,19 +7,13 @@ import type { AgentChipData } from '../AgentChip';
|
|
|
7
7
|
*/
|
|
8
8
|
export type ToolCallChipletInfo = {
|
|
9
9
|
/**
|
|
10
|
-
* Display text for the chiplet
|
|
10
|
+
* Display text for the chiplet.
|
|
11
11
|
*/
|
|
12
12
|
text: string;
|
|
13
13
|
/**
|
|
14
|
-
* Agent data for team tools (if applicable)
|
|
14
|
+
* Agent data for team tools (if applicable).
|
|
15
15
|
*/
|
|
16
16
|
agentData?: AgentChipData;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to wrap the chip text in brackets when rendering.
|
|
19
|
-
*
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
wrapInBrackets?: boolean;
|
|
23
17
|
};
|
|
24
18
|
/**
|
|
25
19
|
* Builds display text for a tool call chiplet.
|
|
@@ -33,12 +27,10 @@ export declare function buildToolCallChipText(chipletInfo: ToolCallChipletInfo):
|
|
|
33
27
|
* Technical to user-friendly tool names and emojis
|
|
34
28
|
*
|
|
35
29
|
* @private utility of `<Chat/>` [🧠] Maybe public?
|
|
36
|
-
*
|
|
37
30
|
*/
|
|
38
31
|
export declare const TOOL_TITLES: Record<string, {
|
|
39
32
|
title: string;
|
|
40
33
|
emoji: string;
|
|
41
|
-
wrapInBrackets?: boolean;
|
|
42
34
|
}>;
|
|
43
35
|
/**
|
|
44
36
|
* Gets the chiplet information including text and agent data (for team tools).
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default citation identifier used for simplified citation markers without an explicit position.
|
|
3
|
+
*
|
|
4
|
+
* @private utility of `<Chat/>`
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_SIMPLIFIED_CITATION_ID = "0:0";
|
|
7
|
+
/**
|
|
8
|
+
* Parsed citation marker normalized to the full OpenAI-style notation.
|
|
9
|
+
*
|
|
10
|
+
* @private utility of `<Chat/>`
|
|
11
|
+
*/
|
|
12
|
+
export type CitationMarker = {
|
|
13
|
+
/**
|
|
14
|
+
* Citation identifier (for example `7:15`).
|
|
15
|
+
*/
|
|
16
|
+
id: string;
|
|
17
|
+
/**
|
|
18
|
+
* Citation source filename or label.
|
|
19
|
+
*/
|
|
20
|
+
source: string;
|
|
21
|
+
/**
|
|
22
|
+
* Original marker exactly as found in the content.
|
|
23
|
+
*/
|
|
24
|
+
raw: string;
|
|
25
|
+
/**
|
|
26
|
+
* Full normalized marker (`【id†source】`).
|
|
27
|
+
*/
|
|
28
|
+
normalized: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Creates a global regular expression that matches citation markers wrapped in `【...】`.
|
|
32
|
+
*
|
|
33
|
+
* @private utility of `<Chat/>`
|
|
34
|
+
*/
|
|
35
|
+
export declare function createCitationMarkerRegex(): RegExp;
|
|
36
|
+
/**
|
|
37
|
+
* Parses one citation marker and normalizes it to full notation.
|
|
38
|
+
*
|
|
39
|
+
* @param rawMarker - Marker including outer brackets.
|
|
40
|
+
* @returns Parsed marker or `null` when the marker is invalid.
|
|
41
|
+
*
|
|
42
|
+
* @private utility of `<Chat/>`
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseCitationMarker(rawMarker: string): CitationMarker | null;
|
|
45
|
+
/**
|
|
46
|
+
* Parses all citation markers from content and normalizes each to full notation.
|
|
47
|
+
*
|
|
48
|
+
* @param content - Content that may contain citation markers.
|
|
49
|
+
* @returns Parsed citation markers in their original order.
|
|
50
|
+
*
|
|
51
|
+
* @private utility of `<Chat/>`
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseCitationMarkersFromContent(content: string): CitationMarker[];
|
|
54
|
+
/**
|
|
55
|
+
* Replaces all citation markers in content using normalized marker metadata.
|
|
56
|
+
*
|
|
57
|
+
* @param content - Content that may contain citation markers.
|
|
58
|
+
* @param replacer - Replacement callback for each valid marker.
|
|
59
|
+
* @returns Content with citation markers replaced.
|
|
60
|
+
*
|
|
61
|
+
* @private utility of `<Chat/>`
|
|
62
|
+
*/
|
|
63
|
+
export declare function replaceCitationMarkers(content: string, replacer: (marker: CitationMarker) => string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Normalizes simplified citation markers to full notation.
|
|
66
|
+
*
|
|
67
|
+
* Example:
|
|
68
|
+
* - `【document.pdf】` -> `【0:0†document.pdf】`
|
|
69
|
+
*
|
|
70
|
+
* @param content - Content that may contain simplified markers.
|
|
71
|
+
* @returns Content where every citation marker is in full notation.
|
|
72
|
+
*
|
|
73
|
+
* @private utility of `<Chat/>`
|
|
74
|
+
*/
|
|
75
|
+
export declare function normalizeCitationMarkersToFullNotation(content: string): string;
|
|
@@ -22,7 +22,9 @@ export type ParsedCitation = {
|
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Parses OpenAI Assistant-style citations from message content
|
|
25
|
-
* Matches
|
|
25
|
+
* Matches both:
|
|
26
|
+
* - Full notation: `【5:13†document.pdf】`
|
|
27
|
+
* - Simplified notation: `【document.pdf】`
|
|
26
28
|
*
|
|
27
29
|
* @param content - The markdown content that may contain citations
|
|
28
30
|
* @returns Array of parsed citations
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported arrow directions.
|
|
3
|
+
*
|
|
4
|
+
* @private internal typing helper for `<ArrowIcon/>`
|
|
5
|
+
*/
|
|
6
|
+
type ArrowDirection = 'DOWN' | 'UP';
|
|
7
|
+
/**
|
|
8
|
+
* Props for rendering a directional arrow icon.
|
|
9
|
+
*
|
|
10
|
+
* @private internal props typing for `<ArrowIcon/>`
|
|
11
|
+
*/
|
|
12
|
+
type ArrowIconProps = {
|
|
13
|
+
direction: ArrowDirection;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
1
16
|
/**
|
|
2
17
|
* Shows simple arrow icon pointing up or down
|
|
3
18
|
*
|
|
4
19
|
* @public exported from `@promptbook/components`
|
|
5
20
|
*/
|
|
6
|
-
export declare const ArrowIcon: ({ direction, size }:
|
|
7
|
-
|
|
8
|
-
size: number;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare const ArrowIcon: ({ direction, size }: ArrowIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -57,6 +57,15 @@ export declare abstract class BaseCommitmentDefinition<TBookCommitment extends s
|
|
|
57
57
|
* Helper method to append content to the system message
|
|
58
58
|
*/
|
|
59
59
|
protected appendToSystemMessage(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
|
|
60
|
+
/**
|
|
61
|
+
* Helper method to create a new requirements object with updated prompt suffix
|
|
62
|
+
*/
|
|
63
|
+
protected updatePromptSuffix(requirements: AgentModelRequirements, contentUpdate: string | ((currentSuffix: string) => string)): AgentModelRequirements;
|
|
64
|
+
/**
|
|
65
|
+
* Helper method to append content to the prompt suffix
|
|
66
|
+
* Default separator is a single newline for bullet lists.
|
|
67
|
+
*/
|
|
68
|
+
protected appendToPromptSuffix(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
|
|
60
69
|
/**
|
|
61
70
|
* Helper method to add a comment section to the system message
|
|
62
71
|
* Comments are lines starting with # that will be removed from the final system message
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Agent as AgentFromKit } from '@openai/agents';
|
|
2
|
+
import OpenAI from 'openai';
|
|
3
|
+
import { TODO_any } from '../../_packages/types.index';
|
|
2
4
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
5
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
6
|
import type { ModelRequirements } from '../../types/ModelRequirements';
|
|
@@ -6,6 +8,42 @@ import type { Prompt } from '../../types/Prompt';
|
|
|
6
8
|
import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
|
|
7
9
|
import type { OpenAiAgentKitExecutionToolsOptions } from './OpenAiAgentKitExecutionToolsOptions';
|
|
8
10
|
import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
|
|
11
|
+
/**
|
|
12
|
+
* Represents the AgentKit output configuration used to match OpenAI `response_format` expectations.
|
|
13
|
+
*
|
|
14
|
+
* @private utility of Open AI
|
|
15
|
+
*/
|
|
16
|
+
export type AgentOutputType = 'text' | JsonSchemaDefinition;
|
|
17
|
+
type JsonSchemaDefinitionEntry = {
|
|
18
|
+
type?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
properties?: Record<string, JsonSchemaDefinitionEntry>;
|
|
21
|
+
required?: Array<string>;
|
|
22
|
+
items?: JsonSchemaDefinitionEntry;
|
|
23
|
+
[key: string]: TODO_any;
|
|
24
|
+
};
|
|
25
|
+
type JsonSchemaDefinition = {
|
|
26
|
+
type: 'json_schema';
|
|
27
|
+
name: string;
|
|
28
|
+
strict: boolean;
|
|
29
|
+
schema: {
|
|
30
|
+
type: 'object';
|
|
31
|
+
properties: Record<string, JsonSchemaDefinitionEntry>;
|
|
32
|
+
required: Array<string>;
|
|
33
|
+
additionalProperties: boolean;
|
|
34
|
+
description?: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type OpenAiChatResponseFormat = OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
|
|
38
|
+
/**
|
|
39
|
+
* Maps OpenAI `response_format` payloads to AgentKit output types so the runner can forward
|
|
40
|
+
* structured-output preferences to OpenAI while still reusing the same AgentKit agent instance.
|
|
41
|
+
*
|
|
42
|
+
* @param responseFormat - The OpenAI `response_format` payload from the user request.
|
|
43
|
+
* @returns An Agent output type compatible with the requested schema or `undefined` when no impact is required.
|
|
44
|
+
* @private utility of Open AI
|
|
45
|
+
*/
|
|
46
|
+
export declare function mapResponseFormatToAgentOutputType(responseFormat?: OpenAiChatResponseFormat): AgentOutputType | undefined;
|
|
9
47
|
/**
|
|
10
48
|
* Alias for OpenAI AgentKit agent to avoid naming confusion with Promptbook agents.
|
|
11
49
|
*/
|
|
@@ -82,6 +120,7 @@ export declare class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandl
|
|
|
82
120
|
readonly prompt: Prompt;
|
|
83
121
|
readonly rawPromptContent?: string;
|
|
84
122
|
readonly onProgress: (chunk: ChatPromptResult) => void;
|
|
123
|
+
readonly responseFormatOutputType?: AgentOutputType;
|
|
85
124
|
}): Promise<ChatPromptResult>;
|
|
86
125
|
/**
|
|
87
126
|
* Builds AgentKit input items from the prompt and optional thread.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LlmToolDefinition } from './LlmToolDefinition';
|
|
2
2
|
import type { ModelVariant } from './ModelVariant';
|
|
3
3
|
import type { number_model_temperature, number_seed, string_model_name, string_system_message } from './typeAliases';
|
|
4
|
+
import type OpenAI from 'openai';
|
|
4
5
|
/**
|
|
5
6
|
* Abstract way to specify the LLM.
|
|
6
7
|
* It does not specify the LLM with concrete version itself, only the requirements for the LLM.
|
|
@@ -54,6 +55,14 @@ export type ChatModelRequirements = CommonModelRequirements & {
|
|
|
54
55
|
* Maximum number of tokens that can be generated by the model
|
|
55
56
|
*/
|
|
56
57
|
readonly maxTokens?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Optional OpenAI `response_format` override that should be forwarded to compatible APIs.
|
|
60
|
+
*/
|
|
61
|
+
readonly responseFormat?: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
|
|
62
|
+
/**
|
|
63
|
+
* Optional OpenAI `tool_choice` override that should be forwarded to compatible APIs.
|
|
64
|
+
*/
|
|
65
|
+
readonly toolChoice?: OpenAI.Chat.Completions.ChatCompletionToolChoiceOption;
|
|
57
66
|
};
|
|
58
67
|
/**
|
|
59
68
|
* Model requirements for the image generation variant
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default placeholder variants shown when an agent is still composing a response.
|
|
3
|
+
*
|
|
4
|
+
* @private BUT maybe export via some package
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_THINKING_MESSAGES: readonly ["Thinking...", "Searching for information...", "Sorting information..."];
|
|
7
|
+
/** @internal */
|
|
8
|
+
export type ThinkingMessageVariant = (typeof DEFAULT_THINKING_MESSAGES)[number];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { string_data_url, string_filename } from '../../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* @@@
|
|
6
|
+
*
|
|
7
|
+
* @private thing of inline knowledge
|
|
8
|
+
*/
|
|
9
|
+
export type InlineKnowledgeSourceFile = {
|
|
10
|
+
readonly filename: string_filename;
|
|
11
|
+
readonly mimeType: string;
|
|
12
|
+
readonly url: string_data_url;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates a data URL that represents the inline knowledge content as a text file.
|
|
16
|
+
*
|
|
17
|
+
* @private thing of inline knowledge
|
|
18
|
+
*/
|
|
19
|
+
export declare function createInlineKnowledgeSourceFile(content: string): InlineKnowledgeSourceFile;
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether the provided source string is a data URL that can be decoded.
|
|
22
|
+
*
|
|
23
|
+
* @private thing of inline knowledge
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDataUrlKnowledgeSource(source: string): source is string_data_url;
|
|
26
|
+
/**
|
|
27
|
+
* Parses a data URL-based knowledge source into its raw buffer, filename, and MIME type.
|
|
28
|
+
*
|
|
29
|
+
* @private thing of inline knowledge
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseDataUrlKnowledgeSource(source: string): {
|
|
32
|
+
readonly buffer: Buffer;
|
|
33
|
+
readonly filename: string_filename;
|
|
34
|
+
readonly mimeType: string;
|
|
35
|
+
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
38
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @@@
|
|
3
|
+
*
|
|
4
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
5
|
+
*/
|
|
6
|
+
type ResolveSpeechRecognitionLanguageOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Overrides the default language resolution when provided.
|
|
9
|
+
*/
|
|
10
|
+
readonly overrideLanguage?: string | null;
|
|
11
|
+
/**
|
|
12
|
+
* Optional Accept-Language header string to derive the speaker language from server-side requests.
|
|
13
|
+
*/
|
|
14
|
+
readonly acceptLanguageHeader?: string | null;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Parses the primary language out of an Accept-Language header value.
|
|
18
|
+
*
|
|
19
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseSpeechRecognitionLanguageFromAcceptLanguageHeader(header?: string | null): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Reads the browser-reported preferred language list and returns the first valid tag.
|
|
24
|
+
*
|
|
25
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
26
|
+
*/
|
|
27
|
+
export declare function getBrowserPreferredSpeechRecognitionLanguage(): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Resolves a speech recognition language tag by checking an optional override, then the Accept-Language header,
|
|
30
|
+
* then the browser preferences, and finally falling back to a default of `en-US`.
|
|
31
|
+
*
|
|
32
|
+
* @private function of Agents Server speech recognition language resolution, not a general-purpose utility
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveSpeechRecognitionLanguage(options?: ResolveSpeechRecognitionLanguageOptions): string;
|
|
35
|
+
export {};
|
|
@@ -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.110.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.110.0-11`).
|
|
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.110.0
|
|
3
|
+
"version": "0.110.0",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"module": "./esm/index.es.js",
|
|
98
98
|
"typings": "./esm/typings/src/_packages/javascript.index.d.ts",
|
|
99
99
|
"peerDependencies": {
|
|
100
|
-
"@promptbook/core": "0.110.0
|
|
100
|
+
"@promptbook/core": "0.110.0"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"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.110.0
|
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.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
|