@promptbook/remote-server 0.104.0-1 → 0.104.0-10

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 (42) hide show
  1. package/esm/index.es.js +42 -37
  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 +10 -2
  6. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -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 +7 -11
  15. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +2 -2
  16. package/esm/typings/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +56 -0
  17. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +21 -11
  18. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +80 -14
  19. package/esm/typings/src/commitments/DICTIONARY/DICTIONARY.d.ts +46 -0
  20. package/esm/typings/src/commitments/index.d.ts +2 -1
  21. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +6 -2
  22. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -0
  26. package/esm/typings/src/types/Message.d.ts +49 -0
  27. package/esm/typings/src/types/ModelRequirements.d.ts +38 -14
  28. package/esm/typings/src/types/typeAliases.d.ts +23 -1
  29. package/esm/typings/src/utils/color/utils/colorToDataUrl.d.ts +2 -1
  30. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +4 -4
  31. package/esm/typings/src/utils/environment/$isRunningInBrowser.d.ts +1 -1
  32. package/esm/typings/src/utils/environment/$isRunningInJest.d.ts +1 -1
  33. package/esm/typings/src/utils/environment/$isRunningInNode.d.ts +1 -1
  34. package/esm/typings/src/utils/environment/$isRunningInWebWorker.d.ts +1 -1
  35. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +2 -2
  36. package/esm/typings/src/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
  37. package/esm/typings/src/utils/random/$randomBase58.d.ts +12 -0
  38. package/esm/typings/src/version.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/umd/index.umd.js +46 -41
  41. package/umd/index.umd.js.map +1 -1
  42. package/esm/typings/src/book-2.0/utils/generateGravatarUrl.d.ts +0 -10
package/esm/index.es.js CHANGED
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
33
33
  * @generated
34
34
  * @see https://github.com/webgptorg/promptbook
35
35
  */
36
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-1';
36
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-10';
37
37
  /**
38
38
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
39
39
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1181,13 +1181,14 @@ class EnvironmentMismatchError extends Error {
1181
1181
  *
1182
1182
  * @public exported from `@promptbook/utils`
1183
1183
  */
1184
- const $isRunningInNode = new Function(`
1184
+ function $isRunningInNode() {
1185
1185
  try {
1186
- return this === global;
1187
- } catch (e) {
1186
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
1187
+ }
1188
+ catch (e) {
1188
1189
  return false;
1189
1190
  }
1190
- `);
1191
+ }
1191
1192
  /**
1192
1193
  * TODO: [🎺]
1193
1194
  */
@@ -3829,6 +3830,15 @@ function countUsage(llmTools) {
3829
3830
  return promptResult;
3830
3831
  };
3831
3832
  }
3833
+ if (llmTools.callImageGenerationModel !== undefined) {
3834
+ proxyTools.callImageGenerationModel = async (prompt) => {
3835
+ // console.info('[🚕] callImageGenerationModel through countTotalUsage');
3836
+ const promptResult = await llmTools.callImageGenerationModel(prompt);
3837
+ totalUsage = addUsage(totalUsage, promptResult.usage);
3838
+ spending.next(promptResult.usage);
3839
+ return promptResult;
3840
+ };
3841
+ }
3832
3842
  // <- Note: [🤖]
3833
3843
  return proxyTools;
3834
3844
  }
