@promptbook/markdown-utils 0.101.0-20 β†’ 0.101.0-21

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 (51) hide show
  1. package/esm/index.es.js +47 -79
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +0 -12
  4. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +0 -24
  5. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +0 -12
  6. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +0 -12
  7. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -6
  8. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +0 -12
  9. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +0 -12
  10. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +0 -6
  11. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +0 -6
  12. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +0 -6
  13. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +0 -12
  14. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +0 -24
  15. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +0 -12
  16. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +0 -12
  17. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +0 -12
  18. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +0 -12
  19. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +0 -12
  20. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  21. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +3 -0
  22. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +3 -0
  23. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +3 -0
  24. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +2 -16
  25. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +3 -0
  26. package/esm/typings/src/execution/PromptResult.d.ts +2 -4
  27. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +2 -5
  28. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -2
  29. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -8
  30. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -5
  31. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -5
  32. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +2 -0
  33. package/esm/typings/src/llm-providers/mocked/test/joker.test.d.ts +4 -0
  34. package/esm/typings/src/llm-providers/mocked/test/mocked-chat.test.d.ts +5 -0
  35. package/esm/typings/src/llm-providers/mocked/test/mocked-completion.test.d.ts +4 -0
  36. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +3 -3
  37. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +1 -0
  38. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -8
  39. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -14
  40. package/esm/typings/src/scripting/_test/postprocessing.test.d.ts +1 -0
  41. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +0 -1
  42. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +2 -2
  43. package/esm/typings/src/version.d.ts +1 -1
  44. package/package.json +1 -1
  45. package/umd/index.umd.js +47 -79
  46. package/umd/index.umd.js.map +1 -1
  47. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +0 -16
  48. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +0 -10
  49. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +0 -10
  50. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +0 -81
  51. /package/esm/typings/src/{llm-providers/_common/profiles/test/llmProviderProfiles.test.d.ts β†’ cli/test/ptbk.test.d.ts} +0 -0
@@ -1,15 +1,10 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
- import type { ChatPromptResult } from '../../execution/PromptResult';
4
- import type { CompletionPromptResult } from '../../execution/PromptResult';
5
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
4
+ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult } from '../../execution/PromptResult';
6
5
  import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
7
- import type { ChatPrompt } from '../../types/Prompt';
8
- import type { CompletionPrompt } from '../../types/Prompt';
9
- import type { EmbeddingPrompt } from '../../types/Prompt';
10
- import type { string_markdown } from '../../types/typeAliases';
11
- import type { string_markdown_text } from '../../types/typeAliases';
12
- import type { string_title } from '../../types/typeAliases';
6
+ import type { ChatPrompt, CompletionPrompt, EmbeddingPrompt } from '../../types/Prompt';
7
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
13
8
  /**
14
9
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
15
10
  *
@@ -24,11 +19,7 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
24
19
  constructor(options: RemoteClientOptions<TCustomOptions>);
25
20
  get title(): string_title & string_markdown_text;
26
21
  get description(): string_markdown;
27
- get profile(): {
28
- name: string;
29
- fullname: string;
30
- color: string;
31
- };
22
+ get profile(): ChatParticipant;
32
23
  /**
33
24
  * Check the configuration of all execution tools
34
25
  */
@@ -10,5 +10,4 @@ import { string_markdown } from '../../types/typeAliases';
10
10
  export declare function humanizeAiText(aiText: string_markdown): string_markdown;
11
11
  /**
12
12
  * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
13
- * TODO: [πŸ…ΎοΈ] !!! Use this across the project where AI text is involved
14
13
  */
