@librechat/agents 3.1.66-dev.0 → 3.1.66

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 (118) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +24 -15
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/common/enum.cjs +0 -13
  4. package/dist/cjs/common/enum.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +0 -3
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/main.cjs +0 -40
  8. package/dist/cjs/main.cjs.map +1 -1
  9. package/dist/cjs/messages/format.cjs +12 -74
  10. package/dist/cjs/messages/format.cjs.map +1 -1
  11. package/dist/cjs/run.cjs +0 -111
  12. package/dist/cjs/run.cjs.map +1 -1
  13. package/dist/cjs/tools/ToolNode.cjs +140 -304
  14. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  15. package/dist/esm/agents/AgentContext.mjs +24 -15
  16. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  17. package/dist/esm/common/enum.mjs +1 -12
  18. package/dist/esm/common/enum.mjs.map +1 -1
  19. package/dist/esm/graphs/Graph.mjs +0 -3
  20. package/dist/esm/graphs/Graph.mjs.map +1 -1
  21. package/dist/esm/main.mjs +1 -10
  22. package/dist/esm/main.mjs.map +1 -1
  23. package/dist/esm/messages/format.mjs +4 -66
  24. package/dist/esm/messages/format.mjs.map +1 -1
  25. package/dist/esm/run.mjs +0 -111
  26. package/dist/esm/run.mjs.map +1 -1
  27. package/dist/esm/tools/ToolNode.mjs +142 -306
  28. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  29. package/dist/types/agents/AgentContext.d.ts +6 -0
  30. package/dist/types/common/enum.d.ts +1 -7
  31. package/dist/types/graphs/Graph.d.ts +0 -2
  32. package/dist/types/index.d.ts +0 -6
  33. package/dist/types/messages/format.d.ts +1 -2
  34. package/dist/types/run.d.ts +0 -1
  35. package/dist/types/tools/ToolNode.d.ts +2 -24
  36. package/dist/types/types/index.d.ts +0 -1
  37. package/dist/types/types/run.d.ts +0 -20
  38. package/dist/types/types/tools.d.ts +1 -38
  39. package/package.json +1 -1
  40. package/src/agents/AgentContext.ts +28 -15
  41. package/src/agents/__tests__/AgentContext.test.ts +110 -0
  42. package/src/common/enum.ts +0 -12
  43. package/src/graphs/Graph.ts +0 -4
  44. package/src/index.ts +0 -8
  45. package/src/messages/format.ts +4 -74
  46. package/src/run.ts +0 -126
  47. package/src/tools/ToolNode.ts +169 -391
  48. package/src/tools/__tests__/ToolNode.session.test.ts +12 -12
  49. package/src/types/index.ts +0 -1
  50. package/src/types/run.ts +0 -20
  51. package/src/types/tools.ts +1 -41
  52. package/dist/cjs/hooks/HookRegistry.cjs +0 -162
  53. package/dist/cjs/hooks/HookRegistry.cjs.map +0 -1
  54. package/dist/cjs/hooks/executeHooks.cjs +0 -276
  55. package/dist/cjs/hooks/executeHooks.cjs.map +0 -1
  56. package/dist/cjs/hooks/matchers.cjs +0 -256
  57. package/dist/cjs/hooks/matchers.cjs.map +0 -1
  58. package/dist/cjs/hooks/types.cjs +0 -27
  59. package/dist/cjs/hooks/types.cjs.map +0 -1
  60. package/dist/cjs/tools/BashExecutor.cjs +0 -175
  61. package/dist/cjs/tools/BashExecutor.cjs.map +0 -1
  62. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +0 -296
  63. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +0 -1
  64. package/dist/cjs/tools/ReadFile.cjs +0 -43
  65. package/dist/cjs/tools/ReadFile.cjs.map +0 -1
  66. package/dist/cjs/tools/SkillTool.cjs +0 -50
  67. package/dist/cjs/tools/SkillTool.cjs.map +0 -1
  68. package/dist/cjs/tools/skillCatalog.cjs +0 -84
  69. package/dist/cjs/tools/skillCatalog.cjs.map +0 -1
  70. package/dist/esm/hooks/HookRegistry.mjs +0 -160
  71. package/dist/esm/hooks/HookRegistry.mjs.map +0 -1
  72. package/dist/esm/hooks/executeHooks.mjs +0 -273
  73. package/dist/esm/hooks/executeHooks.mjs.map +0 -1
  74. package/dist/esm/hooks/matchers.mjs +0 -251
  75. package/dist/esm/hooks/matchers.mjs.map +0 -1
  76. package/dist/esm/hooks/types.mjs +0 -25
  77. package/dist/esm/hooks/types.mjs.map +0 -1
  78. package/dist/esm/tools/BashExecutor.mjs +0 -169
  79. package/dist/esm/tools/BashExecutor.mjs.map +0 -1
  80. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +0 -287
  81. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +0 -1
  82. package/dist/esm/tools/ReadFile.mjs +0 -38
  83. package/dist/esm/tools/ReadFile.mjs.map +0 -1
  84. package/dist/esm/tools/SkillTool.mjs +0 -45
  85. package/dist/esm/tools/SkillTool.mjs.map +0 -1
  86. package/dist/esm/tools/skillCatalog.mjs +0 -82
  87. package/dist/esm/tools/skillCatalog.mjs.map +0 -1
  88. package/dist/types/hooks/HookRegistry.d.ts +0 -56
  89. package/dist/types/hooks/executeHooks.d.ts +0 -79
  90. package/dist/types/hooks/index.d.ts +0 -6
  91. package/dist/types/hooks/matchers.d.ts +0 -95
  92. package/dist/types/hooks/types.d.ts +0 -309
  93. package/dist/types/tools/BashExecutor.d.ts +0 -45
  94. package/dist/types/tools/BashProgrammaticToolCalling.d.ts +0 -72
  95. package/dist/types/tools/ReadFile.d.ts +0 -28
  96. package/dist/types/tools/SkillTool.d.ts +0 -40
  97. package/dist/types/tools/skillCatalog.d.ts +0 -19
  98. package/dist/types/types/skill.d.ts +0 -9
  99. package/src/hooks/HookRegistry.ts +0 -208
  100. package/src/hooks/__tests__/HookRegistry.test.ts +0 -190
  101. package/src/hooks/__tests__/executeHooks.test.ts +0 -1013
  102. package/src/hooks/__tests__/integration.test.ts +0 -337
  103. package/src/hooks/__tests__/matchers.test.ts +0 -238
  104. package/src/hooks/__tests__/toolHooks.test.ts +0 -669
  105. package/src/hooks/executeHooks.ts +0 -375
  106. package/src/hooks/index.ts +0 -55
  107. package/src/hooks/matchers.ts +0 -280
  108. package/src/hooks/types.ts +0 -388
  109. package/src/messages/formatAgentMessages.skills.test.ts +0 -334
  110. package/src/tools/BashExecutor.ts +0 -205
  111. package/src/tools/BashProgrammaticToolCalling.ts +0 -397
  112. package/src/tools/ReadFile.ts +0 -39
  113. package/src/tools/SkillTool.ts +0 -46
  114. package/src/tools/__tests__/ReadFile.test.ts +0 -44
  115. package/src/tools/__tests__/SkillTool.test.ts +0 -442
  116. package/src/tools/__tests__/skillCatalog.test.ts +0 -161
  117. package/src/tools/skillCatalog.ts +0 -126
  118. package/src/types/skill.ts +0 -11
