@promptbook/javascript 0.110.0-8 → 0.110.0-9

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 CHANGED
@@ -18,7 +18,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
18
18
  * @generated
19
19
  * @see https://github.com/webgptorg/promptbook
20
20
  */
21
- const PROMPTBOOK_ENGINE_VERSION = '0.110.0-8';
21
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0-9';
22
22
  /**
23
23
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
24
24
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -18,6 +18,7 @@ import { Chat } from '../book-components/Chat/Chat/Chat';
18
18
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
19
19
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
20
20
  import { ChatSoundToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
21
+ import { ChatVibrationToggle } from '../book-components/Chat/Chat/ChatSoundToggle';
21
22
  import { ChatEffectsSystem } from '../book-components/Chat/effects/ChatEffectsSystem';
22
23
  import { ConfettiEffect } from '../book-components/Chat/effects/components/ConfettiEffect';
23
24
  import { HeartsEffect } from '../book-components/Chat/effects/components/HeartsEffect';
@@ -88,6 +89,7 @@ export { Chat };
88
89
  export type { ChatSoundSystem };
89
90
  export type { ChatProps };
90
91
  export { ChatSoundToggle };
92
+ export { ChatVibrationToggle };
91
93
  export { ChatEffectsSystem };
92
94
  export { ConfettiEffect };
93
95
  export { HeartsEffect };
@@ -16,6 +16,7 @@ import type { AgentChipProps } from '../book-components/Chat/AgentChip/AgentChip
16
16
  import type { ChatSoundSystem } from '../book-components/Chat/Chat/ChatProps';
17
17
  import type { ChatProps } from '../book-components/Chat/Chat/ChatProps';
18
18
  import type { ChatSoundToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
19
+ import type { ChatVibrationToggleProps } from '../book-components/Chat/Chat/ChatSoundToggle';
19
20
  import type { ChatEffect } from '../book-components/Chat/effects/types/ChatEffect';
20
21
  import type { ChatEffectConfig } from '../book-components/Chat/effects/types/ChatEffectConfig';
21
22
  import type { ChatEffectsSystemProps } from '../book-components/Chat/effects/types/ChatEffectsSystemProps';
@@ -373,6 +374,7 @@ import type { number_gigabytes } from '../types/typeAliases';
373
374
  import type { number_terabytes } from '../types/typeAliases';
374
375
  import type { Updatable } from '../types/Updatable';
375
376
  import type { ColorTransformer } from '../utils/color/operators/ColorTransformer';
377
+ import type { ThinkingMessageVariant } from '../utils/DEFAULT_THINKING_MESSAGES';
376
378
  import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
377
379
  import type { ExecCommandOptions } from '../utils/execCommand/ExecCommandOptions';
378
380
  import type { ExecCommandOptionsAdvanced } from '../utils/execCommand/ExecCommandOptions';
@@ -419,6 +421,7 @@ export type { AgentChipProps };
419
421
  export type { ChatSoundSystem };
420
422
  export type { ChatProps };
421
423
  export type { ChatSoundToggleProps };
424
+ export type { ChatVibrationToggleProps };
422
425
  export type { ChatEffect };
423
426
  export type { ChatEffectConfig };
424
427
  export type { ChatEffectsSystemProps };
@@ -776,6 +779,7 @@ export type { number_gigabytes };
776
779
  export type { number_terabytes };
777
780
  export type { Updatable };
778
781
  export type { ColorTransformer };
782
+ export type { ThinkingMessageVariant };
779
783
  export type { PipelineEditableSerialized };
780
784
  export type { ExecCommandOptions };
781
785
  export type { ExecCommandOptionsAdvanced };
@@ -1,6 +1,6 @@
1
1
  import type { LlmToolDefinition } from '../../types/LlmToolDefinition';
2
2
  import type { string_agent_url, string_knowledge_source_link } from '../../types/typeAliases';
3
- import type { TODO_any } from '../../utils/organization/TODO_any';
3
+ import { chococake } from '../../utils/organization/really_any';
4
4
  /**
5
5
  * Model requirements for an agent
6
6
  *
@@ -12,22 +12,16 @@ export type AgentModelRequirements = {
12
12
  */