@@ -2,11 +2,11 @@ import { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
4
4
  *
5
+ * Note: [πŸ”‚] This function is idempotent.
6
+ *
5
7
  * @public exported from `@promptbook/markdown-utils`
6
8
  */
7
9
  export declare function promptbookifyAiText(text: string_markdown): string_markdown;
8
10
  /**
9
- * TODO: !!!!! Make the function idempotent and add "Note: [πŸ”‚] This function is idempotent."
10
- * TODO: [πŸ…ΎοΈ]!!! Use this across the project where AI text is involved
11
11
  * TODO: [🧠][✌️] Make some Promptbook-native token system
12
12
  */
@@ -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.101.0-19`).
18
+ * It follows semantic versioning (e.g., `0.101.0-20`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/markdown-utils",
3
- "version": "0.101.0-20",
3
+ "version": "0.101.0-21",
4
4
  "description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- const PROMPTBOOK_ENGINE_VERSION = '0.101.0-20';
27
+ const PROMPTBOOK_ENGINE_VERSION = '0.101.0-21';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
@@ -2646,75 +2646,13 @@
2646
2646
  }
2647
2647
 
2648
2648
  /**
2649
- * Predefined profiles for LLM providers to maintain consistency across the application
2650
- * These profiles represent each provider as a virtual persona in chat interfaces
2651
- *
2652
- * @private !!!!
2649
+ * Profile for Multiple providers aggregation
2653
2650
  */
2654
- const LLM_PROVIDER_PROFILES = {
2655
- OPENAI: {
2656
- name: 'OPENAI',
2657
- fullname: 'OpenAI GPT',
2658
- color: '#10a37f', // OpenAI's signature green
2659
- // Note: avatarSrc could be added when we have provider logos available
2660
- },
2661
- ANTHROPIC: {
2662
- name: 'ANTHROPIC',
2663
- fullname: 'Anthropic Claude',
2664
- color: '#d97706', // Anthropic's orange/amber color
2665
- },
2666
- AZURE_OPENAI: {
2667
- name: 'AZURE_OPENAI',
2668
- fullname: 'Azure OpenAI',
2669
- color: '#0078d4', // Microsoft Azure blue
2670
- },
2671
- GOOGLE: {
2672
- name: 'GOOGLE',
2673
- fullname: 'Google Gemini',
2674
- color: '#4285f4', // Google blue
2675
- },
2676
- DEEPSEEK: {
2677
- name: 'DEEPSEEK',
2678
- fullname: 'DeepSeek',
2679
- color: '#7c3aed', // Purple color for DeepSeek
2680
- },
2681
- OLLAMA: {
2682
- name: 'OLLAMA',
2683
- fullname: 'Ollama',
2684
- color: '#059669', // Emerald green for local models
2685
- },
2686
- REMOTE: {
2687
- name: 'REMOTE',
2688
- fullname: 'Remote Server',
2689
- color: '#6b7280', // Gray for remote/proxy connections
2690
- },
2691
- MOCKED_ECHO: {
2692
- name: 'MOCKED_ECHO',
2693
- fullname: 'Echo (Test)',
2694
- color: '#8b5cf6', // Purple for test/mock tools
2695
- },
2696
- MOCKED_FAKE: {
2697
- name: 'MOCKED_FAKE',
2698
- fullname: 'Fake LLM (Test)',
2699
- color: '#ec4899', // Pink for fake/test tools
2700
- },
2701
- VERCEL: {
2702
- name: 'VERCEL',
2703
- fullname: 'Vercel AI',
2704
- color: '#000000', // Vercel's black
2705
- },
2706
- MULTIPLE: {
2707
- name: 'MULTIPLE',
2708
- fullname: 'Multiple Providers',
2709
- color: '#6366f1', // Indigo for combined/multiple providers
2710
- },
2651
+ const MULTIPLE_PROVIDER_PROFILE = {
2652
+ name: 'MULTIPLE',
2653
+ fullname: 'Multiple Providers',
2654
+ color: '#6366f1',
2711
2655
  };
2712
- /**
2713
- * TODO: Refactor this - each profile must be alongside the provider definition
2714
- * TODO: [πŸ•›] Unite `AgentBasicInformation`, `ChatParticipant`, `LlmExecutionTools` + `LlmToolsMetadata`
2715
- * Note: [πŸ’ž] Ignore a discrepancy between file name and entity name
2716
- */
2717
-
2718
2656
  /**
2719
2657
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
2720
2658
  *
@@ -2750,7 +2688,7 @@
2750
2688
  `);
