@promptbook/wizard 0.104.0-0 โ†’ 0.104.0-10

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 (42) hide show
  1. package/esm/index.es.js +240 -87
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/servers.d.ts +8 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +10 -2
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  7. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +6 -6
  8. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.closed.test.d.ts +1 -0
  9. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -3
  10. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +5 -1
  11. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +5 -0
  12. package/esm/typings/src/book-components/Chat/CodeBlock/CodeBlock.d.ts +13 -0
  13. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +1 -0
  14. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +7 -11
  15. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  16. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  17. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +21 -11
  18. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +80 -14
  19. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  20. package/esm/typings/src/commitments/index.d.ts +2 -1
  21. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
  22. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  26. package/esm/typings/src/types/Message.d.ts +49 -0
  27. package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
  28. package/esm/typings/src/types/typeAliases.d.ts +23 -1
  29. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
  30. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  31. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  32. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  33. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  34. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  35. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  36. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  37. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  38. package/esm/typings/src/version.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/umd/index.umd.js +246 -93
  41. package/umd/index.umd.js.map +1 -1
  42. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
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-0';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-10';
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
@@ -46,6 +46,8 @@ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-0';
46
46
  * Core Promptbook server configuration.
47
47
  *
48
48
  * This server is also used for auto-federation in the Agents Server.
49
+ *
50
+ * @public exported from `@promptbook/core`
49
51
  */
50
52
  const CORE_SERVER = {
51
53
  title: 'Promptbook Core',
@@ -2526,6 +2528,7 @@ class RemoteLlmExecutionTools {
2526
2528
  }
2527
2529
  }
2528
2530
  /**
2531
+ * TODO: !!!! Deprecate pipeline server and all of its components
2529
2532
  * TODO: Maybe use `$exportJson`
2530
2533
  * TODO: [๐Ÿง ][๐Ÿ›] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
2531
2534
  * TODO: [๐Ÿ“] Allow to list compatible models with each variant
@@ -4699,13 +4702,15 @@ const _AzureOpenAiRegistration = $llmToolsRegister.register(createAzureOpenAiExe
4699
4702
  *
4700
4703
  * @public exported from `@promptbook/utils`
4701
4704
  */
4702
- const $isRunningInJest = new Function(`
4705
+ function $isRunningInJest() {
4706
+ var _a;
4703
4707
  try {
4704
- return process.env.JEST_WORKER_ID !== undefined;
4705
- } catch (e) {
4708
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
4709
+ }
4710
+ catch (e) {
4706
4711
  return false;
4707
4712
  }
4708
- `);
4713
+ }
4709
4714
  /**
4710
4715
  * TODO: [๐ŸŽบ]
4711
4716
  */
