@promptbook/wizard 0.104.0-0 → 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/umd/index.umd.js CHANGED
@@ -48,7 +48,7 @@
48
48
  * @generated
49
49
  * @see https://github.com/webgptorg/promptbook
50
50
  */
51
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-0';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-2';
52
52
  /**
53
53
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
54
54
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4711,13 +4711,15 @@
4711
4711
  *
4712
4712
  * @public exported from `@promptbook/utils`
4713
4713
  */
4714
- const $isRunningInJest = new Function(`
4715
- try {
4716
- return process.env.JEST_WORKER_ID !== undefined;
4717
- } catch (e) {
4718
- return false;
4714
+ function $isRunningInJest() {
4715
+ var _a;
4716
+ try {
4717
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
4718
+ }
4719
+ catch (e) {
4720
+ return false;
4721
+ }
4719
4722
  }
4720
- `);
4721
4723
  /**
4722
4724
  * TODO: [🎺]
4723
4725
  */
@@ -5577,13 +5579,14 @@
5577
5579
  *
5578
5580
  * @public exported from `@promptbook/utils`
5579
5581
  */
5580
- const $isRunningInBrowser = new Function(`
5581
- try {
5582
- return this === window;
5583
- } catch (e) {
5584
- return false;
5582
+ function $isRunningInBrowser() {
5583
+ try {
5584
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
5585
+ }
5586
+ catch (e) {
5587
+ return false;
5588
+ }
5585
5589
  }
5586
- `);
5587
5590
  /**
5588
5591
  * TODO: [🎺]
5589
5592
  */
@@ -5595,17 +5598,17 @@
5595
5598
  *
5596
5599
  * @public exported from `@promptbook/utils`
5597
5600
  */
5598
- const $isRunningInWebWorker = new Function(`
5599
- try {
5600
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
5601
- return true;
5602
- } else {
5601
+ function $isRunningInWebWorker() {
5602
+ try {
5603
+ // Note: Check for importScripts which is specific to workers
5604
+ // and not available in the main browser thread
5605
+ return (typeof self !== 'undefined' &&
5606
+ typeof self.importScripts === 'function');
5607
+ }
5608
+ catch (e) {
5603
5609
  return false;
5604
5610
  }
5605
- } catch (e) {
5606
- return false;
5607
5611
  }
5608
- `);
5609
5612
  /**
5610
5613
  * TODO: [🎺]
5611
5614
  */
@@ -6793,10 +6796,10 @@
6793
6796
  // <- TODO: [🛄]
6794
6797
  }
6795
6798
  /**
6796
- * Default model for image generation variant.
6799
+ * Default model for completion variant.
6797
6800
  */
6798
6801
  getDefaultImageGenerationModel() {
6799
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
6802
+ return this.getDefaultModel('dall-e-3');
6800
6803
  // <- TODO: [🛄]
6801
6804
  }
6802
6805
  }
@@ -7611,11 +7614,10 @@
7611
7614
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
7612
7615
  }
7613
7616
  /**
7614
- * Default model for image generation variant.
7617
+ * Default model for completion variant.
7615
7618
  */
7616
7619
  getDefaultImageGenerationModel() {
7617
- return this.getDefaultModel('!!!'); // <- TODO: [🧠] Pick the best default model
7618
- // <- TODO: [🛄]
7620
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
7619
7621
  }
7620
7622
  }
7621
7623
  /**
@@ -7707,13 +7709,14 @@
7707
7709
  *
7708
7710
  * @public exported from `@promptbook/utils`
7709
7711
  */
7710
- const $isRunningInNode = new Function(`
7711
- try {
7712
- return this === global;
7713
- } catch (e) {
7714
- return false;
7712
+ function $isRunningInNode() {
7713
+ try {
7714
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
7715
+ }
7716
+ catch (e) {
7717
+ return false;
7718
+ }
7715
7719
  }
7716
- `);
7717
7720
  /**
7718
7721
  * TODO: [🎺]
7719
7722
  */
@@ -14133,6 +14136,114 @@
14133
14136
  * Note: [💞] Ignore a discrepancy between file name and entity name
14134
14137
  */
14135
14138
 
