@promptbook/legacy-documents 0.105.0-8 → 0.105.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 (114) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +13 -13
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +21 -11
  7. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/openai.index.d.ts +4 -0
  9. package/esm/typings/src/_packages/types.index.d.ts +32 -2
  10. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  11. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +10 -1
  12. package/esm/typings/src/book-2.0/agent-source/parseTeamCommitment.d.ts +28 -0
  13. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +1 -1
  14. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +5 -0
  15. package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
  16. package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
  17. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +33 -1
  18. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +87 -6
  19. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
  20. package/esm/typings/src/book-components/Chat/Chat/ClockIcon.d.ts +9 -0
  21. package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
  22. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  23. package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
  24. package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
  25. package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
  26. package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
  27. package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
  28. package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
  29. package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
  30. package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
  31. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
  32. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
  33. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
  34. package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
  35. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +34 -6
  36. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +8 -0
  37. package/esm/typings/src/book-components/Chat/utils/createTeamToolNameFromUrl.d.ts +12 -0
  38. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +40 -0
  39. package/esm/typings/src/book-components/Chat/utils/loadAgentProfile.d.ts +69 -0
  40. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
  41. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.d.ts +11 -0
  42. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.test.d.ts +1 -0
  43. package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +64 -0
  44. package/esm/typings/src/book-components/icons/EmailIcon.d.ts +15 -0
  45. package/esm/typings/src/commitments/TEAM/TEAM.d.ts +45 -0
  46. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
  47. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
  48. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +19 -1
  49. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
  50. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
  51. package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +48 -0
  52. package/esm/typings/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +11 -0
  53. package/esm/typings/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +18 -0
  54. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
  55. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
  56. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +5 -0
  57. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +1 -0
  58. package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +6 -0
  59. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  60. package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +6 -0
  61. package/esm/typings/src/commitments/_base/formatOptionalInstructionBlock.d.ts +6 -0
  62. package/esm/typings/src/commitments/_common/commitmentToolFunctions.d.ts +26 -0
  63. package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
  64. package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
  65. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +9 -0
  66. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +13 -0
  67. package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
  68. package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
  69. package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
  70. package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
  71. package/esm/typings/src/commitments/index.d.ts +5 -58
  72. package/esm/typings/src/config.d.ts +6 -0
  73. package/esm/typings/src/constants.d.ts +129 -0
  74. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
  75. package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
  76. package/esm/typings/src/execution/PromptResult.d.ts +2 -19
  77. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +1 -1
  78. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
  79. package/esm/typings/src/llm-providers/agent/Agent.d.ts +15 -1
  80. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
  81. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +5 -0
  82. package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
  83. package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +43 -0
  84. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +4 -2
  85. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +1 -1
  86. package/esm/typings/src/llm-providers/openai/createOpenAiAgentExecutionTools.d.ts +11 -0
  87. package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
  88. package/esm/typings/src/pipeline/prompt-notation.d.ts +27 -2
  89. package/esm/typings/src/pipeline/prompt-notation.test.d.ts +1 -1
  90. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
  91. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
  92. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
  93. package/esm/typings/src/search-engines/SearchEngine.d.ts +1 -1
  94. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
  95. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
  96. package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +1 -1
  97. package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +1 -1
  98. package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +3 -0
  99. package/esm/typings/src/types/ModelRequirements.d.ts +6 -0
  100. package/esm/typings/src/types/Prompt.d.ts +12 -0
  101. package/esm/typings/src/types/ToolCall.d.ts +37 -0
  102. package/esm/typings/src/utils/markdown/extractAllListItemsFromMarkdown.d.ts +1 -2
  103. package/esm/typings/src/utils/markdown/humanizeAiTextEllipsis.d.ts +1 -1
  104. package/esm/typings/src/utils/markdown/humanizeAiTextEmdashed.d.ts +1 -1
  105. package/esm/typings/src/utils/markdown/humanizeAiTextWhitespace.d.ts +1 -1
  106. package/esm/typings/src/utils/markdown/parseMarkdownSection.d.ts +1 -3
  107. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -2
  108. package/esm/typings/src/utils/misc/linguisticHash.d.ts +4 -1
  109. package/esm/typings/src/utils/parameters/templateParameters.d.ts +1 -2
  110. package/esm/typings/src/version.d.ts +1 -1
  111. package/esm/typings/src/wizard/wizard.d.ts +1 -4
  112. package/package.json +2 -2
  113. package/umd/index.umd.js +13 -13
  114. package/umd/index.umd.js.map +1 -1
