@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
@@ -1,4 +1,5 @@
1
1
  import type { BookParameter } from '../book-2.0/agent-source/AgentBasicInformation';
2
+ import type { AgentCapability } from '../book-2.0/agent-source/AgentBasicInformation';
2
3
  import type { AgentBasicInformation } from '../book-2.0/agent-source/AgentBasicInformation';
3
4
  import type { AgentModelRequirements } from '../book-2.0/agent-source/AgentModelRequirements';
4
5
  import type { string_book } from '../book-2.0/agent-source/string_book';
@@ -178,6 +179,8 @@ import type { ScraperSourceHandler } from '../scrapers/_common/Scraper';
178
179
  import type { ScraperIntermediateSource } from '../scrapers/_common/ScraperIntermediateSource';
179
180
  import type { JavascriptExecutionToolsOptions } from '../scripting/javascript/JavascriptExecutionToolsOptions';
180
181
  import type { PostprocessingFunction } from '../scripting/javascript/JavascriptExecutionToolsOptions';
182
+ import type { SearchEngine } from '../search-engines/SearchEngine';
183
+ import type { SearchResult } from '../search-engines/SearchResult';
181
184
  import type { PromptbookStorage } from '../storage/_common/PromptbookStorage';
182
185
  import type { FileCacheStorageOptions } from '../storage/file-cache-storage/FileCacheStorageOptions';
183
186
  import type { IndexedDbStorageOptions } from '../storage/local-storage/utils/IndexedDbStorageOptions';
@@ -367,6 +370,7 @@ import type { ExportJsonOptions } from '../utils/serialization/exportJson';
367
370
  import type { ITakeChain } from '../utils/take/interfaces/ITakeChain';
368
371
  import type { string_promptbook_version } from '../version';
369
372
  export type { BookParameter };
373
+ export type { AgentCapability };
370
374
  export type { AgentBasicInformation };
371
375
  export type { AgentModelRequirements };
372
376
  export type { string_book };
@@ -546,6 +550,8 @@ export type { ScraperSourceHandler };
546
550
  export type { ScraperIntermediateSource };
547
551
  export type { JavascriptExecutionToolsOptions };
548
552
  export type { PostprocessingFunction };
553
+ export type { SearchEngine };
554
+ export type { SearchResult };
549
555
  export type { PromptbookStorage };
550
556
  export type { FileCacheStorageOptions };
551
557
  export type { IndexedDbStorageOptions };
@@ -23,6 +23,24 @@ export type BookParameter = {
23
23
  */
24
24
  description?: string;
25
25
  };
26
+ /**
27
+ * Capability of the agent
28
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
29
+ */
30
+ export type AgentCapability = {
31
+ /**
32
+ * The type of the capability
33
+ */
34
+ type: 'browser' | 'search-engine' | 'knowledge';
35
+ /**
36
+ * The label to display for this capability
37
+ */
38
+ label: string;
39
+ /**
40
+ * The name of the icon to display for this capability
41
+ */
42
+ iconName: string;
43
+ };
26
44
  export type AgentBasicInformation = {
27
45
  /**
28
46
  * Name of the agent
@@ -72,6 +90,11 @@ export type AgentBasicInformation = {
72
90
  * - {parameterName} or {parameter with multiple words} or {parameterName: description text}
73
91
  */
74
92
  parameters: BookParameter[];
93
+ /**
94
+ * Capabilities of the agent
95
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
96
+ */
97
+ capabilities: AgentCapability[];
75
98
  };
76
99
  /**
77
100
  * TODO: [🐱‍🚀] Make all properties of `AgentBasicInformation` readonly
@@ -23,11 +23,11 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
23
23
  */
24
24
  isComplete?: boolean;
25
25
  /**
26
- * @@@
26
+ * The expected answer for the message (used for testing or validation)
27
27
  */
28
28
  expectedAnswer?: string;
29
29
  /**
30
- * @@@
30
+ * Indicates if the message was sent via a voice call
31
31
  */
32
32
  isVoiceCall?: boolean;
33
33
  };
@@ -7,7 +7,7 @@ type DropdownProps = {
7
7
  }>;
8
8
  };
9
9
  /**
10
- * @@@
10
+ * A dropdown menu component that displays a list of actions triggered by a hamburger menu button.
11
11
  *
12
12
  * @private internal subcomponent used by various components
13
13
  */
