@promptbook/javascript 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 +1 -77
  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 +1 -77
  56. package/umd/index.umd.js.map +1 -1
  57. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
@@ -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
+ }
@@ -0,0 +1,49 @@
1
+ import { Arrayable } from 'type-fest';
2
+ import { really_any } from '../_packages/types.index';
3
+ import { id, string_date_iso8601, string_markdown } from './typeAliases';
4
+ /**
5
+ * A generic message structure for various communication channels
6
+ */
7
+ export type Message<TParticipant> = {
8
+ /**
9
+ * Unique identifier of the message
10
+ */
11
+ readonly id?: id;
12
+ /**
13
+ * Date when the message was created
14
+ */
15
+ readonly createdAt?: Date | string_date_iso8601;
16
+ /**
17
+ * The communication channel of the message
18
+ */
19
+ readonly channel?: 'PROMPTBOOK_CHAT' | 'EMAIL' | 'SMS' | 'WHATSAPP' | 'TELEGRAM' | 'SIGNAL' | string | 'UNKNOWN';
20
+ /**
21
+ * Is the message send from the Promptbook or to the Promptbook
22
+ */
23
+ readonly direction?: 'INBOUND' | 'OUTBOUND' | 'INTERNAL' | 'INITIAL';
24
+ /**
25
+ * Who sent the message
26
+ */
27
+ readonly sender: TParticipant;
28
+ /**
29
+ * Who are the recipients of the message
30
+ */
31
+ readonly recipients?: Readonly<Arrayable<TParticipant>>;
32
+ /**
33
+ * The content of the message as markdown
34
+ *
35
+ * Note: We are converting all message content to markdown for consistency
36
+ */
37
+ readonly content: string_markdown;
38
+ /**
39
+ * The thread identifier the message belongs to
40
+ *
41
+ * - `null` means the message is not part of any thread
42
+ * - `undefined` means that we don't know if the message is part of a thread or not
43
+ */
44
+ readonly threadId?: id | null;
45
+ /**
46
+ * Arbitrary metadata associated with the message
47
+ */
48
+ readonly metadata?: Readonly<Record<string, really_any>>;
49
+ };
@@ -17,7 +17,17 @@ export type CompletionModelRequirements = CommonModelRequirements & {
17
17
  /**
18
18
  * Completion model variant
19
19
  */
20
- modelVariant: 'COMPLETION';
20
+ readonly modelVariant: 'COMPLETION';
21
+ /**
22
+ * The temperature of the model
23
+ *
24
+ * Note: [💱] Promptbook is using just `temperature` (not `top_k` and `top_p`)
25
+ */
26
+ readonly temperature?: number_model_temperature;
27
+ /**
28
+ * Maximum number of tokens that can be generated by the model
29
+ */
30
+ readonly maxTokens?: number;
21
31
  };
22
32
  /**
23
33
  * Model requirements for the chat variant
@@ -28,11 +38,21 @@ export type ChatModelRequirements = CommonModelRequirements & {
28
38
  /**
29
39
  * Chat model variant
30
40
  */
31
- modelVariant: 'CHAT';
41
+ readonly modelVariant: 'CHAT';
32
42
  /**
33
43
  * System message to be used in the model
34
44
  */
35
45
  readonly systemMessage?: string_system_message;
46
+ /**
47
+ * The temperature of the model
48
+ *
49
+ * Note: [💱] Promptbook is using just `temperature` (not `top_k` and `top_p`)
50
+ */
51
+ readonly temperature?: number_model_temperature;
52
+ /**
53
+ * Maximum number of tokens that can be generated by the model
54
+ */
55
+ readonly maxTokens?: number;
36
56
  };
37
57
  /**
38
58
  * Model requirements for the image generation variant
@@ -43,7 +63,21 @@ export type ImageGenerationModelRequirements = CommonModelRequirements & {
43
63
  /**
44
64
  * Image generation model variant
45
65
  */
46
- modelVariant: 'IMAGE_GENERATION';
66
+ readonly modelVariant: 'IMAGE_GENERATION';
67
+ /**
68
+ * Size of the generated image
69
+ *
70
+ * e.g. '1536x1536'
71
+ */
72
+ readonly size?: '1024x1024' | '1792x1024' | '1024x1792' | `${number}x${number}`;
73
+ /**
74
+ * Quality of the generated image
75
+ */
76
+ readonly quality?: 'standard' | 'hd';
77
+ /**
78
+ * Style of the generated image
79
+ */
80
+ readonly style?: 'vivid' | 'natural';
47
81
  };