@@ -5565,13 +5570,14 @@ const _OllamaMetadataRegistration = $llmToolsMetadataRegister.register({
5565
5570
  *
5566
5571
  * @public exported from `@promptbook/utils`
5567
5572
  */
5568
- const $isRunningInBrowser = new Function(`
5573
+ function $isRunningInBrowser() {
5569
5574
  try {
5570
- return this === window;
5571
- } catch (e) {
5575
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
5576
+ }
5577
+ catch (e) {
5572
5578
  return false;
5573
5579
  }
5574
- `);
5580
+ }
5575
5581
  /**
5576
5582
  * TODO: [๐ŸŽบ]
5577
5583
  */
@@ -5583,17 +5589,17 @@ const $isRunningInBrowser = new Function(`
5583
5589
  *
5584
5590
  * @public exported from `@promptbook/utils`
5585
5591
  */
5586
- const $isRunningInWebWorker = new Function(`
5592
+ function $isRunningInWebWorker() {
5587
5593
  try {
5588
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
5589
- return true;
5590
- } else {
5591
- return false;
5592
- }
5593
- } catch (e) {
5594
+ // Note: Check for importScripts which is specific to workers
5595
+ // and not available in the main browser thread
5596
+ return (typeof self !== 'undefined' &&
5597
+ typeof self.importScripts === 'function');
5598
+ }
5599
+ catch (e) {
5594
5600
  return false;
5595
5601
  }
5596
- `);
5602
+ }
5597
5603
  /**
5598
5604
  * TODO: [๐ŸŽบ]
5599
5605
  */
@@ -5825,7 +5831,7 @@ class OpenAiCompatibleExecutionTools {
5825
5831
  let threadMessages = [];
5826
5832
  if ('thread' in prompt && Array.isArray(prompt.thread)) {
5827
5833
  threadMessages = prompt.thread.map((msg) => ({
5828
- role: msg.role === 'assistant' ? 'assistant' : 'user',
5834
+ role: msg.sender === 'assistant' ? 'assistant' : 'user',
5829
5835
  content: msg.content,
5830
5836
  }));
5831
5837
  }
@@ -6238,13 +6244,14 @@ class OpenAiCompatibleExecutionTools {
6238
6244
  const modelName = currentModelRequirements.modelName || this.getDefaultImageGenerationModel().modelName;
6239
6245
  const modelSettings = {
6240
6246
  model: modelName,
6241
- // size: currentModelRequirements.size,
6242
- // quality: currentModelRequirements.quality,
6243
- // style: currentModelRequirements.style,
6247
+ size: currentModelRequirements.size,
6248
+ quality: currentModelRequirements.quality,
6249
+ style: currentModelRequirements.style,
6244
6250
  };
6245
6251
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
6246
6252
  const rawRequest = {
6247
6253
  ...modelSettings,
6254
+ size: modelSettings.size || '1024x1024',
6248
6255
  prompt: rawPromptContent,
6249
6256
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
6250
6257
  response_format: 'url', // TODO: [๐Ÿง ] Maybe allow b64_json
@@ -6781,10 +6788,10 @@ class OllamaExecutionTools extends OpenAiCompatibleExecutionTools {
6781
6788
  // <- TODO: [๐Ÿ›„]
6782
6789
  }
6783
6790
  /**
6784
- * Default model for image generation variant.
6791
+ * Default model for completion variant.
6785
6792
  */
6786
6793
  getDefaultImageGenerationModel() {
6787
- return this.getDefaultModel('!!!'); // <- TODO: [๐Ÿง ] Pick the best default model
6794
+ return this.getDefaultModel('dall-e-3');
6788
6795
  // <- TODO: [๐Ÿ›„]
6789
6796
  }
6790
6797
  }
@@ -7599,11 +7606,10 @@ class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompatibleExecutionT
7599
7606
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
7600
7607
  }
7601
7608
  /**
7602
- * Default model for image generation variant.
7609
+ * Default model for completion variant.
7603
7610
  */
7604
7611
  getDefaultImageGenerationModel() {
7605
- return this.getDefaultModel('!!!'); // <- TODO: [๐Ÿง ] Pick the best default model
7606
- // <- TODO: [๐Ÿ›„]
7612
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
7607
7613
  }
7608
7614
  }
7609
7615
  /**
@@ -7695,13 +7701,14 @@ const $scrapersRegister = new $Register('scraper_constructors');
7695
7701
  *
7696
7702
  * @public exported from `@promptbook/utils`
7697
7703
  */
7698
- const $isRunningInNode = new Function(`
7704
+ function $isRunningInNode() {
7699
7705
  try {
7700
- return this === global;
7701
- } catch (e) {
7706
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
7707
+ }
7708
+ catch (e) {
7702
7709
  return false;
7703
7710
  }
7704
- `);
7711
+ }
7705
7712
  /**
7706
7713
  * TODO: [๐ŸŽบ]
7707
7714
  */
@@ -9414,6 +9421,15 @@ function countUsage(llmTools) {
9414
9421
  return promptResult;
9415
9422
  };
9416
9423
  }
9424
+ if (llmTools.callImageGenerationModel !== undefined) {
9425
+ proxyTools.callImageGenerationModel = async (prompt) => {
9426
+ // console.info('[๐Ÿš•] callImageGenerationModel through countTotalUsage');
9427
+ const promptResult = await llmTools.callImageGenerationModel(prompt);
9428
+ totalUsage = addUsage(totalUsage, promptResult.usage);
9429
+ spending.next(promptResult.usage);
9430
+ return promptResult;
9431
+ };
9432
+ }
9417
9433
  // <- Note: [๐Ÿค–]
9418
9434
  return proxyTools;
9419
9435
  }
@@ -9523,6 +9539,12 @@ class MultipleLlmExecutionTools {
9523
9539
  callEmbeddingModel(prompt) {
9524
9540
  return this.callCommonModel(prompt);
9525
9541
  }
9542
+ /**
9543
+ * Calls the best available embedding model
9544
+ */
9545
+ callImageGenerationModel(prompt) {
9546
+ return this.callCommonModel(prompt);
9547
+ }
9526
9548
  // <- Note: [๐Ÿค–]
9527
9549
  /**
9528
9550
  * Calls the best available model
@@ -9549,6 +9571,11 @@ class MultipleLlmExecutionTools {
9549
9571
  continue llm;
9550
9572
  }
9551
9573
  return await llmExecutionTools.callEmbeddingModel(prompt);
9574
+ case 'IMAGE_GENERATION':
9575
+ if (llmExecutionTools.callImageGenerationModel === undefined) {
9576
+ continue llm;
9577
+ }
9578
+ return await llmExecutionTools.callImageGenerationModel(prompt);
9552
9579
  // <- case [๐Ÿค–]:
9553
9580
  default:
9554
9581
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
@@ -11252,8 +11279,9 @@ async function executeAttempts(options) {
11252
11279
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
11253
11280
  break variant;
11254
11281
  case 'EMBEDDING':
11282
+ case 'IMAGE_GENERATION':
11255
11283
  throw new PipelineExecutionError(spaceTrim$1((block) => `
11256
- Embedding model can not be used in pipeline
11284
+ ${modelRequirements.modelVariant} model can not be used in pipeline
11257
11285
 
11258
11286
  This should be catched during parsing
11259
11287
 
@@ -14121,6 +14149,114 @@ class DeleteCommitmentDefinition extends BaseCommitmentDefinition {
14121
14149
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14122
14150
  */
14123
14151
 
14152
+ /**
14153
+ * DICTIONARY commitment definition
14154
+ *
14155
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
14156
+ * in its reasoning and responses. This ensures consistent terminology usage.
14157
+ *
14158
+ * Key features:
14159
+ * - Multiple DICTIONARY commitments are automatically merged into one
14160
+ * - Content is placed in a dedicated section of the system message
14161
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
14162
+ * - Agent should use the defined terms correctly in responses
14163
+ *
14164
+ * Example usage in agent source:
14165
+ *
14166
+ * ```book
14167
+ * Legal Assistant
14168
+ *
14169
+ * PERSONA You are a knowledgeable legal assistant
14170
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14171
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14172
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14173
+ * ```
14174
+ *
14175
+ * @private [๐Ÿช”] Maybe export the commitments through some package
14176
+ */
14177
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
14178
+ constructor() {
14179
+ super('DICTIONARY');
14180
+ }
14181
+ /**
14182
+ * Short one-line description of DICTIONARY.
14183
+ */
14184
+ get description() {
14185
+ return 'Define terms and their meanings for consistent terminology usage.';
14186
+ }
14187
+ /**
14188
+ * Icon for this commitment.
14189
+ */
14190
+ get icon() {
14191
+ return '๐Ÿ“š';
14192
+ }
14193
+ /**
14194
+ * Markdown documentation for DICTIONARY commitment.
14195
+ */
14196
+ get documentation() {
14197
+ return spaceTrim$1(`
14198
+ # DICTIONARY
14199
+
14200
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
14201
+
14202
+ ## Key aspects
14203
+
14204
+ - Multiple \`DICTIONARY\` commitments are merged together.
14205
+ - Terms are defined in the format: "Term is definition"
14206
+ - The agent should use these terms consistently in responses.
14207
+ - Definitions help ensure accurate and consistent terminology.
14208
+
14209
+ ## Examples
14210
+
14211
+ \`\`\`book
14212
+ Legal Assistant
14213
+
14214
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
14215
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14216
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14217
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14218
+ \`\`\`
14219
+
14220
+ \`\`\`book
14221
+ Medical Assistant
14222
+
14223
+ PERSONA You are a helpful medical assistant
14224
+ DICTIONARY Hypertension is persistently high blood pressure
14225
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
14226
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
14227
+ \`\`\`
14228
+ `);
14229
+ }
14230
+ applyToAgentModelRequirements(requirements, content) {
14231
+ var _a;
14232
+ const trimmedContent = content.trim();
14233
+ if (!trimmedContent) {
14234
+ return requirements;
14235
+ }
14236
+ // Get existing dictionary entries from metadata
14237
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
14238
+ // Merge the new dictionary entry with existing entries
14239
+ const mergedDictionary = existingDictionary
14240
+ ? `${existingDictionary}\n${trimmedContent}`
14241
+ : trimmedContent;
14242
+ // Store the merged dictionary in metadata for debugging and inspection
14243
+ const updatedMetadata = {
14244
+ ...requirements.metadata,
14245
+ DICTIONARY: mergedDictionary,
14246
+ };
14247
+ // Create the dictionary section for the system message
14248
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
14249
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
14250
+ return {
14251
+ ...this.appendToSystemMessage(requirements, dictionarySection),
14252
+ metadata: updatedMetadata,
14253
+ };
14254
+ }
14255
+ }
14256
+ /**
14257
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14258
+ */
14259
+
14124
14260
  /**
14125
14261
  * FORMAT commitment definition
14126
14262
  *
@@ -16941,6 +17077,7 @@ const COMMITMENT_REGISTRY = [
16941
17077
  new DeleteCommitmentDefinition('CANCEL'),
16942
17078
  new DeleteCommitmentDefinition('DISCARD'),
16943
17079
  new DeleteCommitmentDefinition('REMOVE'),
17080
+ new DictionaryCommitmentDefinition(),
16944
17081
  new OpenCommitmentDefinition(),
16945
17082
  new ClosedCommitmentDefinition(),
16946
17083
  new UseBrowserCommitmentDefinition(),
@@ -17025,17 +17162,64 @@ function parseAgentSourceWithCommitments(agentSource) {
17025
17162
  };
17026
17163
  }
17027
17164
  const lines = agentSource.split('\n');
17028
- const agentName = (((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null);
17165
+ let agentName = null;
17166
+ let agentNameLineIndex = -1;
17167
+ // Find the agent name: first non-empty line that is not a commitment and not a horizontal line
17168
+ for (let i = 0; i < lines.length; i++) {
17169
+ const line = lines[i];
17170
+ if (line === undefined) {
17171
+ continue;
17172
+ }
17173
+ const trimmed = line.trim();
17174
+ if (!trimmed) {
17175
+ continue;
17176
+ }
17177
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17178
+ if (isHorizontal) {
17179
+ continue;
17180
+ }
17181
+ let isCommitment = false;
17182
+ for (const definition of COMMITMENT_REGISTRY) {
17183
+ const typeRegex = definition.createTypeRegex();
17184
+ const match = typeRegex.exec(trimmed);
17185
+ if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
17186
+ isCommitment = true;
17187
+ break;
17188
+ }
17189
+ }
17190
+ if (!isCommitment) {
17191
+ agentName = trimmed;
17192
+ agentNameLineIndex = i;
17193
+ break;
17194
+ }
17195
+ }
17029
17196
  const commitments = [];
17030
17197
  const nonCommitmentLines = [];
17031
- // Always add the first line (agent name) to non-commitment lines
17032
- if (lines[0] !== undefined) {
17033
- nonCommitmentLines.push(lines[0]);
17198
+ // Add lines before agentName that are horizontal lines (they are non-commitment)
17199
+ for (let i = 0; i < agentNameLineIndex; i++) {
17200
+ const line = lines[i];
17201
+ if (line === undefined) {
17202
+ continue;
17203
+ }
17204
+ const trimmed = line.trim();
17205
+ if (!trimmed) {
17206
+ continue;
17207
+ }
17208
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17209
+ if (isHorizontal) {
17210
+ nonCommitmentLines.push(line);
17211
+ }
17212
+ // Note: Commitments before agentName are not added to nonCommitmentLines
17213
+ }
17214
+ // Add the agent name line to non-commitment lines
17215
+ if (agentNameLineIndex >= 0) {
17216
+ nonCommitmentLines.push(lines[agentNameLineIndex]);
17034
17217
  }
17035
17218
  // Parse commitments with multiline support
17036
17219
  let currentCommitment = null;
17037
- // Process lines starting from the second line (skip agent name)
17038
- for (let i = 1; i < lines.length; i++) {
17220
+ // Process lines starting from after the agent name line
17221
+ const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
17222
+ for (let i = startIndex; i < lines.length; i++) {
17039
17223
  const line = lines[i];
17040
17224
  if (line === undefined) {
17041
17225
  continue;
@@ -17255,7 +17439,12 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
17255
17439
  };
17256
17440
  }
17257
17441
  // Apply each commitment in order using reduce-like pattern
17258
- for (const commitment of filteredCommitments) {
17442
+ for (let i = 0; i < filteredCommitments.length; i++) {
17443
+ const commitment = filteredCommitments[i];
17444
+ // CLOSED commitment should work only if its the last commitment in the book
17445
+ if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
17446
+ continue;
17447
+ }
17259
17448
  const definition = getCommitmentDefinition(commitment.type);
17260
17449
  if (definition) {
17261
17450
  try {
@@ -17350,44 +17539,6 @@ function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
17350
17539
  * TODO: [๐ŸŒบ] Use some intermediate util splitWords
17351
17540
  */
17352
17541
 
17353
- /**
17354
- * Generates a gravatar URL based on agent name for fallback avatar
17355
- *
17356
- * @param agentName The agent name to generate avatar for
17357
- * @returns Gravatar URL
17358
- *
17359
- * @private - [๐Ÿคน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
17360
- */
17361
- function generateGravatarUrl(agentName) {
17362
- // Use a default name if none provided
17363
- const safeName = agentName || 'Anonymous Agent';
17364
- // Create a simple hash from the name for consistent avatar
17365
- let hash = 0;
17366
- for (let i = 0; i < safeName.length; i++) {
17367
- const char = safeName.charCodeAt(i);
17368
- hash = (hash << 5) - hash + char;
17369
- hash = hash & hash; // Convert to 32bit integer
17370
- }
17371
- const avatarId = Math.abs(hash).toString();
17372
- return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
17373
- }
17374
-
17375
- /**
17376
- * Generates an image for the agent to use as profile image
17377
- *
17378
- * @param agentName The agent name to generate avatar for
17379
- * @returns The placeholder profile image URL for the agent
17380
- *
17381
- * @public exported from `@promptbook/core`
17382
- */
17383
- function generatePlaceholderAgentProfileImageUrl(agentName) {
17384
- // Note: [๐Ÿคน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
17385
- return generateGravatarUrl(agentName);
17386
- }
17387
- /**
17388
- * TODO: [๐Ÿคน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
17389
- */
17390
-
17391
17542
  /**
17392
17543
  * Computes SHA-256 hash of the given object
17393
17544
  *
@@ -17812,10 +17963,6 @@ function parseAgentSource(agentSource) {
17812
17963
  const metaType = normalizeTo_camelCase(metaTypeRaw);
17813
17964
  meta[metaType] = spaceTrim$2(commitment.content.substring(metaTypeRaw.length));
17814
17965
  }
17815
- // Generate gravatar fallback if no meta image specified
17816
- if (!meta.image) {
17817
- meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
17818
- }
17819
17966
  // Generate fullname fallback if no meta fullname specified
17820
17967
  if (!meta.fullname) {
17821
17968
  meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
@@ -17827,6 +17974,7 @@ function parseAgentSource(agentSource) {
17827
17974
  return {
17828
17975
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
17829
17976
  agentHash,
17977
+ permanentId: meta.id,
17830
17978
  personaDescription,
17831
17979
  initialMessage,
17832
17980
  meta,
@@ -18552,7 +18700,7 @@ function $registeredLlmToolsMessage() {
18552
18700
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
18553
18701
  ${morePieces.join('; ')}
18554
18702
  `);
18555
- if ($isRunningInNode) {
18703
+ if ($isRunningInNode()) {
18556
18704
  if (isInstalled && isFullyConfigured) {
18557
18705
  providerMessage = colors.green(providerMessage);
18558
18706
  }
@@ -18949,6 +19097,9 @@ function cacheLlmTools(llmTools, options = {}) {
18949
19097
  case 'EMBEDDING':
18950
19098
  promptResult = await llmTools.callEmbeddingModel(prompt);
18951
19099
  break variant;
19100
+ case 'IMAGE_GENERATION':
19101
+ promptResult = await llmTools.callImageGenerationModel(prompt);
19102
+ break variant;
18952
19103
  // <- case [๐Ÿค–]:
18953
19104
  default:
18954
19105
  throw new PipelineExecutionError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -18985,12 +19136,13 @@ function cacheLlmTools(llmTools, options = {}) {
18985
19136
  }
18986
19137
  }
18987
19138
  catch (error) {
19139
+ assertsError(error);
18988
19140
  // If validation throws an unexpected error, don't cache
18989
19141
  shouldCache = false;
18990
19142
  if (isVerbose) {
18991
19143
  console.info('Not caching result due to validation error for key:', key, {
18992
19144
  content: promptResult.content,
18993
- validationError: error instanceof Error ? error.message : String(error),
19145
+ validationError: serializeError(error),
18994
19146
  });
18995
19147
  }
18996
19148
  }
@@ -19036,6 +19188,11 @@ function cacheLlmTools(llmTools, options = {}) {
19036
19188
  return /* not await */ callCommonModel(prompt);
19037
19189
  };
19038
19190
  }
19191
+ if (llmTools.callImageGenerationModel !== undefined) {
19192
+ proxyTools.callImageGenerationModel = async (prompt) => {
19193
+ return /* not await */ callCommonModel(prompt);
19194
+ };
19195
+ }
19039
19196
  // <- Note: [๐Ÿค–]
19040
19197
  return proxyTools;
19041
19198
  }
@@ -21165,11 +21322,7 @@ const modelCommandParser = {
21165
21322
  // TODO: [๐Ÿšœ] DRY
21166
21323
  if ($taskJson.modelRequirements[command.key] !== undefined) {
21167
21324
  if ($taskJson.modelRequirements[command.key] === command.value) {
21168
- console.warn(`Multiple commands \`MODEL ${{
21169
- modelName: 'NAME',
21170
- modelVariant: 'VARIANT',
21171
- maxTokens: '???',
21172
- }[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
21325
+ console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
21173
21326
  // <- TODO: [๐Ÿฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
21174
21327
  }
21175
21328
  else {