@@ -71,6 +71,135 @@ export declare const RESERVED_PARAMETER_RESTRICTED: string;
71
71
  * @public exported from `@promptbook/core`
72
72
  */
73
73
  export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
74
+ /**
75
+ * Limits for IDs, names, and other strings
76
+ *
77
+ * @public exported from `@promptbook/core`
78
+ */
79
+ export declare const LIMITS: {
80
+ /**
81
+ * Minimum length of a name (e.g. agent name, persona name)
82
+ */
83
+ readonly NAME_MIN_LENGTH: 3;
84
+ /**
85
+ * Recommended maximum length of a name
86
+ */
87
+ readonly NAME_MAX_LENGTH: 20;
88
+ /**
89
+ * Maximum length of a short description or a hash
90
+ */
91
+ readonly SHORT_TEXT_MAX_LENGTH: 30;
92
+ /**
93
+ * Gone
94
+ */
95
+ readonly GONE: 410;
96
+ /**
97
+ * Gateway timeout
98
+ */
99
+ readonly GATEWAY_TIMEOUT: 504;
100
+ /**
101
+ * Too many requests
102
+ */
103
+ readonly TOO_MANY_REQUESTS: 429;
104
+ /**
105
+ * Maximum length of a file path segment
106
+ */
107
+ readonly FILE_PATH_SEGMENT_MAX_LENGTH: 8;
108
+ /**
109
+ * Default length of a short name (e.g. for default agent names)
110
+ */
111
+ readonly SHORT_NAME_LENGTH: 6;
112
+ };
113
+ /**
114
+ * Common time intervals in milliseconds
115
+ *
116
+ * @public exported from `@promptbook/core`
117
+ */
118
+ export declare const TIME_INTERVALS: {
119
+ /**
120
+ * Hundred milliseconds
121
+ */
122
+ readonly HUNDRED_MILLISECONDS: 100;
123
+ /**
124
+ * One second in milliseconds
125
+ */
126
+ readonly SECOND: 1000;
127
+ /**
128
+ * Two seconds in milliseconds
129
+ */
130
+ readonly TWO_SECONDS: 2000;
131
+ /**
132
+ * One minute in milliseconds
133
+ */
134
+ readonly MINUTE: 60000;
135
+ /**
136
+ * Thirty seconds in milliseconds
137
+ */
138
+ readonly THIRTY_SECONDS: 30000;
139
+ /**
140
+ * Five seconds in milliseconds
141
+ */
142
+ readonly FIVE_SECONDS: 5000;
143
+ };
144
+ /**
145
+ * Common ports and network limits
146
+ *
147
+ * @public exported from `@promptbook/core`
148
+ */
149
+ export declare const NETWORK_LIMITS: {
150
+ /**
151
+ * Maximum valid port number
152
+ */
153
+ readonly MAX_PORT: 65535;
154
+ };
155
+ /**
156
+ * Common color and image constants
157
+ *
158
+ * @public exported from `@promptbook/core`
159
+ */
160
+ export declare const COLOR_CONSTANTS: {
161
+ /**
162
+ * Maximum value for a color channel (0-255)
163
+ */
164
+ readonly MAX_CHANNEL_VALUE: 255;
165
+ /**
166
+ * Number of possible colors in 24-bit color (0xFFFFFF)
167
+ */
168
+ readonly MAX_24BIT_COLOR: 16777215;
169
+ /**
170
+ * Base for hexadecimal strings
171
+ */
172
+ readonly HEX_BASE: 16;
173
+ /**
174
+ * Length of a hex color without alpha (e.g. "FF0000")
175
+ */
176
+ readonly HEX_COLOR_LENGTH: 6;
177
+ /**
178
+ * Full circle in degrees
179
+ */
180
+ readonly FULL_CIRCLE_DEGREES: 360;
181
+ /**
182
+ * Half circle in degrees
183
+ */
184
+ readonly HALF_CIRCLE_DEGREES: 180;
185
+ };
186
+ /**
187
+ * HTTP Status Codes
188
+ *
189
+ * @public exported from `@promptbook/core`
190
+ */
191
+ export declare const HTTP_STATUS_CODES: {
192
+ readonly OK: 200;
193
+ readonly CREATED: 201;
194
+ readonly BAD_REQUEST: 400;
195
+ readonly UNAUTHORIZED: 401;
196
+ readonly NOT_FOUND: 404;
197
+ readonly INTERNAL_SERVER_ERROR: 500;
198
+ readonly BAD_GATEWAY: 502;
199
+ readonly SERVICE_UNAVAILABLE: 503;
200
+ readonly GATEWAY_TIMEOUT: 504;
201
+ readonly TOO_MANY_REQUESTS: 429;
202
+ };
74
203
  /**
75
204
  * Note: [💞] Ignore a discrepancy between file name and entity name
76
205
  */
