@promptbook/types 0.112.0-39 → 0.112.0-41
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 +23 -21
- package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +8 -2
- package/esm/src/book-components/Chat/Chat/ChatInputArea.d.ts +0 -10
- package/esm/src/book-components/Chat/Chat/ChatInputUploadedFile.d.ts +10 -0
- package/esm/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +46 -0
- package/esm/src/book-components/Chat/Chat/resolveRunBrowserToolCallDetailsState.d.ts +146 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +39 -0
- package/esm/src/book-components/Chat/Chat/useChatPostprocessedMessages.d.ts +17 -0
- package/esm/src/book-components/Chat/Chat/useChatScrollState.d.ts +34 -0
- package/esm/src/book-components/Chat/Chat/useChatToolCallModalState.d.ts +61 -0
- package/esm/src/book-components/Chat/Chat/useChatToolCallState.d.ts +35 -0
- package/esm/src/book-components/Chat/LlmChat/useLlmChatMessageHandler.d.ts +58 -0
- package/esm/src/book-components/Chat/LlmChat/useLlmChatMessages.d.ts +29 -0
- package/esm/src/book-components/Chat/LlmChat/useLlmChatState.d.ts +53 -0
- package/esm/src/collection/pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts +7 -1
- package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +52 -0
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +128 -0
- package/esm/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +3 -3
- package/esm/src/llm-providers/openai/OpenAiVectorStoreHandler.d.ts +54 -0
- package/esm/src/llm-providers/openai/utils/OpenAiCompatibleUnsupportedParameterRetrier.d.ts +29 -0
- package/esm/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +28 -0
- package/esm/src/types/number_usd.d.ts +1 -1
- package/esm/src/types/string_parameter_name.d.ts +2 -2
- package/esm/src/types/typeAliases.d.ts +2 -2
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +8 -2
- package/umd/src/book-components/Chat/Chat/ChatInputArea.d.ts +0 -10
- package/umd/src/book-components/Chat/Chat/ChatInputUploadedFile.d.ts +10 -0
- package/umd/src/book-components/Chat/Chat/ChatToolCallModalContent.d.ts +46 -0
- package/umd/src/book-components/Chat/Chat/resolveRunBrowserToolCallDetailsState.d.ts +146 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +39 -0
- package/umd/src/book-components/Chat/Chat/useChatPostprocessedMessages.d.ts +17 -0
- package/umd/src/book-components/Chat/Chat/useChatScrollState.d.ts +34 -0
- package/umd/src/book-components/Chat/Chat/useChatToolCallModalState.d.ts +61 -0
- package/umd/src/book-components/Chat/Chat/useChatToolCallState.d.ts +35 -0
- package/umd/src/book-components/Chat/LlmChat/useLlmChatMessageHandler.d.ts +58 -0
- package/umd/src/book-components/Chat/LlmChat/useLlmChatMessages.d.ts +29 -0
- package/umd/src/book-components/Chat/LlmChat/useLlmChatState.d.ts +53 -0
- package/umd/src/collection/pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts +7 -1
- package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +52 -0
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +128 -0
- package/umd/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +3 -3
- package/umd/src/llm-providers/openai/OpenAiVectorStoreHandler.d.ts +54 -0
- package/umd/src/llm-providers/openai/utils/OpenAiCompatibleUnsupportedParameterRetrier.d.ts +29 -0
- package/umd/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +28 -0
- package/umd/src/types/number_usd.d.ts +1 -1
- package/umd/src/types/string_parameter_name.d.ts +2 -2
- package/umd/src/types/typeAliases.d.ts +2 -2
- package/umd/src/version.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ChangeEvent, type ClipboardEvent, type DragEvent } from 'react';
|
|
2
|
-
import type { ChatInputUploadedFile } from './
|
|
2
|
+
import type { ChatInputUploadedFile } from './ChatInputUploadedFile';
|
|
3
3
|
import type { ChatProps } from './ChatProps';
|
|
4
4
|
/**
|
|
5
5
|
* Props for `useChatInputAreaAttachments`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ChangeEvent, type KeyboardEvent as ReactKeyboardEvent, type MutableRefObject } from 'react';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
import type { ChatInputUploadedFile } from './ChatInputUploadedFile';
|
|
4
|
+
import type { ChatProps, ChatSoundSystem } from './ChatProps';
|
|
5
|
+
/**
|
|
6
|
+
* Props for `useChatInputAreaComposer`.
|
|
7
|
+
*
|
|
8
|
+
* @private function of `<ChatInputArea/>`
|
|
9
|
+
*/
|
|
10
|
+
type UseChatInputAreaComposerProps = {
|
|
11
|
+
readonly onMessage?: ChatProps['onMessage'];
|
|
12
|
+
readonly onChange?: ChatProps['onChange'];
|
|
13
|
+
readonly defaultMessage?: string;
|
|
14
|
+
readonly enterBehavior?: ChatProps['enterBehavior'];
|
|
15
|
+
readonly resolveEnterBehavior?: ChatProps['resolveEnterBehavior'];
|
|
16
|
+
readonly isFocusedOnLoad?: boolean;
|
|
17
|
+
readonly isMobile: boolean;
|
|
18
|
+
readonly uploadedFiles: ReadonlyArray<ChatInputUploadedFile>;
|
|
19
|
+
readonly uploadedFilesRef: MutableRefObject<Array<ChatInputUploadedFile>>;
|
|
20
|
+
readonly clearUploadedFiles: () => void;
|
|
21
|
+
readonly replyingToMessage?: ChatMessage | null;
|
|
22
|
+
readonly onCancelReply?: ChatProps['onCancelReply'];
|
|
23
|
+
readonly soundSystem?: ChatSoundSystem;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Manages textarea state, send/newline behavior, and deferred Enter resolution for `<ChatInputArea/>`.
|
|
27
|
+
*
|
|
28
|
+
* @private function of `<ChatInputArea/>`
|
|
29
|
+
*/
|
|
30
|
+
export declare function useChatInputAreaComposer(props: UseChatInputAreaComposerProps): {
|
|
31
|
+
textareaRef: import("react").RefObject<HTMLTextAreaElement | null>;
|
|
32
|
+
messageContent: string;
|
|
33
|
+
messageContentRef: import("react").RefObject<string>;
|
|
34
|
+
applyMessageContent: (nextContent: string) => void;
|
|
35
|
+
handleTextInputChange: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
36
|
+
handleComposerKeyDown: (event: ReactKeyboardEvent<HTMLTextAreaElement>) => void;
|
|
37
|
+
handleSend: () => Promise<void>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
2
|
+
/**
|
|
3
|
+
* Inputs required to normalize rendered chat messages.
|
|
4
|
+
*
|
|
5
|
+
* @private function of `useChatPostprocessedMessages`
|
|
6
|
+
*/
|
|
7
|
+
type UseChatPostprocessedMessagesProps = {
|
|
8
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
9
|
+
isAiTextHumanizedAndPromptbookified: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Memoizes the render-only message normalization used by `<Chat/>`.
|
|
13
|
+
*
|
|
14
|
+
* @private function of `<Chat/>`
|
|
15
|
+
*/
|
|
16
|
+
export declare function useChatPostprocessedMessages({ messages, isAiTextHumanizedAndPromptbookified, }: UseChatPostprocessedMessagesProps): ReadonlyArray<ChatMessage>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type MutableRefObject, type UIEvent } from 'react';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
/**
|
|
4
|
+
* Inputs required to coordinate Chat scroll behavior.
|
|
5
|
+
*
|
|
6
|
+
* @private function of `useChatScrollState`
|
|
7
|
+
*/
|
|
8
|
+
type UseChatScrollStateProps = {
|
|
9
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Public result consumed by `<Chat/>`.
|
|
13
|
+
*
|
|
14
|
+
* @private function of `useChatScrollState`
|
|
15
|
+
*/
|
|
16
|
+
type UseChatScrollStateResult = {
|
|
17
|
+
readonly actionsRef: MutableRefObject<HTMLDivElement | null>;
|
|
18
|
+
readonly ariaLabel: string;
|
|
19
|
+
readonly badgeLabel: string;
|
|
20
|
+
readonly handleChatScroll: (event: UIEvent<HTMLDivElement>) => void;
|
|
21
|
+
readonly isMobile: boolean;
|
|
22
|
+
readonly scrollToBottom: (behavior?: 'smooth' | 'auto') => void;
|
|
23
|
+
readonly setChatMessagesElement: (element: HTMLDivElement | null) => void;
|
|
24
|
+
readonly shouldDisableActions: boolean;
|
|
25
|
+
readonly shouldFadeActions: boolean;
|
|
26
|
+
readonly shouldShowScrollToBottom: boolean;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Coordinates auto-scroll, overlap tracking, and the scroll-to-bottom indicator for `<Chat/>`.
|
|
30
|
+
*
|
|
31
|
+
* @private function of `<Chat/>`
|
|
32
|
+
*/
|
|
33
|
+
export declare function useChatScrollState({ messages }: UseChatScrollStateProps): UseChatScrollStateResult;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type MutableRefObject } from 'react';
|
|
2
|
+
import type { AgentChipData } from '../AgentChip/AgentChip';
|
|
3
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
4
|
+
import { type TeamToolCallSummary, type TransitiveToolCall } from '../utils/collectTeamToolCallSummary';
|
|
5
|
+
import { type AgentProfileData } from '../utils/loadAgentProfile';
|
|
6
|
+
import { type TeamToolResult } from '../utils/toolCallParsing';
|
|
7
|
+
/**
|
|
8
|
+
* Tool-call snapshot rendered by the modal.
|
|
9
|
+
*
|
|
10
|
+
* @private function of `ChatToolCallModal`
|
|
11
|
+
*/
|
|
12
|
+
type ToolCallModalToolCall = NonNullable<ChatMessage['toolCalls']>[number];
|
|
13
|
+
/**
|
|
14
|
+
* Export target used by the advanced tool-call report controls.
|
|
15
|
+
*
|
|
16
|
+
* @private function of `ChatToolCallModal`
|
|
17
|
+
*/
|
|
18
|
+
type ToolCallReportDestination = 'clipboard' | 'file';
|
|
19
|
+
/**
|
|
20
|
+
* Inputs required to coordinate `<ChatToolCallModal/>` state.
|
|
21
|
+
*
|
|
22
|
+
* @private function of `useChatToolCallModalState`
|
|
23
|
+
*/
|
|
24
|
+
type UseChatToolCallModalStateProps = {
|
|
25
|
+
readonly isOpen: boolean;
|
|
26
|
+
readonly toolCall: ToolCallModalToolCall | null;
|
|
27
|
+
/**
|
|
28
|
+
* Stable identity of the selected tool call.
|
|
29
|
+
*/
|
|
30
|
+
readonly toolCallIdentity?: string | null;
|
|
31
|
+
readonly onClose: () => void;
|
|
32
|
+
readonly toolTitles?: Record<string, string>;
|
|
33
|
+
readonly teamAgentProfiles?: Record<string, AgentChipData>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* State and callbacks consumed by `<ChatToolCallModal/>`.
|
|
37
|
+
*
|
|
38
|
+
* @private function of `useChatToolCallModalState`
|
|
39
|
+
*/
|
|
40
|
+
type UseChatToolCallModalStateResult = {
|
|
41
|
+
readonly clearSelectedTeamToolCall: () => void;
|
|
42
|
+
readonly exportAdvancedToolCallReport: (destination: ToolCallReportDestination) => Promise<void>;
|
|
43
|
+
readonly focusedToolCall: ToolCallModalToolCall | null;
|
|
44
|
+
readonly isAdvancedView: boolean;
|
|
45
|
+
readonly modalDialogRef: MutableRefObject<HTMLDivElement | null>;
|
|
46
|
+
readonly openAdvancedView: () => void;
|
|
47
|
+
readonly selectTeamToolCall: (toolCall: TransitiveToolCall) => void;
|
|
48
|
+
readonly selectedTeamToolCall: TransitiveToolCall | null;
|
|
49
|
+
readonly teamProfiles: Record<string, AgentProfileData>;
|
|
50
|
+
readonly teamResult: TeamToolResult | null;
|
|
51
|
+
readonly teamToolCallSummary: TeamToolCallSummary;
|
|
52
|
+
readonly toggleViewMode: () => void;
|
|
53
|
+
readonly toolCallDate: Date | null;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Coordinates derived data, modal lifecycle, and advanced-export actions for `<ChatToolCallModal/>`.
|
|
57
|
+
*
|
|
58
|
+
* @private function of `ChatToolCallModal`
|
|
59
|
+
*/
|
|
60
|
+
export declare function useChatToolCallModalState({ isOpen, toolCall, toolCallIdentity, onClose, toolTitles, teamAgentProfiles, }: UseChatToolCallModalStateProps): UseChatToolCallModalStateResult;
|
|
61
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ToolCall } from '../../../types/ToolCall';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
import type { ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
4
|
+
/**
|
|
5
|
+
* Inputs required to keep Chat tool-call and citation modals in sync.
|
|
6
|
+
*
|
|
7
|
+
* @private function of `useChatToolCallState`
|
|
8
|
+
*/
|
|
9
|
+
type UseChatToolCallStateProps = {
|
|
10
|
+
messages: ReadonlyArray<ChatMessage>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* State and callbacks exposed back to `<Chat/>`.
|
|
14
|
+
*
|
|
15
|
+
* @private function of `useChatToolCallState`
|
|
16
|
+
*/
|
|
17
|
+
type UseChatToolCallStateResult = {
|
|
18
|
+
readonly citationModalOpen: boolean;
|
|
19
|
+
readonly closeCitationModal: () => void;
|
|
20
|
+
readonly closeToolCallModal: () => void;
|
|
21
|
+
readonly openCitation: (citation: ParsedCitation) => void;
|
|
22
|
+
readonly openToolCall: (toolCall: ToolCall) => void;
|
|
23
|
+
readonly selectedCitation: ParsedCitation | null;
|
|
24
|
+
readonly selectedMessageAvailableTools: ChatMessage['availableTools'];
|
|
25
|
+
readonly selectedToolCall: ToolCall | null;
|
|
26
|
+
readonly selectedToolCallIdentity: string | null;
|
|
27
|
+
readonly toolCallModalOpen: boolean;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Keeps Chat modal state focused on one selected tool call or citation.
|
|
31
|
+
*
|
|
32
|
+
* @private function of `<Chat/>`
|
|
33
|
+
*/
|
|
34
|
+
export declare function useChatToolCallState({ messages }: UseChatToolCallStateProps): UseChatToolCallStateResult;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Dispatch, type MutableRefObject, type SetStateAction } from 'react';
|
|
2
|
+
import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
|
|
3
|
+
import type { id } from '../../../types/typeAliases';
|
|
4
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
5
|
+
import type { LlmChatProps } from './LlmChatProps';
|
|
6
|
+
/**
|
|
7
|
+
* Minimal task-progress item rendered by `<Chat/>`.
|
|
8
|
+
*
|
|
9
|
+
* @private function of `useLlmChatMessageHandler`
|
|
10
|
+
*/
|
|
11
|
+
type LlmChatTaskProgress = {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly progress?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Internal send signature shared across retry and visibility-recovery flows.
|
|
18
|
+
*
|
|
19
|
+
* @private function of `useLlmChatMessageHandler`
|
|
20
|
+
*/
|
|
21
|
+
type HandleMessageFn = (messageContent: string, attachments?: ChatMessage['attachments']) => Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Inputs required by `useLlmChatMessageHandler`.
|
|
24
|
+
*
|
|
25
|
+
* @private function of `useLlmChatMessageHandler`
|
|
26
|
+
*/
|
|
27
|
+
type UseLlmChatMessageHandlerProps = {
|
|
28
|
+
readonly chatFailMessage: string;
|
|
29
|
+
readonly hasUserInteractedRef: MutableRefObject<boolean>;
|
|
30
|
+
readonly llmParticipantName: id;
|
|
31
|
+
readonly llmTools: LlmExecutionTools;
|
|
32
|
+
readonly messages: ReadonlyArray<ChatMessage>;
|
|
33
|
+
readonly onError?: LlmChatProps['onError'];
|
|
34
|
+
readonly promptParameters: Record<string, string>;
|
|
35
|
+
readonly setMessages: Dispatch<SetStateAction<Array<ChatMessage>>>;
|
|
36
|
+
readonly setTasksProgress: Dispatch<SetStateAction<Array<LlmChatTaskProgress>>>;
|
|
37
|
+
readonly thinkingVariants: ReadonlyArray<string>;
|
|
38
|
+
readonly thread?: ReadonlyArray<ChatMessage>;
|
|
39
|
+
readonly userParticipantName: id;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* State and handlers returned by `useLlmChatMessageHandler`.
|
|
43
|
+
*
|
|
44
|
+
* @private function of `useLlmChatMessageHandler`
|
|
45
|
+
*/
|
|
46
|
+
type UseLlmChatMessageHandlerResult = {
|
|
47
|
+
readonly clearLastFailedMessage: () => void;
|
|
48
|
+
readonly handleMessage: HandleMessageFn;
|
|
49
|
+
readonly handleStopStreaming: () => void;
|
|
50
|
+
readonly isStreaming: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Manages send, stream, retry, and background-recovery flows for `<LlmChat/>`.
|
|
54
|
+
*
|
|
55
|
+
* @private function of `useLlmChatState`
|
|
56
|
+
*/
|
|
57
|
+
export declare function useLlmChatMessageHandler(props: UseLlmChatMessageHandlerProps): UseLlmChatMessageHandlerResult;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Dispatch, type MutableRefObject, type SetStateAction } from 'react';
|
|
2
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
3
|
+
/**
|
|
4
|
+
* Inputs required to manage the persisted `<LlmChat/>` message list.
|
|
5
|
+
*
|
|
6
|
+
* @private function of `useLlmChatMessages`
|
|
7
|
+
*/
|
|
8
|
+
type UseLlmChatMessagesProps = {
|
|
9
|
+
readonly initialMessages?: ReadonlyArray<ChatMessage>;
|
|
10
|
+
readonly persistenceKey?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* State and helpers returned by `useLlmChatMessages`.
|
|
14
|
+
*
|
|
15
|
+
* @private function of `useLlmChatMessages`
|
|
16
|
+
*/
|
|
17
|
+
type UseLlmChatMessagesResult = {
|
|
18
|
+
readonly buildInitialMessages: () => Array<ChatMessage>;
|
|
19
|
+
readonly hasUserInteractedRef: MutableRefObject<boolean>;
|
|
20
|
+
readonly messages: Array<ChatMessage>;
|
|
21
|
+
readonly setMessages: Dispatch<SetStateAction<Array<ChatMessage>>>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Manages initial seeding plus optional local persistence for `<LlmChat/>`.
|
|
25
|
+
*
|
|
26
|
+
* @private function of `useLlmChatState`
|
|
27
|
+
*/
|
|
28
|
+
export declare function useLlmChatMessages(props: UseLlmChatMessagesProps): UseLlmChatMessagesResult;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
2
|
+
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
3
|
+
import type { LlmChatProps } from './LlmChatProps';
|
|
4
|
+
/**
|
|
5
|
+
* Metadata for a teammate agent tool.
|
|
6
|
+
*
|
|
7
|
+
* @private function of `useLlmChatState`
|
|
8
|
+
*/
|
|
9
|
+
type TeammateMetadata = {
|
|
10
|
+
readonly url: string;
|
|
11
|
+
readonly label?: string;
|
|
12
|
+
readonly instructions?: string;
|
|
13
|
+
readonly toolName: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Lookup map of teammate metadata by tool name.
|
|
17
|
+
*
|
|
18
|
+
* @private function of `useLlmChatState`
|
|
19
|
+
*/
|
|
20
|
+
type TeammatesMap = Record<string, TeammateMetadata>;
|
|
21
|
+
/**
|
|
22
|
+
* Minimal task-progress item rendered by `<Chat/>`.
|
|
23
|
+
*
|
|
24
|
+
* @private function of `useLlmChatState`
|
|
25
|
+
*/
|
|
26
|
+
type LlmChatTaskProgress = {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly progress?: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* State returned by `useLlmChatState`.
|
|
33
|
+
*
|
|
34
|
+
* @private function of `useLlmChatState`
|
|
35
|
+
*/
|
|
36
|
+
type UseLlmChatStateResult = {
|
|
37
|
+
readonly handleMessage: (messageContent: string, attachments?: ChatMessage['attachments']) => Promise<void>;
|
|
38
|
+
readonly handleReset: () => Promise<void>;
|
|
39
|
+
readonly handleStopStreaming: () => void;
|
|
40
|
+
readonly isStreaming: boolean;
|
|
41
|
+
readonly isVoiceCalling: boolean;
|
|
42
|
+
readonly messages: Array<ChatMessage>;
|
|
43
|
+
readonly participants: ReadonlyArray<ChatParticipant>;
|
|
44
|
+
readonly tasksProgress: Array<LlmChatTaskProgress>;
|
|
45
|
+
readonly teammates: TeammatesMap | undefined;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Coordinates derived state and handlers consumed by `<LlmChat/>`.
|
|
49
|
+
*
|
|
50
|
+
* @private function of `<LlmChat/>`
|
|
51
|
+
*/
|
|
52
|
+
export declare function useLlmChatState(props: LlmChatProps): UseLlmChatStateResult;
|
|
53
|
+
export {};
|
|
@@ -43,6 +43,12 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
43
43
|
*/
|
|
44
44
|
isCrashedOnError?: boolean;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Tools used by `createPipelineCollectionFromDirectory`.
|
|
48
|
+
*
|
|
49
|
+
* @private internal function of `createPipelineCollectionFromDirectory`
|
|
50
|
+
*/
|
|
51
|
+
type CreatePipelineCollectionFromDirectoryTools = Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>;
|
|
46
52
|
/**
|
|
47
53
|
* Constructs `PipelineCollection` from given directory
|
|
48
54
|
*
|
|
@@ -55,5 +61,5 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
55
61
|
*
|
|
56
62
|
* @public exported from `@promptbook/node`
|
|
57
63
|
*/
|
|
58
|
-
export declare function createPipelineCollectionFromDirectory(rootPath: string_dirname, tools?:
|
|
64
|
+
export declare function createPipelineCollectionFromDirectory(rootPath: string_dirname, tools?: CreatePipelineCollectionFromDirectoryTools, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
|
|
59
65
|
export {};
|
|
@@ -84,4 +84,56 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
|
|
|
84
84
|
* Calls the chat model with agent-specific system prompt and requirements with streaming
|
|
85
85
|
*/
|
|
86
86
|
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void, options?: CallChatModelStreamOptions): Promise<ChatPromptResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Ensures the agent wrapper only processes chat prompts.
|
|
89
|
+
*/
|
|
90
|
+
private requireChatPrompt;
|
|
91
|
+
/**
|
|
92
|
+
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
93
|
+
*/
|
|
94
|
+
private prepareChatPrompt;
|
|
95
|
+
/**
|
|
96
|
+
* Removes bookkeeping-only properties from compiled agent requirements before forwarding them.
|
|
97
|
+
*/
|
|
98
|
+
private getSanitizedAgentModelRequirements;
|
|
99
|
+
/**
|
|
100
|
+
* Dispatches one prepared agent prompt to the correct underlying LLM backend.
|
|
101
|
+
*/
|
|
102
|
+
private callPreparedChatModelStream;
|
|
103
|
+
/**
|
|
104
|
+
* Runs one prepared prompt through the OpenAI AgentKit backend.
|
|
105
|
+
*/
|
|
106
|
+
private callOpenAiAgentKitChatModelStream;
|
|
107
|
+
/**
|
|
108
|
+
* Resolves the AgentKit cache state for the current prompt, including external and in-memory caches.
|
|
109
|
+
*/
|
|
110
|
+
private resolveAgentKitCacheState;
|
|
111
|
+
/**
|
|
112
|
+
* Returns a prepared AgentKit agent, creating one only when the cache could not satisfy the request.
|
|
113
|
+
*/
|
|
114
|
+
private getOrPrepareAgentKitAgent;
|
|
115
|
+
/**
|
|
116
|
+
* Stores freshly prepared AgentKit resources back into the in-memory caches when caching is allowed.
|
|
117
|
+
*/
|
|
118
|
+
private storeAgentKitCache;
|
|
119
|
+
/**
|
|
120
|
+
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
121
|
+
*/
|
|
122
|
+
private callOpenAiAssistantChatModelStream;
|
|
123
|
+
/**
|
|
124
|
+
* Returns an assistant instance matching the current agent requirements, reusing caches when possible.
|
|
125
|
+
*/
|
|
126
|
+
private getOrPrepareOpenAiAssistant;
|
|
127
|
+
/**
|
|
128
|
+
* Stores one assistant id in the shared assistant cache for this agent title.
|
|
129
|
+
*/
|
|
130
|
+
private storeAssistantCache;
|
|
131
|
+
/**
|
|
132
|
+
* Runs one prepared prompt through generic LLM tools that do not need special assistant preparation.
|
|
133
|
+
*/
|
|
134
|
+
private callGenericChatModelStream;
|
|
135
|
+
/**
|
|
136
|
+
* Applies the final agent-level content normalization to the underlying LLM result.
|
|
137
|
+
*/
|
|
138
|
+
private finalizeAgentResult;
|
|
87
139
|
}
|
|
@@ -40,6 +40,134 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiVectorStoreHand
|
|
|
40
40
|
* Calls OpenAI API to use a chat model with streaming.
|
|
41
41
|
*/
|
|
42
42
|
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void, options?: CallChatModelStreamOptions): Promise<ChatPromptResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Logs one assistant chat call when verbose output is enabled.
|
|
45
|
+
*/
|
|
46
|
+
private logAssistantChatCall;
|
|
47
|
+
/**
|
|
48
|
+
* Validates the subset of model requirements supported by OpenAI Assistants.
|
|
49
|
+
*/
|
|
50
|
+
private assertSupportedAssistantModelRequirements;
|
|
51
|
+
/**
|
|
52
|
+
* Returns true when the prompt exposes callable tools that require the Runs API flow.
|
|
53
|
+
*/
|
|
54
|
+
private hasAssistantTools;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves the raw user-visible prompt content sent to the assistant.
|
|
57
|
+
*/
|
|
58
|
+
private createAssistantRawPromptContent;
|
|
59
|
+
/**
|
|
60
|
+
* Builds the thread history plus the current user message for one assistant call.
|
|
61
|
+
*/
|
|
62
|
+
private createAssistantThreadMessages;
|
|
63
|
+
/**
|
|
64
|
+
* Converts the existing prompt thread into OpenAI assistant thread messages.
|
|
65
|
+
*/
|
|
66
|
+
private createAssistantThreadHistoryMessages;
|
|
67
|
+
/**
|
|
68
|
+
* Creates the current user message, including uploaded file attachments when present.
|
|
69
|
+
*/
|
|
70
|
+
private createAssistantCurrentUserMessage;
|
|
71
|
+
/**
|
|
72
|
+
* Runs assistant calls with tools through the non-streaming Runs API.
|
|
73
|
+
*/
|
|
74
|
+
private callChatModelStreamWithTools;
|
|
75
|
+
/**
|
|
76
|
+
* Builds the non-streaming assistant request payload used when tool calls are enabled.
|
|
77
|
+
*/
|
|
78
|
+
private createAssistantToolRunRequest;
|
|
79
|
+
/**
|
|
80
|
+
* Starts the assistant run and keeps polling until the run completes or fails.
|
|
81
|
+
*/
|
|
82
|
+
private executeAssistantToolRun;
|
|
83
|
+
/**
|
|
84
|
+
* Polls one assistant run, executing and submitting tool outputs when OpenAI requests them.
|
|
85
|
+
*/
|
|
86
|
+
private waitForAssistantToolRun;
|
|
87
|
+
/**
|
|
88
|
+
* Executes all required assistant tool calls and submits their outputs back to OpenAI.
|
|
89
|
+
*/
|
|
90
|
+
private submitAssistantRequiredToolOutputs;
|
|
91
|
+
/**
|
|
92
|
+
* Waits a bit and then fetches the latest assistant run status.
|
|
93
|
+
*/
|
|
94
|
+
private retrieveAssistantRunAfterDelay;
|
|
95
|
+
/**
|
|
96
|
+
* Executes each function tool requested by the assistant and records progress snapshots.
|
|
97
|
+
*/
|
|
98
|
+
private executeAssistantRequiredToolCalls;
|
|
99
|
+
/**
|
|
100
|
+
* Executes one function tool requested by the assistant.
|
|
101
|
+
*/
|
|
102
|
+
private executeAssistantRequiredToolCall;
|
|
103
|
+
/**
|
|
104
|
+
* Creates the initial pending snapshot for one assistant tool call.
|
|
105
|
+
*/
|
|
106
|
+
private createPendingAssistantToolCall;
|
|
107
|
+
/**
|
|
108
|
+
* Resolves the configured script tools for assistant tool execution.
|
|
109
|
+
*/
|
|
110
|
+
private resolveAssistantScriptTools;
|
|
111
|
+
/**
|
|
112
|
+
* Executes the configured script tool for one assistant-requested function call.
|
|
113
|
+
*/
|
|
114
|
+
private executeAssistantFunctionTool;
|
|
115
|
+
/**
|
|
116
|
+
* Finalizes one assistant tool-call snapshot after execution ends.
|
|
117
|
+
*/
|
|
118
|
+
private createCompletedAssistantToolCall;
|
|
119
|
+
/**
|
|
120
|
+
* Extracts the latest assistant text response from a completed thread.
|
|
121
|
+
*/
|
|
122
|
+
private extractCompletedAssistantTextContent;
|
|
123
|
+
/**
|
|
124
|
+
* Runs assistant calls without tools through the streaming Assistants API.
|
|
125
|
+
*/
|
|
126
|
+
private callChatModelStreamWithoutTools;
|
|
127
|
+
/**
|
|
128
|
+
* Builds the streaming assistant request payload used when no tool execution flow is needed.
|
|
129
|
+
*/
|
|
130
|
+
private createAssistantStreamingRequest;
|
|
131
|
+
/**
|
|
132
|
+
* Registers verbose stream diagnostics plus incremental text progress forwarding.
|
|
133
|
+
*/
|
|
134
|
+
private attachAssistantStreamListeners;
|
|
135
|
+
/**
|
|
136
|
+
* Resolves the final visible assistant text from a streaming response.
|
|
137
|
+
*/
|
|
138
|
+
private resolveAssistantStreamingResultContent;
|
|
139
|
+
/**
|
|
140
|
+
* Extracts the single text content block returned by the assistant stream.
|
|
141
|
+
*/
|
|
142
|
+
private extractSingleAssistantTextContentBlock;
|
|
143
|
+
/**
|
|
144
|
+
* Rewrites file citation markers to use retrieved filenames instead of generic source labels.
|
|
145
|
+
*/
|
|
146
|
+
private replaceAssistantFileCitationMarkers;
|
|
147
|
+
/**
|
|
148
|
+
* Returns one citation filename, caching OpenAI file lookups across annotations.
|
|
149
|
+
*/
|
|
150
|
+
private retrieveAssistantCitationFilename;
|
|
151
|
+
/**
|
|
152
|
+
* Emits one assistant progress chunk with shared timing and prompt metadata.
|
|
153
|
+
*/
|
|
154
|
+
private emitAssistantProgress;
|
|
155
|
+
/**
|
|
156
|
+
* Creates the final assistant prompt result with uncertain usage plus measured duration.
|
|
157
|
+
*/
|
|
158
|
+
private createAssistantPromptResult;
|
|
159
|
+
/**
|
|
160
|
+
* Computes the usage payload for assistant responses.
|
|
161
|
+
*/
|
|
162
|
+
private createAssistantUsage;
|
|
163
|
+
/**
|
|
164
|
+
* Wraps the final assistant prompt result in the standard exported JSON envelope.
|
|
165
|
+
*/
|
|
166
|
+
private exportAssistantPromptResult;
|
|
167
|
+
/**
|
|
168
|
+
* Logs one assistant request payload when verbose output is enabled.
|
|
169
|
+
*/
|
|
170
|
+
private logVerboseAssistantRequest;
|
|
43
171
|
/**
|
|
44
172
|
* Get an existing assistant tool wrapper
|
|
45
173
|
*/
|
|
@@ -49,11 +49,11 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
49
49
|
/**
|
|
50
50
|
* Calls OpenAI compatible API to use a chat model with streaming.
|
|
51
51
|
*/
|
|
52
|
-
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void,
|
|
52
|
+
callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void, _options?: CallChatModelStreamOptions): Promise<ChatPromptResult>;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Executes one OpenAI request under the shared rate limiter and network retry policy.
|
|
55
55
|
*/
|
|
56
|
-
private
|
|
56
|
+
private executeRateLimitedRequest;
|
|
57
57
|
/**
|
|
58
58
|
* Calls OpenAI API to use a complete model.
|
|
59
59
|
*/
|
|
@@ -6,6 +6,8 @@ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleEx
|
|
|
6
6
|
import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
7
7
|
/**
|
|
8
8
|
* Metadata for uploaded knowledge source files used for vector store diagnostics.
|
|
9
|
+
*
|
|
10
|
+
* @private internal utility of `OpenAiVectorStoreHandler`
|
|
9
11
|
*/
|
|
10
12
|
type KnowledgeSourceUploadMetadata = {
|
|
11
13
|
readonly fileId: string;
|
|
@@ -117,6 +119,58 @@ export declare abstract class OpenAiVectorStoreHandler extends OpenAiExecutionTo
|
|
|
117
119
|
readonly totalBytes: number;
|
|
118
120
|
readonly logLabel: string;
|
|
119
121
|
}): Promise<TODO_any | null>;
|
|
122
|
+
/**
|
|
123
|
+
* Uploads the prepared knowledge-source files with bounded concurrency.
|
|
124
|
+
*/
|
|
125
|
+
private uploadPreparedKnowledgeSourceFiles;
|
|
126
|
+
/**
|
|
127
|
+
* Reuses the shared iterator to upload one slice of knowledge-source files.
|
|
128
|
+
*/
|
|
129
|
+
private uploadPreparedKnowledgeSourceFilesWorker;
|
|
130
|
+
/**
|
|
131
|
+
* Uploads one prepared knowledge-source file to OpenAI and records detailed diagnostics.
|
|
132
|
+
*/
|
|
133
|
+
private uploadPreparedKnowledgeSourceFile;
|
|
134
|
+
/**
|
|
135
|
+
* Creates the OpenAI vector-store file batch for the uploaded knowledge-source files.
|
|
136
|
+
*/
|
|
137
|
+
private createVectorStoreFileBatch;
|
|
138
|
+
/**
|
|
139
|
+
* Logs warnings for unexpected vector-store batch metadata right after creation.
|
|
140
|
+
*/
|
|
141
|
+
private logCreatedVectorStoreFileBatchIssues;
|
|
142
|
+
/**
|
|
143
|
+
* Polls the created vector-store batch until ingestion completes, fails, or times out.
|
|
144
|
+
*/
|
|
145
|
+
private pollVectorStoreFileBatchUntilSettled;
|
|
146
|
+
/**
|
|
147
|
+
* Resolves the next batch id to poll and retrieves the freshest OpenAI batch snapshot.
|
|
148
|
+
*/
|
|
149
|
+
private retrieveVectorStoreFileBatchForPolling;
|
|
150
|
+
/**
|
|
151
|
+
* Normalizes the batch identifier returned by OpenAI and logs unusual id situations once.
|
|
152
|
+
*/
|
|
153
|
+
private resolveVectorStoreFileBatchId;
|
|
154
|
+
/**
|
|
155
|
+
* Tracks observed polling progress and emits throttled verbose status logs.
|
|
156
|
+
*/
|
|
157
|
+
private trackVectorStoreFileBatchProgress;
|
|
158
|
+
/**
|
|
159
|
+
* Emits deeper diagnostics when vector-store ingestion appears stalled for too long.
|
|
160
|
+
*/
|
|
161
|
+
private maybeLogStalledVectorStoreFileBatch;
|
|
162
|
+
/**
|
|
163
|
+
* Handles terminal vector-store batch states that do not require further polling.
|
|
164
|
+
*/
|
|
165
|
+
private handleVectorStoreFileBatchTerminalState;
|
|
166
|
+
/**
|
|
167
|
+
* Stops polling once the batch exceeds the configured timeout and handles optional cancellation.
|
|
168
|
+
*/
|
|
169
|
+
private handleVectorStoreFileBatchTimeout;
|
|
170
|
+
/**
|
|
171
|
+
* Attempts to cancel a timed-out vector-store batch and logs any unusual id situation.
|
|
172
|
+
*/
|
|
173
|
+
private cancelVectorStoreFileBatchAfterTimeout;
|
|
120
174
|
/**
|
|
121
175
|
* Creates a vector store and uploads knowledge sources, returning its ID.
|
|
122
176
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ModelRequirements } from '../../../types/ModelRequirements';
|
|
2
|
+
import type { string_model_name } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Tracks unsupported-parameter retries for one OpenAI-compatible model call.
|
|
5
|
+
*
|
|
6
|
+
* @private helper of `OpenAiCompatibleExecutionTools`
|
|
7
|
+
*/
|
|
8
|
+
export declare class OpenAiCompatibleUnsupportedParameterRetrier {
|
|
9
|
+
private readonly isVerbose;
|
|
10
|
+
private readonly attemptStack;
|
|
11
|
+
private readonly retriedUnsupportedParameters;
|
|
12
|
+
constructor(isVerbose: boolean | undefined);
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the next retry attempt after an unsupported-parameter failure or rethrows the final error.
|
|
15
|
+
*/
|
|
16
|
+
resolveRetryOrThrow<TModelRequirements extends ModelRequirements>(options: {
|
|
17
|
+
readonly error: Error;
|
|
18
|
+
readonly modelName: string_model_name;
|
|
19
|
+
readonly currentModelRequirements: TModelRequirements;
|
|
20
|
+
}): TModelRequirements;
|
|
21
|
+
/**
|
|
22
|
+
* Rethrows the original error or wraps it with the collected retry history.
|
|
23
|
+
*/
|
|
24
|
+
private throwWithAttemptHistory;
|
|
25
|
+
/**
|
|
26
|
+
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
27
|
+
*/
|
|
28
|
+
private createAttemptHistoryError;
|
|
29
|
+
}
|