@promptbook/fake-llm 0.105.0-21 → 0.105.0-23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +121 -4731
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/core.index.d.ts +9 -13
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -2
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
- package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +8 -0
- package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
- package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +21 -0
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
- package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
- package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +16 -2
- package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
- package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
- package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +47 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +10 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +14 -0
- package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
- package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
- package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
- package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
- package/esm/typings/src/commitments/index.d.ts +3 -64
- package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
- package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
- package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/wizard.d.ts +1 -4
- package/package.json +2 -4
- package/umd/index.umd.js +123 -4734
- package/umd/index.umd.js.map +1 -1
|
@@ -9,6 +9,8 @@ import type { AvatarProfileProps } from '../book-components/AvatarProfile/Avatar
|
|
|
9
9
|
import type { AvatarProfileFromSourceProps } from '../book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource';
|
|
10
10
|
import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
11
11
|
import type { AgentChatProps } from '../book-components/Chat/AgentChat/AgentChatProps';
|
|
12
|
+
import type { AgentChipData } from '../book-components/Chat/AgentChip/AgentChip';
|
|
13
|
+
import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip';
|
|
12
14
|
import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
|
|
13
15
|
import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
|
|
14
16
|
import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
|
|
@@ -18,14 +20,18 @@ import type { ChatEffectsSystemProps } from '../book-components/Chat/effects/typ
|
|
|
18
20
|
import type { ChatEffectType } from '../book-components/Chat/effects/types/ChatEffectType';
|
|
19
21
|
import type { ChatAutoScrollConfig } from '../book-components/Chat/hooks/useChatAutoScroll';
|
|
20
22
|
import type { SendMessageToLlmChatFunction } from '../book-components/Chat/hooks/useSendMessageToLlmChat';
|
|
23
|
+
import type { FriendlyErrorMessage } from '../book-components/Chat/LlmChat/FriendlyErrorMessage';
|
|
21
24
|
import type { LlmChatProps } from '../book-components/Chat/LlmChat/LlmChatProps';
|
|
22
25
|
import type { MockedChatDelayConfig } from '../book-components/Chat/MockedChat/MockedChat';
|
|
23
26
|
import type { MockedChatProps } from '../book-components/Chat/MockedChat/MockedChat';
|
|
24
27
|
import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_common/ChatSaveFormatDefinition';
|
|
25
28
|
import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
|
|
29
|
+
import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceChip';
|
|
26
30
|
import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
|
|
27
31
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
28
32
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
|
33
|
+
import type { ToolCallChipletInfo } from '../book-components/Chat/utils/getToolCallChipletText';
|
|
34
|
+
import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
|
|
29
35
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
|
30
36
|
import type { TeamToolResult } from '../book-components/Chat/utils/toolCallParsing';
|
|
31
37
|
import type { QrCodeOptions } from '../book-components/Qr/useQrCode';
|
|
@@ -66,7 +72,6 @@ import type { InstrumentCommand } from '../commands/X_INSTRUMENT/InstrumentComma
|
|
|
66
72
|
import type { BookCommitment } from '../commitments/_base/BookCommitment';
|
|
67
73
|
import type { CommitmentDefinition } from '../commitments/_base/CommitmentDefinition';
|
|
68
74
|
import type { ParsedCommitment } from '../commitments/_base/ParsedCommitment';
|
|
69
|
-
import type { GroupedCommitmentDefinition } from '../commitments/index';
|
|
70
75
|
import type { PrettifyOptions } from '../conversion/prettify/PrettifyOptions';
|
|
71
76
|
import type { renderPipelineMermaidOptions } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
72
77
|
import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
|
|
@@ -398,6 +403,8 @@ export type { AvatarProfileProps };
|
|
|
398
403
|
export type { AvatarProfileFromSourceProps };
|
|
399
404
|
export type { BookEditorProps };
|
|
400
405
|
export type { AgentChatProps };
|
|
406
|
+
export type { AgentChipData };
|
|
407
|
+
export type { AgentChipProps };
|
|
401
408
|
export type { ChatSoundSystem };
|
|
402
409
|
export type { ChatProps };
|
|
403
410
|
export type { ChatSoundToggleProps };
|
|
@@ -407,14 +414,18 @@ export type { ChatEffectsSystemProps };
|
|
|
407
414
|
export type { ChatEffectType };
|
|
408
415
|
export type { ChatAutoScrollConfig };
|
|
409
416
|
export type { SendMessageToLlmChatFunction };
|
|
417
|
+
export type { FriendlyErrorMessage };
|
|
410
418
|
export type { LlmChatProps };
|
|
411
419
|
export type { MockedChatDelayConfig };
|
|
412
420
|
export type { MockedChatProps };
|
|
413
421
|
export type { ChatSaveFormatDefinition };
|
|
414
422
|
export type { string_chat_format_name };
|
|
423
|
+
export type { SourceChipProps };
|
|
415
424
|
export type { ChatToolCall };
|
|
416
425
|
export type { ChatMessage };
|
|
417
426
|
export type { ChatParticipant };
|
|
427
|
+
export type { ToolCallChipletInfo };
|
|
428
|
+
export type { ParsedCitation };
|
|
418
429
|
export type { MessageButton };
|
|
419
430
|
export type { TeamToolResult };
|
|
420
431
|
export type { QrCodeOptions };
|
|
@@ -455,7 +466,6 @@ export type { InstrumentCommand };
|
|
|
455
466
|
export type { BookCommitment };
|
|
456
467
|
export type { CommitmentDefinition };
|
|
457
468
|
export type { ParsedCommitment };
|
|
458
|
-
export type { GroupedCommitmentDefinition };
|
|
459
469
|
export type { PrettifyOptions };
|
|
460
470
|
export type { renderPipelineMermaidOptions };
|
|
461
471
|
export type { CallbackInterfaceToolsOptions };
|
|
@@ -31,7 +31,7 @@ export type AgentCapability = {
|
|
|
31
31
|
/**
|
|
32
32
|
* The type of the capability
|
|
33
33
|
*/
|
|
34
|
-
type: 'browser' | 'search-engine' | 'knowledge' | 'time' | 'inheritance' | 'import' | 'image-generator' | 'team';
|
|
34
|
+
type: 'browser' | 'search-engine' | 'knowledge' | 'time' | 'inheritance' | 'import' | 'image-generator' | 'team' | 'email';
|
|
35
35
|
/**
|
|
36
36
|
* The label to display for this capability
|
|
37
37
|
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { string_url } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Agent profile information for chip display
|
|
5
|
+
*/
|
|
6
|
+
export type AgentChipData = {
|
|
7
|
+
/**
|
|
8
|
+
* Agent URL (required)
|
|
9
|
+
*/
|
|
10
|
+
url: string_url;
|
|
11
|
+
/**
|
|
12
|
+
* Agent display name/label
|
|
13
|
+
*/
|
|
14
|
+
label?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Agent profile image URL
|
|
17
|
+
*/
|
|
18
|
+
imageUrl?: string_url;
|
|
19
|
+
/**
|
|
20
|
+
* Public URL of the agents server (for generating placeholder images)
|
|
21
|
+
*/
|
|
22
|
+
publicUrl?: string_url;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Props for AgentChip component
|
|
26
|
+
*/
|
|
27
|
+
export type AgentChipProps = {
|
|
28
|
+
/**
|
|
29
|
+
* Agent data to display
|
|
30
|
+
*/
|
|
31
|
+
agent: AgentChipData;
|
|
32
|
+
/**
|
|
33
|
+
* Whether this is an ongoing interaction (shows spinner)
|
|
34
|
+
*/
|
|
35
|
+
isOngoing?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether this is clickable (completed state)
|
|
38
|
+
*/
|
|
39
|
+
isClickable?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Click handler
|
|
42
|
+
*/
|
|
43
|
+
onClick?: (event?: React.MouseEvent) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Additional CSS class name
|
|
46
|
+
*/
|
|
47
|
+
className?: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* AgentChip component - displays a chip with agent avatar and name
|
|
51
|
+
*
|
|
52
|
+
* This component is used to display agent interactions in chat messages.
|
|
53
|
+
* It fetches the agent profile if needed and displays the agent's avatar and name.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <AgentChip
|
|
58
|
+
* agent={{ url: 'https://agents.example.com/joe', label: 'Joe' }}
|
|
59
|
+
* isOngoing={false}
|
|
60
|
+
* isClickable={true}
|
|
61
|
+
* onClick={() => console.log('clicked')}
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @private utility of `ChatMessageItem` component
|
|
66
|
+
*/
|
|
67
|
+
export declare function AgentChip({ agent, isOngoing, isClickable, onClick, className }: AgentChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import type { id } from '../../../types/typeAliases';
|
|
3
3
|
import type { ChatMessage } from '../types/ChatMessage';
|
|
4
4
|
import type { ChatParticipant } from '../types/ChatParticipant';
|
|
5
|
+
import { type ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
5
6
|
import type { ChatProps } from './ChatProps';
|
|
6
7
|
/**
|
|
7
8
|
* Props for the `ChatMessageItem` component
|
|
@@ -38,10 +39,24 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
|
|
|
38
39
|
* e.g., { "web_search": "Searching the web..." }
|
|
39
40
|
*/
|
|
40
41
|
toolTitles?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Optional metadata about teammates for team tool calls
|
|
44
|
+
* Maps tool name to agent information
|
|
45
|
+
*/
|
|
46
|
+
teammates?: Record<string, {
|
|
47
|
+
url: string;
|
|
48
|
+
label?: string;
|
|
49
|
+
instructions?: string;
|
|
50
|
+
toolName: string;
|
|
51
|
+
}>;
|
|
41
52
|
/**
|
|
42
53
|
* Called when a tool call chiplet is clicked.
|
|
43
54
|
*/
|
|
44
55
|
onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Called when a source citation chip is clicked.
|
|
58
|
+
*/
|
|
59
|
+
onCitationClick?: (citation: ParsedCitation) => void;
|
|
45
60
|
};
|
|
46
61
|
/**
|
|
47
62
|
* Renders a single chat message item with avatar, content, buttons, and rating.
|
|
@@ -169,6 +169,16 @@ export type ChatProps = {
|
|
|
169
169
|
* e.g., { "web_search": "Searching the web..." }
|
|
170
170
|
*/
|
|
171
171
|
readonly toolTitles?: Record<string, string>;
|
|
172
|
+
/**
|
|
173
|
+
* Optional metadata about teammates for team tool calls
|
|
174
|
+
* Maps tool name to agent information
|
|
175
|
+
*/
|
|
176
|
+
readonly teammates?: Record<string, {
|
|
177
|
+
url: string;
|
|
178
|
+
label?: string;
|
|
179
|
+
instructions?: string;
|
|
180
|
+
toolName: string;
|
|
181
|
+
}>;
|
|
172
182
|
/**
|
|
173
183
|
* Optional callback to create a new agent from the template.
|
|
174
184
|
* If provided, renders the [Create Agent] button for book code blocks.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error types for LlmChat component
|
|
3
|
+
*
|
|
4
|
+
* This is a minimal type definition for use in the Promptbook Engine component.
|
|
5
|
+
* The full implementation is in the Agent Server.
|
|
6
|
+
*/
|
|
7
|
+
export type FriendlyErrorMessage = {
|
|
8
|
+
/**
|
|
9
|
+
* @@@
|
|
10
|
+
*/
|
|
11
|
+
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* @@@
|
|
14
|
+
*/
|
|
15
|
+
message: string;
|
|
16
|
+
/**
|
|
17
|
+
* @@@
|
|
18
|
+
*/
|
|
19
|
+
canRetry: boolean;
|
|
20
|
+
};
|
|
@@ -62,4 +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
|
+
* Optional custom error handler that will be called when an error occurs during chat.
|
|
67
|
+
* If not provided, errors will be displayed as messages in the chat.
|
|
68
|
+
*
|
|
69
|
+
* @param error - The error that occurred
|
|
70
|
+
* @param retry - Function to retry the last failed message
|
|
71
|
+
*/
|
|
72
|
+
onError?(error: unknown, retry: () => void): void;
|
|
65
73
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ParsedCitation } from '../utils/parseCitationsFromContent';
|
|
2
|
+
/**
|
|
3
|
+
* Props for SourceChip component
|
|
4
|
+
*/
|
|
5
|
+
export type SourceChipProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Citation data to display
|
|
8
|
+
*/
|
|
9
|
+
citation: ParsedCitation;
|
|
10
|
+
/**
|
|
11
|
+
* Click handler
|
|
12
|
+
*/
|
|
13
|
+
onClick?: (citation: ParsedCitation) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Additional CSS class name
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* SourceChip component - displays a chip with source document information
|
|
21
|
+
*
|
|
22
|
+
* This component is used to display RAG source citations in chat messages.
|
|
23
|
+
* It displays the source document name and citation ID.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <SourceChip
|
|
28
|
+
* citation={{ id: '5:13', source: 'document.pdf' }}
|
|
29
|
+
* onClick={(citation) => console.log('clicked', citation)}
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @private utility of `ChatMessageItem` component
|
|
34
|
+
*/
|
|
35
|
+
export declare function SourceChip({ citation, onClick, className }: SourceChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -66,6 +66,27 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
|
|
|
66
66
|
*/
|
|
67
67
|
url: string;
|
|
68
68
|
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional source citations/annotations (from RAG systems like OpenAI Assistants)
|
|
71
|
+
*/
|
|
72
|
+
readonly citations?: ReadonlyArray<{
|
|
73
|
+
/**
|
|
74
|
+
* The unique identifier for the citation (e.g., "5:13")
|
|
75
|
+
*/
|
|
76
|
+
id: string;
|
|
77
|
+
/**
|
|
78
|
+
* The source document name (e.g., "document.pdf")
|
|
79
|
+
*/
|
|
80
|
+
source: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional URL to the source document
|
|
83
|
+
*/
|
|
84
|
+
url?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional preview/excerpt from the source
|
|
87
|
+
*/
|
|
88
|
+
excerpt?: string;
|
|
89
|
+
}>;
|
|
69
90
|
};
|
|
70
91
|
/**
|
|
71
92
|
* TODO: Make all fields readonly
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import type { ToolCall } from '../../../types/ToolCall';
|
|
2
|
+
import type { AgentChipData } from '../AgentChip';
|
|
2
3
|
/**
|
|
3
4
|
* Utility to format tool call information for user-friendly display.
|
|
4
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Tool call chiplet information including agent data for team tools
|
|
8
|
+
*/
|
|
9
|
+
export type ToolCallChipletInfo = {
|
|
10
|
+
/**
|
|
11
|
+
* Display text for the chiplet
|
|
12
|
+
*/
|
|
13
|
+
text: string;
|
|
14
|
+
/**
|
|
15
|
+
* Agent data for team tools (if applicable)
|
|
16
|
+
*/
|
|
17
|
+
agentData?: AgentChipData;
|
|
18
|
+
};
|
|
5
19
|
/**
|
|
6
20
|
* Technical to user-friendly tool names and emojis
|
|
7
21
|
*
|
|
@@ -14,6 +28,13 @@ export declare const TOOL_TITLES: Record<string, {
|
|
|
14
28
|
/**
|
|
15
29
|
* Gets the user-friendly text for a tool call chiplet.
|
|
16
30
|
*
|
|
31
|
+
* @deprecated Use getToolCallChipletInfo instead which returns both text and agent data
|
|
17
32
|
* @private [🧠] Maybe public?
|
|
18
33
|
*/
|
|
19
34
|
export declare function getToolCallChipletText(toolCall: ToolCall): string;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the chiplet information including text and agent data (for team tools).
|
|
37
|
+
*
|
|
38
|
+
* @private [🧠] Maybe public?
|
|
39
|
+
*/
|
|
40
|
+
export declare function getToolCallChipletInfo(toolCall: ToolCall): ToolCallChipletInfo;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ChatMessage } from '../types/ChatMessage';
|
|
2
|
+
/**
|
|
3
|
+
* Type representing a parsed citation from RAG sources
|
|
4
|
+
*/
|
|
5
|
+
export type ParsedCitation = {
|
|
6
|
+
/**
|
|
7
|
+
* The unique identifier for the citation (e.g., "5:13")
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The source document name (e.g., "document.pdf")
|
|
12
|
+
*/
|
|
13
|
+
source: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optional URL to the source document
|
|
16
|
+
*/
|
|
17
|
+
url?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional preview/excerpt from the source
|
|
20
|
+
*/
|
|
21
|
+
excerpt?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Parses OpenAI Assistant-style citations from message content
|
|
25
|
+
* Matches patterns like: 【5:13†document.pdf】
|
|
26
|
+
*
|
|
27
|
+
* @param content - The markdown content that may contain citations
|
|
28
|
+
* @returns Array of parsed citations
|
|
29
|
+
*
|
|
30
|
+
* @private utility for internal use
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseCitationsFromContent(content: string): ParsedCitation[];
|
|
33
|
+
/**
|
|
34
|
+
* Removes citation markers from content and returns clean text
|
|
35
|
+
*
|
|
36
|
+
* @param content - The markdown content with citations
|
|
37
|
+
* @returns Content with citation markers removed
|
|
38
|
+
*
|
|
39
|
+
* @private utility for internal use
|
|
40
|
+
*/
|
|
41
|
+
export declare function stripCitationsFromContent(content: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Extracts citations from a chat message if not already present
|
|
44
|
+
*
|
|
45
|
+
* @param message - The chat message to extract citations from
|
|
46
|
+
* @returns The message with citations array populated
|
|
47
|
+
*
|
|
48
|
+
* @private utility for internal use
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractCitationsFromMessage(message: ChatMessage): ChatMessage;
|
|
51
|
+
/**
|
|
52
|
+
* TODO: Maybe spread into multiple files
|
|
53
|
+
*/
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
|
+
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* TEMPLATE commitment definition
|
|
5
|
+
*
|
|
6
|
+
* The TEMPLATE commitment enforces a specific response structure or template
|
|
7
|
+
* that the agent must follow when generating responses. This helps ensure
|
|
8
|
+
* consistent message formatting across all agent interactions.
|
|
9
|
+
*
|
|
10
|
+
* Example usage in agent source:
|
|
11
|
+
*
|
|
12
|
+
* ```book
|
|
13
|
+
* TEMPLATE Always structure your response with: 1) Summary, 2) Details, 3) Next steps
|
|
14
|
+
* TEMPLATE Use the following format: **Question:** [user question] | **Answer:** [your answer]
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* When used without content, it enables template mode which instructs the agent
|
|
18
|
+
* to follow any template patterns defined in other commitments or context.
|
|
19
|
+
*
|
|
20
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
21
|
+
*/
|
|
22
|
+
export declare class TemplateCommitmentDefinition extends BaseCommitmentDefinition<'TEMPLATE' | 'TEMPLATES'> {
|
|
23
|
+
constructor(type?: 'TEMPLATE' | 'TEMPLATES');
|
|
24
|
+
/**
|
|
25
|
+
* Short one-line description of TEMPLATE.
|
|
26
|
+
*/
|
|
27
|
+
get description(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Icon for this commitment.
|
|
30
|
+
*/
|
|
31
|
+
get icon(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Markdown documentation for TEMPLATE commitment.
|
|
34
|
+
*/
|
|
35
|
+
get documentation(): string;
|
|
36
|
+
/**
|
|
37
|
+
* TEMPLATE can be used with or without content.
|
|
38
|
+
*/
|
|
39
|
+
get requiresContent(): boolean;
|
|
40
|
+
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
44
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import { string_javascript_name } from '../../_packages/types.index';
|
|
1
2
|
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
3
|
+
import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
2
4
|
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
5
|
/**
|
|
4
6
|
* USE BROWSER commitment definition
|
|
5
7
|
*
|
|
6
|
-
* The `USE BROWSER` commitment indicates that the agent should utilize
|
|
8
|
+
* The `USE BROWSER` commitment indicates that the agent should utilize browser tools
|
|
7
9
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
8
10
|
*
|
|
11
|
+
* This commitment provides two levels of browser access:
|
|
12
|
+
* 1. One-shot URL fetching: Simple function to fetch and scrape URL content
|
|
13
|
+
* 2. Running browser: For complex tasks like scrolling, clicking, etc. (prepared but not active yet)
|
|
14
|
+
*
|
|
9
15
|
* The content following `USE BROWSER` is ignored (similar to NOTE).
|
|
10
16
|
*
|
|
11
17
|
* Example usage in agent source:
|
|
@@ -38,8 +44,16 @@ export declare class UseBrowserCommitmentDefinition extends BaseCommitmentDefini
|
|
|
38
44
|
/**
|
|
39
45
|
* Gets human-readable titles for tool functions provided by this commitment.
|
|
40
46
|
*/
|
|
41
|
-
getToolTitles(): Record<
|
|
47
|
+
getToolTitles(): Record<string_javascript_name, string>;
|
|
42
48
|
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the browser tool function implementations.
|
|
51
|
+
*
|
|
52
|
+
* This method automatically detects the environment and uses:
|
|
53
|
+
* - Server-side: Direct scraping via fetchUrlContent (Node.js)
|
|
54
|
+
* - Browser: Proxy through Agents Server API via fetchUrlContentViaBrowser
|
|
55
|
+
*/
|
|
56
|
+
getToolFunctions(): Record<string_javascript_name, ToolFunction>;
|
|
43
57
|
}
|
|
44
58
|
/**
|
|
45
59
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches and scrapes content from a URL (SERVER-SIDE ONLY)
|
|
3
|
+
*
|
|
4
|
+
* This function:
|
|
5
|
+
* 1. Fetches the URL content using promptbookFetch
|
|
6
|
+
* 2. Determines the content type (HTML, PDF, etc.)
|
|
7
|
+
* 3. Uses the appropriate scraper to convert to markdown
|
|
8
|
+
* 4. Returns the scraped markdown content
|
|
9
|
+
*
|
|
10
|
+
* @param url The URL to fetch and scrape
|
|
11
|
+
* @returns Markdown content from the URL
|
|
12
|
+
*
|
|
13
|
+
* @private internal utility for USE BROWSER commitment
|
|
14
|
+
*
|
|
15
|
+
* WARNING: This function should NOT be used directly in browser environments.
|
|
16
|
+
* For browser environments, use fetchUrlContentViaBrowser which proxies through
|
|
17
|
+
* the Agents Server API endpoint at /api/scrape
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchUrlContent(url: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
22
|
+
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side safe wrapper for fetching URL content
|
|
3
|
+
*
|
|
4
|
+
* This function proxies requests to the Agents Server API endpoint for scraping,
|
|
5
|
+
* making it safe to use in browser environments.
|
|
6
|
+
*
|
|
7
|
+
* @param url The URL to fetch and scrape
|
|
8
|
+
* @param agentsServerUrl The base URL of the agents server (defaults to current origin)
|
|
9
|
+
* @returns Markdown content from the URL
|
|
10
|
+
*
|
|
11
|
+
* @private internal utility for USE BROWSER commitment
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchUrlContentViaBrowser(url: string, agentsServerUrl?: string): Promise<string>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { string_javascript_name } from '../../_packages/types.index';
|
|
2
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
3
|
+
import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
4
|
+
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
5
|
+
/**
|
|
6
|
+
* USE EMAIL commitment definition
|
|
7
|
+
*
|
|
8
|
+
* The `USE EMAIL` commitment enables the agent to send emails.
|
|
9
|
+
*
|
|
10
|
+
* Example usage in agent source:
|
|
11
|
+
*
|
|
12
|
+
* ```book
|
|
13
|
+
* USE EMAIL
|
|
14
|
+
* USE EMAIL Write always formal and polite emails, always greet.
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
18
|
+
*/
|
|
19
|
+
export declare class UseEmailCommitmentDefinition extends BaseCommitmentDefinition<'USE EMAIL'> {
|
|
20
|
+
constructor();
|
|
21
|
+
get requiresContent(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Short one-line description of USE EMAIL.
|
|
24
|
+
*/
|
|
25
|
+
get description(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Icon for this commitment.
|
|
28
|
+
*/
|
|
29
|
+
get icon(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Markdown documentation for USE EMAIL commitment.
|
|
32
|
+
*/
|
|
33
|
+
get documentation(): string;
|
|
34
|
+
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
35
|
+
/**
|
|
36
|
+
* Gets human-readable titles for tool functions provided by this commitment.
|
|
37
|
+
*/
|
|
38
|
+
getToolTitles(): Record<string_javascript_name, string>;
|
|
39
|
+
/**
|
|
40
|
+
* Gets the `send_email` tool function implementation.
|
|
41
|
+
* Note: This is a placeholder - the actual implementation is provided by the agent server.
|
|
42
|
+
*/
|
|
43
|
+
getToolFunctions(): Record<string_javascript_name, ToolFunction>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
47
|
+
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CommitmentDefinition } from '../_base/CommitmentDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Gets all available commitment definitions
|
|
4
|
+
* @returns Array of all commitment definitions
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/core`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAllCommitmentDefinitions(): ReadonlyArray<CommitmentDefinition>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BookCommitment } from '../_base/BookCommitment';
|
|
2
|
+
/**
|
|
3
|
+
* Gets all available commitment types
|
|
4
|
+
* @returns Array of all commitment types
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/core`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getAllCommitmentTypes(): ReadonlyArray<BookCommitment>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToolFunction } from '../../_packages/types.index';
|
|
2
|
+
import { string_javascript_name } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Gets all function implementations provided by all commitments
|
|
5
|
+
*
|
|
6
|
+
* Note: This function is intended for browser use, there is also equivalent `getAllCommitmentsToolFunctionsForNode` for server use
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/browser`
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAllCommitmentsToolFunctionsForBrowser(): Record<string_javascript_name, ToolFunction>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToolFunction } from '../../_packages/types.index';
|
|
2
|
+
import { string_javascript_name } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Gets all function implementations provided by all commitments
|
|
5
|
+
*
|
|
6
|
+
* Note: This function is intended for server use, there is also equivalent `getAllCommitmentsToolFunctionsForBrowser` for browser use
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/node`
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAllCommitmentsToolFunctionsForNode(): Record<string_javascript_name, ToolFunction>;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
13
|
+
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
14
|
+
*/
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { string_javascript_name } from '../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Gets all tool titles provided by all commitments
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/core`
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAllCommitmentsToolTitles(): Record<string_javascript_name, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BookCommitment } from '../_base/BookCommitment';
|
|
2
|
+
import type { CommitmentDefinition } from '../_base/CommitmentDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* Gets a commitment definition by its type
|
|
5
|
+
* @param type The commitment type to look up
|
|
6
|
+
* @returns The commitment definition or null if not found
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/core`
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCommitmentDefinition(type: BookCommitment): CommitmentDefinition | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommitmentDefinition } from '../_base/CommitmentDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Grouped commitment definition
|
|
4
|
+
*/
|
|
5
|
+
type GroupedCommitmentDefinition = {
|
|
6
|
+
primary: CommitmentDefinition;
|
|
7
|
+
aliases: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Gets all commitment definitions grouped by their aliases
|
|
11
|
+
*
|
|
12
|
+
* @returns Array of grouped commitment definitions
|
|
13
|
+
*
|
|
14
|
+
* @public exported from `@promptbook/core`
|
|
15
|
+
*/
|
|
16
|
+
export declare function getGroupedCommitmentDefinitions(): ReadonlyArray<GroupedCommitmentDefinition>;
|
|
17
|
+
export {};
|