@promptbook/wizard 0.104.0-1 โ†’ 0.104.0-11

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 (57) hide show
  1. package/esm/index.es.js +292 -88
  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 +16 -2
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +29 -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 +9 -13
  15. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +3 -3
  16. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
  17. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  18. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +1 -1
  19. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +1 -1
  20. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +1 -1
  21. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +1 -1
  22. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +1 -1
  23. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +1 -1
  24. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -12
  25. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +27 -15
  26. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  27. package/esm/typings/src/commitments/index.d.ts +2 -1
  28. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +1 -1
  29. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
  30. package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
  31. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  35. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +1 -1
  36. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  37. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  38. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  39. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  40. package/esm/typings/src/types/Message.d.ts +49 -0
  41. package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
  42. package/esm/typings/src/types/typeAliases.d.ts +23 -1
  43. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
  44. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  45. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  46. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  47. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  48. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  49. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  50. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  51. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +3 -2
  52. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  53. package/esm/typings/src/version.d.ts +1 -1
  54. package/package.json +2 -2
  55. package/umd/index.umd.js +298 -94
  56. package/umd/index.umd.js.map +1 -1
  57. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
@@ -1,9 +1,10 @@
1
+ import type { string_persona_description } from '../../types/typeAliases';
1
2
  /**
2
- * @@@@
3
+ * Generates a random agent persona description.
3
4
  *
4
5
  * @private internal helper function
5
6
  */
6
- export declare function $randomAgentPersona(): string;
7
+ export declare function $randomAgentPersona(): string_persona_description;
7
8
  /**
8
9
  * TODO: [๐Ÿคถ] Maybe export through `@promptbook/utils` or `@promptbook/random` package
9
10
  */
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Generates random base58 string
3
+ *
4
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
5
+ * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
6
+ *
7
+ * @param length - length of the string
8
+ * @returns secure random base58 string
9
+ *
10
+ * @private internal helper function
11
+ */
12
+ export declare function $randomBase58(length: number): string;
@@ -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.104.0-0`).
18
+ * It follows semantic versioning (e.g., `0.104.0-10`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/wizard",
3
- "version": "0.104.0-1",
3
+ "version": "0.104.0-11",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -95,7 +95,7 @@
95
95
  "module": "./esm/index.es.js",
96
96
  "typings": "./esm/typings/src/_packages/wizard.index.d.ts",
97
97
  "peerDependencies": {
98
- "@promptbook/core": "0.104.0-1"
98
+ "@promptbook/core": "0.104.0-11"
99
99
  },
100
100
  "dependencies": {
101
101
  "@ai-sdk/deepseek": "0.1.17",
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-1';
51
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
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
@@ -58,6 +58,8 @@
58
58
  * Core Promptbook server configuration.
59
59
  *
60
60
  * This server is also used for auto-federation in the Agents Server.
61
+ *
62
+ * @public exported from `@promptbook/core`
61
63
  */
62
64
  const CORE_SERVER = {
63
65
  title: 'Promptbook Core',
@@ -2538,6 +2540,7 @@
2538
2540
  }
2539
2541
  }
2540
2542
  /**
2543
+ * TODO: !!!! Deprecate pipeline server and all of its components
2541
2544
  * TODO: Maybe use `$exportJson`
2542
2545
  * TODO: [๐Ÿง ][๐Ÿ›] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
2543
2546
  * TODO: [๐Ÿ“] Allow to list compatible models with each variant
@@ -4711,13 +4714,15 @@
4711
4714
  *
4712
4715
  * @public exported from `@promptbook/utils`
4713
4716
  */
4714
- const $isRunningInJest = new Function(`
4715
- try {
4716
- return process.env.JEST_WORKER_ID !== undefined;
4717
- } catch (e) {
4718
- return false;
4717
+ function $isRunningInJest() {
4718
+ var _a;
4719
+ try {
4720
+ return typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.JEST_WORKER_ID) !== undefined;
4721
+ }
4722
+ catch (e) {
4723
+ return false;
4724
+ }
4719
4725
  }
