@promptbook/wizard 0.104.0-1 → 0.104.0-2

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 (29) hide show
  1. package/esm/index.es.js +140 -27
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +6 -2
  4. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  5. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
  6. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  7. package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
  8. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
  9. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  10. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  11. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +13 -7
  12. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +6 -0
  13. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  14. package/esm/typings/src/commitments/index.d.ts +2 -1
  15. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  16. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  17. package/esm/typings/src/types/typeAliases.d.ts +12 -0
  18. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  19. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  20. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  21. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  22. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  23. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  24. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  25. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  26. package/esm/typings/src/version.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/umd/index.umd.js +146 -33
  29. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
36
36
  * @generated
37
37
  * @see https://github.com/webgptorg/promptbook
38
38
  */
39
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-1';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-2';
40
40
  /**
41
41
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
42
42
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4699,13 +4699,15 @@ const _AzureOpenAiRegistration = $llmToolsRegister.register(createAzureOpenAiExe
4699
4699
  *
4700
4700
  * @public exported from `@promptbook/utils`
4701
4701
  */
4702
- const $isRunningInJest = new Function(`
4702
+ function $isRunningInJest() {
4703
+ var _a;
4703
4704
  try {
4704
- return process.env.JEST_WORKER_ID !== undefined;
4705
- } catch (e) {
4705
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
4706
+ }
4707
+ catch (e) {
4706
4708
  return false;
4707
4709
  }
4708
- `);
4710
+ }
4709
4711
  /**
4710
4712
  * TODO: [🎺]
4711
4713
  */