@@ -1,126 +0,0 @@
1
- // src/tools/skillCatalog.ts
2
- import type { SkillCatalogEntry } from '@/types';
3
-
4
- const HEADER = '## Available Skills';
5
- const DEFAULT_CONTEXT_WINDOW_TOKENS = 200_000;
6
- const DEFAULT_BUDGET_PERCENT = 0.01;
7
- const DEFAULT_MAX_ENTRY_CHARS = 250;
8
- const DEFAULT_MIN_DESC_LENGTH = 20;
9
- const DEFAULT_CHARS_PER_TOKEN = 4;
10
-
11
- export type SkillCatalogOptions = {
12
- /** Total context window in tokens. Default: 200_000 */
13
- contextWindowTokens?: number;
14
- /** Fraction of context budget for catalog. Default: 0.01 (1%) */
15
- budgetPercent?: number;
16
- /** Max chars per entry description. Default: 250 */
17
- maxEntryChars?: number;
18
- /** Descriptions below this length trigger names-only fallback. Default: 20 */
19
- minDescLength?: number;
20
- /** Approximate chars per token for budget calculation. Default: 4 */
21
- charsPerToken?: number;
22
- };
23
-
24
- /**
25
- * Formats a skill catalog for injection into agent context.
26
- * Uses a truncation ladder: full descriptions, proportional truncation, names-only.
27
- * Returns empty string for empty input.
28
- */
29
- export function formatSkillCatalog(
30
- skills: SkillCatalogEntry[],
31
- opts?: SkillCatalogOptions
32
- ): string {
33
- if (skills.length === 0) return '';
34
-
35
- const contextWindowTokens =
36
- opts?.contextWindowTokens ?? DEFAULT_CONTEXT_WINDOW_TOKENS;
37
- const budgetPercent = opts?.budgetPercent ?? DEFAULT_BUDGET_PERCENT;
38
- const maxEntryChars = Math.max(
39
- 1,
40
- opts?.maxEntryChars ?? DEFAULT_MAX_ENTRY_CHARS
41
- );
42
- const minDescLength = opts?.minDescLength ?? DEFAULT_MIN_DESC_LENGTH;
43
- const charsPerToken = opts?.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
44
-
45
- const budgetChars = Math.floor(
46
- contextWindowTokens * budgetPercent * charsPerToken
47
- );
48
-
49
- const capped = skills.map((s) => ({
50
- name: s.name,
51
- description:
52
- s.description.length > maxEntryChars
53
- ? s.description.slice(0, maxEntryChars - 1) + '\u2026'
54
- : s.description,
55
- }));
56
-
57
- const fullOutput = formatEntries(capped);
58
- if (fullOutput.length <= budgetChars) return fullOutput;
59
-
60
- const headerLen = HEADER.length + 2;
61
- const newlineChars = capped.length > 1 ? capped.length - 1 : 0;
62
- const availableChars = budgetChars - headerLen - newlineChars;
63
- const perEntryOverhead = 4;
64
- const nameCharsTotal = capped.reduce(
65
- (sum, s) => sum + s.name.length + perEntryOverhead,
66
- 0
67
- );
68
- const availableForDescs = availableChars - nameCharsTotal;
69
-
70
- if (availableForDescs <= 0) {
71
- return fitNamesOnly(capped, budgetChars);
72
- }
73
-
74
- const maxDescPerEntry = Math.floor(availableForDescs / capped.length);
75
-
76
- if (maxDescPerEntry < minDescLength) {
77
- return fitNamesOnly(capped, budgetChars);
78
- }
79
-
80
- const truncated = capped.map((s) => ({
81
- name: s.name,
82
- description:
83
- s.description.length > maxDescPerEntry
84
- ? s.description.slice(0, maxDescPerEntry - 1) + '\u2026'
85
- : s.description,
86
- }));
87
-
88
- const result = formatEntries(truncated);
89
- if (result.length <= budgetChars) return result;
90
- return fitNamesOnly(capped, budgetChars);
91
- }
92
-
93
- function formatEntries(
94
- entries: { name: string; description: string }[]
95
- ): string {
96
- const lines = entries.map((e) =>
97
- e.description ? `- ${e.name}: ${e.description}` : `- ${e.name}`
98
- );
99
- return `${HEADER}\n\n${lines.join('\n')}`;
100
- }
101
-
102
- /** Names-only fallback that drops trailing entries if the list still exceeds budget. */
103
- function fitNamesOnly(
104
- entries: { name: string }[],
105
- budgetChars: number
106
- ): string {
107
- // Format: "HEADER\n\n- name1\n- name2\n..."
108
- // Running sum avoids O(n²) repeated string construction.
109
- const prefix = HEADER.length + 2; // "HEADER\n\n"
110
- const entryOverhead = 2; // "- "
111
- let total = prefix;
112
- let fitCount = 0;
113
-
114
- for (let i = 0; i < entries.length; i++) {
115
- const added = (i > 0 ? 1 : 0) + entryOverhead + entries[i].name.length;
116
- if (total + added > budgetChars) break;
117
- total += added;
118
- fitCount = i + 1;
119
- }
120
-
121
- if (fitCount === 0) return '';
122
- const namesOnly = entries
123
- .slice(0, fitCount)
124
- .map((s) => ({ name: s.name, description: '' }));
125
- return formatEntries(namesOnly);
126
- }
@@ -1,11 +0,0 @@
1
- // src/types/skill.ts
2
-
3
- /** Minimal skill metadata for catalog assembly. The host provides these from its own data layer. */
4
- export type SkillCatalogEntry = {
5
- /** Kebab-case identifier (what the model passes to SkillTool) */
6
- name: string;
7
- /** One-line description for the catalog listing */
8
- description: string;
9
- /** Optional human-readable label (UI only, not shown to model) */
10
- displayTitle?: string;
11
- };