@sjts/ai-shared 30.2.2

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 (86) hide show
  1. package/LICENCE +5 -0
  2. package/dist/enums/AIModelName.d.ts +36 -0
  3. package/dist/enums/AIModelName.js +48 -0
  4. package/dist/enums/AIProvider.d.ts +14 -0
  5. package/dist/enums/AIProvider.js +15 -0
  6. package/dist/enums/AIToolChoice.d.ts +5 -0
  7. package/dist/enums/AIToolChoice.js +6 -0
  8. package/dist/enums/BeatStage.d.ts +10 -0
  9. package/dist/enums/BeatStage.js +18 -0
  10. package/dist/enums/BeatStatus.d.ts +6 -0
  11. package/dist/enums/BeatStatus.js +7 -0
  12. package/dist/enums/index.d.ts +5 -0
  13. package/dist/enums/index.js +5 -0
  14. package/dist/index.d.ts +5 -0
  15. package/dist/index.js +5 -0
  16. package/dist/llms.d.ts +4 -0
  17. package/dist/llms.js +96 -0
  18. package/dist/llmsets.d.ts +7 -0
  19. package/dist/llmsets.js +27 -0
  20. package/dist/types/AIConfig.d.ts +27 -0
  21. package/dist/types/AIConfig.js +10 -0
  22. package/dist/types/AIEmbedding.d.ts +1 -0
  23. package/dist/types/AIEmbedding.js +1 -0
  24. package/dist/types/AIEvent.d.ts +30 -0
  25. package/dist/types/AIEvent.js +1 -0
  26. package/dist/types/AIEventType.d.ts +6 -0
  27. package/dist/types/AIEventType.js +7 -0
  28. package/dist/types/AIImage.d.ts +4 -0
  29. package/dist/types/AIImage.js +1 -0
  30. package/dist/types/AIThoughtInput.d.ts +7 -0
  31. package/dist/types/AIThoughtInput.js +1 -0
  32. package/dist/types/AIThoughtOutput.d.ts +2 -0
  33. package/dist/types/AIThoughtOutput.js +1 -0
  34. package/dist/types/AITool.d.ts +6 -0
  35. package/dist/types/AITool.js +1 -0
  36. package/dist/types/AIToolCall.d.ts +5 -0
  37. package/dist/types/AIToolCall.js +1 -0
  38. package/dist/types/AIToolResponse.d.ts +5 -0
  39. package/dist/types/AIToolResponse.js +1 -0
  40. package/dist/types/LLM.d.ts +13 -0
  41. package/dist/types/LLM.js +14 -0
  42. package/dist/types/LLMIntelligenceLevel.d.ts +5 -0
  43. package/dist/types/LLMIntelligenceLevel.js +6 -0
  44. package/dist/types/LLMSet.d.ts +6 -0
  45. package/dist/types/LLMSet.js +1 -0
  46. package/dist/types/Param.d.ts +14 -0
  47. package/dist/types/Param.js +1 -0
  48. package/dist/types/ParamType.d.ts +14 -0
  49. package/dist/types/ParamType.js +15 -0
  50. package/dist/types/Prompt.d.ts +5 -0
  51. package/dist/types/Prompt.js +1 -0
  52. package/dist/types/index.d.ts +16 -0
  53. package/dist/types/index.js +16 -0
  54. package/dist/utils/index.d.ts +15 -0
  55. package/dist/utils/index.js +15 -0
  56. package/dist/utils/makeBulletList.d.ts +1 -0
  57. package/dist/utils/makeBulletList.js +24 -0
  58. package/dist/utils/makeCodeBlock.d.ts +1 -0
  59. package/dist/utils/makeCodeBlock.js +3 -0
  60. package/dist/utils/makeH1.d.ts +1 -0
  61. package/dist/utils/makeH1.js +5 -0
  62. package/dist/utils/makeH2.d.ts +1 -0
  63. package/dist/utils/makeH2.js +5 -0
  64. package/dist/utils/makeH3.d.ts +1 -0
  65. package/dist/utils/makeH3.js +5 -0
  66. package/dist/utils/makeH4.d.ts +1 -0
  67. package/dist/utils/makeH4.js +5 -0
  68. package/dist/utils/makeJSONBlock.d.ts +1 -0
  69. package/dist/utils/makeJSONBlock.js +95 -0
  70. package/dist/utils/makeTextBlock.d.ts +1 -0
  71. package/dist/utils/makeTextBlock.js +3 -0
  72. package/dist/utils/makeTypescriptBlock.d.ts +1 -0
  73. package/dist/utils/makeTypescriptBlock.js +10 -0
  74. package/dist/utils/mdAdjustHeadings.d.ts +1 -0
  75. package/dist/utils/mdAdjustHeadings.js +27 -0
  76. package/dist/utils/mergePrompts.d.ts +7 -0
  77. package/dist/utils/mergePrompts.js +17 -0
  78. package/dist/utils/parseJson.d.ts +1 -0
  79. package/dist/utils/parseJson.js +11 -0
  80. package/dist/utils/promptAdjustHeadings.d.ts +2 -0
  81. package/dist/utils/promptAdjustHeadings.js +4 -0
  82. package/dist/utils/textJoin.d.ts +1 -0
  83. package/dist/utils/textJoin.js +3 -0
  84. package/dist/utils/trim.d.ts +1 -0
  85. package/dist/utils/trim.js +5 -0
  86. package/package.json +36 -0