@@ -4,7 +4,7 @@ type HamburgerMenuProps = {
4
4
  className?: string;
5
5
  };
6
6
  /**
7
- * @@@
7
+ * An animated hamburger menu button component.
8
8
  *
9
9
  * @private Internal component
10
10
  */
@@ -1,6 +1,6 @@
1
1
  import { SVGProps } from 'react';
2
2
  /**
3
- * @@@
3
+ * Renders an about icon
4
4
  *
5
5
  * @private internal subcomponent used by various components
6
6
  */
@@ -3,7 +3,7 @@ type AttachmentIconProps = {
3
3
  color?: string;
4
4
  };
5
5
  /**
6
- * @@@
6
+ * Renders an attachment icon
7
7
  *
8
8
  * @public exported from `@promptbook/components`
9
9
  */
@@ -3,7 +3,7 @@ type CameraIconProps = {
3
3
  color?: string;
4
4
  };
5
5
  /**
6
- * @@@
6
+ * Renders a camera icon
7
7
  *
8
8
  * @public exported from `@promptbook/components`
9
9
  */
@@ -1,6 +1,6 @@
1
1
  import { SVGProps } from 'react';
2
2
  /**
3
- * @@@
3
+ * Renders a download icon
4
4
  *
5
5
  * @private internal subcomponent used by various components
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import { SVGProps } from 'react';
2
2
  /**
3
- * @@@
3
+ * Renders a menu icon
4
4
  *
5
5
  * @private internal subcomponent used by various components
6
6
  */
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  /**
3
- * @@@
3
+ * Renders a save icon
4
4
  *
5
5
  * @public exported from `@promptbook/components`
6
6
  */