@@ -3938,6 +3948,12 @@ class MultipleLlmExecutionTools {
3938
3948
  callEmbeddingModel(prompt) {
3939
3949
  return this.callCommonModel(prompt);
3940
3950
  }
3951
+ /**
3952
+ * Calls the best available embedding model
3953
+ */
3954
+ callImageGenerationModel(prompt) {
3955
+ return this.callCommonModel(prompt);
3956
+ }
3941
3957
  // <- Note: [🤖]
3942
3958
  /**
3943
3959
  * Calls the best available model
@@ -3964,6 +3980,11 @@ class MultipleLlmExecutionTools {
3964
3980
  continue llm;
3965
3981
  }
3966
3982
  return await llmExecutionTools.callEmbeddingModel(prompt);
3983
+ case 'IMAGE_GENERATION':
3984
+ if (llmExecutionTools.callImageGenerationModel === undefined) {
3985
+ continue llm;
3986
+ }
3987
+ return await llmExecutionTools.callImageGenerationModel(prompt);
3967
3988
  // <- case [🤖]:
3968
3989
  default:
3969
3990
  throw new UnexpectedError(`Unknown model variant "${prompt.modelRequirements.modelVariant}" in ${llmExecutionTools.title}`);
@@ -6510,8 +6531,9 @@ async function executeAttempts(options) {
6510
6531
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6511
6532
  break variant;
6512
6533
  case 'EMBEDDING':
6534
+ case 'IMAGE_GENERATION':
6513
6535
  throw new PipelineExecutionError(spaceTrim$1((block) => `
6514
- Embedding model can not be used in pipeline
6536
+ ${modelRequirements.modelVariant} model can not be used in pipeline
6515
6537
 
6516
6538
  This should be catched during parsing
6517
6539
 
@@ -7652,13 +7674,14 @@ function createPipelineExecutor(options) {
7652
7674
  *
7653
7675
  * @public exported from `@promptbook/utils`
7654
7676
  */
7655
- const $isRunningInBrowser = new Function(`
7677
+ function $isRunningInBrowser() {
7656
7678
  try {
7657
- return this === window;
7658
- } catch (e) {
7679
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
7680
+ }
7681
+ catch (e) {
7659
7682
  return false;
7660
7683
  }
7661
- `);
7684
+ }
7662
7685
  /**
7663
7686
  * TODO: [🎺]
7664
7687
  */
@@ -7670,17 +7693,17 @@ const $isRunningInBrowser = new Function(`
7670
7693
  *
7671
7694
  * @public exported from `@promptbook/utils`
7672
7695
  */
7673
- const $isRunningInWebWorker = new Function(`
7696
+ function $isRunningInWebWorker() {
7674
7697
  try {
7675
- if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {
7676
- return true;
7677
- } else {
7678
- return false;
7679
- }
7680
- } catch (e) {
7698
+ // Note: Check for importScripts which is specific to workers
7699
+ // and not available in the main browser thread
7700
+ return (typeof self !== 'undefined' &&
7701
+ typeof self.importScripts === 'function');
7702
+ }
7703
+ catch (e) {
7681
7704
  return false;
7682
7705
  }
7683
- `);
7706
+ }
7684
7707
  /**
7685
7708
  * TODO: [🎺]
7686
7709
  */
@@ -7812,7 +7835,7 @@ function $registeredLlmToolsMessage() {
7812
7835
  ${i + 1}) **${title}** \`${className}\` from \`${packageName}\`
7813
7836
  ${morePieces.join('; ')}
7814
7837
  `);
7815
- if ($isRunningInNode) {
7838
+ if ($isRunningInNode()) {
7816
7839
  if (isInstalled && isFullyConfigured) {
7817
7840
  providerMessage = colors.green(providerMessage);
7818
7841
  }
@@ -7976,24 +7999,6 @@ function normalizeTo_camelCase(text, _isFirstLetterCapital = false) {
7976
7999
  * TODO: [🌺] Use some intermediate util splitWords
7977
8000
  */
7978
8001
 
7979
- /**
7980
- * Detects if the code is running in jest environment
7981
- *
7982
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
7983
- *
7984
- * @public exported from `@promptbook/utils`
7985
- */
7986
- new Function(`
7987
- try {
7988
- return process.env.JEST_WORKER_ID !== undefined;
7989
- } catch (e) {
7990
- return false;
7991
- }
7992
- `);
7993
- /**
7994
- * TODO: [🎺]
7995
- */
7996
-
7997
8002
  /**
7998
8003
  * Makes first letter of a string lowercase
7999
8004
  *