@promptbook/wizard 0.101.0-8 → 0.101.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.
Files changed (88) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +423 -250
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +14 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +11 -4
  8. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +3 -0
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +4 -22
  10. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +1 -26
  11. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +2 -8
  12. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +0 -24
  13. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +2 -8
  14. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +2 -8
  15. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -6
  16. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +2 -8
  17. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +2 -8
  18. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +0 -6
  19. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +0 -6
  20. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +0 -6
  21. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +25 -10
  22. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +2 -8
  23. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +2 -8
  24. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +0 -12
  25. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +0 -12
  26. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +2 -8
  27. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +2 -8
  28. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  29. package/esm/typings/src/book-2.0/commitments/index.d.ts +1 -1
  30. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -0
  31. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +5 -2
  32. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +3 -0
  33. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +18 -1
  34. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +8 -0
  35. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +2 -15
  36. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +9 -0
  37. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  38. package/esm/typings/src/book-components/Chat/hooks/index.d.ts +2 -0
  39. package/esm/typings/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +41 -0
  40. package/esm/typings/src/book-components/Chat/hooks/useSendMessageToLlmChat.d.ts +44 -0
  41. package/esm/typings/src/book-components/Chat/utils/parseMessageButtons.d.ts +22 -0
  42. package/esm/typings/src/book-components/icons/PauseIcon.d.ts +8 -0
  43. package/esm/typings/src/book-components/icons/PlayIcon.d.ts +8 -0
  44. package/esm/typings/src/execution/PromptResult.d.ts +2 -4
  45. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -2
  46. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +1 -3
  47. package/esm/typings/src/formats/csv/CsvFormatError.d.ts +1 -1
  48. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -2
  51. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +8 -2
  52. package/esm/typings/src/llm-providers/_common/utils/removeUnsupportedModelRequirements.d.ts +25 -0
  53. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +7 -18
  54. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +11 -0
  55. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +2 -1
  56. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +58 -0
  57. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +29 -0
  58. package/esm/typings/src/llm-providers/agent/playground/playground.d.ts +8 -0
  59. package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +11 -0
  60. package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +13 -0
  61. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -8
  62. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -5
  63. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -0
  64. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -10
  65. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +4 -6
  66. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +3 -3
  67. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +16 -8
  68. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -8
  69. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -14
  70. package/esm/typings/src/personas/preparePersona.d.ts +1 -0
  71. package/esm/typings/src/remote-server/openapi-types.d.ts +31 -31
  72. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -2
  73. package/esm/typings/src/types/ModelRequirements.d.ts +2 -4
  74. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +1 -1
  75. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +1 -1
  76. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +0 -1
  77. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +2 -2
  78. package/esm/typings/src/version.d.ts +1 -1
  79. package/package.json +2 -2
  80. package/umd/index.umd.js +423 -250
  81. package/umd/index.umd.js.map +1 -1
  82. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +0 -17
  83. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +0 -12
  84. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +0 -16
  85. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +0 -10
  86. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +0 -10
  87. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +0 -81
  88. /package/esm/typings/src/llm-providers/_common/{profiles/test/llmProviderProfiles.test.d.ts → utils/removeUnsupportedModelRequirements.test.d.ts} +0 -0
@@ -23,7 +23,7 @@ import { NotYetImplementedCommitmentDefinition } from './_base/NotYetImplemented
23
23
  *
24
24
  * @private Use functions to access commitments instead of this array directly
25
25
  */