4720
- `);
4721
4726
  /**
4722
4727
  * TODO: [๐ŸŽบ]
4723
4728
  */
@@ -5577,13 +5582,14 @@
5577
5582
  *
5578
5583
  * @public exported from `@promptbook/utils`
5579
5584
  */
5580
- const $isRunningInBrowser = new Function(`
5581
- try {
5582
- return this === window;
5583
- } catch (e) {
5584
- return false;
5585
+ function $isRunningInBrowser() {
5586
+ try {
5587
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
5588
+ }
5589
+ catch (e) {
5590
+ return false;
5591
+ }
5585
5592
  }
5586
- `);
5587
5593
  /**
5588
5594
  * TODO: [๐ŸŽบ]
5589
5595
  */
@@ -5595,17 +5601,17 @@
5595
5601
  *
5596
5602
  * @public exported from `@promptbook/utils`
5597
5603
  */
5598
- const $isRunningInWebWorker = new Function(`
5599
- try {
5600
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
5601
- return true;
5602
- } else {
5604
+ function $isRunningInWebWorker() {
5605
+ try {
5606
+ // Note: Check for importScripts which is specific to workers
5607
+ // and not available in the main browser thread
5608
+ return (typeof self !== 'undefined' &&
5609
+ typeof self.importScripts === 'function');
5610
+ }
5611
+ catch (e) {
5603
5612
  return false;
5604
5613
  }
5605
- } catch (e) {
5606
- return false;
5607
5614
  }
5608
- `);
5609
5615
  /**
5610
5616
  * TODO: [๐ŸŽบ]
5611
5617
  */
@@ -5837,7 +5843,7 @@
5837
5843
  let threadMessages = [];
5838
5844
  if ('thread' in prompt && Array.isArray(prompt.thread)) {
5839
5845
  threadMessages = prompt.thread.map((msg) => ({
5840
- role: msg.role === 'assistant' ? 'assistant' : 'user',
5846
+ role: msg.sender === 'assistant' ? 'assistant' : 'user',
5841
5847
  content: msg.content,
5842
5848
  }));
5843
5849
  }
@@ -6250,13 +6256,14 @@
6250
6256
  const modelName = currentModelRequirements.modelName || this.getDefaultImageGenerationModel().modelName;
6251
6257
  const modelSettings = {
6252
6258
  model: modelName,
6253
- // size: currentModelRequirements.size,
6254
- // quality: currentModelRequirements.quality,
6255
- // style: currentModelRequirements.style,
6259
+ size: currentModelRequirements.size,
6260
+ quality: currentModelRequirements.quality,
6261
+ style: currentModelRequirements.style,
6256
6262
  };
6257
6263
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
6258
6264
  const rawRequest = {
6259
6265
  ...modelSettings,
6266
+ size: modelSettings.size || '1024x1024',
6260
6267
  prompt: rawPromptContent,
6261
6268
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
6262
6269
  response_format: 'url', // TODO: [๐Ÿง ] Maybe allow b64_json
@@ -6793,10 +6800,10 @@
6793
6800
  // <- TODO: [๐Ÿ›„]
6794
6801
  }
6795
6802
  /**
6796
- * Default model for image generation variant.
6803
+ * Default model for completion variant.
6797
6804
  */
6798
6805
  getDefaultImageGenerationModel() {
6799
- return this.getDefaultModel('!!!'); // <- TODO: [๐Ÿง ] Pick the best default model
6806
+ return this.getDefaultModel('dall-e-3');
6800
6807
  // <- TODO: [๐Ÿ›„]
6801
6808
  }
6802
6809
  }
@@ -7611,11 +7618,10 @@
7611
7618
  throw new PipelineExecutionError(`${this.title} does not support EMBEDDING model variant`);
7612
7619
  }
7613
7620
  /**
7614
- * Default model for image generation variant.
7621
+ * Default model for completion variant.
7615
7622
  */
7616
7623
  getDefaultImageGenerationModel() {
7617
- return this.getDefaultModel('!!!'); // <- TODO: [๐Ÿง ] Pick the best default model
7618
- // <- TODO: [๐Ÿ›„]
7624
+ throw new PipelineExecutionError(`${this.title} does not support IMAGE_GENERATION model variant`);
7619
7625
  }
7620
7626
  }
7621
7627
  /**
@@ -7707,13 +7713,14 @@
7707
7713
  *
7708
7714
  * @public exported from `@promptbook/utils`
7709
7715
  */
7710
- const $isRunningInNode = new Function(`
7711
- try {
7712
- return this === global;
7713
- } catch (e) {
7714
- return false;
7716
+ function $isRunningInNode() {
7717
+ try {
7718
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
7719
+ }
7720
+ catch (e) {
7721
+ return false;
7722
+ }
7715
7723
  }
7716
- `);
7717
7724
  /**
7718
7725
  * TODO: [๐ŸŽบ]
7719
7726
  */
@@ -9426,6 +9433,15 @@
9426
9433
  return promptResult;
9427
9434
  };
9428
9435
  }
9436
+ if (llmTools.callImageGenerationModel !== undefined) {
9437
+ proxyTools.callImageGenerationModel = async (prompt) => {
9438
+ // console.info('[๐Ÿš•] callImageGenerationModel through countTotalUsage');
9439
+ const promptResult = await llmTools.callImageGenerationModel(prompt);
9440
+ totalUsage = addUsage(totalUsage, promptResult.usage);
9441
+ spending.next(promptResult.usage);
9442
+ return promptResult;
9443
+ };
9444
+ }
9429
9445
  // <- Note: [๐Ÿค–]
9430
9446
  return proxyTools;
9431
9447
  }
@@ -9434,7 +9450,7 @@
9434
9450
  * TODO: [๐Ÿง ] Is there some meaningfull way how to test this util
9435
9451
  * TODO: [๐Ÿง ][๐ŸŒฏ] Maybe a way how to hide ability to `get totalUsage`
9436
9452
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
9437
- * TODO: [๐Ÿ‘ทโ€โ™‚๏ธ] @@@ Manual about construction of llmTools
9453
+ * TODO: [๐Ÿ‘ทโ€โ™‚๏ธ] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
9438
9454
  */
9439
9455
 
9440
9456
  /**
@@ -9535,6 +9551,12 @@
9535
9551
  callEmbeddingModel(prompt) {
9536
9552
  return this.callCommonModel(prompt);
9537
9553
  }
9554
+ /**
9555
+ * Calls the best available embedding model
9556
+ */
9557
+ callImageGenerationModel(prompt) {
9558
+ return this.callCommonModel(prompt);
9559
+ }
9538
9560
  // <- Note: [๐Ÿค–]
9539
9561
  /**
9540
9562
  * Calls the best available model
@@ -9561,6 +9583,11 @@
9561
9583
  continue llm;
9562
9584
  }
9563
9585
  return await llmExecutionTools.callEmbeddingModel(prompt);
9586
+ case 'IMAGE_GENERATION':
9587
+ if (llmExecutionTools.callImageGenerationModel === undefined) {
9588
+ continue llm;
9589
+ }
9590
+ return await llmExecutionTools.callImageGenerationModel(prompt);
9564
9591
  // <- case [๐Ÿค–]:
9565
9592
  default:
9566
9593
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
@@ -11264,8 +11291,9 @@
11264
11291
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
11265
11292
  break variant;
11266
11293
  case 'EMBEDDING':
11294
+ case 'IMAGE_GENERATION':
11267
11295
  throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
11268
- Embedding model can not be used in pipeline
11296
+ ${modelRequirements.modelVariant} model can not be used in pipeline
11269
11297
 
11270
11298
  This should be catched during parsing
11271
11299
 
@@ -14133,6 +14161,114 @@
14133
14161
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14134
14162
  */
14135
14163
 
14164
+ /**
14165
+ * DICTIONARY commitment definition
14166
+ *
14167
+ * The DICTIONARY commitment defines specific terms and their meanings that the agent should use correctly
14168
+ * in its reasoning and responses. This ensures consistent terminology usage.
14169
+ *
14170
+ * Key features:
14171
+ * - Multiple DICTIONARY commitments are automatically merged into one
14172
+ * - Content is placed in a dedicated section of the system message
14173
+ * - Terms and definitions are stored in metadata.DICTIONARY for debugging
14174
+ * - Agent should use the defined terms correctly in responses
14175
+ *
14176
+ * Example usage in agent source:
14177
+ *
14178
+ * ```book
14179
+ * Legal Assistant
14180
+ *
14181
+ * PERSONA You are a knowledgeable legal assistant
14182
+ * DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14183
+ * DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14184
+ * DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14185
+ * ```
14186
+ *
14187
+ * @private [๐Ÿช”] Maybe export the commitments through some package
14188
+ */
14189
+ class DictionaryCommitmentDefinition extends BaseCommitmentDefinition {
14190
+ constructor() {
14191
+ super('DICTIONARY');
14192
+ }
14193
+ /**
14194
+ * Short one-line description of DICTIONARY.
14195
+ */
14196
+ get description() {
14197
+ return 'Define terms and their meanings for consistent terminology usage.';
14198
+ }
14199
+ /**
14200
+ * Icon for this commitment.
14201
+ */
14202
+ get icon() {
14203
+ return '๐Ÿ“š';
14204
+ }
14205
+ /**
14206
+ * Markdown documentation for DICTIONARY commitment.
14207
+ */
14208
+ get documentation() {
14209
+ return spaceTrim$1.spaceTrim(`
14210
+ # DICTIONARY
14211
+
14212
+ Defines specific terms and their meanings that the agent should use correctly in reasoning and responses.
14213
+
14214
+ ## Key aspects
14215
+
14216
+ - Multiple \`DICTIONARY\` commitments are merged together.
14217
+ - Terms are defined in the format: "Term is definition"
14218
+ - The agent should use these terms consistently in responses.
14219
+ - Definitions help ensure accurate and consistent terminology.
14220
+
14221
+ ## Examples
14222
+
14223
+ \`\`\`book
14224
+ Legal Assistant
14225
+
14226
+ PERSONA You are a knowledgeable legal assistant specializing in criminal law
14227
+ DICTIONARY Misdemeanor is a minor wrongdoing or criminal offense
14228
+ DICTIONARY Felony is a serious crime usually punishable by imprisonment for more than one year
14229
+ DICTIONARY Tort is a civil wrong that causes harm or loss to another person, leading to legal liability
14230
+ \`\`\`
14231
+
14232
+ \`\`\`book
14233
+ Medical Assistant
14234
+
14235
+ PERSONA You are a helpful medical assistant
14236
+ DICTIONARY Hypertension is persistently high blood pressure
14237
+ DICTIONARY Diabetes is a chronic condition that affects how the body processes blood sugar
14238
+ DICTIONARY Vaccine is a biological preparation that provides active immunity to a particular disease
14239
+ \`\`\`
14240
+ `);
14241
+ }
14242
+ applyToAgentModelRequirements(requirements, content) {
14243
+ var _a;
14244
+ const trimmedContent = content.trim();
14245
+ if (!trimmedContent) {
14246
+ return requirements;
14247
+ }
14248
+ // Get existing dictionary entries from metadata
14249
+ const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
14250
+ // Merge the new dictionary entry with existing entries
14251
+ const mergedDictionary = existingDictionary
14252
+ ? `${existingDictionary}\n${trimmedContent}`
14253
+ : trimmedContent;
14254
+ // Store the merged dictionary in metadata for debugging and inspection
14255
+ const updatedMetadata = {
14256
+ ...requirements.metadata,
14257
+ DICTIONARY: mergedDictionary,
14258
+ };
14259
+ // Create the dictionary section for the system message
14260
+ // Format: "# DICTIONARY\nTerm: definition\nTerm: definition..."
14261
+ const dictionarySection = `# DICTIONARY\n${mergedDictionary}`;
14262
+ return {
14263
+ ...this.appendToSystemMessage(requirements, dictionarySection),
14264
+ metadata: updatedMetadata,
14265
+ };
14266
+ }
14267
+ }
14268
+ /**
14269
+ * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
14270
+ */
14271
+
14136
14272
  /**
14137
14273
  * FORMAT commitment definition
14138
14274
  *
@@ -16953,6 +17089,7 @@
16953
17089
  new DeleteCommitmentDefinition('CANCEL'),
16954
17090
  new DeleteCommitmentDefinition('DISCARD'),
16955
17091
  new DeleteCommitmentDefinition('REMOVE'),
17092
+ new DictionaryCommitmentDefinition(),
16956
17093
  new OpenCommitmentDefinition(),
16957
17094
  new ClosedCommitmentDefinition(),
16958
17095
  new UseBrowserCommitmentDefinition(),
@@ -17037,17 +17174,64 @@
17037
17174
  };
17038
17175
  }
17039
17176
  const lines = agentSource.split('\n');
17040
- const agentName = (((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.trim()) || null);
17177
+ let agentName = null;
17178
+ let agentNameLineIndex = -1;
17179
+ // Find the agent name: first non-empty line that is not a commitment and not a horizontal line
17180
+ for (let i = 0; i < lines.length; i++) {
17181
+ const line = lines[i];
17182
+ if (line === undefined) {
17183
+ continue;
17184
+ }
17185
+ const trimmed = line.trim();
17186
+ if (!trimmed) {
17187
+ continue;
17188
+ }
17189
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17190
+ if (isHorizontal) {
17191
+ continue;
17192
+ }
17193
+ let isCommitment = false;
17194
+ for (const definition of COMMITMENT_REGISTRY) {
17195
+ const typeRegex = definition.createTypeRegex();
17196
+ const match = typeRegex.exec(trimmed);
17197
+ if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
17198
+ isCommitment = true;
17199
+ break;
17200
+ }
17201
+ }
17202
+ if (!isCommitment) {
17203
+ agentName = trimmed;
17204
+ agentNameLineIndex = i;
17205
+ break;
17206
+ }
17207
+ }
17041
17208
  const commitments = [];
17042
17209
  const nonCommitmentLines = [];
17043
- // Always add the first line (agent name) to non-commitment lines
17044
- if (lines[0] !== undefined) {
17045
- nonCommitmentLines.push(lines[0]);
17210
+ // Add lines before agentName that are horizontal lines (they are non-commitment)
17211
+ for (let i = 0; i < agentNameLineIndex; i++) {
17212
+ const line = lines[i];
17213
+ if (line === undefined) {
17214
+ continue;
17215
+ }
17216
+ const trimmed = line.trim();
17217
+ if (!trimmed) {
17218
+ continue;
17219
+ }
17220
+ const isHorizontal = HORIZONTAL_LINE_PATTERN.test(line);
17221
+ if (isHorizontal) {
17222
+ nonCommitmentLines.push(line);
17223
+ }
17224
+ // Note: Commitments before agentName are not added to nonCommitmentLines
17225
+ }
17226
+ // Add the agent name line to non-commitment lines
17227
+ if (agentNameLineIndex >= 0) {
17228
+ nonCommitmentLines.push(lines[agentNameLineIndex]);
17046
17229
  }
17047
17230
  // Parse commitments with multiline support
17048
17231
  let currentCommitment = null;
17049
- // Process lines starting from the second line (skip agent name)
17050
- for (let i = 1; i < lines.length; i++) {
17232
+ // Process lines starting from after the agent name line
17233
+ const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
17234
+ for (let i = startIndex; i < lines.length; i++) {
17051
17235
  const line = lines[i];
17052
17236
  if (line === undefined) {
17053
17237
  continue;
@@ -17267,7 +17451,12 @@
17267
17451
  };
17268
17452
  }
17269
17453
  // Apply each commitment in order using reduce-like pattern
17270
- for (const commitment of filteredCommitments) {
17454
+ for (let i = 0; i < filteredCommitments.length; i++) {
17455
+ const commitment = filteredCommitments[i];
17456
+ // CLOSED commitment should work only if its the last commitment in the book
17457
+ if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
17458
+ continue;
17459
+ }
17271
17460
  const definition = getCommitmentDefinition(commitment.type);
17272
17461
  if (definition) {
17273
17462
  try {
@@ -17362,44 +17551,6 @@
17362
17551
  * TODO: [๐ŸŒบ] Use some intermediate util splitWords
17363
17552
  */