@@ -26,11 +26,11 @@ export declare class AgentCollectionInSupabase {
26
26
  */
27
27
  listAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
28
28
  /**
29
- * [🐱‍🚀]@@@
29
+ * Retrieves the permanent ID of an agent by its name or permanent ID.
30
30
  */
31
31
  getAgentPermanentId(agentNameOrPermanentId: string_agent_name | string_agent_permanent_id): Promise<string_agent_permanent_id>;
32
32
  /**
33
- * [🐱‍🚀]@@@
33
+ * Retrieves the source code of an agent by its name or permanent ID.
34
34
  */
35
35
  getAgentSource(agentNameOrPermanentId: string_agent_name | string_agent_permanent_id): Promise<string_book>;
36
36
  /**
@@ -108,60 +108,6 @@ export type AgentsDatabaseSchema = {
108
108
  }
109
109
  ];
110
110
  };
111
- GenerationLock: {
112
- Row: {
113
- id: number;
114
- createdAt: string;
115
- updatedAt: string;
116
- lockKey: string;
117
- expiresAt: string;
118
- };
119
- Insert: {
120
- id?: number;
121
- createdAt?: string;
122
- updatedAt?: string;
123
- lockKey: string;
124
- expiresAt: string;
125
- };
126
- Update: {
127
- id?: number;
128
- createdAt?: string;
129
- updatedAt?: string;
130
- lockKey?: string;
131
- expiresAt?: string;
132
- };
133
- Relationships: [];
134
- };
135
- Image: {
136
- Row: {
137
- id: number;
138
- createdAt: string;
139
- updatedAt: string;
140
- filename: string;
141
- prompt: string;
142
- cdnUrl: string;
143
- cdnKey: string;
144
- };
145
- Insert: {
146
- id?: number;
147
- createdAt?: string;
148
- updatedAt?: string;
149
- filename: string;
150
- prompt: string;
151
- cdnUrl: string;
152
- cdnKey: string;
153
- };
154
- Update: {
155
- id?: number;
156
- createdAt?: string;
157
- updatedAt?: string;
158
- filename?: string;
159
- prompt?: string;
160
- cdnUrl?: string;
161
- cdnKey?: string;
162
- };
163
- Relationships: [];
164
- };
165
111
  };
166
112
  Views: Record<string, never>;
167
113
  Functions: Record<string, never>;
@@ -13,5 +13,5 @@ export declare function countUsage(llmTools: LlmExecutionTools): LlmExecutionToo
13
13
  * TODO: [🧠] Is there some meaningfull way how to test this util
14
14
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
15
15
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
16
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
16
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
17
17
  */
@@ -1,5 +1,5 @@
1
1
  import { BehaviorSubject } from 'rxjs';
2
- import type { AgentBasicInformation, BookParameter } from '../../book-2.0/agent-source/AgentBasicInformation';
2
+ import type { AgentBasicInformation, AgentCapability, BookParameter } from '../../book-2.0/agent-source/AgentBasicInformation';
3
3
  import type { string_book } from '../../book-2.0/agent-source/string_book';
4
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
5
5
  import type { ChatPromptResult } from '../../execution/PromptResult';
@@ -37,6 +37,11 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
37
37
  * Links found in the agent source
38
38
  */
39
39
  links: Array<string_agent_url>;
40
+ /**
41
+ * Capabilities of the agent
42
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
43
+ */
44
+ capabilities: AgentCapability[];
40
45
  /**
41
46
  * Computed hash of the agent source for integrity verification
42
47
  */
@@ -1,6 +1,6 @@
1
1
  import type { ServerInfo } from './types';
2
2
  /**
3
- * @@@
3
+ * Renders the HTML document for the Promptbook Server UI.
4
4
  *
5
5
  * @private internal utility of Remote Server
6
6
  */
@@ -0,0 +1,9 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_markdown, string_markdown_text, string_title } from '../types/typeAliases';
3
+ import type { SearchResult } from './SearchResult';
4
+ export type SearchEngine = {
5
+ readonly title: string_title & string_markdown_text;
6
+ readonly description?: string_markdown;
7
+ checkConfiguration(): Promisable<void>;
8
+ search(query: string): Promise<SearchResult[]>;
9
+ };
@@ -0,0 +1,18 @@
1
+ import type { string_url } from '../types/typeAliases';
2
+ /**
3
+ * @@@
4
+ */
5
+ export type SearchResult = {
6
+ /**
7
+ * @@@
8
+ */
9
+ title: string;
10
+ /**
11
+ * @@@
12
+ */
13
+ url: string_url;
14
+ /**
15
+ * @@@
16
+ */
17
+ snippet: string;
18
+ };
@@ -0,0 +1,15 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
3
+ import type { SearchEngine } from '../SearchEngine';
4
+ import type { SearchResult } from '../SearchResult';
5
+ /**
6
+ * @@@
7
+ *
8
+ * @private <- TODO: !!!! Export via some package
9
+ */
10
+ export declare class BingSearchEngine implements SearchEngine {
11
+ get title(): string_title & string_markdown_text;
12
+ get description(): string_markdown;
13
+ checkConfiguration(): Promisable<void>;
14
+ search(query: string): Promise<SearchResult[]>;
15
+ }
@@ -0,0 +1,15 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
3
+ import type { SearchEngine } from '../SearchEngine';
4
+ import type { SearchResult } from '../SearchResult';
5
+ /**
6
+ * @@@
7
+ *
8
+ * @private <- TODO: !!!! Export via some package, maybe `@promptbook/search-engines` or `@promptbook/fake-llm`
9
+ */
10
+ export declare class DummySearchEngine implements SearchEngine {
11
+ get title(): string_title & string_markdown_text;
12
+ get description(): string_markdown;
13
+ checkConfiguration(): Promisable<void>;
14
+ search(query: string): Promise<SearchResult[]>;
15
+ }
@@ -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
  */