@@ -9,4 +9,5 @@ export declare function $provideExecutablesForNode(options?: PrepareAndScrapeOpt
9
9
  /**
10
10
  * TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
12
13
  */
@@ -1,8 +1,5 @@
1
1
  import type { ModelVariant } from '../types/ModelVariant';
2
- import type { number_usd } from '../types/typeAliases';
3
- import type { string_model_description } from '../types/typeAliases';
4
- import type { string_model_name } from '../types/typeAliases';
5
- import type { string_title } from '../types/typeAliases';
2
+ import type { number_usd, string_model_description, string_model_name, string_title, string_url } from '../types/typeAliases';
6
3
  /**
7
4
  * Represents a model that can be used for prompt execution
8
5
  */
@@ -40,6 +37,10 @@ export type AvailableModel = {
40
37
  readonly prompt: number_usd;
41
38
  readonly output: number_usd;
42
39
  };
40
+ /**
41
+ * URL to the model (or provider) documentation
42
+ */
43
+ readonly documentationUrl?: string_url;
43
44
  /**
44
45
  * If the model is deprecated, it should not be used for new tasks
45
46
  */
@@ -1,5 +1,5 @@
1
+ import type { ToolCall } from '../types/ToolCall';
1
2
  import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
2
- import type { TODO_any } from '../utils/organization/TODO_any';
3
3
  import type { TODO_object } from '../utils/organization/TODO_object';
4
4
  import type { EmbeddingVector } from './EmbeddingVector';
5
5
  import type { Usage } from './Usage';
@@ -26,24 +26,7 @@ export type ChatPromptResult = CommonPromptResult & {
26
26
  /**
27
27
  * Optional tool calls made during the execution
28
28
  */
29
- readonly toolCalls?: ReadonlyArray<{
30
- /**
31
- * Name of the tool
32
- */
33
- readonly name: string;
34
- /**
35
- * Arguments of the tool call
36
- */
37
- readonly arguments: string;
38
- /**
39
- * Result of the tool call
40
- */
41
- readonly result: string;
42
- /**
43
- * Raw tool call from the model
44
- */
45
- readonly rawToolCall: TODO_any;
46
- }>;
29
+ readonly toolCalls?: ReadonlyArray<ToolCall>;
47
30
  };
48
31
  /**
49
32
  * Image prompt result
@@ -1,8 +1,8 @@
1
1
  import type { PartialDeep, Promisable, ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
+ import type { LlmCall } from '../../types/LlmCall';
3
4
  import type { InputParameters } from '../../types/typeAliases';
4
5
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
5
- import type { LlmCall } from '../../types/LlmCall';
6
6
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
7
7
  /**
8
8
  * Options for executing an entire pipeline, including input parameters, pipeline context, and progress callbacks.
@@ -10,4 +10,5 @@ import type { ExecutionTools } from '../ExecutionTools';
10
10
  export declare function $provideExecutionToolsForNode(options?: PrepareAndScrapeOptions): Promise<ExecutionTools>;
11
11
  /**
12
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
13
14
  */
@@ -14,7 +14,8 @@ import type { AgentOptions } from './AgentOptions';
14
14
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
15
15
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
16
16
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
17
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
17
+ * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
18
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
18
19
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
19
20
  *
20
21
  * @public exported from `@promptbook/core`
@@ -50,6 +51,15 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
50
51
  question: string | null;
51
52
  answer: string;
52
53
  }>;