48
82
  /**
49
83
  * Model requirements for the embedding variant
@@ -54,7 +88,7 @@ export type EmbeddingModelRequirements = CommonModelRequirements & {
54
88
  /**
55
89
  * Embedding model variant
56
90
  */
57
- modelVariant: 'EMBEDDING';
91
+ readonly modelVariant: 'EMBEDDING';
58
92
  };
59
93
  /**
60
94
  * Common properties for all model requirements variants
@@ -84,20 +118,10 @@ export type CommonModelRequirements = {
84
118
  * @example 'gpt-4', 'gpt-4-32k-0314', 'gpt-3.5-turbo-instruct',...
85
119
  */
86
120
  readonly modelName?: string_model_name;
87
- /**
88
- * The temperature of the model
89
- *
90
- * Note: [💱] Promptbook is using just `temperature` (not `top_k` and `top_p`)
91
- */
92
- readonly temperature?: number_model_temperature;
93
121
  /**
94
122
  * Seed for the model
95
123
  */
96
124
  readonly seed?: number_seed;
97
- /**
98
- * Maximum number of tokens that can be generated by the model
99
- */
100
- readonly maxTokens?: number;
101
125
  };
102
126
  /**
103
127
  * TODO: [🧠][🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (similar that `user` identification is not here)
@@ -14,9 +14,15 @@ export type string_model_name = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-3
14
14
  /**
15
15
  * Semantic helper
16
16
  *
17
- * For example `"A cat wearing a hat"`
17
+ * For example `"How many eyes does a cat have?"`
18
18
  */
19
19
  export type string_prompt = string;
20
+ /**
21
+ * Semantic helper
22
+ *
23
+ * For example `"A cat wearing a hat"`
24
+ */
25
+ export type string_prompt_image = string;
20
26
  /**
21
27
  * Semantic helper
22
28
  *
@@ -140,6 +146,8 @@ export type string_title = string;
140
146
  * Semantic helper
141
147
  *
142
148
  * For example `"My AI Assistant"`
149
+ *
150
+ * TODO: !!!! Brand the type
143
151
  */
144
152
  export type string_agent_name = string;
145
153
  /**
@@ -154,6 +162,14 @@ export type string_agent_name_in_book = string;
154
162
  * For example `"b126926439c5fcb83609888a11283723c1ef137c0ad599a77a1be81812bd221d"`
155
163
  */
156
164
  export type string_agent_hash = string_sha256;
165
+ /**
166
+ * Semantic helper
167
+ *
168
+ * For example `"3mJr7AoUXx2Wqd"`
169
+ *
170
+ * TODO: !!!! Brand the type
171
+ */
172
+ export type string_agent_permanent_id = string_base_58;
157
173
  /**
158
174
  * Unstructured description of the persona
159
175
  *
@@ -499,6 +515,12 @@ export type string_user_id = id | string_email;
499
515
  * For example `"b126926439c5fcb83609888a11283723c1ef137c0ad599a77a1be81812bd221d"`
500
516
  */
501
517
  export type string_sha256 = string;
518
+ /**
519
+ * Semantic helper
520
+ *
521
+ * For example `"4JmF3b2J5dGVz"`
522
+ */
523
+ export type string_base_58 = string;
502
524
  /**
503
525
  * Semantic helper
504
526
  *
@@ -1,10 +1,11 @@
1
+ import { string_color, string_data_url, string_url_image } from '../../../types/typeAliases';
1
2
  import { Color } from '../Color';
2
3
  /**
3
4
  * Makes data url from color
4
5
  *
5
6
  * @public exported from `@promptbook/color`
6
7
  */
7
- export declare function colorToDataUrl(color: Color): string;
8
+ export declare function colorToDataUrl(color: Color | string_color): string_data_url & string_url_image;
8
9
  /**
9
10
  * TODO: Make as functions NOT const
10
11
  */
@@ -6,10 +6,10 @@
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
8
  export declare function $detectRuntimeEnvironment(): {
9
- isRunningInBrowser: any;
10
- isRunningInJest: any;
11
- isRunningInNode: any;
12
- isRunningInWebWorker: any;
9
+ isRunningInBrowser: boolean;
10
+ isRunningInJest: boolean;
11
+ isRunningInNode: boolean;
12
+ isRunningInWebWorker: boolean;
13
13
  };