26
- export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"SCENARIOS">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"GOALS">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
26
+ export declare const COMMITMENT_REGISTRY: readonly [PersonaCommitmentDefinition, PersonaCommitmentDefinition, KnowledgeCommitmentDefinition, MemoryCommitmentDefinition, MemoryCommitmentDefinition, StyleCommitmentDefinition, StyleCommitmentDefinition, RuleCommitmentDefinition, RuleCommitmentDefinition, SampleCommitmentDefinition, SampleCommitmentDefinition, FormatCommitmentDefinition, FormatCommitmentDefinition, ModelCommitmentDefinition, ModelCommitmentDefinition, ActionCommitmentDefinition, ActionCommitmentDefinition, MetaCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, NoteCommitmentDefinition, GoalCommitmentDefinition, GoalCommitmentDefinition, MessageCommitmentDefinition, MessageCommitmentDefinition, ScenarioCommitmentDefinition, ScenarioCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, DeleteCommitmentDefinition, NotYetImplementedCommitmentDefinition<"EXPECT">, NotYetImplementedCommitmentDefinition<"BEHAVIOUR">, NotYetImplementedCommitmentDefinition<"BEHAVIOURS">, NotYetImplementedCommitmentDefinition<"AVOID">, NotYetImplementedCommitmentDefinition<"AVOIDANCE">, NotYetImplementedCommitmentDefinition<"CONTEXT">];
27
27
  /**
28
28
  * Gets a commitment definition by its type
29
29
  * @param type The commitment type to look up
@@ -8,3 +8,6 @@ import { string_agent_name, string_url_image } from '../../types/typeAliases';
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare function generatePlaceholderAgentProfileImageUrl(agentName?: string_agent_name): string_url_image;
11
+ /**
12
+ * TODO: [🤹] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
13
+ */
@@ -9,7 +9,7 @@ export type AvatarChipProps = {
9
9
  /**
10
10
  * Avatar to be shown
11
11
  */
12
- readonly avatarBasicInformation: AgentBasicInformation;
12
+ readonly avatarBasicInformation: Omit<AgentBasicInformation, 'parameters'>;
13
13
  /**
14
14
  * Whether this chip is a template avatar
15
15
  */
@@ -21,7 +21,7 @@ export type AvatarChipProps = {
21
21
  /**
22
22
  * Called when chip is clicked
23
23
  */
24
- readonly onSelect?: (avatar: AgentBasicInformation) => void;
24
+ readonly onSelect?: (avatar: Omit<AgentBasicInformation, 'parameters'>) => void;
25
25
  /**
26
26
  * Whether this chip is selected
27
27
  */
@@ -33,3 +33,6 @@ export type AvatarChipProps = {
33
33
  * @public exported from `@promptbook/components`
34
34
  */
35
35
  export declare function AvatarChip(props: AvatarChipProps): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
38
+ */
@@ -21,3 +21,6 @@ export type AvatarProfileProps = {
21
21
  * @public exported from `@promptbook/components`
22
22
  */
23
23
  export declare function AvatarProfile(props: AvatarProfileProps): import("react/jsx-runtime").JSX.Element;
24
+ /**
25
+ * TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
26
+ */
@@ -31,11 +31,28 @@ export type MockedChatDelayConfig = {
31
31
  *
32
32
  * @public exported from `@promptbook/components`
33
33
  */
34
- export type MockedChatProps = ChatProps & {
34
+ export type MockedChatProps = Omit<ChatProps, 'onReset' | /*'onMessage' | */ 'onUseTemplate' | 'isVoiceRecognitionButtonShown'> & {
35
+ /**
36
+ * Whether the chat can be reset via the "New chat" button.
37
+ *
38
+ * When true (default), the reset button is shown and clicking it restarts the simulated flow.
39
+ * When false, the reset button is hidden (read-only simulation without manual restart).
40
+ *
41
+ * @default true
42
+ */
43
+ isResettable?: boolean;
35
44
  /**
36
45
  * Optional delays configuration for emulating typing behavior
37
46
  */
38
47
  delayConfig?: MockedChatDelayConfig;
48
+ /**
49
+ * When true, shows Pause/Resume control and allows pausing the simulated flow.
50
+ * Pausing finishes the currently typing message first (transitions via PAUSING state),
51
+ * then prevents new messages from starting until resumed.
52
+ *
53
+ * @default true
54
+ */
55
+ isPausable?: boolean;
39
56
  };
40
57
  /**
41
58
  * MockedChat component that shows the same chat as Chat but emulates ongoing discussion
@@ -41,6 +41,11 @@ export type BookEditorProps = {
41
41
  * If true, disables border radius making the editor have sharp corners
42
42
  */
43
43
  readonly isBorderRadiusDisabled?: boolean;
44
+ /**
45
+ * If true, shows the footer with book title and version information.
46
+ * By default, the footer is hidden.
47
+ */
48
+ readonly isFooterShown?: boolean;
44
49
  };
45
50
  /**
46
51
  * Renders a book editor
@@ -48,3 +53,6 @@ export type BookEditorProps = {
48
53
  * @public exported from `@promptbook/components`
49
54
  */
50
55
  export declare function BookEditor(props: BookEditorProps): import("react/jsx-runtime").JSX.Element;
56
+ /**
57
+ * TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
58
+ */
@@ -1,18 +1,5 @@
1
- import { Promisable } from 'type-fest';
2
- import type { string_book } from '../../book-2.0/agent-source/string_book';
1
+ import { BookEditorProps } from './BookEditor';
3
2
  /**
4
3
  * @private util of `<BookEditor />`
5
4
  */
6
- export type BookEditorInnerProps = {
7
- className?: string;
8
- fontClassName?: string;
9
- value?: string_book;
10
- onChange?(value: string_book): void;
11
- onFileUpload?(file: File): Promisable<string>;
12
- isVerbose?: boolean;
13
- isBorderRadiusDisabled?: boolean;
14
- };
15
- /**
16
- * @private util of `<BookEditor />`
17
- */
18
- export declare function BookEditorInner(props: BookEditorInnerProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function BookEditorInner(props: BookEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -66,6 +66,12 @@ export type ChatProps = {
66
66
  * If not provided, the chat bar will not be rendered
67
67
  */
68
68
  readonly children?: ReactNode;
69
+ /**
70
+ * Extra action buttons/elements rendered in the actions toolbar
71
+ * (next to reset / template buttons). Keeps consumers DRY when
72
+ * adding feature–specific controls (e.g. Pause / Resume in MockedChat).
73
+ */
74
+ readonly extraActions?: ReactNode;
69
75
  /**
70
76
  * Optional CSS class name which will be added to root <div/> element
71
77
  */
@@ -140,3 +146,6 @@ export type ChatProps = {
140
146
  url: string;
141
147
  }): Promisable<void>;
142
148
  };
149
+ /**
150
+ * TODO: [☁️] Export component prop types only to `@promptbook/components` (not `@promptbook/types`)
151
+ */
@@ -2,6 +2,7 @@ import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
2
2
  import type { ChatProps } from '../Chat/ChatProps';
3
3
  import type { ChatMessage } from '../types/ChatMessage';
4
4
  import type { ChatParticipant } from '../types/ChatParticipant';
5
+ import type { SendMessageToLlmChatFunction } from '../hooks/useSendMessageToLlmChat';
5
6
  /**
6
7
  * Props for LlmChat component, derived from ChatProps but with LLM-specific modifications
7
8
  *
@@ -17,8 +18,20 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
17
18
  * When provided, the conversation will be saved and restored from localStorage
18
19
  */
19
20
  readonly persistenceKey?: string;
21
+ /**
22
+ * Optional initial messages to pre-populate the chat.
23
+ * - They can include both USER and ASSISTANT messages.
24
+ * - They are only used when there is no persisted conversation (persistence takes precedence).
25
+ * - They are not automatically persisted until the user sends a new message.
26
+ */
27
+ readonly initialMessages?: ReadonlyArray<ChatMessage>;
20
28
  /**
21
29
  * Called when the chat state changes (messages, participants, etc.)
22
30
  */
23
31
  onChange?(messages: ReadonlyArray<ChatMessage>, participants: ReadonlyArray<ChatParticipant>): void;
32
+ /**
33
+ * Optional external sendMessage function produced by useSendMessageToLlmChat hook.
34
+ * When provided, LlmChat will attach its internal handler to it (no React context needed).
35
+ */
36
+ readonly sendMessage?: SendMessageToLlmChatFunction;
24
37
  };
@@ -0,0 +1,2 @@
1
+ export * from './useChatAutoScroll';
2
+ export * from './useSendMessageToLlmChat';
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Configuration for the auto-scroll behavior
3
+ */
4
+ export type ChatAutoScrollConfig = {
5
+ /**
6
+ * Threshold in pixels from bottom to consider as "at bottom"
7
+ * @default 100
8
+ */
9
+ bottomThreshold?: number;
10
+ /**
11
+ * Whether to use smooth scrolling
12
+ * @default true
13
+ */
14
+ smoothScroll?: boolean;
15
+ /**
16
+ * Delay before checking scroll position after new messages (in milliseconds)
17
+ * @default 100
18
+ */
19
+ scrollCheckDelay?: number;
20
+ };
21
+ /**
22
+ * Hook for managing auto-scroll behavior in chat components
23
+ *
24
+ * This hook provides:
25
+ * - Automatic scrolling to bottom when new messages arrive (if user is already at bottom)
26
+ * - Detection of when user scrolls away from bottom
27
+ * - Scroll-to-bottom functionality with smooth animation
28
+ * - Mobile-optimized scrolling behavior
29
+ *
30
+ * @public exported from `@promptbook/components`
31
+ */
32
+ export declare function useChatAutoScroll(config?: ChatAutoScrollConfig): {
33
+ isAutoScrolling: boolean;
34
+ chatMessagesRef: (element: HTMLDivElement | null) => void;
35
+ handleScroll: (event: React.UIEvent<HTMLDivElement>) => void;
36
+ handleMessagesChange: () => void;
37
+ scrollToBottom: () => void;
38
+ enableAutoScroll: () => void;
39
+ disableAutoScroll: () => void;
40
+ isMobile: boolean;
41
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Function type for sending a message to LlmChat.
3
+ *
4
+ * Implementation detail: The returned function is "attachable".
5
+ * LlmChat will call the internal `_attach` method (if present) to bind
6
+ * its real message handler. Messages sent before attachment are queued
7
+ * and flushed after attachment.
8
+ *
9
+ * @public exported from `@promptbook/components`
10
+ */
11
+ export type SendMessageToLlmChatFunction = {
12
+ /**
13
+ * Send a message to the bound LlmChat instance (or queue it until attached).
14
+ */
15
+ (message: string): void;
16
+ /**
17
+ * Internal method used by the <LlmChat/> component to attach its handler.
18
+ * Not intended for consumer usage.
19
+ *
20
+ * @internal
21
+ */
22
+ _attach?: (handler: (message: string) => Promise<void> | void) => void;
23
+ };
24
+ /**
25
+ * Hook to create a sendMessage function for an <LlmChat/> component WITHOUT needing any React Context.
26
+ *
27
+ * Usage pattern:
28
+ * ```tsx
29
+ * const sendMessage = useSendMessageToLlmChat();
30
+ * return (
31
+ * <>
32
+ * <button onClick={() => sendMessage('Hello!')}>Hello</button>
33
+ * <LlmChat llmTools={llmTools} sendMessage={sendMessage} />
34
+ * </>
35
+ * );
36
+ * ```
37
+ *
38
+ * - No provider wrapping needed.
39
+ * - Safe to call before the <LlmChat/> mounts (messages will be queued).
40
+ * - Keeps DRY by letting <LlmChat/> reuse its internal `handleMessage` logic.
41
+ *
42
+ * @public exported from `@promptbook/components`
43
+ */
44
+ export declare function useSendMessageToLlmChat(): SendMessageToLlmChatFunction;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Represents a parsed message button from markdown
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export type MessageButton = {
7
+ text: string;
8
+ message: string;
9
+ };
10
+ /**
11
+ * Parses markdown buttons in the format [Button Text](?message=Message%20to%20send)
12
+ * Returns both the content without buttons and the extracted buttons
13
+ *
14
+ * @param content The markdown content that may contain buttons
15
+ * @returns Object with contentWithoutButtons and buttons array
16
+ *
17
+ * @public exported from `@promptbook/components`
18
+ */
19
+ export declare function parseMessageButtons(content: string): {
20
+ contentWithoutButtons: string;
21
+ buttons: MessageButton[];
22
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pause icon (two vertical bars)
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const PauseIcon: ({ size }: {
7
+ size?: number | undefined;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Play icon (triangle) used for resume action
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const PlayIcon: ({ size }: {
7
+ size?: number | undefined;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,4 @@
1
- import type { string_date_iso8601 } from '../types/typeAliases';
2
- import type { string_model_name } from '../types/typeAliases';
3
- import type { string_prompt } from '../types/typeAliases';
1
+ import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
4
2
  import type { TODO_object } from '../utils/organization/TODO_object';
5
3
  import type { EmbeddingVector } from './EmbeddingVector';
6
4
  import type { Usage } from './Usage';
@@ -44,7 +42,7 @@ export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
44
42
  */
45
43
  export type CommonPromptResult = {
46
44
  /**
47
- * Exact text response from the model
45
+ * Text response from the model
48
46
  */
49
47
  readonly content: string;
50
48
  /**
@@ -1,8 +1,7 @@
1
1
  import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { Parameters } from '../../types/typeAliases';
5
- import type { string_parameter_name } from '../../types/typeAliases';
4
+ import type { Parameters, string_parameter_name } from '../../types/typeAliases';
6
5
  import type { TODO_string } from '../../utils/organization/TODO_string';
7
6
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
8
7
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
@@ -1,9 +1,7 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { Parameters } from '../../types/typeAliases';
5
- import type { string_markdown } from '../../types/typeAliases';
6
- import type { string_parameter_value } from '../../types/typeAliases';
4
+ import type { Parameters, string_markdown, string_parameter_value } from '../../types/typeAliases';
7
5
  import type { ExecutionTools } from '../ExecutionTools';
8
6
  /**
9
7
  * Options for retrieving relevant knowledge for a specific task during pipeline execution.
@@ -1,4 +1,4 @@
1
- import { AbstractFormatError } from "../../errors/AbstractFormatError";
1
+ import { AbstractFormatError } from '../../errors/AbstractFormatError';
2
2
  /**
3
3
  * This error indicates problem with parsing of CSV
4
4
  *
@@ -16,4 +16,4 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
16
16
  export declare function $provideLlmToolsConfigurationFromEnv(): Promise<LlmToolsConfiguration>;
17
17
  /**
18
18
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
19
- */
19
+ */
@@ -24,4 +24,4 @@ export {};
24
24
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
25
25
  * TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
26
26
  * TODO: [®] DRY Register logi
27
- */
27
+ */
@@ -1,7 +1,6 @@
1
1
  import { Promisable } from 'type-fest';
2
2
  import type { Identification } from '../../../remote-server/socket-types/_subtypes/Identification';
3
- import type { string_app_id } from '../../../types/typeAliases';
4
- import type { string_url } from '../../../types/typeAliases';
3
+ import type { string_app_id, string_url } from '../../../types/typeAliases';
5
4
  import type { really_any } from '../../../utils/organization/really_any';
6
5
  import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
7
6
  import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
@@ -1,4 +1,4 @@
1
- import type { string_user_id } from '../../../types/typeAliases';
1
+ import type { string_markdown_text, string_mime_type_with_wildcard, string_user_id } from '../../../types/typeAliases';
2
2
  import { MultipleLlmExecutionTools } from '../../_multiple/MultipleLlmExecutionTools';
3
3
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
4
4
  /**
@@ -7,12 +7,18 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
7
7
  * @private internal type for `$provideLlmToolsFromEnv` and `$provideLlmToolsForTestingAndScriptsAndPlayground`
8
8
  */
9
9
  export type CreateLlmToolsFromConfigurationOptions = {
10
+ /**
11
+ * Title of the LLM tools
12
+ *
13
+ * @default 'LLM Tools from Configuration'
14
+ */
15
+ readonly title?: string_mime_type_with_wildcard & string_markdown_text;
10
16
  /**
11
17
  * This will will be passed to the created `LlmExecutionTools`
12
18
  *
13
19
  * @default false
14
20
  */
15
- isVerbose?: boolean;
21
+ readonly isVerbose?: boolean;
16
22
  /**
17
23
  * Identifier of the end user
18
24
  *
@@ -0,0 +1,25 @@
1
+ import type { ModelRequirements } from '../../../types/ModelRequirements';
2
+ /**
3
+ * Parses an OpenAI error message to identify which parameter is unsupported
4
+ *
5
+ * @param errorMessage The error message from OpenAI API
6
+ * @returns The parameter name that is unsupported, or null if not an unsupported parameter error
7
+ * @private utility of LLM Tools
8
+ */
9
+ export declare function parseUnsupportedParameterError(errorMessage: string): string | null;
10
+ /**
11
+ * Creates a copy of model requirements with the specified parameter removed
12
+ *
13
+ * @param modelRequirements Original model requirements
14
+ * @param unsupportedParameter The parameter to remove
15
+ * @returns New model requirements without the unsupported parameter
16
+ * @private utility of LLM Tools
17
+ */
18
+ export declare function removeUnsupportedModelRequirement(modelRequirements: ModelRequirements, unsupportedParameter: string): ModelRequirements;
19
+ /**
20
+ * Checks if an error is an "Unsupported value" error from OpenAI
21
+ * @param error The error to check
22
+ * @returns true if this is an unsupported parameter error
23
+ * @private utility of LLM Tools
24
+ */
25
+ export declare function isUnsupportedParameterError(error: Error): boolean;
@@ -1,16 +1,9 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
- import type { ChatPromptResult } from '../../execution/PromptResult';
4
- import type { CompletionPromptResult } from '../../execution/PromptResult';
5
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
6
- import type { PromptResult } from '../../execution/PromptResult';
7
- import type { ChatPrompt } from '../../types/Prompt';
8
- import type { CompletionPrompt } from '../../types/Prompt';
9
- import type { EmbeddingPrompt } from '../../types/Prompt';
10
- import type { Prompt } from '../../types/Prompt';
11
- import type { string_markdown } from '../../types/typeAliases';
12
- import type { string_markdown_text } from '../../types/typeAliases';
13
- import type { string_title } from '../../types/typeAliases';
4
+ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../../execution/PromptResult';
5
+ import type { ChatPrompt, CompletionPrompt, EmbeddingPrompt, Prompt } from '../../types/Prompt';
6
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
14
7
  /**
15
8
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
16
9
  *
@@ -18,6 +11,7 @@ import type { string_title } from '../../types/typeAliases';
18
11
  * @public exported from `@promptbook/core`
19
12
  */
20
13
  export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
14
+ readonly title: string_title & string_markdown_text;
21
15
  /**
22
16
  * Array of execution tools in order of priority
23
17
  */
@@ -25,14 +19,9 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
25
19
  /**
26
20
  * Gets array of execution tools in order of priority
27
21
  */
28
- constructor(...llmExecutionTools: ReadonlyArray<LlmExecutionTools>);
29
- get title(): string_title & string_markdown_text;
22
+ constructor(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>);
30
23
  get description(): string_markdown;
31
- get profile(): {
32
- name: string;
33
- fullname: string;
34
- color: string;
35
- };
24
+ get profile(): ChatParticipant;
36
25
  /**
37
26
  * Check the configuration of all execution tools
38
27
  */
@@ -0,0 +1,11 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
3
+ /**
4
+ * Just returns the given `LlmExecutionTools` or joins multiple into one
5
+ *
6
+ * @public exported from `@promptbook/core`
7
+ */
8
+ export declare function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools: undefined | LlmExecutionTools | ReadonlyArray<LlmExecutionTools>): LlmExecutionTools | MultipleLlmExecutionTools;
9
+ /**
10
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
11
+ */
@@ -1,4 +1,5 @@
1
1
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import { string_markdown_text, string_title } from '../../types/typeAliases';
2
3
  import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
3
4
  /**
4
5
  * Joins multiple LLM Execution Tools into one
@@ -15,7 +16,7 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
15
16
  *
16
17
  * @public exported from `@promptbook/core`
17
18
  */
18
- export declare function joinLlmExecutionTools(...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
19
+ export declare function joinLlmExecutionTools(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
19
20
  /**
20
21
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
21
22
  */
@@ -0,0 +1,58 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_book } from '../../book-2.0/agent-source/string_book';
3
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
4
+ import type { AvailableModel } from '../../execution/AvailableModel';
5
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
6
+ import type { ChatPromptResult } from '../../execution/PromptResult';
7
+ import type { Prompt } from '../../types/Prompt';
8
+ import type { string_markdown, string_markdown_text, string_model_name, string_title } from '../../types/typeAliases';
9
+ /**
10
+ * Execution Tools for calling LLM models with a predefined agent "soul"
11
+ * This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
12
+ *
13
+ * @public exported from `@promptbook/core`
14
+ */
15
+ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
16
+ private readonly llmTools;
17
+ private readonly agentSource;
18
+ /**
19
+ * Cached model requirements to avoid re-parsing the agent source
20
+ */
21
+ private _cachedModelRequirements;
22
+ /**
23
+ * Cached parsed agent information
24
+ */
25
+ private _cachedAgentInfo;
26
+ /**
27
+ * Creates new AgentLlmExecutionTools
28
+ *
29
+ * @param llmTools The underlying LLM execution tools to wrap
30
+ * @param agentSource The agent source string that defines the agent's behavior
31
+ */
32
+ constructor(llmTools: LlmExecutionTools, agentSource: string_book);
33
+ /**
34
+ * Get cached or parse agent information
35
+ */
36
+ private getAgentInfo;
37
+ /**
38
+ * Get cached or create agent model requirements
39
+ */
40
+ private getAgentModelRequirements;
41
+ get title(): string_title & string_markdown_text;
42
+ get description(): string_markdown;
43
+ get profile(): ChatParticipant | undefined;
44
+ checkConfiguration(): Promisable<void>;
45
+ /**
46
+ * Returns a virtual model name representing the agent behavior
47
+ */
48
+ get modelName(): string_model_name;
49
+ listModels(): Promisable<ReadonlyArray<AvailableModel>>;
50
+ /**
51
+ * Calls the chat model with agent-specific system prompt and requirements
52
+ */
53
+ callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
54
+ }
55
+ /**
56
+ * TODO: [🍚] Implement Destroyable pattern to free resources
57
+ * TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
58
+ */
@@ -0,0 +1,29 @@
1
+ import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import { AgentLlmExecutionTools } from './AgentLlmExecutionTools';
4
+ /**
5
+ * Options for creating AgentLlmExecutionTools
6
+ */
7
+ export type CreateAgentLlmExecutionToolsOptions = {
8
+ /**
9
+ * The underlying LLM execution tools to wrap
10
+ */
11
+ llmTools: LlmExecutionTools;
12
+ /**
13
+ * The agent source string that defines the agent's behavior
14
+ */
15
+ agentSource: string_book;
16
+ };
17
+ /**
18
+ * Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
19
+ *
20
+ * @public exported from `@promptbook/core`
21
+ */
22
+ export declare const createAgentLlmExecutionTools: ((options: CreateAgentLlmExecutionToolsOptions) => AgentLlmExecutionTools) & {
23
+ packageName: string;
24
+ className: string;
25
+ };
26
+ /**
27
+ * TODO: [🧠] Consider adding validation for agent source format
28
+ * TODO: [🧠] Consider adding options for caching behavior
29
+ */
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
3
+ /**
4
+ * TODO: [🧠] Add more complex agent scenarios
5
+ * TODO: [🧠] Add parameter substitution demo
6
+ * TODO: [🧠] Add multi-turn conversation demo
7
+ * Note: [⚫] Code in this file should never be published in any package
8
+ */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Metadata for Agent LLM execution tools
3
+ *
4
+ * @public exported from `@promptbook/core`
5
+ */
6
+ export declare const _AgentMetadata: import("../../utils/$Register").Registration;
7
+ /**
8
+ * TODO: [🧠] Consider adding a special trust level for AgentLlmExecutionTools
9
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
10
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11
+ */
@@ -0,0 +1,13 @@
1
+ import type { Registration } from '../../utils/$Register';
2
+ /**
3
+ * Registration of Agent LLM provider
4
+ *
5
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ */
9
+ export declare const _AgentRegistration: Registration;
10
+ /**
11
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
12
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13
+ */