@@ -5565,13 +5567,14 @@ const _OllamaMetadataRegistration = $llmToolsMetadataRegister.register({
5565
5567
  *
5566
5568
  * @public exported from `@promptbook/utils`
5567
5569
  */
5568
- const $isRunningInBrowser = new Function(`
5570
+ function $isRunningInBrowser() {
5569
5571
  try {
5570
- return this === window;
5571
- } catch (e) {
5572
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
5573
+ }
5574
+ catch (e) {
5572
5575
  return false;
5573
5576
  }
5574
- `);
5577
+ }
5575
5578
  /**
5576
5579
  * TODO: [🎺]
5577
5580
  */
@@ -5583,17 +5586,17 @@ const $isRunningInBrowser = new Function(`
5583
5586
  *
5584
5587
  * @public exported from `@promptbook/utils`
5585
5588
  */
5586
- const $isRunningInWebWorker = new Function(`
5589
+ function $isRunningInWebWorker() {
5587
5590
  try {
5588
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
5589
- return true;
5590
- } else {
5591
- return false;
5592
- }
5593
- } catch (e) {
5591
+ // Note: Check for importScripts which is specific to workers
5592
+ // and not available in the main browser thread
5593
+ return (typeof self !== 'undefined' &&
5594
+ typeof self.importScripts === 'function');
5595
+ }
5596
+ catch (e) {
5594
5597
  return false;
5595
5598
  }
5596
- `);
5599
+ }
5597
5600
  /**
5598
5601
  * TODO: [🎺]
5599
5602
  */
@@ -6781,10 +6784,10 @@ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
6781
6784
  // <- TODO: [🛄]
6782
6785
  }
6783
6786
  /**
6784
- * Default model for image generation variant.
6787
+ * Default model for completion variant.
6785
6788
  */
6786
6789
  getDefaultImageGenerationModel() {
6787
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
6790
+ return this.getDefaultModel('dall-e-3');
6788
6791
  // <- TODO: [🛄]
6789
6792
  }
6790
6793
  }
@@ -7599,11 +7602,10 @@ class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompatibleExecutionT
7599
7602
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
7600
7603
  }
7601
7604
  /**
7602
- * Default model for image generation variant.
7605
+ * Default model for completion variant.
7603
7606
  */
7604
7607
  getDefaultImageGenerationModel() {
7605
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
7606
- // <- TODO: [🛄]
7608
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
7607
7609
  }
7608
7610
  }
7609
7611
  /**
@@ -7695,13 +7697,14 @@ const $scrapersRegister = new $Register('scraper_constructors');
7695
7697
  *
7696
7698
  * @public exported from `@promptbook/utils`
7697
7699
  */
7698
- const $isRunningInNode = new Function(`
7700
+ function $isRunningInNode() {
7699
7701
  try {
7700
- return this === global;
7701
- } catch (e) {
7702
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
7703
+ }
7704
+ catch (e) {
7702
7705
  return false;
7703
7706
  }
7704
- `);
7707
+ }
7705
7708
  /**
7706
7709
  * TODO: [🎺]
7707
7710
  */
@@ -14121,6 +14124,114 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
14121
14124
  * Note: [💞] Ignore a discrepancy between file name and entity name
14122
14125
  */
14123
14126
 
14127
+ /**
14128
+ * DICTIONARY commitment definition
14129
+ *
14130
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
14131
+ * in its reasoning and responses. This ensures consistent terminology usage.
14132
+ *
14133
+ * Key features:
14134
+ * - Multiple DICTIONARY commitments are automatically merged into one
14135
+ * - Content is placed in a dedicated section of the system message
14136
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
14137
+ * - Agent should use the defined terms correctly in responses
14138
+ *
14139
+ * Example usage in agent source:
14140
+ *
14141
+ * ```book
14142
+ * Legal Assistant
14143
+ *
14144
+ * PERSONA You are a knowledgeable legal assistant
14145
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14146
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14147
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14148
+ * ```
14149
+ *
14150
+ * @private [🪔] Maybe export the commitments through some package
14151
+ */
14152
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
14153
+ constructor() {
14154
+ super('DICTIONARY');
14155
+ }
14156
+ /**
14157
+ * Short one-line description of DICTIONARY.
14158
+ */
14159
+ get description() {
14160
+ return 'Define terms and their meanings for consistent terminology usage.';
14161
+ }
14162
+ /**
14163
+ * Icon for this commitment.
14164
+ */
14165
+ get icon() {
14166
+ return '📚';
14167
+ }
14168
+ /**
14169
+ * Markdown documentation for DICTIONARY commitment.
14170
+ */
14171
+ get documentation() {
14172
+ return spaceTrim$1(`
14173
+ # DICTIONARY
14174
+
14175
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
14176
+
14177
+ ## Key aspects
14178
+
14179
+ - Multiple \`DICTIONARY\` commitments are merged together.
14180
+ - Terms are defined in the format: "Term is definition"
14181
+ - The agent should use these terms consistently in responses.
14182
+ - Definitions help ensure accurate and consistent terminology.
14183
+
14184
+ ## Examples
14185
+
14186
+ \`\`\`book
14187
+ Legal Assistant
14188
+
14189
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
14190
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14191
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14192
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14193
+ \`\`\`
14194
+
14195
+ \`\`\`book
14196
+ Medical Assistant
14197
+
14198
+ PERSONA You are a helpful medical assistant
14199
+ DICTIONARY Hypertension is persistently high blood pressure
14200
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
14201
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
14202
+ \`\`\`
14203
+ `);
14204
+ }
14205
+ applyToAgentModelRequirements(requirements, content) {
14206
+ var _a;
14207
+ const trimmedContent = content.trim();
14208
+ if (!trimmedContent) {
14209
+ return requirements;
14210
+ }
14211
+ // Get existing dictionary entries from metadata
14212
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
14213
+ // Merge the new dictionary entry with existing entries
14214
+ const mergedDictionary = existingDictionary
14215
+ ? `${existingDictionary}\n${trimmedContent}`
14216
+ : trimmedContent;
14217
+ // Store the merged dictionary in metadata for debugging and inspection
14218
+ const updatedMetadata = {
14219
+ ...requirements.metadata,
14220
+ DICTIONARY: mergedDictionary,
14221
+ };
14222
+ // Create the dictionary section for the system message
14223
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
14224
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
14225
+ return {
14226
+ ...this.appendToSystemMessage(requirements, dictionarySection),
14227
+ metadata: updatedMetadata,
14228
+ };
14229
+ }
14230
+ }
14231
+ /**
14232
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14233
+ */
14234
+
14124
14235
  /**
14125
14236
  * FORMAT commitment definition
14126
14237
  *
@@ -16941,6 +17052,7 @@ const COMMITMENT_REGISTRY = [
16941
17052
  new DeleteCommitmentDefinition('CANCEL'),
16942
17053
  new DeleteCommitmentDefinition('DISCARD'),
16943
17054
  new DeleteCommitmentDefinition('REMOVE'),
17055
+ new DictionaryCommitmentDefinition(),
16944
17056
  new OpenCommitmentDefinition(),
16945
17057
  new ClosedCommitmentDefinition(),
16946
17058
  new UseBrowserCommitmentDefinition(),
@@ -17827,6 +17939,7 @@ function parseAgentSource(agentSource) {
17827
17939
  return {
17828
17940
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
17829
17941
  agentHash,
17942
+ permanentId: meta.id,
17830
17943
  personaDescription,
17831
17944
  initialMessage,
17832
17945
  meta,
@@ -18552,7 +18665,7 @@ function $registeredLlmToolsMessage() {
18552
18665
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
18553
18666
  ${morePieces.join('; ')}
18554
18667
  `);
18555
- if ($isRunningInNode) {
18668
+ if ($isRunningInNode()) {
18556
18669
  if (isInstalled && isFullyConfigured) {
18557
18670
  providerMessage = colors.green(providerMessage);
18558
18671
  }