14139
+ /**
14140
+ * DICTIONARY commitment definition
14141
+ *
14142
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
14143
+ * in its reasoning and responses. This ensures consistent terminology usage.
14144
+ *
14145
+ * Key features:
14146
+ * - Multiple DICTIONARY commitments are automatically merged into one
14147
+ * - Content is placed in a dedicated section of the system message
14148
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
14149
+ * - Agent should use the defined terms correctly in responses
14150
+ *
14151
+ * Example usage in agent source:
14152
+ *
14153
+ * ```book
14154
+ * Legal Assistant
14155
+ *
14156
+ * PERSONA You are a knowledgeable legal assistant
14157
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14158
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14159
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14160
+ * ```
14161
+ *
14162
+ * @private [🪔] Maybe export the commitments through some package
14163
+ */
14164
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
14165
+ constructor() {
14166
+ super('DICTIONARY');
14167
+ }
14168
+ /**
14169
+ * Short one-line description of DICTIONARY.
14170
+ */
14171
+ get description() {
14172
+ return 'Define terms and their meanings for consistent terminology usage.';
14173
+ }
14174
+ /**
14175
+ * Icon for this commitment.
14176
+ */
14177
+ get icon() {
14178
+ return '📚';
14179
+ }
14180
+ /**
14181
+ * Markdown documentation for DICTIONARY commitment.
14182
+ */
14183
+ get documentation() {
14184
+ return spaceTrim$1.spaceTrim(`
14185
+ # DICTIONARY
14186
+
14187
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
14188
+
14189
+ ## Key aspects
14190
+
14191
+ - Multiple \`DICTIONARY\` commitments are merged together.
14192
+ - Terms are defined in the format: "Term is definition"
14193
+ - The agent should use these terms consistently in responses.
14194
+ - Definitions help ensure accurate and consistent terminology.
14195
+
14196
+ ## Examples
14197
+
14198
+ \`\`\`book
14199
+ Legal Assistant
14200
+
14201
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
14202
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14203
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14204
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14205
+ \`\`\`
14206
+
14207
+ \`\`\`book
14208
+ Medical Assistant
14209
+
14210
+ PERSONA You are a helpful medical assistant
14211
+ DICTIONARY Hypertension is persistently high blood pressure
14212
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
14213
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
14214
+ \`\`\`
14215
+ `);
14216
+ }
14217
+ applyToAgentModelRequirements(requirements, content) {
14218
+ var _a;
14219
+ const trimmedContent = content.trim();
14220
+ if (!trimmedContent) {
14221
+ return requirements;
14222
+ }
14223
+ // Get existing dictionary entries from metadata
14224
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
14225
+ // Merge the new dictionary entry with existing entries
14226
+ const mergedDictionary = existingDictionary
14227
+ ? `${existingDictionary}\n${trimmedContent}`
14228
+ : trimmedContent;
14229
+ // Store the merged dictionary in metadata for debugging and inspection
14230
+ const updatedMetadata = {
14231
+ ...requirements.metadata,
14232
+ DICTIONARY: mergedDictionary,
14233
+ };
14234
+ // Create the dictionary section for the system message
14235
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
14236
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
14237
+ return {
14238
+ ...this.appendToSystemMessage(requirements, dictionarySection),
14239
+ metadata: updatedMetadata,
14240
+ };
14241
+ }
14242
+ }
14243
+ /**
14244
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14245
+ */
14246
+
14136
14247
  /**
14137
14248
  * FORMAT commitment definition
14138
14249
  *
@@ -16953,6 +17064,7 @@
16953
17064
  new DeleteCommitmentDefinition('CANCEL'),
16954
17065
  new DeleteCommitmentDefinition('DISCARD'),
16955
17066
  new DeleteCommitmentDefinition('REMOVE'),
17067
+ new DictionaryCommitmentDefinition(),
16956
17068
  new OpenCommitmentDefinition(),
16957
17069
  new ClosedCommitmentDefinition(),
16958
17070
  new UseBrowserCommitmentDefinition(),
@@ -17839,6 +17951,7 @@
17839
17951
  return {
17840
17952
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
17841
17953
  agentHash,
17954
+ permanentId: meta.id,
17842
17955
  personaDescription,
17843
17956
  initialMessage,
17844
17957
  meta,
@@ -18564,7 +18677,7 @@
18564
18677
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
18565
18678
  ${morePieces.join('; ')}
18566
18679
  `);
18567
- if ($isRunningInNode) {
18680
+ if ($isRunningInNode()) {
18568
18681
  if (isInstalled && isFullyConfigured) {
18569
18682
  providerMessage = colors__default["default"].green(providerMessage);
18570
18683
  }