54
+ /**
55
+ * Knowledge sources (documents, URLs) used by the agent
56
+ * This is parsed from KNOWLEDGE commitments
57
+ * Used for resolving document citations when the agent references sources
58
+ */
59
+ knowledgeSources: Array<{
60
+ url: string;
61
+ filename: string;
62
+ }>;
53
63
  /**
54
64
  * Computed hash of the agent source for integrity verification
55
65
  */
@@ -67,6 +77,10 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
67
77
  description?: string;
68
78
  [key: string]: string | undefined;
69
79
  };
80
+ /**
81
+ * Human-readable titles for tool functions
82
+ */
83
+ toolTitles: Record<string, string>;
70
84
  /**
71
85
  * Not used in Agent, always returns empty array
72
86
  */
@@ -16,7 +16,8 @@ import type { CreateAgentLlmExecutionToolsOptions } from './CreateAgentLlmExecut
16
16
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
17
17
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
18
18
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
19
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
19
+ * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
20
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
20
21
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
21
22
  *
22
23
  * @public exported from `@promptbook/core`
@@ -27,6 +28,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
27
28
  * Cache of OpenAI assistants to avoid creating duplicates
28
29
  */
29
30
  private static assistantCache;
31
+ /**
32
+ * Cache of OpenAI vector stores to avoid creating duplicates
33
+ */
34
+ private static vectorStoreCache;
30
35
  /**
31
36
  * Cached model requirements to avoid re-parsing the agent source
32
37
  */
