@vybestack/llxprt-code-agents 0.10.0-nightly.260613.1adad3b34

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 (176) hide show
  1. package/dist/.last_build +0 -0
  2. package/dist/index.d.ts +10 -0
  3. package/dist/index.js +11 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/agents/executor-prompt-builder.d.ts +19 -0
  6. package/dist/src/agents/executor-prompt-builder.js +44 -0
  7. package/dist/src/agents/executor-prompt-builder.js.map +1 -0
  8. package/dist/src/agents/executor-termination.d.ts +22 -0
  9. package/dist/src/agents/executor-termination.js +44 -0
  10. package/dist/src/agents/executor-termination.js.map +1 -0
  11. package/dist/src/agents/executor-validation.d.ts +17 -0
  12. package/dist/src/agents/executor-validation.js +35 -0
  13. package/dist/src/agents/executor-validation.js.map +1 -0
  14. package/dist/src/agents/executor.d.ts +136 -0
  15. package/dist/src/agents/executor.js +874 -0
  16. package/dist/src/agents/executor.js.map +1 -0
  17. package/dist/src/agents/invocation.d.ts +45 -0
  18. package/dist/src/agents/invocation.js +118 -0
  19. package/dist/src/agents/invocation.js.map +1 -0
  20. package/dist/src/agents/recovery.d.ts +75 -0
  21. package/dist/src/agents/recovery.js +107 -0
  22. package/dist/src/agents/recovery.js.map +1 -0
  23. package/dist/src/agents/types.d.ts +149 -0
  24. package/dist/src/agents/types.js +18 -0
  25. package/dist/src/agents/types.js.map +1 -0
  26. package/dist/src/agents/utils.d.ts +15 -0
  27. package/dist/src/agents/utils.js +28 -0
  28. package/dist/src/agents/utils.js.map +1 -0
  29. package/dist/src/compression/CompressionHandler.d.ts +178 -0
  30. package/dist/src/compression/CompressionHandler.js +630 -0
  31. package/dist/src/compression/CompressionHandler.js.map +1 -0
  32. package/dist/src/compression/HighDensityStrategy.d.ts +113 -0
  33. package/dist/src/compression/HighDensityStrategy.js +769 -0
  34. package/dist/src/compression/HighDensityStrategy.js.map +1 -0
  35. package/dist/src/compression/MiddleOutStrategy.d.ts +27 -0
  36. package/dist/src/compression/MiddleOutStrategy.js +347 -0
  37. package/dist/src/compression/MiddleOutStrategy.js.map +1 -0
  38. package/dist/src/compression/OneShotStrategy.d.ts +22 -0
  39. package/dist/src/compression/OneShotStrategy.js +235 -0
  40. package/dist/src/compression/OneShotStrategy.js.map +1 -0
  41. package/dist/src/compression/TopDownTruncationStrategy.d.ts +13 -0
  42. package/dist/src/compression/TopDownTruncationStrategy.js +74 -0
  43. package/dist/src/compression/TopDownTruncationStrategy.js.map +1 -0
  44. package/dist/src/compression/compressionBudgeting.d.ts +34 -0
  45. package/dist/src/compression/compressionBudgeting.js +139 -0
  46. package/dist/src/compression/compressionBudgeting.js.map +1 -0
  47. package/dist/src/compression/compressionStrategyFactory.d.ts +23 -0
  48. package/dist/src/compression/compressionStrategyFactory.js +40 -0
  49. package/dist/src/compression/compressionStrategyFactory.js.map +1 -0
  50. package/dist/src/compression/index.d.ts +16 -0
  51. package/dist/src/compression/index.js +17 -0
  52. package/dist/src/compression/index.js.map +1 -0
  53. package/dist/src/compression/reasoningUtils.d.ts +18 -0
  54. package/dist/src/compression/reasoningUtils.js +22 -0
  55. package/dist/src/compression/reasoningUtils.js.map +1 -0
  56. package/dist/src/compression/utils.d.ts +114 -0
  57. package/dist/src/compression/utils.js +316 -0
  58. package/dist/src/compression/utils.js.map +1 -0
  59. package/dist/src/core/AgentHookManager.d.ts +41 -0
  60. package/dist/src/core/AgentHookManager.js +65 -0
  61. package/dist/src/core/AgentHookManager.js.map +1 -0
  62. package/dist/src/core/ChatSessionFactory.d.ts +50 -0
  63. package/dist/src/core/ChatSessionFactory.js +216 -0
  64. package/dist/src/core/ChatSessionFactory.js.map +1 -0
  65. package/dist/src/core/ConversationManager.d.ts +113 -0
  66. package/dist/src/core/ConversationManager.js +311 -0
  67. package/dist/src/core/ConversationManager.js.map +1 -0
  68. package/dist/src/core/DirectMessageProcessor.d.ts +79 -0
  69. package/dist/src/core/DirectMessageProcessor.js +478 -0
  70. package/dist/src/core/DirectMessageProcessor.js.map +1 -0
  71. package/dist/src/core/IdeContextTracker.d.ts +56 -0
  72. package/dist/src/core/IdeContextTracker.js +207 -0
  73. package/dist/src/core/IdeContextTracker.js.map +1 -0
  74. package/dist/src/core/MessageConverter.d.ts +78 -0
  75. package/dist/src/core/MessageConverter.js +492 -0
  76. package/dist/src/core/MessageConverter.js.map +1 -0
  77. package/dist/src/core/MessageStreamOrchestrator.d.ts +85 -0
  78. package/dist/src/core/MessageStreamOrchestrator.js +448 -0
  79. package/dist/src/core/MessageStreamOrchestrator.js.map +1 -0
  80. package/dist/src/core/MessageStreamTerminalHandler.d.ts +16 -0
  81. package/dist/src/core/MessageStreamTerminalHandler.js +170 -0
  82. package/dist/src/core/MessageStreamTerminalHandler.js.map +1 -0
  83. package/dist/src/core/StreamProcessor.d.ts +105 -0
  84. package/dist/src/core/StreamProcessor.js +660 -0
  85. package/dist/src/core/StreamProcessor.js.map +1 -0
  86. package/dist/src/core/TodoContinuationService.d.ts +74 -0
  87. package/dist/src/core/TodoContinuationService.js +312 -0
  88. package/dist/src/core/TodoContinuationService.js.map +1 -0
  89. package/dist/src/core/TurnProcessor.d.ts +91 -0
  90. package/dist/src/core/TurnProcessor.js +540 -0
  91. package/dist/src/core/TurnProcessor.js.map +1 -0
  92. package/dist/src/core/baseLlmClient.d.ts +115 -0
  93. package/dist/src/core/baseLlmClient.js +231 -0
  94. package/dist/src/core/baseLlmClient.js.map +1 -0
  95. package/dist/src/core/bucketFailoverIntegration.d.ts +62 -0
  96. package/dist/src/core/bucketFailoverIntegration.js +186 -0
  97. package/dist/src/core/bucketFailoverIntegration.js.map +1 -0
  98. package/dist/src/core/chatSession.d.ts +121 -0
  99. package/dist/src/core/chatSession.js +720 -0
  100. package/dist/src/core/chatSession.js.map +1 -0
  101. package/dist/src/core/client.d.ts +132 -0
  102. package/dist/src/core/client.js +524 -0
  103. package/dist/src/core/client.js.map +1 -0
  104. package/dist/src/core/clientHelpers.d.ts +15 -0
  105. package/dist/src/core/clientHelpers.js +122 -0
  106. package/dist/src/core/clientHelpers.js.map +1 -0
  107. package/dist/src/core/clientLlmUtilities.d.ts +30 -0
  108. package/dist/src/core/clientLlmUtilities.js +125 -0
  109. package/dist/src/core/clientLlmUtilities.js.map +1 -0
  110. package/dist/src/core/clientToolGovernance.d.ts +37 -0
  111. package/dist/src/core/clientToolGovernance.js +104 -0
  112. package/dist/src/core/clientToolGovernance.js.map +1 -0
  113. package/dist/src/core/compression-config.d.ts +12 -0
  114. package/dist/src/core/compression-config.js +21 -0
  115. package/dist/src/core/compression-config.js.map +1 -0
  116. package/dist/src/core/coreToolScheduler.d.ts +105 -0
  117. package/dist/src/core/coreToolScheduler.js +453 -0
  118. package/dist/src/core/coreToolScheduler.js.map +1 -0
  119. package/dist/src/core/hookToolRestrictions.d.ts +18 -0
  120. package/dist/src/core/hookToolRestrictions.js +187 -0
  121. package/dist/src/core/hookToolRestrictions.js.map +1 -0
  122. package/dist/src/core/nonInteractiveToolExecutor.d.ts +17 -0
  123. package/dist/src/core/nonInteractiveToolExecutor.js +102 -0
  124. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
  125. package/dist/src/core/subagent.d.ts +105 -0
  126. package/dist/src/core/subagent.js +650 -0
  127. package/dist/src/core/subagent.js.map +1 -0
  128. package/dist/src/core/subagentExecution.d.ts +104 -0
  129. package/dist/src/core/subagentExecution.js +275 -0
  130. package/dist/src/core/subagentExecution.js.map +1 -0
  131. package/dist/src/core/subagentOrchestrator.d.ts +84 -0
  132. package/dist/src/core/subagentOrchestrator.js +503 -0
  133. package/dist/src/core/subagentOrchestrator.js.map +1 -0
  134. package/dist/src/core/subagentRuntimeSetup.d.ts +75 -0
  135. package/dist/src/core/subagentRuntimeSetup.js +387 -0
  136. package/dist/src/core/subagentRuntimeSetup.js.map +1 -0
  137. package/dist/src/core/subagentScheduler.d.ts +17 -0
  138. package/dist/src/core/subagentScheduler.js +7 -0
  139. package/dist/src/core/subagentScheduler.js.map +1 -0
  140. package/dist/src/core/subagentToolProcessing.d.ts +51 -0
  141. package/dist/src/core/subagentToolProcessing.js +359 -0
  142. package/dist/src/core/subagentToolProcessing.js.map +1 -0
  143. package/dist/src/core/toolGovernance.d.ts +18 -0
  144. package/dist/src/core/toolGovernance.js +50 -0
  145. package/dist/src/core/toolGovernance.js.map +1 -0
  146. package/dist/src/core/turn.d.ts +47 -0
  147. package/dist/src/core/turn.js +455 -0
  148. package/dist/src/core/turn.js.map +1 -0
  149. package/dist/src/core/turnLogging.d.ts +35 -0
  150. package/dist/src/core/turnLogging.js +80 -0
  151. package/dist/src/core/turnLogging.js.map +1 -0
  152. package/dist/src/index.d.ts +32 -0
  153. package/dist/src/index.js +44 -0
  154. package/dist/src/index.js.map +1 -0
  155. package/dist/src/scheduler/confirmation-coordinator.d.ts +139 -0
  156. package/dist/src/scheduler/confirmation-coordinator.js +443 -0
  157. package/dist/src/scheduler/confirmation-coordinator.js.map +1 -0
  158. package/dist/src/scheduler/result-aggregator.d.ts +127 -0
  159. package/dist/src/scheduler/result-aggregator.js +302 -0
  160. package/dist/src/scheduler/result-aggregator.js.map +1 -0
  161. package/dist/src/scheduler/status-transitions.d.ts +39 -0
  162. package/dist/src/scheduler/status-transitions.js +184 -0
  163. package/dist/src/scheduler/status-transitions.js.map +1 -0
  164. package/dist/src/scheduler/tool-dispatcher.d.ts +40 -0
  165. package/dist/src/scheduler/tool-dispatcher.js +120 -0
  166. package/dist/src/scheduler/tool-dispatcher.js.map +1 -0
  167. package/dist/src/scheduler/tool-executor.d.ts +44 -0
  168. package/dist/src/scheduler/tool-executor.js +117 -0
  169. package/dist/src/scheduler/tool-executor.js.map +1 -0
  170. package/dist/src/scheduler/utils.d.ts +11 -0
  171. package/dist/src/scheduler/utils.js +19 -0
  172. package/dist/src/scheduler/utils.js.map +1 -0
  173. package/dist/src/tools/task.d.ts +128 -0
  174. package/dist/src/tools/task.js +932 -0
  175. package/dist/src/tools/task.js.map +1 -0
  176. package/package.json +54 -0
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export function isThinkingSupported(model) {
7
+ return !model.startsWith('gemini-2.0');
8
+ }
9
+ /**
10
+ * Returns the index of the content after the fraction of the total characters in the history.
11
+ *
12
+ * Exported for testing purposes.
13
+ */
14
+ export function findCompressSplitPoint(contents, fraction) {
15
+ if (fraction <= 0 || fraction >= 1) {
16
+ throw new Error('Fraction must be between 0 and 1');
17
+ }
18
+ const charCounts = contents.map((content) => JSON.stringify(content).length);
19
+ const totalCharCount = charCounts.reduce((sum, length) => sum + length, 0);
20
+ const targetCharCount = totalCharCount * fraction;
21
+ let lastSplitPoint = 0;
22
+ let lastToolCallSplitPoint = 0;
23
+ let toolCallSplitPointAfterTarget = null;
24
+ let cumulativeCharCount = 0;
25
+ for (let i = 0; i < contents.length; i++) {
26
+ const content = contents[i];
27
+ const hasFunctionResponse = content.parts?.some((part) => Boolean(part.functionResponse)) === true;
28
+ const hasFunctionCall = content.parts?.some((part) => Boolean(part.functionCall)) === true;
29
+ if (content.role === 'user' && !hasFunctionResponse) {
30
+ if (cumulativeCharCount >= targetCharCount) {
31
+ return i;
32
+ }
33
+ lastSplitPoint = i;
34
+ }
35
+ if (content.role === 'model' && hasFunctionCall) {
36
+ if (cumulativeCharCount >= targetCharCount &&
37
+ toolCallSplitPointAfterTarget === null) {
38
+ toolCallSplitPointAfterTarget = i;
39
+ }
40
+ lastToolCallSplitPoint = i;
41
+ }
42
+ cumulativeCharCount += charCounts[i];
43
+ }
44
+ const lastContent = contents[contents.length - 1];
45
+ const hasNoFunctionCall = (content) => {
46
+ const parts = content?.parts;
47
+ return parts?.some((part) => Boolean(part.functionCall)) !== true;
48
+ };
49
+ if (lastSplitPoint > 0) {
50
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
51
+ if (lastContent?.role === 'model' && hasNoFunctionCall(lastContent)) {
52
+ return contents.length;
53
+ }
54
+ return lastSplitPoint;
55
+ }
56
+ if (toolCallSplitPointAfterTarget !== null) {
57
+ return toolCallSplitPointAfterTarget;
58
+ }
59
+ if (lastToolCallSplitPoint > 0) {
60
+ return lastToolCallSplitPoint;
61
+ }
62
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
63
+ if (lastContent?.role === 'model' && hasNoFunctionCall(lastContent)) {
64
+ return contents.length;
65
+ }
66
+ return lastSplitPoint;
67
+ }
68
+ export function extractPromptText(request) {
69
+ if (typeof request === 'string')
70
+ return request;
71
+ if (Array.isArray(request)) {
72
+ return request
73
+ .map((part) => {
74
+ if (typeof part === 'string')
75
+ return part;
76
+ // Preserve defensive runtime check: part could be null at runtime despite types.
77
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
78
+ if (part !== null && typeof part === 'object' && 'text' in part) {
79
+ return part.text;
80
+ }
81
+ return '';
82
+ })
83
+ .filter(Boolean)
84
+ .join(' ');
85
+ }
86
+ // Not an array, check for single object with text
87
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
88
+ if (request !== null && typeof request === 'object' && 'text' in request) {
89
+ return request.text;
90
+ }
91
+ return '';
92
+ }
93
+ export function estimateTextOnlyLength(request) {
94
+ if (typeof request === 'string') {
95
+ return request.length;
96
+ }
97
+ if (!Array.isArray(request)) {
98
+ if (typeof request === 'object' &&
99
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
100
+ request !== null &&
101
+ 'text' in request &&
102
+ request.text) {
103
+ return request.text.length;
104
+ }
105
+ return 0;
106
+ }
107
+ let textLength = 0;
108
+ for (const part of request) {
109
+ if (typeof part === 'string') {
110
+ textLength += part.length;
111
+ }
112
+ else if (typeof part === 'object' &&
113
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider client runtime payloads.
114
+ part !== null &&
115
+ 'text' in part &&
116
+ part.text) {
117
+ textLength += part.text.length;
118
+ }
119
+ }
120
+ return textLength;
121
+ }
122
+ //# sourceMappingURL=clientHelpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../../src/core/clientHelpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,UAAU,mBAAmB,CAAC,KAAa;IAC/C,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAmB,EACnB,QAAgB;IAEhB,IAAI,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3E,MAAM,eAAe,GAAG,cAAc,GAAG,QAAQ,CAAC;IAElD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,IAAI,6BAA6B,GAAkB,IAAI,CAAC;IACxD,IAAI,mBAAmB,GAAG,CAAC,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE5B,MAAM,mBAAmB,GACvB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IA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AI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,IACE,OAAO,OAAO,KAAK,QAAQ;YAC3B,4GAA4G;YAC5G,OAAO,KAAK,IAAI;YAChB,MAAM,IAAI,OAAO;YACjB,OAAO,CAAC,IAAI,EACZ,CAAC;YACD,OAAQ,OAA4B,CAAC,IAAI,CAAC,MAAM,CAAC;QACnD,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,UAAU,IAAI,IAAI,CAAC,MAAM,CAAC;QAC5B,CAAC;aAAM,IACL,OAAO,IAAI,KAAK,QAAQ;YACxB,4GAA4G;YAC5G,IAAI,KAAK,IAAI;YACb,MAAM,IAAI,IAAI;YACd,IAAI,CAAC,IAAI,EACT,CAAC;YACD,UAAU,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { GenerateContentConfig, Content, GenerateContentResponse } from '@google/genai';
7
+ import type { ContentGenerator } from '@vybestack/llxprt-code-core/core/contentGenerator.js';
8
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
9
+ import type { BaseLLMClient } from './baseLlmClient.js';
10
+ /**
11
+ * Generates structured JSON using the BaseLLMClient utility path.
12
+ *
13
+ * Uses getCoreSystemPromptAsync directly — the lightweight path that includes
14
+ * userMemory and mcpInstructions but NOT environment context, core memory, or
15
+ * JIT memory (those are only in buildSystemInstruction used by startChat).
16
+ */
17
+ export declare function generateJson(config: Config, _contentGenerator: ContentGenerator, baseLlmClient: BaseLLMClient, contents: Content[], schema: Record<string, unknown>, abortSignal: AbortSignal, model: string, generationConfig: GenerateContentConfig | undefined, lastPromptId: string): Promise<Record<string, unknown>>;
18
+ /**
19
+ * Generates content using ContentGenerator directly.
20
+ *
21
+ * Uses getCoreSystemPromptAsync directly — the lightweight path that includes
22
+ * userMemory and mcpInstructions but NOT environment context, core memory, or
23
+ * JIT memory (those are only in buildSystemInstruction used by startChat).
24
+ */
25
+ export declare function generateContent(config: Config, contentGenerator: ContentGenerator, contents: Content[], generationConfig: GenerateContentConfig, abortSignal: AbortSignal, model: string, lastPromptId: string, baseGenerateContentConfig: GenerateContentConfig): Promise<GenerateContentResponse>;
26
+ /**
27
+ * Generates embeddings for an array of text strings.
28
+ * Returns an empty array for empty input without making any API call.
29
+ */
30
+ export declare function generateEmbedding(baseLlmClient: BaseLLMClient, texts: string[], embeddingModel: string): Promise<number[][]>;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { getCoreSystemPromptAsync } from '@vybestack/llxprt-code-core/core/prompts.js';
7
+ import { getEnabledToolNamesForPrompt, shouldIncludeSubagentDelegationForConfig, } from './clientToolGovernance.js';
8
+ import { reportError } from '@vybestack/llxprt-code-core/utils/errorReporting.js';
9
+ import { retryWithBackoff } from '@vybestack/llxprt-code-core/utils/retry.js';
10
+ import { getErrorMessage } from '@vybestack/llxprt-code-core/utils/errors.js';
11
+ import { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
12
+ async function buildLightweightSystemPrompt(config, model) {
13
+ const userMemory = config.getUserMemory();
14
+ const mcpInstructions = config.getMcpClientManager()?.getMcpInstructions();
15
+ const enabledToolNames = getEnabledToolNamesForPrompt(config);
16
+ const includeSubagentDelegation = await shouldIncludeSubagentDelegationForConfig(config, enabledToolNames);
17
+ return getCoreSystemPromptAsync({
18
+ userMemory,
19
+ mcpInstructions,
20
+ model,
21
+ includeSubagentDelegation,
22
+ tools: enabledToolNames,
23
+ interactionMode: config.isInteractive() ? 'interactive' : 'non-interactive',
24
+ });
25
+ }
26
+ /**
27
+ * Generates structured JSON using the BaseLLMClient utility path.
28
+ *
29
+ * Uses getCoreSystemPromptAsync directly — the lightweight path that includes
30
+ * userMemory and mcpInstructions but NOT environment context, core memory, or
31
+ * JIT memory (those are only in buildSystemInstruction used by startChat).
32
+ */
33
+ export async function generateJson(config, _contentGenerator, baseLlmClient, contents, schema, abortSignal, model, generationConfig = {}, lastPromptId) {
34
+ const logger = new DebugLogger('llxprt:core:clientLlmUtilities');
35
+ try {
36
+ const systemInstruction = await buildLightweightSystemPrompt(config, model);
37
+ const prompt = contents
38
+ .map((c) => c.parts
39
+ ?.map((p) => ('text' in p ? (p.text ?? '') : ''))
40
+ .filter((s) => s.length > 0)
41
+ .join('\n') ?? '')
42
+ .filter((s) => s.length > 0)
43
+ .join('\n\n');
44
+ const apiCall = async () => baseLlmClient.generateJson({
45
+ prompt,
46
+ schema,
47
+ model,
48
+ systemInstruction,
49
+ temperature: generationConfig.temperature ?? 0,
50
+ promptId: lastPromptId,
51
+ });
52
+ const result = await retryWithBackoff(apiCall, { signal: abortSignal });
53
+ // Gemini sometimes returns a bare "user"/"model" string instead of JSON
54
+ // when asked for `next_speaker`. Wrap it so callers always get an object.
55
+ if (typeof result === 'string' &&
56
+ (result === 'user' || result === 'model') &&
57
+ contents.some((c) => c.parts?.some((p) => 'text' in p && (p.text?.includes('next_speaker') ?? false)) ?? false)) {
58
+ logger.warn(() => `[generateJson] Gemini returned plain text "${result}" instead of JSON for next speaker check. Converting to valid response.`);
59
+ return {
60
+ reasoning: 'Gemini returned plain text response',
61
+ next_speaker: result,
62
+ };
63
+ }
64
+ return result;
65
+ }
66
+ catch (error) {
67
+ if (abortSignal.aborted) {
68
+ throw error;
69
+ }
70
+ await reportError(error, 'Error generating JSON content via API.', contents, 'generateJson-api');
71
+ throw error;
72
+ }
73
+ }
74
+ /**
75
+ * Generates content using ContentGenerator directly.
76
+ *
77
+ * Uses getCoreSystemPromptAsync directly — the lightweight path that includes
78
+ * userMemory and mcpInstructions but NOT environment context, core memory, or
79
+ * JIT memory (those are only in buildSystemInstruction used by startChat).
80
+ */
81
+ export async function generateContent(config, contentGenerator, contents, generationConfig, abortSignal, model, lastPromptId, baseGenerateContentConfig) {
82
+ const configToUse = {
83
+ ...baseGenerateContentConfig,
84
+ ...generationConfig,
85
+ };
86
+ try {
87
+ const systemInstruction = await buildLightweightSystemPrompt(config, model);
88
+ const requestConfig = {
89
+ ...configToUse,
90
+ abortSignal,
91
+ systemInstruction,
92
+ };
93
+ const apiCall = () => contentGenerator.generateContent({
94
+ model,
95
+ contents,
96
+ config: requestConfig,
97
+ }, lastPromptId);
98
+ return await retryWithBackoff(apiCall, { signal: abortSignal });
99
+ }
100
+ catch (error) {
101
+ if (abortSignal.aborted) {
102
+ throw error;
103
+ }
104
+ await reportError(error, `Error generating content via API with model ${model}.`, {
105
+ requestContents: contents,
106
+ requestConfig: configToUse,
107
+ }, 'generateContent-api');
108
+ throw new Error(`Failed to generate content with model ${model}: ${getErrorMessage(error)}`);
109
+ }
110
+ }
111
+ /**
112
+ * Generates embeddings for an array of text strings.
113
+ * Returns an empty array for empty input without making any API call.
114
+ */
115
+ export async function generateEmbedding(baseLlmClient, texts, embeddingModel) {
116
+ if (texts.length === 0) {
117
+ return [];
118
+ }
119
+ const result = await baseLlmClient.generateEmbedding({
120
+ text: texts,
121
+ model: embeddingModel,
122
+ });
123
+ return result;
124
+ }
125
+ //# sourceMappingURL=clientLlmUtilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientLlmUtilities.js","sourceRoot":"","sources":["../../../src/core/clientLlmUtilities.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,EAAE,wBAAwB,EAAE,MAAM,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W;SAC3B,EACD,qBAAqB,CACtB,CAAC;QACF,MAAM,IAAI,KAAK,CACb,yCAAyC,KAAK,KAAK,eAAe,CAAC,KAAK,CAAC,EAAE,CAC5E,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,aAA4B,EAC5B,KAAe,EACf,cAAsB;IAEtB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,iBAAiB,CAAC;QACnD,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,cAAc;KACtB,CAAC,CAAC;IAEH,OAAO,MAAoB,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { FunctionDeclaration } from '@google/genai';
7
+ import type { ToolRegistryView } from '@vybestack/llxprt-code-core/runtime/AgentRuntimeContext.js';
8
+ import type { ToolRegistry } from '@vybestack/llxprt-code-tools';
9
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
10
+ export { shouldIncludeSubagentDelegation } from '@vybestack/llxprt-code-core/prompt-config/subagent-delegation.js';
11
+ /**
12
+ * Reads the tool governance ephemeral settings (allowed/disabled tool lists).
13
+ * Returns undefined if neither list is configured.
14
+ */
15
+ export declare function getToolGovernanceEphemerals(config: Config): {
16
+ allowed?: string[];
17
+ disabled?: string[];
18
+ } | undefined;
19
+ /**
20
+ * Parses a raw tool list setting value into a clean string array.
21
+ * Filters out non-string and empty entries.
22
+ */
23
+ export declare function readToolList(value: unknown): string[];
24
+ /**
25
+ * Builds the list of FunctionDeclarations for a given ToolRegistryView.
26
+ * Falls back to getAllTools then getFunctionDeclarations.
27
+ */
28
+ export declare function buildToolDeclarationsFromView(toolRegistry: ToolRegistry | undefined, view: ToolRegistryView): FunctionDeclaration[];
29
+ /**
30
+ * Returns the deduplicated list of enabled tool names for use in system prompts.
31
+ */
32
+ export declare function getEnabledToolNamesForPrompt(config: Config): string[];
33
+ /**
34
+ * Determines whether to include subagent delegation instructions in the prompt.
35
+ * Delegates to the shared shouldIncludeSubagentDelegation function.
36
+ */
37
+ export declare function shouldIncludeSubagentDelegationForConfig(config: Config, enabledToolNames: string[]): Promise<boolean>;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { shouldIncludeSubagentDelegation } from '@vybestack/llxprt-code-core/prompt-config/subagent-delegation.js';
7
+ export { shouldIncludeSubagentDelegation } from '@vybestack/llxprt-code-core/prompt-config/subagent-delegation.js';
8
+ /**
9
+ * Reads the tool governance ephemeral settings (allowed/disabled tool lists).
10
+ * Returns undefined if neither list is configured.
11
+ */
12
+ export function getToolGovernanceEphemerals(config) {
13
+ const allowedList = readToolList(config.getEphemeralSetting('tools.allowed'));
14
+ const disabledList = readToolList(config.getEphemeralSetting('tools.disabled') ??
15
+ config.getEphemeralSetting('disabled-tools'));
16
+ const hasAllowed = allowedList.length > 0;
17
+ const hasDisabled = disabledList.length > 0;
18
+ if (!hasAllowed && !hasDisabled) {
19
+ return undefined;
20
+ }
21
+ return {
22
+ allowed: hasAllowed ? allowedList : undefined,
23
+ disabled: hasDisabled ? disabledList : undefined,
24
+ };
25
+ }
26
+ /**
27
+ * Parses a raw tool list setting value into a clean string array.
28
+ * Filters out non-string and empty entries.
29
+ */
30
+ export function readToolList(value) {
31
+ if (!Array.isArray(value)) {
32
+ return [];
33
+ }
34
+ const filtered = value
35
+ .filter((entry) => typeof entry === 'string' && entry.trim().length > 0)
36
+ .map((entry) => entry.trim());
37
+ return filtered.length > 0 ? [...filtered] : [];
38
+ }
39
+ /**
40
+ * Builds the list of FunctionDeclarations for a given ToolRegistryView.
41
+ * Falls back to getAllTools then getFunctionDeclarations.
42
+ */
43
+ export function buildToolDeclarationsFromView(toolRegistry, view) {
44
+ if (!toolRegistry) {
45
+ return [];
46
+ }
47
+ const allowedNames = view.listToolNames();
48
+ if (allowedNames.length === 0) {
49
+ return [];
50
+ }
51
+ const declarations = [];
52
+ if (typeof toolRegistry.getFunctionDeclarations === 'function') {
53
+ const declarationsByName = new Map(toolRegistry
54
+ .getFunctionDeclarations()
55
+ .map((decl) => [decl.name, decl]));
56
+ for (const name of allowedNames) {
57
+ const declaration = declarationsByName.get(name);
58
+ if (declaration) {
59
+ declarations.push(declaration);
60
+ }
61
+ }
62
+ return declarations;
63
+ }
64
+ if (typeof toolRegistry.getAllTools === 'function') {
65
+ const toolsByName = new Map(toolRegistry.getAllTools().map((tool) => [tool.name, tool]));
66
+ for (const name of allowedNames) {
67
+ const tool = toolsByName.get(name);
68
+ if (!tool) {
69
+ continue;
70
+ }
71
+ const schema = tool.schema;
72
+ if (schema) {
73
+ declarations.push(schema);
74
+ }
75
+ }
76
+ }
77
+ return declarations;
78
+ }
79
+ /**
80
+ * Returns the deduplicated list of enabled tool names for use in system prompts.
81
+ */
82
+ export function getEnabledToolNamesForPrompt(config) {
83
+ const toolRegistry = config.getToolRegistry();
84
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Config test doubles and runtime bootstrap may omit a tool registry.
85
+ if (toolRegistry == null) {
86
+ return [];
87
+ }
88
+ if (typeof toolRegistry.getEnabledTools !==
89
+ 'function') {
90
+ return [];
91
+ }
92
+ return Array.from(new Set(toolRegistry
93
+ .getEnabledTools()
94
+ .map((tool) => tool.name)
95
+ .filter(Boolean)));
96
+ }
97
+ /**
98
+ * Determines whether to include subagent delegation instructions in the prompt.
99
+ * Delegates to the shared shouldIncludeSubagentDelegation function.
100
+ */
101
+ export async function shouldIncludeSubagentDelegationForConfig(config, enabledToolNames) {
102
+ return shouldIncludeSubagentDelegation(enabledToolNames, () => config.getSubagentManager());
103
+ }
104
+ //# sourceMappingURL=clientToolGovernance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CAAC,CAC5D,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;YAChC,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAI,IAAyC,CAAC,MAAM,CAAC;YACjE,IAAI,MAAM,EAAE,CAAC;gBACX,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAAC,MAAc;IACzD,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC;IAC9C,8IAA8I;IAC9I,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,IACE,OAAQ,YAA8C,CAAC,eAAe;QACtE,UAAU,EACV,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CACf,IAAI,GAAG,CACL,YAAY;SACT,eAAe,EAAE;SACjB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,MAAM,CAAC,OAAO,CAAC,CACnB,CACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wCAAwC,CAC5D,MAAc,EACd,gBAA0B;IAE1B,OAAO,+BAA+B,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAC5D,MAAM,CAAC,kBAAkB,EAAE,CAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Vybestack LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Compression configuration constants
8
+ */
9
+ export declare const COMPRESSION_TOKEN_THRESHOLD = 0.85;
10
+ export declare const COMPRESSION_PRESERVE_THRESHOLD: number;
11
+ export declare const COMPRESSION_TOP_PRESERVE_THRESHOLD = 0.2;
12
+ export declare const MAX_MESSAGE_CHARS_IN_PRESERVED = 5000;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Vybestack LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Compression configuration constants
8
+ */
9
+ // Threshold for compression token count as a fraction of the model's token limit.
10
+ // If the chat history exceeds this threshold, it will be compressed.
11
+ // Increased from 0.7 to 0.85 to reduce compression aggressiveness.
12
+ export const COMPRESSION_TOKEN_THRESHOLD = 0.85;
13
+ // Dynamic preservation threshold calculation: 2 × (1 - compressionThreshold)
14
+ // If compression triggers at 85% (0.85), preserve only 30% (2 × 0.15 = 0.3)
15
+ // This ensures more aggressive compression when we're closer to limits
16
+ export const COMPRESSION_PRESERVE_THRESHOLD = 2 * (1 - COMPRESSION_TOKEN_THRESHOLD);
17
+ // Threshold for preserving the top portion of conversation (original user intent)
18
+ export const COMPRESSION_TOP_PRESERVE_THRESHOLD = 0.2;
19
+ // Maximum characters to preserve in individual messages for saved sections
20
+ export const MAX_MESSAGE_CHARS_IN_PRESERVED = 5000;
21
+ //# sourceMappingURL=compression-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compression-config.js","sourceRoot":"","sources":["../../../src/core/compression-config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AAEH,kFAAkF;AAClF,qEAAqE;AACrE,mEAAmE;AACnE,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,6EAA6E;AAC7E,4EAA4E;AAC5E,uEAAuE;AACvE,MAAM,CAAC,MAAM,8BAA8B,GACzC,CAAC,GAAG,CAAC,CAAC,GAAG,2BAA2B,CAAC,CAAC;AAExC,kFAAkF;AAClF,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAEtD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
7
+ import type { ToolRegistry } from '@vybestack/llxprt-code-tools';
8
+ import type { ToolCallRequestInfo } from '@vybestack/llxprt-code-core/core/turn.js';
9
+ import { ToolConfirmationOutcome, type ToolConfirmationPayload } from '@vybestack/llxprt-code-tools';
10
+ import type { EditorType } from '@vybestack/llxprt-code-core/utils/editor.js';
11
+ import type { MessageBus } from '@vybestack/llxprt-code-core/confirmation-bus/message-bus.js';
12
+ import type { OutputUpdateHandler, AllToolCallsCompleteHandler, ToolCallsUpdateHandler } from '@vybestack/llxprt-code-core/scheduler/types.js';
13
+ import type { ToolSchedulerContract } from '@vybestack/llxprt-code-core/core/toolSchedulerContract.js';
14
+ export { ValidatingToolCall, ScheduledToolCall, ErroredToolCall, SuccessfulToolCall, ExecutingToolCall, CancelledToolCall, WaitingToolCall, ToolCall, CompletedToolCall, Status, ConfirmHandler, OutputUpdateHandler, AllToolCallsCompleteHandler, ToolCallsUpdateHandler, } from '@vybestack/llxprt-code-core/scheduler/types.js';
15
+ /**
16
+ * @plan PLAN-20260309-MESSAGEBUS-DI-REMEDIATION.P05
17
+ * @requirement REQ-D01-001.1
18
+ * @requirement REQ-D01-001.2
19
+ * @pseudocode lines 56-72
20
+ */
21
+ export interface CoreToolSchedulerOptions {
22
+ config: Config;
23
+ messageBus: MessageBus;
24
+ toolRegistry: ToolRegistry;
25
+ outputUpdateHandler?: OutputUpdateHandler;
26
+ onAllToolCallsComplete?: AllToolCallsCompleteHandler;
27
+ onToolCallsUpdate?: ToolCallsUpdateHandler;
28
+ getPreferredEditor: () => EditorType | undefined;
29
+ onEditorClose: () => void;
30
+ onEditorOpen?: () => void;
31
+ toolContextInteractiveMode?: boolean;
32
+ }
33
+ export declare class CoreToolScheduler implements ToolSchedulerContract {
34
+ private toolCalls;
35
+ private outputUpdateHandler?;
36
+ private onAllToolCallsComplete?;
37
+ private onToolCallsUpdate?;
38
+ private getPreferredEditor;
39
+ private config;
40
+ private readonly toolExecutor;
41
+ private readonly toolDispatcher;
42
+ private readonly confirmationCoordinator;
43
+ private onEditorClose;
44
+ private onEditorOpen?;
45
+ private isFinalizingToolCalls;
46
+ private isScheduling;
47
+ private toolContextInteractiveMode;
48
+ private requestQueue;
49
+ private readonly resultAggregator;
50
+ private seenCallIds;
51
+ /**
52
+ * @plan PLAN-20260309-MESSAGEBUS-DI-REMEDIATION.P05
53
+ * @requirement REQ-D01-001.1
54
+ * @requirement REQ-D01-001.2
55
+ * @pseudocode lines 56-72
56
+ */
57
+ constructor(options: CoreToolSchedulerOptions);
58
+ setCallbacks(options: CoreToolSchedulerOptions): void;
59
+ /**
60
+ * Cleanup method to unsubscribe from message bus.
61
+ * Call this when the scheduler is no longer needed.
62
+ */
63
+ dispose(): void;
64
+ private setStatusInternal;
65
+ private setArgsInternal;
66
+ private setPidInternal;
67
+ private isRunning;
68
+ protected getToolSuggestion(unknownToolName: string, topN?: number): string;
69
+ protected publishBufferedResults(signal: AbortSignal): Promise<void>;
70
+ schedule(request: ToolCallRequestInfo | ToolCallRequestInfo[], signal: AbortSignal): Promise<void>;
71
+ private deduplicateRequests;
72
+ private isHookRestrictedRequest;
73
+ private evaluateToolCall;
74
+ private _schedule;
75
+ /**
76
+ * Public delegating facade — preserves the original public API.
77
+ * All confirmation flow logic now lives in ConfirmationCoordinator.
78
+ */
79
+ handleConfirmationResponse(callId: string, originalOnConfirm: (outcome: ToolConfirmationOutcome, payload?: ToolConfirmationPayload) => Promise<void>, outcome: ToolConfirmationOutcome, signal: AbortSignal, payload?: ToolConfirmationPayload, skipBusPublish?: boolean): Promise<void>;
80
+ private approveToolCall;
81
+ /**
82
+ * Handles an execution error: cancels on abort, otherwise buffers the error.
83
+ */
84
+ private _handleExecutionError;
85
+ /**
86
+ * Handles a publish error by logging and setting an error status if needed.
87
+ */
88
+ private _handlePublishError;
89
+ /**
90
+ * Launch a single scheduled tool call and wire up result buffering / error handling.
91
+ * @requirement:HOOK-017,HOOK-019,HOOK-129,HOOK-131,HOOK-132,HOOK-134 - Hook result application
92
+ */
93
+ private launchToolExecution;
94
+ private attemptExecutionOfScheduledCalls;
95
+ private checkAndNotifyCompletion;
96
+ private notifyToolCallsUpdate;
97
+ private setToolCallOutcome;
98
+ /**
99
+ * Synchronously cancels all queued and active tool calls in the scheduler.
100
+ * This updates the status of tracked tools to 'cancelled'.
101
+ * Note: The actual async execution of tools is interrupted by the AbortSignal
102
+ * passed during scheduling, which the caller is responsible for aborting.
103
+ */
104
+ cancelAll(): void;
105
+ }