package/LICENCE ADDED
@@ -0,0 +1,5 @@
1
+
2
+ Copyright (C) Mr Stephen James - All Rights Reserved
3
+ Unauthorized copying of any files within this source code repository, via any medium is strictly prohibited
4
+ Proprietary and confidential
5
+ Written by Steve James <steve@stevejames.dev>, March 2019
@@ -0,0 +1,36 @@
1
+ export declare enum AIModelName {
2
+ TEXT_EMBED = "Text Embed",
3
+ GPT4_1 = "GPT 4.1",
4
+ O3 = "o3",
5
+ O4Mini = "o4 Mini",
6
+ O3Mini = "o3 Mini",
7
+ NOVA_PRO = "Nova Pro",
8
+ NOVA_MICRO = "Nova Micro",
9
+ NOVA_LITE = "Nova Lite",
10
+ CLAUDE4_OPUS = "Claude 4.0 Opus",
11
+ CLAUDE4_SONNET = "Claude 4.0 Sonnet",
12
+ CLAUDE3_7_SONNET = "Claude 3.7 Sonnet",
13
+ CLAUDE3_5_SONNET = "Claude 3.5 Sonnet",
14
+ CLAUDE3_5_HAIKU = "Claude 3.5 Haiku",
15
+ GEMINI_2_5_FLASH = "Gemini 2.5 Flash",
16
+ GEMINI_2_5_PRO = "Gemini 2.5 Pro",
17
+ GEMINI_2_0_PRO = "Gemini 2.0 Pro",
18
+ GEMINI_2_0_FLASH = "Gemini 2.0 Flash",
19
+ GROK_3 = "Grok 3",
20
+ GROK_2 = "Grok 2",
21
+ GROK_3_FAST = "Grok 3 Fast",
22
+ GROK_3_MINI = "Grok 3 Mini",
23
+ GROK_3_MINI_FAST = "Grok 3 Mini Fast",
24
+ MISTRAL_LARGE = "Mistral Large",
25
+ MISTRAL_MEDIUM = "Mistral Medium",
26
+ MISTRAL_SMALL = "Mistral Small",
27
+ QWEN_3 = "Qwen 3",
28
+ QWEN_QWQ = "Qwen QwQ",
29
+ LLAMA4_MAVERICK = "Llama 4 Maverick",
30
+ LLAMA4_SCOUT = "Llama 4 Scout",
31
+ LLAMA3_3 = "Llama 3.3",
32
+ DEEPSEEK_V3 = "DeepSeek V3",
33
+ DEEPSEEK_R1 = "DeepSeek R1",
34
+ MERCURY = "Mercury",
35
+ MERCURY_CODER = "Mercury Coder"
36
+ }
@@ -0,0 +1,48 @@
1
+ export var AIModelName;
2
+ (function (AIModelName) {
3
+ // GENERIC
4
+ AIModelName["TEXT_EMBED"] = "Text Embed";
5
+ // OPEN AI
6
+ AIModelName["GPT4_1"] = "GPT 4.1";
7
+ AIModelName["O3"] = "o3";
8
+ AIModelName["O4Mini"] = "o4 Mini";
9
+ AIModelName["O3Mini"] = "o3 Mini";
10
+ // NOVA
11
+ AIModelName["NOVA_PRO"] = "Nova Pro";
12
+ AIModelName["NOVA_MICRO"] = "Nova Micro";
13
+ AIModelName["NOVA_LITE"] = "Nova Lite";
14
+ // CLAUDE
15
+ AIModelName["CLAUDE4_OPUS"] = "Claude 4.0 Opus";
16
+ AIModelName["CLAUDE4_SONNET"] = "Claude 4.0 Sonnet";
17
+ AIModelName["CLAUDE3_7_SONNET"] = "Claude 3.7 Sonnet";
18
+ AIModelName["CLAUDE3_5_SONNET"] = "Claude 3.5 Sonnet";
19
+ AIModelName["CLAUDE3_5_HAIKU"] = "Claude 3.5 Haiku";
20
+ // GEMINI
21
+ AIModelName["GEMINI_2_5_FLASH"] = "Gemini 2.5 Flash";
22
+ AIModelName["GEMINI_2_5_PRO"] = "Gemini 2.5 Pro";
23
+ AIModelName["GEMINI_2_0_PRO"] = "Gemini 2.0 Pro";
24
+ AIModelName["GEMINI_2_0_FLASH"] = "Gemini 2.0 Flash";
25
+ // GROK
26
+ AIModelName["GROK_3"] = "Grok 3";
27
+ AIModelName["GROK_2"] = "Grok 2";
28
+ AIModelName["GROK_3_FAST"] = "Grok 3 Fast";
29
+ AIModelName["GROK_3_MINI"] = "Grok 3 Mini";
30
+ AIModelName["GROK_3_MINI_FAST"] = "Grok 3 Mini Fast";
31
+ // MIXSTRAL
32
+ AIModelName["MISTRAL_LARGE"] = "Mistral Large";
33
+ AIModelName["MISTRAL_MEDIUM"] = "Mistral Medium";
34
+ AIModelName["MISTRAL_SMALL"] = "Mistral Small";
35
+ // QWEN
36
+ AIModelName["QWEN_3"] = "Qwen 3";
37
+ AIModelName["QWEN_QWQ"] = "Qwen QwQ";
38
+ // LLAMA
39
+ AIModelName["LLAMA4_MAVERICK"] = "Llama 4 Maverick";
40
+ AIModelName["LLAMA4_SCOUT"] = "Llama 4 Scout";
41
+ AIModelName["LLAMA3_3"] = "Llama 3.3";
42
+ // DEEPSEEK
43
+ AIModelName["DEEPSEEK_V3"] = "DeepSeek V3";
44
+ AIModelName["DEEPSEEK_R1"] = "DeepSeek R1";
45
+ // MERCURY
46
+ AIModelName["MERCURY"] = "Mercury";
47
+ AIModelName["MERCURY_CODER"] = "Mercury Coder";
48
+ })(AIModelName || (AIModelName = {}));
@@ -0,0 +1,14 @@
1
+ export declare enum AIProvider {
2
+ OPENAI = "Open AI",
3
+ ANTHROPIC = "Anthropic",
4
+ GOOGLE = "Google",
5
+ AMAZON = "Amazon",
6
+ XAI = "xAI",
7
+ MISTRAL = "Mistral",
8
+ TOGETHERAI = "Together AI",
9
+ GROQ = "Groq",
10
+ SAMBANOVA = "Samba Nova",
11
+ CEREBRAS = "Cerebras",
12
+ VOYAGEAI = "Voyage AI",
13
+ INCEPTION_LABS = "Inception Labs"
14
+ }
@@ -0,0 +1,15 @@
1
+ export var AIProvider;
2
+ (function (AIProvider) {
3
+ AIProvider["OPENAI"] = "Open AI";
4
+ AIProvider["ANTHROPIC"] = "Anthropic";
5
+ AIProvider["GOOGLE"] = "Google";
6
+ AIProvider["AMAZON"] = "Amazon";
7
+ AIProvider["XAI"] = "xAI";
8
+ AIProvider["MISTRAL"] = "Mistral";
9
+ AIProvider["TOGETHERAI"] = "Together AI";
10
+ AIProvider["GROQ"] = "Groq";
11
+ AIProvider["SAMBANOVA"] = "Samba Nova";
12
+ AIProvider["CEREBRAS"] = "Cerebras";
13
+ AIProvider["VOYAGEAI"] = "Voyage AI";
14
+ AIProvider["INCEPTION_LABS"] = "Inception Labs";
15
+ })(AIProvider || (AIProvider = {}));
@@ -0,0 +1,5 @@
1
+ export declare enum AIToolChoice {
2
+ REQUIRED = "required",
3
+ AUTO = "auto",
4
+ NONE = "none"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var AIToolChoice;
2
+ (function (AIToolChoice) {
3
+ AIToolChoice["REQUIRED"] = "required";
4
+ AIToolChoice["AUTO"] = "auto";
5
+ AIToolChoice["NONE"] = "none";
6
+ })(AIToolChoice || (AIToolChoice = {}));
@@ -0,0 +1,10 @@
1
+ export declare enum BeatStage {
2
+ START = "start",
3
+ RECOLLECTION = "recollection",
4
+ PERCEPTION = "perception",
5
+ TASK_EXECUTION = "task_execution",
6
+ EXECUTIVE_CONTROL = "executive_control",
7
+ ACTUATION = "actuation",
8
+ STOP = "stop"
9
+ }
10
+ export declare const BeatStages: BeatStage[];
@@ -0,0 +1,18 @@
1
+ export var BeatStage;
2
+ (function (BeatStage) {
3
+ BeatStage["START"] = "start";
4
+ BeatStage["RECOLLECTION"] = "recollection";
5
+ BeatStage["PERCEPTION"] = "perception";
6
+ BeatStage["TASK_EXECUTION"] = "task_execution";
7
+ BeatStage["EXECUTIVE_CONTROL"] = "executive_control";
8
+ BeatStage["ACTUATION"] = "actuation";
9
+ BeatStage["STOP"] = "stop";
10
+ })(BeatStage || (BeatStage = {}));
11
+ export const BeatStages = [
12
+ BeatStage.START,
13
+ BeatStage.RECOLLECTION,
14
+ BeatStage.PERCEPTION,
15
+ BeatStage.EXECUTIVE_CONTROL,
16
+ BeatStage.ACTUATION,
17
+ BeatStage.STOP,
18
+ ];
@@ -0,0 +1,6 @@
1
+ export declare enum AgiBeatStatus {
2
+ RUNNING = "RUNNING",
3
+ CANCELLED = "CANCELLED",
4
+ COMPLETE = "COMPLETE",
5
+ FAILED = "FAILED"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var AgiBeatStatus;
2
+ (function (AgiBeatStatus) {
3
+ AgiBeatStatus["RUNNING"] = "RUNNING";
4
+ AgiBeatStatus["CANCELLED"] = "CANCELLED";
5
+ AgiBeatStatus["COMPLETE"] = "COMPLETE";
6
+ AgiBeatStatus["FAILED"] = "FAILED";
7
+ })(AgiBeatStatus || (AgiBeatStatus = {}));
@@ -0,0 +1,5 @@
1
+ export * from './AIModelName.js';
2
+ export * from './AIProvider.js';
3
+ export * from './AIToolChoice.js';
4
+ export * from './BeatStage.js';
5
+ export * from './BeatStatus.js';
@@ -0,0 +1,5 @@
1
+ export * from './AIModelName.js';
2
+ export * from './AIProvider.js';
3
+ export * from './AIToolChoice.js';
4
+ export * from './BeatStage.js';
5
+ export * from './BeatStatus.js';
@@ -0,0 +1,5 @@
1
+ export * from './enums/index.js';
2
+ export * from './llms.js';
3
+ export * from './llmsets.js';
4
+ export * from './types/index.js';
5
+ export * from './utils/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './enums/index.js';
2
+ export * from './llms.js';
3
+ export * from './llmsets.js';
4
+ export * from './types/index.js';
5
+ export * from './utils/index.js';
package/dist/llms.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { AIProvider, AIModelName as M } from './enums/index.js';
2
+ import { LLM } from './types/LLM.js';
3
+ export declare const llms: Record<AIProvider, LLM[]>;
4
+ export declare const findLLM: (provider: AIProvider, model: M) => LLM;
package/dist/llms.js ADDED
@@ -0,0 +1,96 @@
1
+ import { AIModelName as M, AIProvider as P } from './enums/index.js';
2
+ import { makeLLM as make } from './types/LLM.js';
3
+ const T = true;
4
+ const F = false;
5
+ // prettier-ignore
6
+ export const llms = {
7
+ // Open AI
8
+ [P.OPENAI]: [
9
+ make(P.OPENAI, M.GPT4_1, 'gpt-4.1-2025-04-14', T, T, 2, 8, 88.83),
10
+ make(P.OPENAI, M.O3, 'o3', T, T, 10, 40, 17.9),
11
+ make(P.OPENAI, M.O4Mini, 'o4-mini-2025-04-16', T, T, 1.1, 4.4, 25.13),
12
+ make(P.OPENAI, M.O3Mini, 'o3-mini', T, T, 1.1, 4.4, 30.62),
13
+ make(P.OPENAI, M.TEXT_EMBED, 'text-embedding-3-small')
14
+ ],
15
+ // Anthropic
16
+ [P.ANTHROPIC]: [
17
+ make(P.ANTHROPIC, M.CLAUDE4_OPUS, 'claude-opus-4-20250514', T, T, 15, 75, 64.11),
18
+ make(P.ANTHROPIC, M.CLAUDE4_SONNET, 'claude-sonnet-4-20250514', T, T, 3, 15, 64.11),
19
+ make(P.ANTHROPIC, M.CLAUDE3_7_SONNET, 'claude-3-7-sonnet-latest', T, T, 3, 15, 64.11),
20
+ make(P.ANTHROPIC, M.CLAUDE3_5_SONNET, 'claude-3-5-sonnet-latest', T, T, 3, 15, 64.55),
21
+ make(P.ANTHROPIC, M.CLAUDE3_5_HAIKU, 'claude-3-5-haiku-latest', T, T, 0.8, 4, 61.3),
22
+ ],
23
+ // Amazon
24
+ [P.AMAZON]: [
25
+ make(P.AMAZON, M.NOVA_PRO, 'arn:aws:bedrock:ap-southeast-2:396657583517:inference-profile/apac.amazon.nova-pro-v1:0', T, T),
26
+ make(P.AMAZON, M.NOVA_MICRO, 'amazon.nova-micro-v1:0', T, T),
27
+ make(P.AMAZON, M.NOVA_LITE, 'amazon.nova-lite-v1:0', T, T),
28
+ make(P.AMAZON, M.CLAUDE3_5_SONNET, 'arn:aws:bedrock:ap-southeast-2:396657583517:inference-profile/apac.anthropic.claude-3-5-sonnet-20241022-v2:0', T, T),
29
+ make(P.AMAZON, M.CLAUDE3_7_SONNET, 'arn:aws:bedrock:ap-southeast-2:396657583517:inference-profile/apac.anthropic.claude-3-7-sonnet-20250219-v1:0', T, T)
30
+ ],
31
+ // Google
32
+ [P.GOOGLE]: [
33
+ make(P.GOOGLE, M.GEMINI_2_5_PRO, 'gemini-2.5-pro-exp-03-25', T, T, 1.25, 15, 74.31),
34
+ make(P.GOOGLE, M.GEMINI_2_5_FLASH, 'models/gemini-2.5-flash-preview-04-17', T, T, 0.15, 0.6, 133.58),
35
+ make(P.GOOGLE, M.GEMINI_2_0_FLASH, 'gemini-2.0-flash', T, T, 0.1, 0.4, 144.4),
36
+ ],
37
+ // Grok
38
+ [P.XAI]: [
39
+ make(P.XAI, M.GROK_3, 'grok-3-beta', T, T, 3, 15, 34.63),
40
+ make(P.XAI, M.GROK_3_FAST, 'grok-3-fast-beta', T, T, 5, 25, 80.43),
41
+ make(P.XAI, M.GROK_3_MINI, 'grok-3-mini-beta', T, T, 0.3, 0.5, 32.03),
42
+ make(P.XAI, M.GROK_3_MINI_FAST, 'grok-3-mini-fast-beta', T, T, 0.6, 4, 59.84),
43
+ ],
44
+ // Mistral
45
+ [P.MISTRAL]: [
46
+ make(P.MISTRAL, M.MISTRAL_LARGE, 'mistral-large-latest', T, T, 2, 6, 20.15),
47
+ make(P.MISTRAL, M.MISTRAL_MEDIUM, 'mistral-medium-2505', T, T, 0.4, 2),
48
+ make(P.MISTRAL, M.MISTRAL_SMALL, 'mistral-small-latest', T, T, 0.1, 0.3, 56.65),
49
+ ],
50
+ // Together AI
51
+ [P.TOGETHERAI]: [
52
+ make(P.TOGETHERAI, M.LLAMA4_MAVERICK, 'meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8', T, T, 0.27, 0.85, 78.49),
53
+ make(P.TOGETHERAI, M.LLAMA4_SCOUT, 'meta-llama/Llama-4-Scout-17B-16E-Instruct', T, T, 0.18, 0.59, 71.58),
54
+ make(P.TOGETHERAI, M.LLAMA3_3, 'meta-llama/Llama-3.3-70B-Instruct-Turbo', T, T, 0, .88, 153.97),
55
+ make(P.TOGETHERAI, M.DEEPSEEK_V3, 'deepseek-ai/DeepSeek-V3', T, T, 0, 1.25, 48.43),
56
+ make(P.TOGETHERAI, M.QWEN_3, 'Qwen/Qwen3-235B-A22B-fp8-tput', T, T, 0.2, 0.6, 11.87),
57
+ ],
58
+ // Groq
59
+ [P.GROQ]: [
60
+ make(P.GROQ, M.LLAMA4_MAVERICK, 'meta-llama/llama-4-maverick-17b-128e-instruct', T, T, 0.2, 0.6, 174.28),
61
+ make(P.GROQ, M.LLAMA4_SCOUT, 'meta-llama/llama-4-scout-17b-16e-instruct', T, T, 0.11, 0.34, 321.89),
62
+ make(P.GROQ, M.LLAMA3_3, 'llama-3.3-70b-versatile', T, T, 0.59, 0.79, 183.27),
63
+ make(P.GROQ, M.DEEPSEEK_R1, 'deepseek-r1-distill-llama-70b', T, T, 0.29, 0.39, 149.36),
64
+ make(P.GROQ, M.QWEN_QWQ, 'qwen-qwq-32b', T, T, 0.29, 0.39, 149.36),
65
+ ],
66
+ // Inception Labs
67
+ [P.INCEPTION_LABS]: [
68
+ make(P.INCEPTION_LABS, M.MERCURY, 'mercury'),
69
+ make(P.INCEPTION_LABS, M.MERCURY_CODER, 'mercury-coder'),
70
+ ],
71
+ // SambaNova
72
+ [P.SAMBANOVA]: [
73
+ make(P.SAMBANOVA, M.DEEPSEEK_V3, 'DeepSeek-V3-0324', T, T, 3, 4.5, 140),
74
+ make(P.SAMBANOVA, M.LLAMA4_MAVERICK, 'Llama-4-Maverick-17B-128E-Instruct', T, T, 0.63, 1.8, 272.04),
75
+ make(P.SAMBANOVA, M.LLAMA4_SCOUT, 'Llama-4-Scout-17B-16E-Instruct', T, T, 0.4, 0.7, 211.93),
76
+ make(P.SAMBANOVA, M.QWEN_3, 'Qwen3-32B', T, T, 0.29, 0.39, 130.71),
77
+ ],
78
+ // Cerebras
79
+ [P.CEREBRAS]: [
80
+ make(P.CEREBRAS, M.LLAMA4_SCOUT, 'llama-4-scout-17b-16e-instruct', T, T),
81
+ make(P.CEREBRAS, M.LLAMA3_3, 'llama-3.3-70b', T, T),
82
+ ],
83
+ // Voyage AI
84
+ [P.VOYAGEAI]: [
85
+ make(P.VOYAGEAI, M.TEXT_EMBED, 'voyage-3-large')
86
+ ],
87
+ };
88
+ export const findLLM = (provider, model) => {
89
+ const models = llms[provider];
90
+ if (!models)
91
+ throw new Error(`Provider ${provider} not found`);
92
+ const retVal = models.find(m => m.modelName === model);
93
+ if (!retVal)
94
+ throw new Error(`Model ${model} not found for provider ${provider}`);
95
+ return retVal;
96
+ };
@@ -0,0 +1,7 @@
1
+ import { LLMSet } from './types';
2
+ export declare const llmsets: {
3
+ level4: LLMSet;
4
+ level3: LLMSet;
5
+ level2: LLMSet;
6
+ level1: LLMSet;
7
+ };
@@ -0,0 +1,27 @@
1
+ import { AIModelName, AIProvider } from './enums';
2
+ import { LLMIntelligenceLevel, makeLLMKey } from './types';
3
+ const CLAUDE4 = makeLLMKey(AIProvider.ANTHROPIC, AIModelName.CLAUDE4_SONNET);
4
+ const CLAUDE3_5 = makeLLMKey(AIProvider.ANTHROPIC, AIModelName.CLAUDE3_5_SONNET);
5
+ const LLAMA4 = makeLLMKey(AIProvider.GROQ, AIModelName.LLAMA4_MAVERICK);
6
+ export const llmsets = {
7
+ level4: {
8
+ [LLMIntelligenceLevel.SUPERSMART]: CLAUDE4,
9
+ [LLMIntelligenceLevel.SMART]: CLAUDE4,
10
+ [LLMIntelligenceLevel.QUICK]: LLAMA4,
11
+ },
12
+ level3: {
13
+ [LLMIntelligenceLevel.SUPERSMART]: CLAUDE4,
14
+ [LLMIntelligenceLevel.SMART]: CLAUDE3_5,
15
+ [LLMIntelligenceLevel.QUICK]: LLAMA4,
16
+ },
17
+ level2: {
18
+ [LLMIntelligenceLevel.SUPERSMART]: CLAUDE4,
19
+ [LLMIntelligenceLevel.SMART]: LLAMA4,
20
+ [LLMIntelligenceLevel.QUICK]: LLAMA4,
21
+ },
22
+ level1: {
23
+ [LLMIntelligenceLevel.SUPERSMART]: LLAMA4,
24
+ [LLMIntelligenceLevel.SMART]: LLAMA4,
25
+ [LLMIntelligenceLevel.QUICK]: LLAMA4,
26
+ },
27
+ };
@@ -0,0 +1,27 @@
1
+ import { APIConfig } from '@sjts/lib-utils';
2
+ import { AIToolChoice } from '../enums/AIToolChoice.js';
3
+ import { LLM } from './LLM.js';
4
+ export type AIModelConfig = {
5
+ llm: LLM;
6
+ api: APIConfig;
7
+ };
8
+ export type AIConfig = AIModelConfig & {
9
+ timeout?: number;
10
+ max_tokens?: number;
11
+ temperature?: number;
12
+ top_p?: number;
13
+ frequency_penalty?: number;
14
+ presence_penalty?: number;
15
+ dimensions?: number;
16
+ tool_choice?: AIToolChoice;
17
+ jsonMode?: boolean;
18
+ };
19
+ export declare const defaultAIConfig: {
20
+ timeout: number;
21
+ max_tokens: number;
22
+ temperature: number;
23
+ top_p: number;
24
+ frequency_penalty: number;
25
+ presence_penalty: number;
26
+ tool_choice: AIToolChoice;
27
+ };
@@ -0,0 +1,10 @@
1
+ import { AIToolChoice } from '../enums/AIToolChoice.js';
2
+ export const defaultAIConfig = {
3
+ timeout: 1000 * 60,
4
+ max_tokens: 2048 * 2,
5
+ temperature: 0.5,
6
+ top_p: 1,
7
+ frequency_penalty: 0,
8
+ presence_penalty: 0,
9
+ tool_choice: AIToolChoice.AUTO,
10
+ };
@@ -0,0 +1 @@
1
+ export type AIEmbedding = number[];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ import { AIEventType } from './AIEventType.js';
2
+ import { AIImage } from './AIImage.js';
3
+ import { AIToolCall } from './AIToolCall.js';
4
+ import { AIToolResponse } from './AIToolResponse.js';
5
+ export type AIEventBase = {
6
+ id?: string;
7
+ type: AIEventType;
8
+ createdAt?: string;
9
+ updatedAt?: string;
10
+ };
11
+ export type AIEventUserChat = AIEventBase & {
12
+ type: AIEventType.USER_CHAT;
13
+ content: string;
14
+ images?: AIImage[];
15
+ };
16
+ export type AIEventAIChat = AIEventBase & {
17
+ type: AIEventType.AI_CHAT;
18
+ content: string;
19
+ };
20
+ export type AIEventToolRequest = AIEventBase & {
21
+ type: AIEventType.TOOL_REQUEST;
22
+ content?: string;
23
+ toolCalls: AIToolCall[];
24
+ };
25
+ export type AIEventToolResponse = AIEventBase & AIToolResponse & {
26
+ type: AIEventType.TOOL_RESPONSE;
27
+ };
28
+ export type AIEvent = AIEventAIChat | AIEventUserChat | AIEventToolRequest | AIEventToolResponse;
29
+ export type AIEventChat = AIEventAIChat | AIEventUserChat;
30
+ export type AIEventTool = AIEventToolRequest | AIEventToolResponse;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare enum AIEventType {
2
+ USER_CHAT = "USER_CHAT",
3
+ AI_CHAT = "AI_CHAT",
4
+ TOOL_REQUEST = "TOOL_REQUEST",
5
+ TOOL_RESPONSE = "TOOL_RESPONSE"
6
+ }
@@ -0,0 +1,7 @@
1
+ export var AIEventType;
2
+ (function (AIEventType) {
3
+ AIEventType["USER_CHAT"] = "USER_CHAT";
4
+ AIEventType["AI_CHAT"] = "AI_CHAT";
5
+ AIEventType["TOOL_REQUEST"] = "TOOL_REQUEST";
6
+ AIEventType["TOOL_RESPONSE"] = "TOOL_RESPONSE";
7
+ })(AIEventType || (AIEventType = {}));
@@ -0,0 +1,4 @@
1
+ export type AIImage = {
2
+ mime: string;
3
+ data: string;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import { AIEvent } from './AIEvent.js';
2
+ import { AITool } from './AITool.js';
3
+ export type AIThoughtInput = {
4
+ context?: string;
5
+ history: AIEvent[];
6
+ tools?: AITool[];
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { AIEventAIChat, AIEventToolRequest } from './AIEvent.js';
2
+ export type AIThoughtOutput = AIEventAIChat | AIEventToolRequest;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { Params } from './Param.js';
2
+ export type AITool = {
3
+ key: string;
4
+ description?: string;
5
+ params: Params;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export type AIToolCall = {
2
+ callId: string;
3
+ tool: string;
4
+ params: any;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export type AIToolResponse = {
2
+ callId: string;
3
+ tool: string;
4
+ content: string;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export type LLM = {
2
+ key: string;
3
+ provider: string;
4
+ modelName: string;
5
+ model: string;
6
+ tooluse?: boolean;
7
+ vision?: boolean;
8
+ speed: number;
9
+ costIn: number;
10
+ costOut: number;
11
+ };
12
+ export declare const makeLLMKey: (provider: string, modelName: string) => string;
13
+ export declare function makeLLM(provider: string, modelName: string, model: string, tooluse?: boolean, vision?: boolean, costIn?: number, costOut?: number, speed?: number): LLM;
@@ -0,0 +1,14 @@
1
+ export const makeLLMKey = (provider, modelName) => `${provider}###${modelName}`;
2
+ export function makeLLM(provider, modelName, model, tooluse = false, vision = false, costIn = 99999, costOut = 99999, speed = 99999) {
3
+ return {
4
+ key: makeLLMKey(provider, modelName),
5
+ provider,
6
+ modelName,
7
+ model,
8
+ tooluse,
9
+ vision,
10
+ speed,
11
+ costIn,
12
+ costOut,
13
+ };
14
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum LLMIntelligenceLevel {
2
+ SUPERSMART = "supersmart",
3
+ SMART = "smart",
4
+ QUICK = "quick"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var LLMIntelligenceLevel;
2
+ (function (LLMIntelligenceLevel) {
3
+ LLMIntelligenceLevel["SUPERSMART"] = "supersmart";
4
+ LLMIntelligenceLevel["SMART"] = "smart";
5
+ LLMIntelligenceLevel["QUICK"] = "quick";
6
+ })(LLMIntelligenceLevel || (LLMIntelligenceLevel = {}));
@@ -0,0 +1,6 @@
1
+ import { LLMIntelligenceLevel } from './LLMIntelligenceLevel.js';
2
+ export type LLMSet = {
3
+ [LLMIntelligenceLevel.SUPERSMART]: string;
4
+ [LLMIntelligenceLevel.SMART]: string;
5
+ [LLMIntelligenceLevel.QUICK]: string;
6
+ };
@@ -0,0 +1 @@
1
+ import { LLMIntelligenceLevel } from './LLMIntelligenceLevel.js';
@@ -0,0 +1,14 @@
1
+ import { ParamType } from './ParamType.js';
2
+ export type Params = {
3
+ [key: string]: Param;
4
+ };
5
+ export type Param = {
6
+ type: ParamType;
7
+ min?: number;
8
+ max?: number;
9
+ description?: string;
10
+ enum?: string[];
11
+ example?: any;
12
+ required?: boolean;
13
+ properties?: Params;
14
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ export declare enum ParamType {
2
+ BOOLEAN = "BOOLEAN",
3
+ BOOLEAN_ARRAY = "BOOLEAN_ARRAY",
4
+ NUMBER = "NUMBER",
5
+ NUMBER_ARRAY = "NUMBER_ARRAY",
6
+ STRING = "STRING",
7
+ STRING_ARRAY = "STRING_ARRAY",
8
+ DATE = "DATE",
9
+ DATE_ARRAY = "DATE_ARRAY",
10
+ DATE_TIME = "DATE_TIME",
11
+ DATE_TIME_ARRAY = "DATE_TIME_ARRAY",
12
+ OBJECT = "OBJECT",
13
+ OBJECT_ARRAY = "OBJECT_ARRAY"
14
+ }
@@ -0,0 +1,15 @@
1
+ export var ParamType;
2
+ (function (ParamType) {
3
+ ParamType["BOOLEAN"] = "BOOLEAN";
4
+ ParamType["BOOLEAN_ARRAY"] = "BOOLEAN_ARRAY";
5
+ ParamType["NUMBER"] = "NUMBER";
6
+ ParamType["NUMBER_ARRAY"] = "NUMBER_ARRAY";
7
+ ParamType["STRING"] = "STRING";
8
+ ParamType["STRING_ARRAY"] = "STRING_ARRAY";
9
+ ParamType["DATE"] = "DATE";
10
+ ParamType["DATE_ARRAY"] = "DATE_ARRAY";
11
+ ParamType["DATE_TIME"] = "DATE_TIME";
12
+ ParamType["DATE_TIME_ARRAY"] = "DATE_TIME_ARRAY";
13
+ ParamType["OBJECT"] = "OBJECT";
14
+ ParamType["OBJECT_ARRAY"] = "OBJECT_ARRAY";
15
+ })(ParamType || (ParamType = {}));
@@ -0,0 +1,5 @@
1
+ import { AIImage } from './AIImage.js';
2
+ export type Prompt = {
3
+ text: string;
4
+ images?: AIImage[];
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export * from './AIConfig.js';
2
+ export * from './AIEmbedding.js';
3
+ export * from './AIEvent.js';
4
+ export * from './AIEventType.js';
5
+ export * from './AIImage.js';
6
+ export * from './AIThoughtInput.js';
7
+ export * from './AIThoughtOutput.js';
8
+ export * from './AITool.js';
9
+ export * from './AIToolCall.js';
10
+ export * from './AIToolResponse.js';
11
+ export * from './LLM.js';
12
+ export * from './LLMIntelligenceLevel.js';
13
+ export * from './LLMSet.js';
14
+ export * from './Param.js';
15
+ export * from './ParamType.js';
16
+ export * from './Prompt.js';
@@ -0,0 +1,16 @@
1
+ export * from './AIConfig.js';
2
+ export * from './AIEmbedding.js';
3
+ export * from './AIEvent.js';
4
+ export * from './AIEventType.js';
5
+ export * from './AIImage.js';
6
+ export * from './AIThoughtInput.js';
7
+ export * from './AIThoughtOutput.js';
8
+ export * from './AITool.js';
9
+ export * from './AIToolCall.js';
10
+ export * from './AIToolResponse.js';
11
+ export * from './LLM.js';
12
+ export * from './LLMIntelligenceLevel.js';
13
+ export * from './LLMSet.js';
14
+ export * from './Param.js';
15
+ export * from './ParamType.js';
16
+ export * from './Prompt.js';
@@ -0,0 +1,15 @@
1
+ export * from './makeBulletList.js';
2
+ export * from './makeCodeBlock.js';
3
+ export * from './makeH1.js';
4
+ export * from './makeH2.js';
5
+ export * from './makeH3.js';
6
+ export * from './makeH4.js';
7
+ export * from './makeJSONBlock.js';
8
+ export * from './makeTextBlock.js';
9
+ export * from './makeTypescriptBlock.js';
10
+ export * from './mdAdjustHeadings.js';
11
+ export * from './mergePrompts.js';
12
+ export * from './parseJson.js';
13
+ export * from './promptAdjustHeadings.js';
14
+ export * from './textJoin.js';
15
+ export * from './trim.js';
@@ -0,0 +1,15 @@
1
+ export * from './makeBulletList.js';
2
+ export * from './makeCodeBlock.js';
3
+ export * from './makeH1.js';
4
+ export * from './makeH2.js';
5
+ export * from './makeH3.js';
6
+ export * from './makeH4.js';
7
+ export * from './makeJSONBlock.js';
8
+ export * from './makeTextBlock.js';
9
+ export * from './makeTypescriptBlock.js';
10
+ export * from './mdAdjustHeadings.js';
11
+ export * from './mergePrompts.js';
12
+ export * from './parseJson.js';
13
+ export * from './promptAdjustHeadings.js';
14
+ export * from './textJoin.js';
15
+ export * from './trim.js';
@@ -0,0 +1 @@
1
+ export declare function makeBulletList(content: string | string[], emtpyText?: string): string;
@@ -0,0 +1,24 @@
1
+ export function makeBulletList(content, emtpyText = '') {
2
+ return Array.isArray(content)
3
+ ? !content?.length
4
+ ? emtpyText
5
+ : content.map(c => indentAndBullet(c)).join('\n')
6
+ : !content
7
+ ? emtpyText
8
+ : content;
9
+ }
10
+ function indentAndBullet(c) {
11
+ const tabSplit = c.split('\t');
12
+ let blah = true;
13
+ let output = '- ';
14
+ for (let bit of tabSplit) {
15
+ if (!bit && blah) {
16
+ output = `\t${output}`;
17
+ }
18
+ else {
19
+ blah = false;
20
+ output += bit;
21
+ }
22
+ }
23
+ return output.endsWith('.') ? output : output + '.';
24
+ }
@@ -0,0 +1 @@
1
+ export declare function makeCodeBlock(content: string, emptyText?: string): string;
@@ -0,0 +1,3 @@
1
+ export function makeCodeBlock(content, emptyText = 'No data') {
2
+ return !content?.length ? emptyText : '```\n' + content + '\n```';
3
+ }
@@ -0,0 +1 @@
1
+ export declare function makeH1(title: string): string;
@@ -0,0 +1,5 @@
1
+ export function makeH1(title) {
2
+ if (!title)
3
+ return '';
4
+ return `# ${title}`;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function makeH2(title: string): string;
@@ -0,0 +1,5 @@
1
+ export function makeH2(title) {
2
+ if (!title)
3
+ return '';
4
+ return `## ${title}`;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function makeH3(title: string): string;
@@ -0,0 +1,5 @@
1
+ export function makeH3(title) {
2
+ if (!title)
3
+ return '';
4
+ return `### ${title}`;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function makeH4(title: string): string;
@@ -0,0 +1,5 @@
1
+ export function makeH4(title) {
2
+ if (!title)
3
+ return '';
4
+ return `#### ${title}`;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function makeJSONBlock(content: any | any[], emptyText?: string): string;
@@ -0,0 +1,95 @@
1
+ export function makeJSONBlock(content, emptyText = 'No data') {
2
+ return Array.isArray(content)
3
+ ? !content?.length
4
+ ? emptyText
5
+ : '```json\n' + parseJsonWithComments(content) + '\n```'
6
+ : !content
7
+ ? emptyText
8
+ : '```json\n' + parseJsonWithComments(content) + '\n```';
9
+ }
10
+ function isCommentObject(obj) {
11
+ return (obj !== null &&
12
+ typeof obj === 'object' &&
13
+ '__comment' in obj &&
14
+ 'value' in obj &&
15
+ Object.keys(obj).length === 2);
16
+ }
17
+ function parseJsonWithComments(obj, indent = 0) {
18
+ const indentStr = ' '.repeat(indent);
19
+ const nextIndentStr = ' '.repeat(indent + 3);
20
+ // Handle comment objects at the root level
21
+ if (isCommentObject(obj)) {
22
+ const commentLines = obj.__comment.split('\n');
23
+ const comments = commentLines.map(line => `${indentStr}// ${line}`).join('\n');
24
+ return comments + '\n' + parseJsonWithComments(obj.value, indent);
25
+ }
26
+ if (Array.isArray(obj)) {
27
+ if (obj.length === 0) {
28
+ return '[]';
29
+ }
30
+ let result = '[\n';
31
+ for (let i = 0; i < obj.length; i++) {
32
+ const item = obj[i];
33
+ if (isCommentObject(item)) {
34
+ // Add comment lines
35
+ const commentLines = item.__comment.split('\n');
36
+ commentLines.forEach(line => {
37
+ result += `${nextIndentStr}// ${line}\n`;
38
+ });
39
+ // Add the actual value
40
+ result += `${nextIndentStr}${parseJsonWithComments(item.value, indent + 3)}`;
41
+ }
42
+ else {
43
+ result += `${nextIndentStr}${parseJsonWithComments(item, indent + 3)}`;
44
+ }
45
+ if (i < obj.length - 1) {
46
+ result += ',';
47
+ }
48
+ result += '\n';
49
+ }
50
+ result += `${indentStr}]`;
51
+ return result;
52
+ }
53
+ if (obj !== null && typeof obj === 'object') {
54
+ const keys = Object.keys(obj);
55
+ if (keys.length === 0) {
56
+ return '{}';
57
+ }
58
+ let result = '{\n';
59
+ const keyCount = keys.length;
60
+ let processedKeys = 0;
61
+ for (const key of keys) {
62
+ const value = obj[key];
63
+ if (isCommentObject(value)) {
64
+ // Add comment lines
65
+ const commentLines = value.__comment.split('\n');
66
+ commentLines.forEach(line => {
67
+ result += `${nextIndentStr}// ${line}\n`;
68
+ });
69
+ // Add the key-value pair with quoted property name
70
+ result += `${nextIndentStr}${JSON.stringify(key)}: ${parseJsonWithComments(value.value, indent + 3)}`;
71
+ }
72
+ else {
73
+ // Quote the property name for valid JSON
74
+ result += `${nextIndentStr}${JSON.stringify(key)}: ${parseJsonWithComments(value, indent + 3)}`;
75
+ }
76
+ processedKeys++;
77
+ if (processedKeys < keyCount) {
78
+ result += ',';
79
+ }
80
+ result += '\n';
81
+ }
82
+ result += `${indentStr}}`;
83
+ return result;
84
+ }
85
+ // Handle primitive values
86
+ if (typeof obj === 'string') {
87
+ return JSON.stringify(obj);
88
+ }
89
+ else if (obj === undefined) {
90
+ return 'undefined';
91
+ }
92
+ else {
93
+ return JSON.stringify(obj);
94
+ }
95
+ }
@@ -0,0 +1 @@
1
+ export declare function makeTextBlock(content: string, emptyText?: string): string;
@@ -0,0 +1,3 @@
1
+ export function makeTextBlock(content, emptyText = 'No data') {
2
+ return !content?.length ? emptyText : '```text\n' + content + '\n```';
3
+ }
@@ -0,0 +1 @@
1
+ export declare function makeTypescriptBlock(content: string, lineNos?: boolean): string;
@@ -0,0 +1,10 @@
1
+ export function makeTypescriptBlock(content, lineNos = false) {
2
+ const lines = content
3
+ .split('\n')
4
+ .map((l, idx) => (lineNos ? contentLine(l, idx) : l))
5
+ .join('\n');
6
+ return '```typescript' + (lineNos ? ' showLineNumbers' : '') + '\n' + lines + '\n```';
7
+ }
8
+ function contentLine(line, idx) {
9
+ return `${(idx + 1).toString().padStart(4, ' ')} ${line}`;
10
+ }
@@ -0,0 +1 @@
1
+ export declare function mdAdjustHeadings(md: string, topLevel: number): string;
@@ -0,0 +1,27 @@
1
+ export function mdAdjustHeadings(md, topLevel) {
2
+ // Split the prompt into lines for processing
3
+ const lines = md.split('\n');
4
+ const result = [];
5
+ // Process each line
6
+ for (let line of lines) {
7
+ // Check if the line is a heading (starts with one or more '#' characters)
8
+ const headingMatch = line.match(/^(#+)\s+(.*)/);
9
+ if (headingMatch) {
10
+ // Extract the heading level and content
11
+ const currentLevel = headingMatch[1].length;
12
+ const headingContent = headingMatch[2];
13
+ // Calculate the new heading level (original level + topLevel - 1)
14
+ // This ensures that level 1 headings become topLevel headings
15
+ const newLevel = currentLevel + topLevel - 1;
16
+ // Construct the new heading with the adjusted level
17
+ const newHeading = '#'.repeat(newLevel) + ' ' + headingContent;
18
+ result.push(newHeading);
19
+ }
20
+ else {
21
+ // Not a heading, keep the line as is
22
+ result.push(line);
23
+ }
24
+ }
25
+ // Join the lines back together and return
26
+ return result.join('\n');
27
+ }
@@ -0,0 +1,7 @@
1
+ import { Prompt } from '../types/index.js';
2
+ export type MergePromptsOptions = {
3
+ joiner?: string;
4
+ title?: string;
5
+ level?: number;
6
+ };
7
+ export declare const mergePrompts: (prompts: Prompt[], o?: MergePromptsOptions) => Prompt;
@@ -0,0 +1,17 @@
1
+ import { makeH1 } from './makeH1.js';
2
+ import { promptAdjustHeadings } from './promptAdjustHeadings.js';
3
+ import { textJoin } from './textJoin.js';
4
+ export const mergePrompts = (prompts, o = {}) => {
5
+ const { joiner = '', title, level = 1 } = o;
6
+ const texts = prompts.map(p => p.text).filter(Boolean);
7
+ const images = prompts
8
+ .map(p => p.images)
9
+ .filter(Boolean)
10
+ .flat();
11
+ return promptAdjustHeadings({
12
+ text: texts?.length
13
+ ? textJoin([title ? makeH1(title) : undefined, texts.join(joiner + '\n')])
14
+ : '',
15
+ images,
16
+ }, level);
17
+ };
@@ -0,0 +1 @@
1
+ export declare function parseJson<T = any>(json?: string): T | undefined;
@@ -0,0 +1,11 @@
1
+ import { Logger } from '@sjts/lib-log';
2
+ import { jsonrepair } from 'jsonrepair';
3
+ export function parseJson(json) {
4
+ try {
5
+ return JSON.parse(jsonrepair(json ?? '{}') ?? '{}');
6
+ }
7
+ catch (e) {
8
+ Logger.error('Error parsing JSON', { e, json });
9
+ return undefined;
10
+ }
11
+ }
@@ -0,0 +1,2 @@
1
+ import { Prompt } from '../types/index.js';
2
+ export declare function promptAdjustHeadings(prompt: Prompt, topLevel: number): Prompt;
@@ -0,0 +1,4 @@
1
+ import { mdAdjustHeadings } from './mdAdjustHeadings.js';
2
+ export function promptAdjustHeadings(prompt, topLevel) {
3
+ return { text: mdAdjustHeadings(prompt.text, topLevel), images: prompt.images };
4
+ }
@@ -0,0 +1 @@
1
+ export declare function textJoin(texts?: (string | undefined)[], joiner?: string): string;
@@ -0,0 +1,3 @@
1
+ export function textJoin(texts = [], joiner = '\n') {
2
+ return texts.filter(Boolean).join(joiner).trim();
3
+ }
@@ -0,0 +1 @@
1
+ export declare function trim(text: string): string;
@@ -0,0 +1,5 @@
1
+ export function trim(text) {
2
+ if (!text)
3
+ return '';
4
+ return text.trim();
5
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@sjts/ai-shared",
3
+ "description": "The Steve James Typescript AI Shared package",
4
+ "version": "30.2.2",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "build:clean": "yarn run clean && yarn run build",
18
+ "clean": "rm -rf dist",
19
+ "release:patch": "yarn version patch && yarn npm publish",
20
+ "release:minor": "yarn version minor && yarn npm publish",
21
+ "release:major": "yarn version major && yarn npm publish"
22
+ },
23
+ "prettier": "@sjts/lib-devops/prettier.json",
24
+ "dependencies": {
25
+ "@sjts/lib-log": "30.2.0",
26
+ "@sjts/lib-utils": "30.2.0",
27
+ "jsonrepair": "^3.7.0"
28
+ },
29
+ "devDependencies": {
30
+ "@sjts/lib-devops": "30.2.0",
31
+ "typescript": "^5.8.3"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ }
36
+ }