17364
17553
 
17365
- /**
17366
- * Generates a gravatar URL based on agent name for fallback avatar
17367
- *
17368
- * @param agentName The agent name to generate avatar for
17369
- * @returns Gravatar URL
17370
- *
17371
- * @private - [๐Ÿคน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
17372
- */
17373
- function generateGravatarUrl(agentName) {
17374
- // Use a default name if none provided
17375
- const safeName = agentName || 'Anonymous Agent';
17376
- // Create a simple hash from the name for consistent avatar
17377
- let hash = 0;
17378
- for (let i = 0; i < safeName.length; i++) {
17379
- const char = safeName.charCodeAt(i);
17380
- hash = (hash << 5) - hash + char;
17381
- hash = hash & hash; // Convert to 32bit integer
17382
- }
17383
- const avatarId = Math.abs(hash).toString();
17384
- return `https://www.gravatar.com/avatar/${avatarId}?default=robohash&size=200&rating=x`;
17385
- }
17386
-
17387
- /**
17388
- * Generates an image for the agent to use as profile image
17389
- *
17390
- * @param agentName The agent name to generate avatar for
17391
- * @returns The placeholder profile image URL for the agent
17392
- *
17393
- * @public exported from `@promptbook/core`
17394
- */
17395
- function generatePlaceholderAgentProfileImageUrl(agentName) {
17396
- // Note: [๐Ÿคน] The fact that profile image is Gravatar is just implementation detail which should be hidden for consumer
17397
- return generateGravatarUrl(agentName);
17398
- }
17399
- /**
17400
- * TODO: [๐Ÿคน] Figure out best placeholder image generator https://i.pravatar.cc/1000?u=568
17401
- */
17402
-
17403
17554
  /**
17404
17555
  * Computes SHA-256 hash of the given object
17405
17556
  *
@@ -17794,7 +17945,57 @@
17794
17945
  }
17795
17946
  const meta = {};
17796
17947
  const links = [];
17948
+ const capabilities = [];
17797
17949
  for (const commitment of parseResult.commitments) {
17950
+ if (commitment.type === 'USE BROWSER') {
17951
+ capabilities.push({
17952
+ type: 'browser',
17953
+ label: 'Browser',
17954
+ iconName: 'Globe',
17955
+ });
17956
+ continue;
17957
+ }
17958
+ if (commitment.type === 'USE SEARCH ENGINE') {
17959
+ capabilities.push({
17960
+ type: 'search-engine',
17961
+ label: 'Search Internet',
17962
+ iconName: 'Search',
17963
+ });
17964
+ continue;
17965
+ }
17966
+ if (commitment.type === 'KNOWLEDGE') {
17967
+ const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
17968
+ let label = content;
17969
+ let iconName = 'Book';
17970
+ if (content.startsWith('http://') || content.startsWith('https://')) {
17971
+ try {
17972
+ const url = new URL(content);
17973
+ if (url.pathname.endsWith('.pdf')) {
17974
+ label = url.pathname.split('/').pop() || 'Document.pdf';
17975
+ iconName = 'FileText';
17976
+ }
17977
+ else {
17978
+ label = url.hostname.replace(/^www\./, '');
17979
+ }
17980
+ }
17981
+ catch (e) {
17982
+ // Invalid URL, treat as text
17983
+ }
17984
+ }
17985
+ else {
17986
+ // Text content - take first few words
17987
+ const words = content.split(/\s+/);
17988
+ if (words.length > 4) {
17989
+ label = words.slice(0, 4).join(' ') + '...';
17990
+ }
17991
+ }
17992
+ capabilities.push({
17993
+ type: 'knowledge',
17994
+ label,
17995
+ iconName,
17996
+ });
17997
+ continue;
17998
+ }
17798
17999
  if (commitment.type === 'META LINK') {
17799
18000
  const linkValue = spaceTrim__default["default"](commitment.content);
17800
18001
  links.push(linkValue);
@@ -17824,10 +18025,6 @@
17824
18025
  const metaType = normalizeTo_camelCase(metaTypeRaw);
17825
18026
  meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
17826
18027
  }
17827
- // Generate gravatar fallback if no meta image specified
17828
- if (!meta.image) {
17829
- meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
17830
- }
17831
18028
  // Generate fullname fallback if no meta fullname specified
17832
18029
  if (!meta.fullname) {
17833
18030
  meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
@@ -17839,11 +18036,13 @@
17839
18036
  return {
17840
18037
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
17841
18038
  agentHash,
18039
+ permanentId: meta.id,
17842
18040
  personaDescription,
17843
18041
  initialMessage,
17844
18042
  meta,
17845
18043
  links,
17846
18044
  parameters,
18045
+ capabilities,
17847
18046
  };
17848
18047
  }
17849
18048
  /**
@@ -18564,7 +18763,7 @@
18564
18763
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
18565
18764
  ${morePieces.join('; ')}
18566
18765
  `);
18567
- if ($isRunningInNode) {
18766
+ if ($isRunningInNode()) {
18568
18767
  if (isInstalled && isFullyConfigured) {
18569
18768
  providerMessage = colors__default["default"].green(providerMessage);
18570
18769
  }
@@ -18961,6 +19160,9 @@
18961
19160
  case 'EMBEDDING':
18962
19161
  promptResult = await llmTools.callEmbeddingModel(prompt);
18963
19162
  break variant;
19163
+ case 'IMAGE_GENERATION':
19164
+ promptResult = await llmTools.callImageGenerationModel(prompt);
19165
+ break variant;
18964
19166
  // <- case [๐Ÿค–]:
18965
19167
  default:
18966
19168
  throw new PipelineExecutionError(`Unknown model variant "${prompt.modelRequirements.modelVariant}"`);
@@ -18997,12 +19199,13 @@
18997
19199
  }
18998
19200
  }
18999
19201
  catch (error) {
19202
+ assertsError(error);
19000
19203
  // If validation throws an unexpected error, don't cache
19001
19204
  shouldCache = false;
19002
19205
  if (isVerbose) {
19003
19206
  console.info('Not caching result due to validation error for key:', key, {
19004
19207
  content: promptResult.content,
19005
- validationError: error instanceof Error ? error.message : String(error),
19208
+ validationError: serializeError(error),
19006
19209
  });
19007
19210
  }
19008
19211
  }
@@ -19048,6 +19251,11 @@
19048
19251
  return /* not await */ callCommonModel(prompt);
19049
19252
  };
19050
19253
  }
19254
+ if (llmTools.callImageGenerationModel !== undefined) {
19255
+ proxyTools.callImageGenerationModel = async (prompt) => {
19256
+ return /* not await */ callCommonModel(prompt);
19257
+ };
19258
+ }
19051
19259
  // <- Note: [๐Ÿค–]
19052
19260
  return proxyTools;
19053
19261
  }
@@ -21177,11 +21385,7 @@
21177
21385
  // TODO: [๐Ÿšœ] DRY
21178
21386
  if ($taskJson.modelRequirements[command.key] !== undefined) {
21179
21387
  if ($taskJson.modelRequirements[command.key] === command.value) {
21180
- console.warn(`Multiple commands \`MODEL ${{
21181
- modelName: 'NAME',
21182
- modelVariant: 'VARIANT',
21183
- maxTokens: '???',
21184
- }[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
21388
+ console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
21185
21389
  // <- TODO: [๐Ÿฎ] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
21186
21390
  }
21187
21391
  else {