@promptbook/core 0.104.0-10 → 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 (27) hide show
  1. package/esm/index.es.js +64 -6
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  4. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +23 -0
  5. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +2 -2
  6. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
  7. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
  8. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +1 -1
  9. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +1 -1
  10. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +1 -1
  11. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +1 -1
  12. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +1 -1
  13. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +1 -1
  14. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -2
  15. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +0 -54
  16. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +1 -1
  17. package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
  18. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +1 -1
  19. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  20. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  21. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  22. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  23. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +3 -2
  24. package/esm/typings/src/version.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/umd/index.umd.js +64 -6
  27. package/umd/index.umd.js.map +1 -1
package/esm/index.es.js CHANGED
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-10';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3763,7 +3763,7 @@ function countUsage(llmTools) {
3763
3763
  * TODO: [🧠] Is there some meaningfull way how to test this util
3764
3764
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
3765
3765
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
3766
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3766
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
3767
3767
  */
3768
3768
 
3769
3769
  /**
@@ -11895,7 +11895,57 @@ function parseAgentSource(agentSource) {
11895
11895
  }
11896
11896
  const meta = {};
11897
11897
  const links = [];
11898
+ const capabilities = [];
11898
11899
  for (const commitment of parseResult.commitments) {
11900
+ if (commitment.type === 'USE BROWSER') {
11901
+ capabilities.push({
11902
+ type: 'browser',
11903
+ label: 'Browser',
11904
+ iconName: 'Globe',
11905
+ });
11906
+ continue;
11907
+ }
11908
+ if (commitment.type === 'USE SEARCH ENGINE') {
11909
+ capabilities.push({
11910
+ type: 'search-engine',
11911
+ label: 'Search Internet',
11912
+ iconName: 'Search',
11913
+ });
11914
+ continue;
11915
+ }
11916
+ if (commitment.type === 'KNOWLEDGE') {
11917
+ const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
11918
+ let label = content;
11919
+ let iconName = 'Book';
11920
+ if (content.startsWith('http://') || content.startsWith('https://')) {
11921
+ try {
11922
+ const url = new URL(content);
11923
+ if (url.pathname.endsWith('.pdf')) {
11924
+ label = url.pathname.split('/').pop() || 'Document.pdf';
11925
+ iconName = 'FileText';
11926
+ }
11927
+ else {
11928
+ label = url.hostname.replace(/^www\./, '');
11929
+ }
11930
+ }
11931
+ catch (e) {
11932
+ // Invalid URL, treat as text
11933
+ }
11934
+ }
11935
+ else {
11936
+ // Text content - take first few words
11937
+ const words = content.split(/\s+/);
11938
+ if (words.length > 4) {
11939
+ label = words.slice(0, 4).join(' ') + '...';
11940
+ }
11941
+ }
11942
+ capabilities.push({
11943
+ type: 'knowledge',
11944
+ label,
11945
+ iconName,
11946
+ });
11947
+ continue;
11948
+ }
11899
11949
  if (commitment.type === 'META LINK') {
11900
11950
  const linkValue = spaceTrim$2(commitment.content);
11901
11951
  links.push(linkValue);
@@ -11942,6 +11992,7 @@ function parseAgentSource(agentSource) {
11942
11992
  meta,
11943
11993
  links,
11944
11994
  parameters,
11995
+ capabilities,
11945
11996
  };
11946
11997
  }
11947
11998
  /**
@@ -12244,7 +12295,7 @@ class AgentCollectionInSupabase /* TODO: [🐱‍🚀] implements Agent */ {
12244
12295
  });
12245
12296
  }
12246
12297
  /**
12247
- * [🐱‍🚀]@@@
12298
+ * Retrieves the permanent ID of an agent by its name or permanent ID.
12248
12299
  */
12249
12300
  async getAgentPermanentId(agentNameOrPermanentId) {
12250
12301
  const selectResult = await this.supabaseClient
@@ -12258,7 +12309,7 @@ class AgentCollectionInSupabase /* TODO: [🐱‍🚀] implements Agent */ {
12258
12309
  return selectResult.data.permanentId;
12259
12310
  }
12260
12311
  /**
12261
- * [🐱‍🚀]@@@
12312
+ * Retrieves the source code of an agent by its name or permanent ID.
12262
12313
  */
12263
12314
  async getAgentSource(agentNameOrPermanentId) {
12264
12315
  const selectResult = await this.supabaseClient
@@ -12535,6 +12586,7 @@ class AgentCollectionInSupabase /* TODO: [🐱‍🚀] implements Agent */ {
12535
12586
  getTableName(tableName) {
12536
12587
  const { tablePrefix = '' } = this.options || {};
12537
12588
  return `${tablePrefix}${tableName}`;
12589
+ // <- TODO: [🏧] DRY
12538
12590
  }
12539
12591
  }
12540
12592
  /**
@@ -19591,6 +19643,11 @@ class Agent extends AgentLlmExecutionTools {
19591
19643
  * Links found in the agent source
19592
19644
  */
19593
19645
  this.links = [];
19646
+ /**
19647
+ * Capabilities of the agent
19648
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
19649
+ */
19650
+ this.capabilities = [];
19594
19651
  /**
19595
19652
  * Metadata like image or color
19596
19653
  */
@@ -19600,11 +19657,12 @@ class Agent extends AgentLlmExecutionTools {
19600
19657
  this.agentSource = agentSource;
19601
19658
  this.agentSource.subscribe((source) => {
19602
19659
  this.updateAgentSource(source);
19603
- const { agentName, personaDescription, initialMessage, links, meta } = parseAgentSource(source);
19660
+ const { agentName, personaDescription, initialMessage, links, meta, capabilities } = parseAgentSource(source);
19604
19661
  this._agentName = agentName;
19605
19662
  this.personaDescription = personaDescription;
19606
19663
  this.initialMessage = initialMessage;
19607
19664
  this.links = links;
19665
+ this.capabilities = capabilities;
19608
19666
  this.meta = { ...this.meta, ...meta };
19609
19667
  });
19610
19668
  }
@@ -21175,7 +21233,7 @@ const PERSONALITIES = [
21175
21233
  'Serious and focused AI consultant.',
21176
21234
  ];
21177
21235
  /**
21178
- * @@@@
21236
+ * Generates a random agent persona description.
21179
21237
  *
21180
21238
  * @private internal helper function
21181
21239
  */