@@ -23,7 +23,12 @@ export declare class RemoteAgent extends Agent {
23
23
  private agentUrl;
24
24
  private _remoteAgentName;
25
25
  private _remoteAgentHash;
26
+ toolTitles: Record<string, string>;
26
27
  private _isVoiceCallingEnabled;
28
+ knowledgeSources: Array<{
29
+ url: string;
30
+ filename: string;
31
+ }>;
27
32
  private constructor();
28
33
  get agentName(): string_agent_name;
29
34
  get agentHash(): string_agent_hash;
@@ -10,5 +10,6 @@ export declare const createGoogleExecutionTools: ((options: GoogleExecutionTools
10
10
  className: string;
11
11
  };
12
12
  /**
13
+ * TODO: !!!!! Rename to `createGoogleLlmExecutionTools`, `...GoogleLlmExecutionTools`
13
14
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14
15
  */
@@ -0,0 +1,43 @@
1
+ import OpenAI from 'openai';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { ChatPromptResult } from '../../execution/PromptResult';
4
+ import type { Prompt } from '../../types/Prompt';
5
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
6
+ import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
7
+ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
8
+ /**
9
+ * Options for OpenAiAgentExecutionTools
10
+ */
11
+ export type OpenAiAgentExecutionToolsOptions = OpenAiCompatibleExecutionToolsNonProxiedOptions & {
12
+ /**
13
+ * ID of the vector store to use for file search
14
+ */
15
+ readonly vectorStoreId?: string;
16
+ };
17
+ /**
18
+ * Execution Tools for calling OpenAI API using the Responses API (Agents)
19
+ *
20
+ * @public exported from `@promptbook/openai`
21
+ */
22
+ export declare class OpenAiAgentExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
23
+ readonly vectorStoreId?: string;
24
+ constructor(options: OpenAiAgentExecutionToolsOptions);
25
+ get title(): string_title & string_markdown_text;
26
+ get description(): string_markdown;
27
+ /**
28
+ * Calls OpenAI API to use a chat model with streaming.
29
+ */
30
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
31
+ /**
32
+ * Creates a vector store from knowledge sources
33
+ */
34
+ static createVectorStore(client: OpenAI, name: string, knowledgeSources: ReadonlyArray<string>): Promise<string>;
35
+ /**
36
+ * Discriminant for type guards
37
+ */
38
+ protected get discriminant(): string;
39
+ /**
40
+ * Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAgentExecutionTools`
41
+ */
42
+ static isOpenAiAgentExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAgentExecutionTools;
43
+ }
@@ -18,6 +18,7 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
18
18
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
19
19
  *
20
20
  * @public exported from `@promptbook/openai`
21
+ * @deprecated Use `OpenAiAgentExecutionTools` instead which uses the new OpenAI Responses API
21
22
  */
22
23
  export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
23
24
  readonly assistantId: string_token;
@@ -33,11 +34,11 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
33
34
  /**
34
35
  * Calls OpenAI API to use a chat model.
35
36
  */
36
- callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
37
+ callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
37
38
  /**
38
39
  * Calls OpenAI API to use a chat model with streaming.
39
40
  */
40
- callChatModelStream(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
41
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
41
42
  /**
42
43
  * Get an existing assistant tool wrapper
43
44
  */
@@ -94,6 +95,7 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
94
95
  static isOpenAiAssistantExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAssistantExecutionTools;
95
96
  }
96
97
  /**
98
+ * TODO: !!!!! [✨🥚] Knowledge should work both with and without scrapers
97
99
  * TODO: [🙎] In `OpenAiAssistantExecutionTools` Allow to create abstract assistants with `isCreatingNewAssistantsAllowed`
98
100
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizard for those who want to use just OpenAI
99
101
  * TODO: Maybe make custom OpenAiError
@@ -73,7 +73,7 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
73
73
  /**
74
74
  * Calls OpenAI compatible API to use a image generation model
75
75
  */
76
- callImageGenerationModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ImagePromptResult>;
76
+ callImageGenerationModel(prompt: Prompt): Promise<ImagePromptResult>;
77
77
  /**
78
78
  * Internal method that handles parameter retry for image generation model calls
79
79
  */
@@ -0,0 +1,11 @@
1
+ import { OpenAiAgentExecutionTools } from './OpenAiAgentExecutionTools';
2
+ import type { OpenAiAgentExecutionToolsOptions } from './OpenAiAgentExecutionTools';
3
+ /**
4
+ * Execution Tools for calling OpenAI API using Responses API
5
+ *
6
+ * @public exported from `@promptbook/openai`
7
+ */
8
+ export declare const createOpenAiAgentExecutionTools: ((options: OpenAiAgentExecutionToolsOptions) => OpenAiAgentExecutionTools) & {
9
+ packageName: string;
10
+ className: string;
11
+ };
@@ -0,0 +1,7 @@
1
+ import OpenAI from 'openai';
2
+ /**
3
+ * Uploads files to OpenAI and returns their IDs
4
+ *
5
+ * @private utility for `OpenAiAssistantExecutionTools` and `OpenAiCompatibleExecutionTools`
6
+ */
7
+ export declare function uploadFilesToOpenAi(client: OpenAI, files: Array<File>): Promise<Array<string>>;
@@ -1,4 +1,28 @@
1
1
  import type { string_prompt } from '../types/typeAliases';
2
+ import type { really_unknown } from '../utils/organization/really_unknown';
3
+ /**
4
+ * Prompt string wrapper to retain prompt context across interpolations.
5
+ *
6
+ * @public exported from `@promptbook/utils`
7
+ */
8
+ export declare class PromptString extends String {
9
+ /**
10
+ * @param value Prompt content.
11
+ */
12
+ constructor(value: string_prompt);
13
+ /**
14
+ * Returns the prompt as a primitive string.
15
+ */
16
+ toString(): string_prompt;
17
+ /**
18
+ * Returns the prompt as a primitive string for implicit coercion.
19
+ */
20
+ valueOf(): string_prompt;
21
+ /**
22
+ * Ensures template literal coercion returns the raw string.
23
+ */
24
+ [Symbol.toPrimitive](): string_prompt;
25
+ }
2
26
  /**
3
27
  * Tag function for notating a prompt as template literal
4
28
  *
@@ -9,10 +33,10 @@ import type { string_prompt } from '../types/typeAliases';
9
33
  *
10
34
  * @param strings
11
35
  * @param values
12
- * @returns the prompt string
36
+ * @returns prompt content wrapped as a PromptString
13
37
  * @public exported from `@promptbook/utils`
14
38
  */
15
- export declare function prompt(strings: TemplateStringsArray, ...values: Array<string>): string_prompt;
39
+ export declare function prompt(strings: TemplateStringsArray, ...values: Array<really_unknown>): PromptString;
16
40
  /**
17
41
  * Tag function for notating a prompt as template literal
18
42
  *
@@ -26,6 +50,7 @@ export declare function prompt(strings: TemplateStringsArray, ...values: Array<s
26
50
  */
27
51
  export declare const promptTemplate: typeof prompt;
28
52
  /**
53
+ * TODO: Maybe split into multiple files
29
54
  * TODO: [🧠][🈴] Where is the best location for this file
30
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
31
56
  */
@@ -1,4 +1,4 @@
1
1
  export {};
2
2
  /**
3
- * TODO: [🧠][🈴] Where is the best location for this file
3
+ * TODO: [??][??] Where is the best location for this file
4
4
  */
@@ -9,4 +9,5 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
9
9
  export declare function $provideFilesystemForNode(options?: Pick<PrepareAndScrapeOptions, 'isVerbose'>): FilesystemTools;
10
10
  /**
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
12
13
  */
@@ -10,4 +10,5 @@ import type { Scraper } from '../Scraper';
10
10
  export declare function $provideScrapersForNode(tools: Pick<ExecutionTools, 'fs' | 'llm' | 'executables'>, options?: PrepareAndScrapeOptions): Promise<ReadonlyArray<Scraper>>;
11
11
  /**
12
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
13
14
  */
@@ -8,4 +8,5 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
8
8
  export declare function $provideScriptingForNode(options?: PrepareAndScrapeOptions): Promise<ReadonlyArray<ScriptExecutionTools>>;
9
9
  /**
10
10
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
11
12
  */
@@ -5,5 +5,5 @@ export type SearchEngine = {
5
5
  readonly title: string_title & string_markdown_text;
6
6
  readonly description?: string_markdown;
7
7
  checkConfiguration(): Promisable<void>;
8
- search(query: string): Promise<SearchResult[]>;
8
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
9
9
  };
@@ -11,5 +11,5 @@ export declare class BingSearchEngine implements SearchEngine {
11
11
  get title(): string_title & string_markdown_text;
12
12
  get description(): string_markdown;
13
13
  checkConfiguration(): Promisable<void>;
14
- search(query: string): Promise<SearchResult[]>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
15
  }
@@ -11,5 +11,5 @@ export declare class DummySearchEngine implements SearchEngine {
11
11
  get title(): string_title & string_markdown_text;
12
12
  get description(): string_markdown;
13
13
  checkConfiguration(): Promisable<void>;
14
- search(query: string): Promise<SearchResult[]>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
15
  }
@@ -14,5 +14,5 @@ export declare class GoogleSearchEngine implements SearchEngine {
14
14
  * @see https://developers.google.com/custom-search/v1/overview
15
15
  */
16
16
  checkConfiguration(): Promisable<void>;
17
- search(query: string): Promise<SearchResult[]>;
17
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
18
18
  }
@@ -11,5 +11,5 @@ export declare class SerpSearchEngine implements SearchEngine {
11
11
  get title(): string_title & string_markdown_text;
12
12
  get description(): string_markdown;
13
13
  checkConfiguration(): Promisable<void>;
14
- search(query: string): Promise<SearchResult[]>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
15
  }
@@ -19,6 +19,9 @@ export type OpenAiSpeechRecognitionOptions = {
19
19
  export declare class OpenAiSpeechRecognition implements SpeechRecognition {
20
20
  private readonly options;
21
21
  private mediaRecorder;
22
+ private audioContext;
23
+ private analyser;
24
+ private silenceTimeout;
22
25
  private audioChunks;
23
26
  private callbacks;
24
27
  private _state;
@@ -129,6 +129,12 @@ export type CommonModelRequirements = {
129
129
  * Note: [🚉] This is fully serializable as JSON
130
130
  */
131
131
  readonly tools?: LlmToolDefinition[];
132
+ /**
133
+ * Optional list of knowledge source links that the model can use
134
+ *
135
+ * Note: [🚉] This is fully serializable as JSON
136
+ */
137
+ readonly knowledgeSources?: string[];
132
138
  };
133
139
  /**
134
140
  * TODO: [🧠][🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (similar that `user` identification is not here)
@@ -57,6 +57,10 @@ export type ChatPrompt = CommonPrompt & {
57
57
  * Optional tools that can be called by the model
58
58
  */
59
59
  tools?: Array<LlmToolDefinition>;
60
+ /**
61
+ * Optional file attachments
62
+ */
63
+ files?: Array<File>;
60
64
  };
61
65
  /**
62
66
  * Image prompt
@@ -68,6 +72,14 @@ export type ImagePrompt = CommonPrompt & {
68
72
  * Requirements for image generation model
69
73
  */
70
74
  modelRequirements: ImageGenerationModelRequirements;
75
+ /**
76
+ * Optional file attachments
77
+ */
78
+ attachments?: Array<{
79
+ name: string;
80
+ type: string;
81
+ url: string;
82
+ }>;
71
83
  };
72
84
  /**
73
85
  * Embedding prompt
@@ -0,0 +1,37 @@
1
+ import type { string_date_iso8601 } from './typeAliases';
2
+ import type { TODO_any } from '../utils/organization/TODO_any';
3
+ /**
4
+ * Represents a single tool call with its inputs, outputs, and timing.
5
+ *
6
+ * Note: This is fully serializable as JSON.
7
+ */
8
+ export type ToolCall = {
9
+ /**
10
+ * Name of the tool.
11
+ */
12
+ readonly name: string;
13
+ /**
14
+ * Arguments for the tool call.
15
+ */
16
+ readonly arguments?: string | Record<string, TODO_any>;
17
+ /**
18
+ * Result of the tool call.
19
+ */
20
+ readonly result?: TODO_any;
21
+ /**
22
+ * Raw tool call payload from the model.
23
+ */
24
+ readonly rawToolCall?: TODO_any;
25
+ /**
26
+ * Timestamp when the tool call was initiated.
27
+ */
28
+ readonly createdAt?: string_date_iso8601;
29
+ /**
30
+ * Errors thrown during tool execution.
31
+ */
32
+ readonly errors?: ReadonlyArray<TODO_any>;
33
+ /**
34
+ * Warnings reported during tool execution.
35
+ */
36
+ readonly warnings?: ReadonlyArray<TODO_any>;
37
+ };
@@ -1,5 +1,4 @@
1
- import type { string_markdown } from '../../types/typeAliases';
2
- import type { string_markdown_text } from '../../types/typeAliases';
1
+ import type { string_markdown, string_markdown_text } from '../../types/typeAliases';
3
2
  /**
4
3
  * Utility function to extract all list items from markdown
5
4
  *
@@ -1,6 +1,6 @@
1
1
  import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
- * Change ellipsis character to three dots `…` -> `...`
3
+ * Change ellipsis characters and dot leaders to three dots `…` -> `...`
4
4
  *
5
5
  * Note: [🔂] This function is idempotent.
6
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
@@ -1,6 +1,6 @@
1
1
  import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
- * Change em-dashes to regular dashes `—` -> `-`
3
+ * Change dash-like characters to regular dashes `—` -> `-` and remove soft hyphens
4
4
  *
5
5
  * Note: [🔂] This function is idempotent.
6
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`
@@ -1,6 +1,6 @@
1
1
  import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
- * Change unprintable hard spaces to regular spaces
3
+ * Change unprintable hard spaces to regular spaces and drop zero-width spaces
4
4
  *
5
5
  * Note: [🔂] This function is idempotent.
6
6
  * Tip: If you want to do the full cleanup, look for `humanizeAiText` exported `@promptbook/markdown-utils`