13
13
  readonly systemMessage: string;
14
14
  /**
15
- * The model name to use for this agent
15
+ * Text appended to every user prompt after the user's input and before tools/messages.
16
+ *
17
+ * This allows commitments to emphasize important rules or reminders that should be
18
+ * visible in the prompt in addition to the system message.
16
19
  */
17
- readonly modelName: string;
20
+ readonly promptSuffix: string;
18
21
  /**
19
- * Optional list of MCP servers that the agent can connect to
20
- */
21
- readonly mcpServers?: ReadonlyArray<string>;
22
- /**
23
- * Optional link to the parent agent from which this agent inherits
24
- *
25
- * Note: [🆓] There are several cases what the agent ancestor could be:
26
- * - 1) `parentAgentUrl` is `string_agent_url` valid agent URL
27
- * - 2) `parentAgentUrl` is explicitly `null` (forcefully no parent)
28
- * - 3) `parentAgentUrl` is not defined `undefined`, the default ancestor agent, Adam, will be used
22
+ * The model name to use for this agent
29
23
  */
30
- readonly parentAgentUrl?: string_agent_url | null;
24
+ readonly modelName: string;
31
25
  /**
32
26
  * List of imported agent URLs
33
27
  */
@@ -64,17 +58,24 @@ export type AgentModelRequirements = {
64
58
  */
65
59
  readonly tools?: ReadonlyArray<LlmToolDefinition>;
66
60
  /**
67
- * Arbitrary metadata storage for commitments
68
- * Each commitment can store its own data here
61
+ * Optional list of MCP servers that the agent can connect to
69
62
  */
70
- readonly metadata?: Record<string, TODO_any>;
63
+ readonly mcpServers?: ReadonlyArray<string>;
71
64
  /**
72
- * Notes associated with the agent
73
- *
74
- * Note: This does not affect agent behavior in any way
65
+ * The URL of the parent agent to inherit from, or null if there is no parent (i.e., do not inherit from any agent)
66
+ */
67
+ readonly parentAgentUrl: string_agent_url | null;
68
+ /**
69
+ * Is the agent closed to modification by conversation (i.e., it will not learn from interactions and its source code will remain static during conversation)
70
+ */
71
+ readonly isClosed: boolean;
72
+ /**
73
+ * Arbitrary metadata storage for commitments
74
+ * Each commitment can store its own data here
75
75
  */
76
- readonly notes?: ReadonlyArray<string>;
76
+ readonly _metadata?: Record<string, chococake>;
77
77
  };
78
78
  /**
79
79
  * TODO: [🐤] DRY `AgentModelRequirements` and `ModelRequirements`
80
+ * TODO: [🧠] `isClosed` and `parentAgentUrl` doesn't truly belong to `AgentModelRequirements` nor agent profile but it is in the `AgentModelRequirements` because of some legacy - maybe figure out better place
80
81
  */
@@ -29,6 +29,7 @@ export type ChatInputAreaProps = {
29
29
  onChange?: ChatProps['onChange'];
30
30
  onFileUpload?: ChatProps['onFileUpload'];
31
31
  speechRecognition?: ChatProps['speechRecognition'];
32
+ speechRecognitionLanguage?: ChatProps['speechRecognitionLanguage'];
32
33
  defaultMessage?: string;
33
34
  placeholderMessageContent?: string;
34
35
  isFocusedOnLoad?: boolean;
@@ -52,6 +52,10 @@ type ChatMessageItemProps = Pick<ChatProps, 'onMessage' | 'participants'> & {
52
52
  * Called when a source citation chip is clicked.
53
53
  */
54
54
  onCitationClick?: (citation: ParsedCitation) => void;
55
+ /**
56
+ * Optional sound system for triggering tool chip events.
57
+ */
58
+ soundSystem?: ChatProps['soundSystem'];
55
59
  };
56
60
  /**
57
61
  * Metadata for a teammate agent tool.
@@ -27,6 +27,7 @@ export type ChatMessageListProps = {
27
27
  teammates?: ChatProps['teammates'];
28
28
  onToolCallClick?: (toolCall: NonNullable<ChatMessage['toolCalls']>[number]) => void;
29
29
  onCitationClick?: (citation: ParsedCitation) => void;
30
+ soundSystem?: ChatProps['soundSystem'];
30
31
  setChatMessagesElement: (element: HTMLDivElement | null) => void;
31
32
  onScroll: (event: UIEvent<HTMLDivElement>) => void;
32
33
  chatMessagesClassName?: string;
@@ -20,6 +20,16 @@ export type ChatSoundSystem = {
20
20
  isEnabled(): boolean;
21
21
  setEnabled(enabled: boolean): void;
22
22
  toggle(): boolean;
23
+ /**
24
+ * Optional helpers for haptic vibration state.
25
+ */
26
+ isVibrationEnabled?(): boolean;
27
+ setVibrationEnabled?(enabled: boolean): void;
28
+ toggleVibration?(): boolean;
29
+ /**
30
+ * Optional vibration helper to stay in sync with sound events.
31
+ */
32
+ vibrate?(event: string): void;
23
33
  };