@@ -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-9`).
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/core",
3
- "version": "0.104.0-10",
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,
package/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-10';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3764,7 +3764,7 @@
3764
3764
  * TODO: [🧠] Is there some meaningfull way how to test this util
3765
3765
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
3766
3766
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
3767
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
3767
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
3768
3768
  */
3769
3769
 
3770
3770
  /**
@@ -11896,7 +11896,57 @@
11896
11896
  }
11897
11897
  const meta = {};
11898
11898
  const links = [];
11899
+ const capabilities = [];
11899
11900
  for (const commitment of parseResult.commitments) {
11901
+ if (commitment.type === 'USE BROWSER') {
11902
+ capabilities.push({
11903
+ type: 'browser',
11904
+ label: 'Browser',
11905
+ iconName: 'Globe',
11906
+ });
11907
+ continue;
11908
+ }
11909
+ if (commitment.type === 'USE SEARCH ENGINE') {
11910
+ capabilities.push({
11911
+ type: 'search-engine',
11912
+ label: 'Search Internet',
11913
+ iconName: 'Search',
11914
+ });
11915
+ continue;
11916
+ }
11917
+ if (commitment.type === 'KNOWLEDGE') {
11918
+ const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
11919
+ let label = content;
11920
+ let iconName = 'Book';
11921
+ if (content.startsWith('http://') || content.startsWith('https://')) {
11922
+ try {
11923
+ const url = new URL(content);
11924
+ if (url.pathname.endsWith('.pdf')) {
11925
+ label = url.pathname.split('/').pop() || 'Document.pdf';
11926
+ iconName = 'FileText';
11927
+ }
11928
+ else {
11929
+ label = url.hostname.replace(/^www\./, '');
11930
+ }
11931
+ }
11932
+ catch (e) {
11933
+ // Invalid URL, treat as text
11934
+ }
11935
+ }
11936
+ else {
11937
+ // Text content - take first few words
11938
+ const words = content.split(/\s+/);
11939
+ if (words.length > 4) {
11940
+ label = words.slice(0, 4).join(' ') + '...';
11941
+ }
11942
+ }
11943
+ capabilities.push({
11944
+ type: 'knowledge',
11945
+ label,
11946
+ iconName,
11947
+ });
11948
+ continue;
11949
+ }
11900
11950
  if (commitment.type === 'META LINK') {
11901
11951
  const linkValue = spaceTrim__default["default"](commitment.content);
11902
11952
  links.push(linkValue);
@@ -11943,6 +11993,7 @@
11943
11993
  meta,
11944
11994
  links,
11945
11995
  parameters,
11996
+ capabilities,
11946
11997
  };
11947
11998
  }
11948
11999
  /**
@@ -12245,7 +12296,7 @@
12245
12296
  });
12246
12297
  }
12247
12298
  /**
12248
- * [🐱‍🚀]@@@
12299
+ * Retrieves the permanent ID of an agent by its name or permanent ID.
12249
12300
  */
12250
12301
  async getAgentPermanentId(agentNameOrPermanentId) {
12251
12302
  const selectResult = await this.supabaseClient
@@ -12259,7 +12310,7 @@
12259
12310
  return selectResult.data.permanentId;
12260
12311
  }
12261
12312
  /**
12262
- * [🐱‍🚀]@@@
12313
+ * Retrieves the source code of an agent by its name or permanent ID.
12263
12314
  */
12264
12315
  async getAgentSource(agentNameOrPermanentId) {
12265
12316
  const selectResult = await this.supabaseClient
@@ -12536,6 +12587,7 @@
12536
12587
  getTableName(tableName) {
12537
12588
  const { tablePrefix = '' } = this.options || {};
12538
12589
  return `${tablePrefix}${tableName}`;
12590
+ // <- TODO: [🏧] DRY
12539
12591
  }
12540
12592
  }
12541
12593
  /**
@@ -19592,6 +19644,11 @@
19592
19644
  * Links found in the agent source
19593
19645
  */
19594
19646
  this.links = [];
19647
+ /**
19648
+ * Capabilities of the agent
19649
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
19650
+ */
19651
+ this.capabilities = [];
19595
19652
  /**
19596
19653
  * Metadata like image or color
19597
19654
  */
@@ -19601,11 +19658,12 @@
19601
19658
  this.agentSource = agentSource;
19602
19659
  this.agentSource.subscribe((source) => {
19603
19660
  this.updateAgentSource(source);
19604
- const { agentName, personaDescription, initialMessage, links, meta } = parseAgentSource(source);
19661
+ const { agentName, personaDescription, initialMessage, links, meta, capabilities } = parseAgentSource(source);
19605
19662
  this._agentName = agentName;
19606
19663
  this.personaDescription = personaDescription;
19607
19664
  this.initialMessage = initialMessage;
19608
19665
  this.links = links;
19666
+ this.capabilities = capabilities;
19609
19667
  this.meta = { ...this.meta, ...meta };
19610
19668
  });
19611
19669
  }
@@ -21176,7 +21234,7 @@
21176
21234
  'Serious and focused AI consultant.',
21177
21235
  ];
21178
21236
  /**
21179
- * @@@@
21237
+ * Generates a random agent persona description.
21180
21238
  *
21181
21239
  * @private internal helper function
21182
21240
  */