@promptbook/remote-server 0.110.0-9 → 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 +56 -11
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -2
- package/esm/typings/src/_packages/types.index.d.ts +6 -0
- 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/ChatProps.d.ts +11 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +12 -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/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +56 -11
- package/umd/index.umd.js.map +1 -1
|
@@ -15,10 +15,12 @@ import { BookEditor } from '../book-components/BookEditor/BookEditor';
|
|
|
15
15
|
import { AgentChat } from '../book-components/Chat/AgentChat/AgentChat';
|
|
16
16
|
import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
|
|
17
17
|
import { Chat } from '../book-components/Chat/Chat/Chat';
|
|
18
|
+
import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
|
|
18
19
|
import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
|
|
19
20
|
import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
|
|
20
21
|
import { ChatSoundToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
21
22
|
import { ChatVibrationToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
23
|
+
import { ChatSoundAndVibrationPanel } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
22
24
|
import { ChatEffectsSystem } from '../book-components/Chat/effects/ChatEffectsSystem';
|
|
23
25
|
import { ConfettiEffect } from '../book-components/Chat/effects/components/ConfettiEffect';
|
|
24
26
|
import { HeartsEffect } from '../book-components/Chat/effects/components/HeartsEffect';
|
|
@@ -86,10 +88,12 @@ export { BookEditor };
|
|
|
86
88
|
export { AgentChat };
|
|
87
89
|
export type { AgentChatProps };
|
|
88
90
|
export { Chat };
|
|
91
|
+
export type { ChatFeedbackResponse };
|
|
89
92
|
export type { ChatSoundSystem };
|
|
90
93
|
export type { ChatProps };
|
|
91
94
|
export { ChatSoundToggle };
|
|
92
95
|
export { ChatVibrationToggle };
|
|
96
|
+
export { ChatSoundAndVibrationPanel };
|
|
93
97
|
export { ChatEffectsSystem };
|
|
94
98
|
export { ConfettiEffect };
|
|
95
99
|
export { HeartsEffect };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
2
|
import { computeAgentHash } from '../book-2.0/agent-source/computeAgentHash';
|
|
3
3
|
import { createAgentModelRequirements } from '../book-2.0/agent-source/createAgentModelRequirements';
|
|
4
|
-
import {
|
|
4
|
+
import type { CreateAgentModelRequirementsOptions } from '../book-2.0/agent-source/CreateAgentModelRequirementsOptions';
|
|
5
5
|
import { createDefaultAgentName } from '../book-2.0/agent-source/createDefaultAgentName';
|
|
6
6
|
import { normalizeAgentName } from '../book-2.0/agent-source/normalizeAgentName';
|
|
7
7
|
import { PADDING_LINES } from '../book-2.0/agent-source/padBook';
|
|
@@ -205,7 +205,7 @@ import { PUBLIC_AGENTS_SERVERS } from '../../servers';
|
|
|
205
205
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
206
206
|
export { computeAgentHash };
|
|
207
207
|
export { createAgentModelRequirements };
|
|
208
|
-
export {
|
|
208
|
+
export type { CreateAgentModelRequirementsOptions };
|
|
209
209
|
export { createDefaultAgentName };
|
|
210
210
|
export { normalizeAgentName };
|
|
211
211
|
export { PADDING_LINES };
|
|
@@ -2,6 +2,7 @@ import type { BookParameter } from '../book-2.0/agent-source/AgentBasicInformati
|
|
|
2
2
|
import type { AgentCapability } from '../book-2.0/agent-source/AgentBasicInformation';
|
|
3
3
|
import type { AgentBasicInformation } from '../book-2.0/agent-source/AgentBasicInformation';
|
|
4
4
|
import type { AgentModelRequirements } from '../book-2.0/agent-source/AgentModelRequirements';
|
|
5
|
+
import type { CreateAgentModelRequirementsOptions } from '../book-2.0/agent-source/CreateAgentModelRequirementsOptions';
|
|
5
6
|
import type { string_book } from '../book-2.0/agent-source/string_book';
|
|
6
7
|
import type { AvatarChipProps } from '../book-components/AvatarProfile/AvatarChip/AvatarChip';
|
|
7
8
|
import type { AvatarChipFromSourceProps } from '../book-components/AvatarProfile/AvatarChip/AvatarChipFromSource';
|
|
@@ -13,10 +14,12 @@ import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
|
13
14
|
import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
|
|
14
15
|
import type { AgentChipData } from '../book-components/Chat/AgentChip/AgentChip';
|
|
15
16
|
import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip';
|
|
17
|
+
import type { ChatFeedbackResponse } from '../book-components/Chat/Chat/ChatProps';
|
|
16
18
|
import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
|
|
17
19
|
import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
|
|
18
20
|
import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
19
21
|
import type { ChatVibrationToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
22
|
+
import type { ChatSoundAndVibrationPanelProps } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
20
23
|
import type { ChatEffect } from '../book-components/Chat/effects/types/ChatEffect';
|
|
21
24
|
import type { ChatEffectConfig } from '../book-components/Chat/effects/types/ChatEffectConfig';
|
|
22
25
|
import type { ChatEffectsSystemProps } from '../book-components/Chat/effects/types/ChatEffectsSystemProps';
|
|
@@ -407,6 +410,7 @@ export type { BookParameter };
|
|
|
407
410
|
export type { AgentCapability };
|
|
408
411
|
export type { AgentBasicInformation };
|
|
409
412
|
export type { AgentModelRequirements };
|
|
413
|
+
export type { CreateAgentModelRequirementsOptions };
|
|
410
414
|
export type { string_book };
|
|
411
415
|
export type { AvatarChipProps };
|
|
412
416
|
export type { AvatarChipFromSourceProps };
|
|
@@ -418,10 +422,12 @@ export type { BookEditorProps };
|
|
|
418
422
|
export type { AgentChatProps };
|
|
419
423
|
export type { AgentChipData };
|
|
420
424
|
export type { AgentChipProps };
|
|
425
|
+
export type { ChatFeedbackResponse };
|
|
421
426
|
export type { ChatSoundSystem };
|
|
422
427
|
export type { ChatProps };
|
|
423
428
|
export type { ChatSoundToggleProps };
|
|
424
429
|
export type { ChatVibrationToggleProps };
|
|
430
|
+
export type { ChatSoundAndVibrationPanelProps };
|
|
425
431
|
export type { ChatEffect };
|
|
426
432
|
export type { ChatEffectConfig };
|
|
427
433
|
export type { ChatEffectsSystemProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BookCommitment } from '../../commitments/_base/BookCommitment';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves compact agent references that appear inside FROM, IMPORT, and TEAM commitments.
|
|
4
|
+
*
|
|
5
|
+
* Implementations are expected to rewrite reference tokens such as `{Activation code agent}`
|
|
6
|
+
* or `@Superagent` into concrete agent URLs before the commitment is applied.
|
|
7
|
+
*
|
|
8
|
+
* @private @@@
|
|
9
|
+
*/
|
|
10
|
+
export type AgentReferenceResolver = {
|
|
11
|
+
/**
|
|
12
|
+
* Normalizes the content of a commitment before it is applied to the model requirements.
|
|
13
|
+
*
|
|
14
|
+
* @param commitmentType - The commitment keyword (e.g. FROM, IMPORT, TEAM)
|
|
15
|
+
* @param content - Original payload of the commitment
|
|
16
|
+
*/
|
|
17
|
+
resolveCommitmentContent(commitmentType: BookCommitment, content: string): Promise<string>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentReferenceResolver } from './AgentReferenceResolver';
|
|
2
|
+
/**
|
|
3
|
+
* Options for `createAgentModelRequirements` and `createAgentModelRequirementsWithCommitments`.
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/core`
|
|
6
|
+
*/
|
|
7
|
+
export type CreateAgentModelRequirementsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Resolver that transforms compact agent references (FROM, IMPORT, TEAM) into concrete URLs.
|
|
10
|
+
*/
|
|
11
|
+
readonly agentReferenceResolver?: AgentReferenceResolver;
|
|
12
|
+
};
|
|
@@ -2,17 +2,23 @@ import type { AvailableModel } from '../../execution/AvailableModel';
|
|
|
2
2
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
3
|
import type { string_agent_name, string_model_name, string_system_message, string_url_image } from '../../types/typeAliases';
|
|
4
4
|
import type { AgentModelRequirements } from './AgentModelRequirements';
|
|
5
|
+
import type { CreateAgentModelRequirementsOptions } from './CreateAgentModelRequirementsOptions';
|
|
5
6
|
import type { string_book } from './string_book';
|
|
6
7
|
/**
|
|
7
|
-
* Creates model requirements for an agent based on its source
|
|
8
|
+
* Creates model requirements for an agent based on its source.
|
|
8
9
|
*
|
|
9
10
|
* There are 2 similar functions:
|
|
10
11
|
* - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
|
|
11
12
|
* - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
|
|
12
13
|
*
|
|
14
|
+
* @param agentSource - Book describing the agent.
|
|
15
|
+
* @param modelName - Optional override for the agent's model.
|
|
16
|
+
* @param availableModels - Models that could fulfill the agent.
|
|
17
|
+
* @param llmTools - Execution tools used when selecting a best model.
|
|
18
|
+
* @param options - Optional hooks such as the agent reference resolver.
|
|
13
19
|
* @public exported from `@promptbook/core`
|
|
14
20
|
*/
|
|
15
|
-
export declare function createAgentModelRequirements(agentSource: string_book, modelName?: string_model_name, availableModels?: readonly AvailableModel[], llmTools?: LlmExecutionTools): Promise<AgentModelRequirements>;
|
|
21
|
+
export declare function createAgentModelRequirements(agentSource: string_book, modelName?: string_model_name, availableModels?: readonly AvailableModel[], llmTools?: LlmExecutionTools, options?: CreateAgentModelRequirementsOptions): Promise<AgentModelRequirements>;
|
|
16
22
|
/**
|
|
17
23
|
* Extracts MCP servers from agent source
|
|
18
24
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { string_model_name } from '../../types/typeAliases';
|
|
2
2
|
import type { AgentModelRequirements } from './AgentModelRequirements';
|
|
3
|
+
import type { CreateAgentModelRequirementsOptions } from './CreateAgentModelRequirementsOptions';
|
|
3
4
|
import type { string_book } from './string_book';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
* This function uses a reduce-like pattern where each commitment applies its changes
|
|
7
|
-
* to build the final requirements starting from a basic empty model
|
|
6
|
+
* @@@
|
|
8
7
|
*
|
|
9
|
-
* @
|
|
8
|
+
* @private @@@
|
|
10
9
|
*/
|
|
11
|
-
export declare function createAgentModelRequirementsWithCommitments(agentSource: string_book, modelName?: string_model_name): Promise<AgentModelRequirements>;
|
|
10
|
+
export declare function createAgentModelRequirementsWithCommitments(agentSource: string_book, modelName?: string_model_name, options?: CreateAgentModelRequirementsOptions): Promise<AgentModelRequirements>;
|
|
@@ -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.
|
|
@@ -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
|
|
@@ -40,3 +40,15 @@ export type ChatVibrationToggleProps = {
|
|
|
40
40
|
* @public exported from `@promptbook/components`
|
|
41
41
|
*/
|
|
42
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;
|
|
@@ -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 {};
|
|
@@ -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/remote-server",
|
|
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,
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"module": "./esm/index.es.js",
|
|
99
99
|
"typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@promptbook/core": "0.110.0
|
|
101
|
+
"@promptbook/core": "0.110.0"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
104
|
"@mozilla/readability": "0.6.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* @generated
|
|
51
51
|
* @see https://github.com/webgptorg/promptbook
|
|
52
52
|
*/
|
|
53
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0
|
|
53
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0';
|
|
54
54
|
/**
|
|
55
55
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
56
56
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -14056,7 +14056,8 @@
|
|
|
14056
14056
|
if (!trimmedContent) {
|
|
14057
14057
|
return requirements;
|
|
14058
14058
|
}
|
|
14059
|
-
|
|
14059
|
+
// Keep TEAM resilient: unresolved/malformed teammate entries are skipped, valid ones are still registered.
|
|
14060
|
+
const teammates = parseTeamCommitmentContent(trimmedContent, { strict: false });
|
|
14060
14061
|
if (teammates.length === 0) {
|
|
14061
14062
|
return requirements;
|
|
14062
14063
|
}
|
|
@@ -18403,14 +18404,42 @@
|
|
|
18403
18404
|
}
|
|
18404
18405
|
|
|
18405
18406
|
/**
|
|
18406
|
-
* Creates agent model requirements using the new commitment system
|
|
18407
|
+
* Creates agent model requirements using the new commitment system.
|
|
18408
|
+
*
|
|
18407
18409
|
* This function uses a reduce-like pattern where each commitment applies its changes
|
|
18408
|
-
* to build the final requirements starting from a basic empty model
|
|
18410
|
+
* to build the final requirements starting from a basic empty model.
|
|
18409
18411
|
*
|
|
18410
|
-
* @
|
|
18412
|
+
* @param agentSource - Agent source book to parse.
|
|
18413
|
+
* @param modelName - Optional override for the agent model name.
|
|
18414
|
+
* @param options - Additional options such as the agent reference resolver.
|
|
18415
|
+
*
|
|
18416
|
+
* @private @@@
|
|
18417
|
+
*/
|
|
18418
|
+
const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS', 'TEAM']);
|
|
18419
|
+
/**
|
|
18420
|
+
* Returns a safe fallback content when a resolver fails to transform a reference commitment.
|
|
18421
|
+
*
|
|
18422
|
+
* @param commitmentType - Commitment being resolved.
|
|
18423
|
+
* @param originalContent - Original unresolved commitment content.
|
|
18424
|
+
* @returns Fallback content that keeps requirement creation resilient.
|
|
18411
18425
|
*/
|
|
18412
|
-
|
|
18426
|
+
function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
18427
|
+
if (commitmentType === 'FROM') {
|
|
18428
|
+
return 'VOID';
|
|
18429
|
+
}
|
|
18430
|
+
if (commitmentType === 'IMPORT' || commitmentType === 'IMPORTS' || commitmentType === 'TEAM') {
|
|
18431
|
+
return '';
|
|
18432
|
+
}
|
|
18433
|
+
return originalContent;
|
|
18434
|
+
}
|
|
18435
|
+
/**
|
|
18436
|
+
* @@@
|
|
18437
|
+
*
|
|
18438
|
+
* @private @@@
|
|
18439
|
+
*/
|
|
18440
|
+
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
18413
18441
|
var _a;
|
|
18442
|
+
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
18414
18443
|
// Parse the agent source to extract commitments
|
|
18415
18444
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
18416
18445
|
// Apply DELETE filtering: remove prior commitments tagged by parameters targeted by DELETE/CANCEL/DISCARD/REMOVE
|
|
@@ -18462,6 +18491,17 @@
|
|
|
18462
18491
|
// Apply each commitment in order using reduce-like pattern
|
|
18463
18492
|
for (let i = 0; i < filteredCommitments.length; i++) {
|
|
18464
18493
|
const commitment = filteredCommitments[i];
|
|
18494
|
+
const isReferenceCommitment = Boolean(agentReferenceResolver && COMMITMENTS_WITH_AGENT_REFERENCES.has(commitment.type));
|
|
18495
|
+
let commitmentContent = commitment.content;
|
|
18496
|
+
if (isReferenceCommitment && agentReferenceResolver) {
|
|
18497
|
+
try {
|
|
18498
|
+
commitmentContent = await agentReferenceResolver.resolveCommitmentContent(commitment.type, commitment.content);
|
|
18499
|
+
}
|
|
18500
|
+
catch (error) {
|
|
18501
|
+
console.warn(`Failed to resolve commitment references for ${commitment.type}, falling back to safe defaults:`, error);
|
|
18502
|
+
commitmentContent = getSafeReferenceCommitmentFallback(commitment.type, commitment.content);
|
|
18503
|
+
}
|
|
18504
|
+
}
|
|
18465
18505
|
// CLOSED commitment should work only if its the last commitment in the book
|
|
18466
18506
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
18467
18507
|
continue;
|
|
@@ -18469,7 +18509,7 @@
|
|
|
18469
18509
|
const definition = getCommitmentDefinition(commitment.type);
|
|
18470
18510
|
if (definition) {
|
|
18471
18511
|
try {
|
|
18472
|
-
requirements = definition.applyToAgentModelRequirements(requirements,
|
|
18512
|
+
requirements = definition.applyToAgentModelRequirements(requirements, commitmentContent);
|
|
18473
18513
|
}
|
|
18474
18514
|
catch (error) {
|
|
18475
18515
|
console.warn(`Failed to apply commitment ${commitment.type}:`, error);
|
|
@@ -18617,23 +18657,28 @@
|
|
|
18617
18657
|
}
|
|
18618
18658
|
|
|
18619
18659
|
/**
|
|
18620
|
-
* Creates model requirements for an agent based on its source
|
|
18660
|
+
* Creates model requirements for an agent based on its source.
|
|
18621
18661
|
*
|
|
18622
18662
|
* There are 2 similar functions:
|
|
18623
18663
|
* - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
|
|
18624
18664
|
* - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronous.
|
|
18625
18665
|
*
|
|
18666
|
+
* @param agentSource - Book describing the agent.
|
|
18667
|
+
* @param modelName - Optional override for the agent's model.
|
|
18668
|
+
* @param availableModels - Models that could fulfill the agent.
|
|
18669
|
+
* @param llmTools - Execution tools used when selecting a best model.
|
|
18670
|
+
* @param options - Optional hooks such as the agent reference resolver.
|
|
18626
18671
|
* @public exported from `@promptbook/core`
|
|
18627
18672
|
*/
|
|
18628
|
-
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools) {
|
|
18673
|
+
async function createAgentModelRequirements(agentSource, modelName, availableModels, llmTools, options) {
|
|
18629
18674
|
// If availableModels are provided and no specific modelName is given,
|
|
18630
18675
|
// use preparePersona to select the best model
|
|
18631
18676
|
if (availableModels && !modelName && llmTools) {
|
|
18632
18677
|
const selectedModelName = await selectBestModelUsingPersona(agentSource, llmTools);
|
|
18633
|
-
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName);
|
|
18678
|
+
return createAgentModelRequirementsWithCommitments(agentSource, selectedModelName, options);
|
|
18634
18679
|
}
|
|
18635
18680
|
// Use the new commitment-based system with provided or default model
|
|
18636
|
-
return createAgentModelRequirementsWithCommitments(agentSource, modelName);
|
|
18681
|
+
return createAgentModelRequirementsWithCommitments(agentSource, modelName, options);
|
|
18637
18682
|
}
|
|
18638
18683
|
/**
|
|
18639
18684
|
* Selects the best model using the preparePersona function
|