14
14
  /**
15
15
  * TODO: [🎺] Also detect and report node version here
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
- export declare const $isRunningInBrowser: Function;
8
+ export declare function $isRunningInBrowser(): boolean;
9
9
  /**
10
10
  * TODO: [🎺]
11
11
  */
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
- export declare const $isRunningInJest: Function;
8
+ export declare function $isRunningInJest(): boolean;
9
9
  /**
10
10
  * TODO: [🎺]
11
11
  */
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
- export declare const $isRunningInNode: Function;
8
+ export declare function $isRunningInNode(): boolean;
9
9
  /**
10
10
  * TODO: [🎺]
11
11
  */
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * @public exported from `@promptbook/utils`
7
7
  */
8
- export declare const $isRunningInWebWorker: Function;
8
+ export declare function $isRunningInWebWorker(): boolean;
9
9
  /**
10
10
  * TODO: [🎺]
11
11
  */
@@ -2,7 +2,7 @@ import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Single code block inside markdown.
4
4
  */
5
- export type CodeBlock = {
5
+ export type MarkdownCodeBlock = {
6
6
  /**
7
7
  * Which notation was used to open the code block
8
8
  */
@@ -30,7 +30,7 @@ export type CodeBlock = {
30
30
  * @throws {ParseError} if block is not closed properly
31
31
  * @public exported from `@promptbook/markdown-utils`
32
32
  */
33
- export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<CodeBlock>;
33
+ export declare function extractAllBlocksFromMarkdown(markdown: string_markdown): ReadonlyArray<MarkdownCodeBlock>;
34
34
  /**
35
35
  * TODO: Maybe name for `blockNotation` instead of '```' and '>'
36
36
  */
@@ -1,5 +1,5 @@
1
1
  import type { string_markdown } from '../../types/typeAliases';
2
- import type { CodeBlock } from './extractAllBlocksFromMarkdown';
2
+ import type { MarkdownCodeBlock } from './extractAllBlocksFromMarkdown';
3
3
  /**
4
4
  * Extracts exactly ONE code block from markdown.
5
5
  *
@@ -16,7 +16,7 @@ import type { CodeBlock } from './extractAllBlocksFromMarkdown';
16
16
  * @public exported from `@promptbook/markdown-utils`
17
17
  * @throws {ParseError} if there is not exactly one code block in the markdown
18
18
  */
19
- export declare function extractOneBlockFromMarkdown(markdown: string_markdown): CodeBlock;
19
+ export declare function extractOneBlockFromMarkdown(markdown: string_markdown): MarkdownCodeBlock;
20
20
  /***
21
21
  * TODO: [🍓][🌻] Decide of this is internal utility, external util OR validator/postprocessor
22
22
  */
@@ -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/javascript",
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,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/javascript.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.104.0-1"
97
+ "@promptbook/core": "0.104.0-11"
98
98
  },
99
99
  "dependencies": {
100
100
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  * @generated
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-1';
25
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1948,82 +1948,6 @@
1948
1948
  }
1949
1949
  }
1950
1950
 
1951
- /**
1952
- * Detects if the code is running in a browser environment in main thread (Not in a web worker)
1953
- *
1954
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1955
- *
1956
- * @public exported from `@promptbook/utils`
1957
- */
1958
- new Function(`
1959
- try {
1960
- return this === window;
1961
- } catch (e) {
1962
- return false;
1963
- }
1964
- `);
1965
- /**
1966
- * TODO: [🎺]
1967
- */
1968
-
1969
- /**
1970
- * Detects if the code is running in jest environment
1971
- *
1972
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1973
- *
1974
- * @public exported from `@promptbook/utils`
1975
- */
1976
- new Function(`
1977
- try {
1978
- return process.env.JEST_WORKER_ID !== undefined;
1979
- } catch (e) {
1980
- return false;
1981
- }
1982
- `);
1983
- /**
1984
- * TODO: [🎺]
1985
- */
1986
-
1987
- /**
1988
- * Detects if the code is running in a Node.js environment
1989
- *
1990
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1991
- *
1992
- * @public exported from `@promptbook/utils`
1993
- */
1994
- new Function(`
1995
- try {
1996
- return this === global;
1997
- } catch (e) {
1998
- return false;
1999
- }
2000
- `);
2001
- /**
2002
- * TODO: [🎺]
2003
- */
2004
-
2005
- /**
2006
- * Detects if the code is running in a web worker
2007
- *
2008
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
2009
- *
2010
- * @public exported from `@promptbook/utils`
2011
- */
2012
- new Function(`
2013
- try {
2014
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
2015
- return true;
2016
- } else {
2017
- return false;
2018
- }
2019
- } catch (e) {
2020
- return false;
2021
- }
2022
- `);
2023
- /**
2024
- * TODO: [🎺]
2025
- */
2026
-
2027
1951
  /**
2028
1952
  * Makes first letter of a string uppercase
2029
1953
  *