@promptbook/node 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 +44 -43
  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 +48 -47
  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/node",
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,
@@ -93,7 +93,7 @@
93
93
  "module": "./esm/index.es.js",
94
94
  "typings": "./esm/typings/src/_packages/node.index.d.ts",
95
95
  "peerDependencies": {
96
- "@promptbook/core": "0.104.0-1"
96
+ "@promptbook/core": "0.104.0-11"
97
97
  },
98
98
  "dependencies": {
99
99
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -45,7 +45,7 @@
45
45
  * @generated
46
46
  * @see https://github.com/webgptorg/promptbook
47
47
  */
48
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-1';
48
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
49
49
  /**
50
50
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
51
51
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -4056,6 +4056,12 @@
4056
4056
  callEmbeddingModel(prompt) {
4057
4057
  return this.callCommonModel(prompt);
4058
4058
  }
4059
+ /**
4060
+ * Calls the best available embedding model
4061
+ */
4062
+ callImageGenerationModel(prompt) {
4063
+ return this.callCommonModel(prompt);
4064
+ }
4059
4065
  // <- Note: [🤖]
4060
4066
  /**
4061
4067
  * Calls the best available model
@@ -4082,6 +4088,11 @@
4082
4088
  continue llm;
4083
4089
  }
4084
4090
  return await llmExecutionTools.callEmbeddingModel(prompt);
4091
+ case 'IMAGE_GENERATION':
4092
+ if (llmExecutionTools.callImageGenerationModel === undefined) {
4093
+ continue llm;
4094
+ }
4095
+ return await llmExecutionTools.callImageGenerationModel(prompt);
4085
4096
  // <- case [🤖]:
4086
4097
  default:
4087
4098
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
@@ -4985,8 +4996,9 @@
4985
4996
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
4986
4997
  break variant;
4987
4998
  case 'EMBEDDING':
4999
+ case 'IMAGE_GENERATION':
4988
5000
  throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
4989
- Embedding model can not be used in pipeline
5001
+ ${modelRequirements.modelVariant} model can not be used in pipeline
4990
5002
 
4991
5003
  This should be catched during parsing
4992
5004
 
@@ -6211,6 +6223,15 @@
6211
6223
  return promptResult;
6212
6224
  };
6213
6225
  }
6226
+ if (llmTools.callImageGenerationModel !== undefined) {
6227
+ proxyTools.callImageGenerationModel = async (prompt) => {
6228
+ // console.info('[🚕] callImageGenerationModel through countTotalUsage');
6229
+ const promptResult = await llmTools.callImageGenerationModel(prompt);
6230
+ totalUsage = addUsage(totalUsage, promptResult.usage);
6231
+ spending.next(promptResult.usage);
6232
+ return promptResult;
6233
+ };
6234
+ }
6214
6235
  // <- Note: [🤖]
6215
6236
  return proxyTools;
6216
6237
  }
@@ -6219,7 +6240,7 @@
6219
6240
  * TODO: [🧠] Is there some meaningfull way how to test this util
6220
6241
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
6221
6242
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
6222
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
6243
+ * TODO: [👷‍♂️] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
6223
6244
  */
6224
6245
 
6225
6246
  /**
@@ -8942,11 +8963,7 @@
8942
8963
  // TODO: [🚜] DRY
8943
8964
  if ($taskJson.modelRequirements[command.key] !== undefined) {
8944
8965
  if ($taskJson.modelRequirements[command.key] === command.value) {
8945
- console.warn(`Multiple commands \`MODEL ${{
8946
- modelName: 'NAME',
8947
- modelVariant: 'VARIANT',
8948
- maxTokens: '???',
8949
- }[command.key]} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
8966
+ console.warn(`Multiple commands \`MODEL ${command.key} ${command.value}\` in the task "${$taskJson.title || $taskJson.name}"`);
8950
8967
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
8951
8968
  }
8952
8969
  else {
@@ -10828,13 +10845,14 @@
10828
10845
  *
10829
10846
  * @public exported from `@promptbook/utils`
10830
10847
  */
10831
- const $isRunningInNode = new Function(`
10832
- try {
10833
- return this === global;
10834
- } catch (e) {
10835
- return false;
10848
+ function $isRunningInNode() {
10849
+ try {
10850
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
10851
+ }
10852
+ catch (e) {
10853
+ return false;
10854
+ }
10836
10855
  }
10837
- `);
10838
10856
  /**
10839
10857
  * TODO: [🎺]
10840
10858
  */
@@ -11395,7 +11413,7 @@
11395
11413
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
11396
11414
  ${morePieces.join('; ')}
11397
11415
  `);
11398
- if ($isRunningInNode) {
11416
+ if ($isRunningInNode()) {
11399
11417
  if (isInstalled && isFullyConfigured) {
11400
11418
  providerMessage = colors__default["default"].green(providerMessage);
11401
11419
  }
@@ -11499,13 +11517,14 @@
11499
11517
  *
11500
11518
  * @public exported from `@promptbook/utils`
11501
11519
  */
11502
- const $isRunningInBrowser = new Function(`
11503
- try {
11504
- return this === window;
11505
- } catch (e) {
11506
- return false;
11520
+ function $isRunningInBrowser() {
11521
+ try {
11522
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
11523
+ }
11524
+ catch (e) {
11525
+ return false;
11526
+ }
11507
11527
  }
11508
- `);
11509
11528
  /**
11510
11529
  * TODO: [🎺]
11511
11530
  */
@@ -11517,17 +11536,17 @@
11517
11536
  *
11518
11537
  * @public exported from `@promptbook/utils`
11519
11538
  */
11520
- const $isRunningInWebWorker = new Function(`
11521
- try {
11522
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
11523
- return true;
11524
- } else {
11539
+ function $isRunningInWebWorker() {
11540
+ try {
11541
+ // Note: Check for importScripts which is specific to workers
11542
+ // and not available in the main browser thread
11543
+ return (typeof self !== 'undefined' &&
11544
+ typeof self.importScripts === 'function');
11545
+ }
11546
+ catch (e) {
11525
11547
  return false;
11526
11548
  }
11527
- } catch (e) {
11528
- return false;
11529
11549
  }
11530
- `);
11531
11550
  /**
11532
11551
  * TODO: [🎺]
11533
11552
  */
@@ -11682,24 +11701,6 @@
11682
11701
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11683
11702
  */
11684
11703
 
11685
- /**
11686
- * Detects if the code is running in jest environment
11687
- *
11688
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
11689
- *
11690
- * @public exported from `@promptbook/utils`
11691
- */
11692
- new Function(`
11693
- try {
11694
- return process.env.JEST_WORKER_ID !== undefined;
11695
- } catch (e) {
11696
- return false;
11697
- }
11698
- `);
11699
- /**
11700
- * TODO: [🎺]
11701
- */
11702
-
11703
11704
  /**
11704
11705
  * Makes first letter of a string lowercase
11705
11706
  *