24
34
  /**
25
35
  * @public exported from `@promptbook/components`
@@ -66,6 +76,11 @@ export type ChatProps = {
66
76
  * Speech recognition provider
67
77
  */
68
78
  readonly speechRecognition?: SpeechRecognition;
79
+ /**
80
+ * Optional language tag (BCP 47) to force speech recognition to use a specific language.
81
+ * When not provided, the browser preferences are used with a fallback to `en-US`.
82
+ */
83
+ readonly speechRecognitionLanguage?: string;
69
84
  /**
70
85
  * Optional placeholder message for the textarea
71
86
  *
@@ -21,3 +21,22 @@ export type ChatSoundToggleProps = {
21
21
  * @public exported from `@promptbook/components`
22
22
  */
23
23
  export declare function ChatSoundToggle(props: ChatSoundToggleProps): import("react/jsx-runtime").JSX.Element;
24
+ /**
25
+ * Props for the chat vibration toggle.
26
+ */
27
+ export type ChatVibrationToggleProps = {
28
+ /**
29
+ * The sound system instance that supports vibration helpers.
30
+ */
31
+ soundSystem: ChatSoundSystem;
32
+ /**
33
+ * Optional CSS class name.
34
+ */
35
+ className?: string;
36
+ };
37
+ /**
38
+ * ChatVibrationToggle component that controls haptic feedback.
39
+ *
40
+ * @public exported from `@promptbook/components`
41
+ */
42
+ export declare function ChatVibrationToggle(props: ChatVibrationToggleProps): import("react/jsx-runtime").JSX.Element | null;
@@ -62,6 +62,12 @@ export type LlmChatProps = Omit<ChatProps, 'messages' | 'onMessage' | 'onChange'
62
62
  * e.g., { "web_search": "Searching the web..." }
63
63
  */
64
64
  readonly toolTitles?: Record<string, string>;
65
+ /**
66
+ * Custom variants for the placeholder thinking message shown while the agent buffers its response.
67
+ *
68
+ * @default Shared thinking message variants
69
+ */
70
+ readonly thinkingMessages?: ReadonlyArray<string>;
65
71
  /**
66
72
  * Optional custom error handler that will be called when an error occurs during chat.
67
73
  * If not provided, errors will be displayed as messages in the chat.
@@ -57,6 +57,15 @@ export declare abstract class BaseCommitmentDefinition<TBookCommitment extends s
57
57
  * Helper method to append content to the system message
58
58
  */