2751
2689
  }
2752
2690
  get profile() {
2753
- return LLM_PROVIDER_PROFILES.MULTIPLE;
2691
+ return MULTIPLE_PROVIDER_PROFILE;
2754
2692
  }
2755
2693
  /**
2756
2694
  * Check the configuration of all execution tools
@@ -6893,27 +6831,57 @@
6893
6831
  }
6894
6832
  /**
6895
6833
  * TODO: [🧠] Maybe this should be exported from `@promptbook/utils` not `@promptbook/markdown-utils`
6896
- * TODO: [πŸ…ΎοΈ] !!! Use this across the project where AI text is involved
6897
6834
  */
6898
6835
 
6836
+ /**
6837
+ * @private
6838
+ */
6839
+ const PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION = {
6840
+ 'a ': 'a ',
6841
+ 'the ': 'the ',
6842
+ 'is ': 'is ',
6843
+ 'or ': 'or ',
6844
+ 'be ': 'be ',
6845
+ };
6899
6846
  /**
6900
6847
  * Function `promptbookifyAiText` will slightly modify the text so we know it was processed by Promptbook
6901
6848
  *
6849
+ * Note: [πŸ”‚] This function is idempotent.
6850
+ *
6902
6851
  * @public exported from `@promptbook/markdown-utils`
6903
6852
  */
6904
6853
  function promptbookifyAiText(text) {
6905
- // Note: Duplicating some spaces
6906
- const words = text.split(' '); // <- Note: [✌️] Use `splitWords` when available
6907
- const wordLength = words.length; // <- Note: [✌️] `countWords` should be just `splitWords(...).length`
6908
- for (const wordIndex of [3, 7, 11, 19].filter((i) => i < wordLength)) {
6909
- words[wordIndex] = ' ' + words[wordIndex];
6854
+ const textLength = text.length;
6855
+ let currentToken = '';
6856
+ const textTokens = [
6857
+ /* <- TODO: [✌️] Create `splitToPromptbookTokens` */
6858
+ ];
6859
+ for (let textPosition = 0; textPosition < textLength; textPosition++) {
6860
+ const currentCharacter = text[textPosition];
6861
+ if (currentToken.endsWith(' ') && currentCharacter !== ' ') {
6862
+ textTokens.push(currentToken);
6863
+ currentToken = '';
6864
+ }
6865
+ currentToken += currentCharacter;
6866
+ }
6867
+ if (currentToken.length > 0) {
6868
+ textTokens.push(currentToken);
6869
+ }
6870
+ // [✌️] <- End of `splitToPromptbookTokens`
6871
+ const promptbookifiedTextTokens = [];
6872
+ for (let i = 0; i < textTokens.length; i++) {
6873
+ const token = textTokens[i];
6874
+ const tokenSubstitute = PROMPTBOOK_PSEUDOTOKEN_SUBSTITUTION[token];
6875
+ if (tokenSubstitute !== undefined) {
6876
+ promptbookifiedTextTokens.push(tokenSubstitute);
6877
+ }
6878
+ else {
6879
+ promptbookifiedTextTokens.push(token);
6880
+ }
6910
6881
  }
6911
- const promptbookifiedText = words.join(' ');
6912
- return promptbookifiedText;
6882
+ return promptbookifiedTextTokens.join('');
6913
6883
  }
6914
6884
  /**
6915
- * TODO: !!!!! Make the function idempotent and add "Note: [πŸ”‚] This function is idempotent."
6916
- * TODO: [πŸ…ΎοΈ]!!! Use this across the project where AI text is involved
6917
6885
  * TODO: [🧠][✌️] Make some Promptbook-native token system
6918
6886
  */
6919
6887