59
59
  protected appendToSystemMessage(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
60
+ /**
61
+ * Helper method to create a new requirements object with updated prompt suffix
62
+ */
63
+ protected updatePromptSuffix(requirements: AgentModelRequirements, contentUpdate: string | ((currentSuffix: string) => string)): AgentModelRequirements;
64
+ /**
65
+ * Helper method to append content to the prompt suffix
66
+ * Default separator is a single newline for bullet lists.
67
+ */
68
+ protected appendToPromptSuffix(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
60
69
  /**
61
70
  * Helper method to add a comment section to the system message
62
71
  * Comments are lines starting with # that will be removed from the final system message
@@ -1,4 +1,6 @@
1
1
  import { Agent as AgentFromKit } from '@openai/agents';
2
+ import OpenAI from 'openai';
3
+ import { TODO_any } from '../../_packages/types.index';
2
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
5
  import type { ChatPromptResult } from '../../execution/PromptResult';
4
6
  import type { ModelRequirements } from '../../types/ModelRequirements';
@@ -6,6 +8,42 @@ import type { Prompt } from '../../types/Prompt';
6
8
  import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
7
9
  import type { OpenAiAgentKitExecutionToolsOptions } from './OpenAiAgentKitExecutionToolsOptions';
8
10
  import { OpenAiVectorStoreHandler } from './OpenAiVectorStoreHandler';
11
+ /**
12
+ * Represents the AgentKit output configuration used to match OpenAI `response_format` expectations.
13
+ *
14
+ * @private utility of Open AI
15
+ */
16
+ export type AgentOutputType = 'text' | JsonSchemaDefinition;
17
+ type JsonSchemaDefinitionEntry = {
18
+ type?: string;
19
+ description?: string;
20
+ properties?: Record<string, JsonSchemaDefinitionEntry>;
21
+ required?: Array<string>;
22
+ items?: JsonSchemaDefinitionEntry;
23
+ [key: string]: TODO_any;
24
+ };
25
+ type JsonSchemaDefinition = {
26
+ type: 'json_schema';
27
+ name: string;
28
+ strict: boolean;
29
+ schema: {
30
+ type: 'object';
31
+ properties: Record<string, JsonSchemaDefinitionEntry>;
32
+ required: Array<string>;
33
+ additionalProperties: boolean;
34
+ description?: string;
35
+ };
36
+ };
37
+ type OpenAiChatResponseFormat = OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
38
+ /**
39
+ * Maps OpenAI `response_format` payloads to AgentKit output types so the runner can forward
40
+ * structured-output preferences to OpenAI while still reusing the same AgentKit agent instance.
41
+ *
42
+ * @param responseFormat - The OpenAI `response_format` payload from the user request.
43
+ * @returns An Agent output type compatible with the requested schema or `undefined` when no impact is required.
44
+ * @private utility of Open AI
45
+ */
46
+ export declare function mapResponseFormatToAgentOutputType(responseFormat?: OpenAiChatResponseFormat): AgentOutputType | undefined;
9
47
  /**
10
48
  * Alias for OpenAI AgentKit agent to avoid naming confusion with Promptbook agents.
11
49
  */
@@ -82,6 +120,7 @@ export declare class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandl
82
120
  readonly prompt: Prompt;
83
121
  readonly rawPromptContent?: string;
84
122
  readonly onProgress: (chunk: ChatPromptResult) => void;
123
+ readonly responseFormatOutputType?: AgentOutputType;
85
124
  }): Promise<ChatPromptResult>;
86
125
  /**
87
126
  * Builds AgentKit input items from the prompt and optional thread.
@@ -23,5 +23,6 @@ export type LlmToolDefinition = {
23
23
  description?: string;
24
24
  }>;
25
25
  readonly required?: string[];
26
+ readonly additionalProperties?: boolean;
26
27
  };
27
28
  };
@@ -1,6 +1,7 @@
1
1
  import type { LlmToolDefinition } from './LlmToolDefinition';
2
2
  import type { ModelVariant } from './ModelVariant';
3
3
  import type { number_model_temperature, number_seed, string_model_name, string_system_message } from './typeAliases';
4
+ import type OpenAI from 'openai';
4
5
  /**
5
6
  * Abstract way to specify the LLM.
6
7
  * It does not specify the LLM with concrete version itself, only the requirements for the LLM.
@@ -54,6 +55,14 @@ export type ChatModelRequirements = CommonModelRequirements & {
54
55
  * Maximum number of tokens that can be generated by the model
55
56
  */
56
57
  readonly maxTokens?: number;
58
+ /**
59
+ * Optional OpenAI `response_format` override that should be forwarded to compatible APIs.
60
+ */
61
+ readonly responseFormat?: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming['response_format'];
62
+ /**
63
+ * Optional OpenAI `tool_choice` override that should be forwarded to compatible APIs.
64
+ */
65
+ readonly toolChoice?: OpenAI.Chat.Completions.ChatCompletionToolChoiceOption;
57
66
  };
58
67
  /**
59
68
  * Model requirements for the image generation variant
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Default placeholder variants shown when an agent is still composing a response.
3
+ *
4
+ * @private BUT maybe export via some package
5
+ */
6
+ export declare const DEFAULT_THINKING_MESSAGES: readonly ["Thinking...", "Searching for information...", "Sorting information..."];
7
+ /** @internal */
8
+ export type ThinkingMessageVariant = (typeof DEFAULT_THINKING_MESSAGES)[number];
@@ -0,0 +1,38 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import type { string_data_url, string_filename } from '../../types/typeAliases';
4
+ /**
5
+ * @@@
6
+ *
7
+ * @private thing of inline knowledge
8
+ */
9
+ export type InlineKnowledgeSourceFile = {
10
+ readonly filename: string_filename;
11
+ readonly mimeType: string;
12
+ readonly url: string_data_url;
13
+ };
14
+ /**
15
+ * Creates a data URL that represents the inline knowledge content as a text file.
16
+ *
17
+ * @private thing of inline knowledge
18
+ */
19
+ export declare function createInlineKnowledgeSourceFile(content: string): InlineKnowledgeSourceFile;
20
+ /**
21
+ * Checks whether the provided source string is a data URL that can be decoded.
22
+ *
23
+ * @private thing of inline knowledge
24
+ */
25
+ export declare function isDataUrlKnowledgeSource(source: string): source is string_data_url;
26
+ /**
27
+ * Parses a data URL-based knowledge source into its raw buffer, filename, and MIME type.
28
+ *
29
+ * @private thing of inline knowledge
30
+ */
31
+ export declare function parseDataUrlKnowledgeSource(source: string): {
32
+ readonly buffer: Buffer;
33
+ readonly filename: string_filename;
34
+ readonly mimeType: string;
35
+ } | null;
36
+ /**
37
+ * Note: [💞] Ignore a discrepancy between file name and entity name
38
+ */
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @@@
3
+ *
4
+ * @private function of Agents Server speech recognition language resolution, not a general-purpose utility
5
+ */
6
+ type ResolveSpeechRecognitionLanguageOptions = {
7
+ /**
8
+ * Overrides the default language resolution when provided.
9
+ */
10
+ readonly overrideLanguage?: string | null;
11
+ /**
12
+ * Optional Accept-Language header string to derive the speaker language from server-side requests.
13
+ */
14
+ readonly acceptLanguageHeader?: string | null;
15
+ };
16
+ /**
17
+ * Parses the primary language out of an Accept-Language header value.
18
+ *
19
+ * @private function of Agents Server speech recognition language resolution, not a general-purpose utility
20
+ */
21
+ export declare function parseSpeechRecognitionLanguageFromAcceptLanguageHeader(header?: string | null): string | undefined;
22
+ /**
23
+ * Reads the browser-reported preferred language list and returns the first valid tag.
24
+ *
25
+ * @private function of Agents Server speech recognition language resolution, not a general-purpose utility
26
+ */
27
+ export declare function getBrowserPreferredSpeechRecognitionLanguage(): string | undefined;
28
+ /**
29
+ * Resolves a speech recognition language tag by checking an optional override, then the Accept-Language header,
30
+ * then the browser preferences, and finally falling back to a default of `en-US`.
31
+ *
32
+ * @private function of Agents Server speech recognition language resolution, not a general-purpose utility
33
+ */
34
+ export declare function resolveSpeechRecognitionLanguage(options?: ResolveSpeechRecognitionLanguageOptions): string;
35
+ export {};
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.110.0-7`).
18
+ * It follows semantic versioning (e.g., `0.110.0-8`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/javascript",
3
- "version": "0.110.0-8",
3
+ "version": "0.110.0-9",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -97,7 +97,7 @@
97
97
  "module": "./esm/index.es.js",
98
98
  "typings": "./esm/typings/src/_packages/javascript.index.d.ts",
99
99
  "peerDependencies": {
100
- "@promptbook/core": "0.110.0-8"
100
+ "@promptbook/core": "0.110.0-9"
101
101
  },
102
102
  "dependencies": {
103
103
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- const PROMPTBOOK_ENGINE_VERSION = '0.110.0-8';
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.110.0-9';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name