@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,540 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ApiError, } from '@google/genai';
7
+ import { retryWithBackoff } from '@vybestack/llxprt-code-core/utils/retry.js';
8
+ import { createAbortError } from '@vybestack/llxprt-code-core/utils/delay.js';
9
+ import { nextStreamEventWithIdleTimeout, resolveStreamIdleTimeoutMs, } from '@vybestack/llxprt-code-core/utils/streamIdleTimeout.js';
10
+ import { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
11
+ import { ContentConverters } from '@vybestack/llxprt-code-core/services/history/ContentConverters.js';
12
+ import { normalizeToolInteractionInput, convertIContentToResponse, } from './MessageConverter.js';
13
+ import { StreamEventType, InvalidStreamError, EmptyStreamError, isThoughtPart, isSchemaDepthError, INVALID_CONTENT_RETRY_OPTIONS, } from '@vybestack/llxprt-code-core/core/chatSessionTypes.js';
14
+ import { attachHookRestrictedAllowedTools, filterHookRestrictedContents, filterHookRestrictedContent, getHookRestrictedAllowedTools, } from './hookToolRestrictions.js';
15
+ import { canonicalizeToolName } from './toolGovernance.js';
16
+ import { AgentExecutionStoppedError, AgentExecutionBlockedError, } from './chatSession.js';
17
+ import { logApiRequest, logApiResponse, logApiError } from './turnLogging.js';
18
+ import { hasCycleInSchema } from '@vybestack/llxprt-code-tools';
19
+ /**
20
+ * Handles turn-level operations: sendMessage, sendMessageStream, waitForIdle.
21
+ * Orchestrates non-streaming sends and delegates streaming to StreamProcessor.
22
+ */
23
+ export class TurnProcessor {
24
+ runtimeContext;
25
+ compressionHandler;
26
+ providerResolver;
27
+ providerRuntimeBuilder;
28
+ generationConfig;
29
+ historyService;
30
+ streamProcessor;
31
+ makePositionMatcher;
32
+ resolveProviderBaseUrl;
33
+ logger = new DebugLogger('llxprt:turn-processor');
34
+ sendPromise = Promise.resolve();
35
+ lastPromptTokenCount = null;
36
+ constructor(runtimeContext, compressionHandler, providerResolver, providerRuntimeBuilder, generationConfig, historyService, streamProcessor, makePositionMatcher, resolveProviderBaseUrl) {
37
+ this.runtimeContext = runtimeContext;
38
+ this.compressionHandler = compressionHandler;
39
+ this.providerResolver = providerResolver;
40
+ this.providerRuntimeBuilder = providerRuntimeBuilder;
41
+ this.generationConfig = generationConfig;
42
+ this.historyService = historyService;
43
+ this.streamProcessor = streamProcessor;
44
+ this.makePositionMatcher = makePositionMatcher;
45
+ this.resolveProviderBaseUrl = resolveProviderBaseUrl;
46
+ }
47
+ /**
48
+ * Sends a non-streaming message to the provider.
49
+ * Waits for previous send, prepares message, calls provider, commits result to history.
50
+ */
51
+ async sendMessage(params, prompt_id) {
52
+ await this.sendPromise;
53
+ this.lastPromptTokenCount = null;
54
+ const prepared = await this._prepareSendMessage(params, prompt_id);
55
+ const provider = this.providerResolver('sendMessage');
56
+ const response = await this._executeSendWithRetry(params, prepared.userIContents, provider, prompt_id);
57
+ this.sendPromise = this._commitSendResult(response, prepared.userContent, params, prompt_id);
58
+ await this.sendPromise.catch(() => {
59
+ this.sendPromise = Promise.resolve();
60
+ });
61
+ return response;
62
+ }
63
+ /**
64
+ * Sends a streaming message to the provider.
65
+ * Waits for previous send, prepares message, delegates to StreamProcessor.
66
+ */
67
+ async sendMessageStream(params, prompt_id) {
68
+ await this.sendPromise;
69
+ this.lastPromptTokenCount = null;
70
+ const userContent = normalizeToolInteractionInput(params.message);
71
+ const userIContents = this._convertToIContents(userContent);
72
+ const pendingTokens = await this.estimatePendingTokens(userIContents);
73
+ await this.compressionHandler.ensureCompressionBeforeSend(prompt_id, pendingTokens, 'stream', 'auto');
74
+ let streamDoneResolver;
75
+ this.sendPromise = new Promise((resolve) => {
76
+ streamDoneResolver = resolve;
77
+ });
78
+ // Force-resolve sendPromise when the abort signal fires.
79
+ // This prevents a permanent deadlock when .return() can't propagate
80
+ // through a generator blocked on a hung inner iterator (e.g. stalled
81
+ // HTTP stream after idle timeout).
82
+ const abortSignal = params.config?.abortSignal;
83
+ const onAbort = () => streamDoneResolver();
84
+ if (abortSignal) {
85
+ if (abortSignal.aborted) {
86
+ streamDoneResolver();
87
+ }
88
+ else {
89
+ abortSignal.addEventListener('abort', onAbort, { once: true });
90
+ }
91
+ }
92
+ return this._createStreamGenerator(params, prompt_id, pendingTokens, userContent, () => {
93
+ abortSignal?.removeEventListener('abort', onAbort);
94
+ streamDoneResolver();
95
+ });
96
+ }
97
+ async *_createStreamGenerator(params, prompt_id, pendingTokens, userContent, onDone) {
98
+ try {
99
+ let lastError = new Error('Request failed after all retries.');
100
+ // eslint-disable-next-line sonarjs/too-many-break-or-continue-in-loop -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
101
+ for (let attempt = 0; attempt < INVALID_CONTENT_RETRY_OPTIONS.maxAttempts; attempt++) {
102
+ try {
103
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
104
+ if (attempt > 0)
105
+ yield { type: StreamEventType.RETRY };
106
+ const currentParams = this._applyRetryTemperature(params, attempt);
107
+ const stream = await this.streamProcessor.makeApiCallAndProcessStream(currentParams, prompt_id, pendingTokens, userContent);
108
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
109
+ for await (const chunk of stream) {
110
+ yield { type: StreamEventType.CHUNK, value: chunk };
111
+ }
112
+ lastError = null;
113
+ break;
114
+ }
115
+ catch (error) {
116
+ // Handle hook execution control errors before retry logic
117
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
118
+ if (error instanceof AgentExecutionStoppedError) {
119
+ yield {
120
+ type: StreamEventType.AGENT_EXECUTION_STOPPED,
121
+ reason: error.reason,
122
+ systemMessage: error.systemMessage,
123
+ contextCleared: error.contextCleared,
124
+ };
125
+ lastError = null;
126
+ break;
127
+ }
128
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
129
+ if (error instanceof AgentExecutionBlockedError) {
130
+ yield {
131
+ type: StreamEventType.AGENT_EXECUTION_BLOCKED,
132
+ reason: error.reason,
133
+ systemMessage: error.systemMessage,
134
+ contextCleared: error.contextCleared,
135
+ };
136
+ // If there's a synthetic response, yield it as a chunk
137
+ if (error.syntheticResponse) {
138
+ yield {
139
+ type: StreamEventType.CHUNK,
140
+ value: error.syntheticResponse,
141
+ };
142
+ }
143
+ lastError = null;
144
+ break;
145
+ }
146
+ lastError = error;
147
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
148
+ if ((error instanceof InvalidStreamError ||
149
+ error instanceof EmptyStreamError) &&
150
+ attempt < INVALID_CONTENT_RETRY_OPTIONS.maxAttempts - 1) {
151
+ await new Promise((res) => setTimeout(res, INVALID_CONTENT_RETRY_OPTIONS.initialDelayMs * (attempt + 1)));
152
+ continue;
153
+ }
154
+ break;
155
+ }
156
+ }
157
+ if (lastError != null)
158
+ throw lastError;
159
+ }
160
+ finally {
161
+ onDone();
162
+ }
163
+ }
164
+ _applyRetryTemperature(params, attempt) {
165
+ if (attempt === 0)
166
+ return params;
167
+ const baselineTemperature = Math.max(params.config?.temperature ?? 1, 1);
168
+ const newTemperature = Math.min(Math.max(baselineTemperature + attempt * 0.1, 0), 2);
169
+ return {
170
+ ...params,
171
+ config: { ...params.config, temperature: newTemperature },
172
+ };
173
+ }
174
+ _convertToIContents(userContent) {
175
+ const contents = Array.isArray(userContent) ? userContent : [userContent];
176
+ const matcher = this.makePositionMatcher();
177
+ return contents.map((content) => {
178
+ const turnKey = this.historyService.generateTurnKey();
179
+ const idGen = this.historyService.getIdGeneratorCallback(turnKey);
180
+ return ContentConverters.toIContent(content, idGen, matcher, turnKey);
181
+ });
182
+ }
183
+ /**
184
+ * Waits for any pending send operation to complete.
185
+ * Fail-open: swallows errors from previous failed sends.
186
+ */
187
+ async waitForIdle() {
188
+ try {
189
+ await this.sendPromise;
190
+ }
191
+ catch {
192
+ // If a previous send failed, sendPromise can reject; callers that just need
193
+ // a "best effort" flush should not fail provider switching.
194
+ }
195
+ }
196
+ /**
197
+ * Estimates the token count for pending IContent items.
198
+ */
199
+ async estimatePendingTokens(contents) {
200
+ return this.compressionHandler.estimatePendingTokens(contents);
201
+ }
202
+ /**
203
+ * Prepares user message: validates, converts input, estimates tokens, compresses if needed.
204
+ */
205
+ async _prepareSendMessage(params, prompt_id) {
206
+ const userContent = normalizeToolInteractionInput(params.message);
207
+ const userIContents = this._convertToIContents(userContent);
208
+ const pendingTokens = await this.estimatePendingTokens(userIContents);
209
+ await this.compressionHandler.ensureCompressionBeforeSend(prompt_id, pendingTokens, 'send', 'auto');
210
+ const provider = this.providerResolver('sendMessage');
211
+ await this.compressionHandler.enforceContextWindow(pendingTokens, prompt_id, provider);
212
+ return { userContent, userIContents, pendingTokens };
213
+ }
214
+ /**
215
+ * Executes the provider call with retry and bucket failover.
216
+ */
217
+ async _executeSendWithRetry(params, userIContents, provider, prompt_id) {
218
+ this._validateProvider(provider);
219
+ const iContents = this.historyService.getCuratedForProvider(userIContents);
220
+ logApiRequest(this.runtimeContext, this.runtimeContext.state, ContentConverters.toGeminiContents(iContents), this.runtimeContext.state.model, prompt_id);
221
+ const providerBaseUrl = this.resolveProviderBaseUrl(provider);
222
+ const startTime = Date.now();
223
+ try {
224
+ const response = await retryWithBackoff(() => this._executeProviderCall(provider, params, iContents, providerBaseUrl), {
225
+ shouldRetryOnError: (error) => {
226
+ if (error instanceof ApiError && error.message) {
227
+ if (error.status === 400 || isSchemaDepthError(error.message))
228
+ return false;
229
+ if (error.status === 429 ||
230
+ (error.status >= 500 && error.status < 600))
231
+ return true;
232
+ }
233
+ return false;
234
+ },
235
+ signal: params.config?.abortSignal,
236
+ });
237
+ const durationMs = Date.now() - startTime;
238
+ logApiResponse(this.runtimeContext, this.runtimeContext.state, this.runtimeContext.state.model, prompt_id, durationMs, response.usageMetadata, JSON.stringify(response));
239
+ return response;
240
+ }
241
+ catch (error) {
242
+ const durationMs = Date.now() - startTime;
243
+ logApiError(this.runtimeContext, this.runtimeContext.state, this.runtimeContext.state.model, prompt_id, durationMs, error);
244
+ this._enrichSchemaDepthError(error);
245
+ this.sendPromise = Promise.resolve();
246
+ throw error;
247
+ }
248
+ }
249
+ _validateProvider(provider) {
250
+ this.logger.debug(() => '[TurnProcessor] Active provider snapshot before send', {
251
+ providerName: provider.name,
252
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Turn processor runtime payloads.
253
+ providerDefaultModel: provider.getDefaultModel?.(),
254
+ configModel: this.runtimeContext.state.model,
255
+ baseUrl: this.resolveProviderBaseUrl(provider),
256
+ });
257
+ if (typeof provider.generateChatCompletion !== 'function') {
258
+ throw new Error(`Provider ${provider.name} does not support IContent interface`);
259
+ }
260
+ }
261
+ /**
262
+ * Executes the actual provider.generateChatCompletion call.
263
+ */
264
+ async _executeProviderCall(provider, params, requestContents, providerBaseUrl) {
265
+ const configForHooks = this.runtimeContext.providerRuntime.config;
266
+ const requestTools = this._selectRequestTools(params);
267
+ const toolSelection = await this._applyToolSelectionHook(configForHooks, requestTools);
268
+ const tools = toolSelection.tools;
269
+ this._logToolDiagnostics(provider, tools, providerBaseUrl);
270
+ const runtimeContext = this.providerRuntimeBuilder('TurnProcessor.executeProviderCall', { toolCount: tools?.length ?? 0 });
271
+ const timeoutController = new AbortController();
272
+ const upstreamAbortSignal = params.config?.abortSignal;
273
+ const onAbort = () => timeoutController.abort();
274
+ upstreamAbortSignal?.addEventListener('abort', onAbort, { once: true });
275
+ if (upstreamAbortSignal?.aborted === true) {
276
+ onAbort();
277
+ }
278
+ try {
279
+ const streamResponse = this._createProviderStream(provider, requestContents, tools, runtimeContext, timeoutController.signal);
280
+ const lastResponse = await this._consumeProviderStream(streamResponse, runtimeContext, timeoutController, upstreamAbortSignal);
281
+ return attachHookRestrictedAllowedTools(convertIContentToResponse(lastResponse), toolSelection.allowedFunctionNames);
282
+ }
283
+ finally {
284
+ timeoutController.abort();
285
+ upstreamAbortSignal?.removeEventListener('abort', onAbort);
286
+ }
287
+ }
288
+ _createProviderStream(provider, requestContents, tools, runtimeContext, timeoutSignal) {
289
+ return provider.generateChatCompletion({
290
+ contents: requestContents,
291
+ tools: tools,
292
+ config: runtimeContext.config,
293
+ runtime: runtimeContext,
294
+ invocation: {
295
+ signal: timeoutSignal,
296
+ },
297
+ settings: runtimeContext.settingsService,
298
+ metadata: runtimeContext.metadata,
299
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Turn processor runtime payloads.
300
+ userMemory: runtimeContext.config?.getUserMemory?.(),
301
+ });
302
+ }
303
+ async _consumeProviderStream(streamResponse, runtimeContext, timeoutController, upstreamAbortSignal) {
304
+ let lastResponse;
305
+ const blocks = [];
306
+ const iterator = streamResponse[Symbol.asyncIterator]();
307
+ const effectiveTimeoutMs = resolveStreamIdleTimeoutMs(runtimeContext.config);
308
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Turn processor runtime payloads.
309
+ while (true) {
310
+ const nextResponse = await this._readProviderStreamResponse(iterator, timeoutController, upstreamAbortSignal, effectiveTimeoutMs);
311
+ if (nextResponse.done === true) {
312
+ break;
313
+ }
314
+ const iContent = nextResponse.value;
315
+ this._trackProviderPromptTokens(iContent);
316
+ blocks.push(...iContent.blocks);
317
+ lastResponse = iContent;
318
+ }
319
+ if (!lastResponse)
320
+ throw new Error('No response from provider');
321
+ return { ...lastResponse, blocks };
322
+ }
323
+ _readProviderStreamResponse(iterator, timeoutController, upstreamAbortSignal, effectiveTimeoutMs) {
324
+ if (effectiveTimeoutMs <= 0) {
325
+ return iterator.next();
326
+ }
327
+ return nextStreamEventWithIdleTimeout({
328
+ iterator,
329
+ timeoutMs: effectiveTimeoutMs,
330
+ signal: timeoutController.signal,
331
+ onTimeout: () => {
332
+ if (upstreamAbortSignal?.aborted === true) {
333
+ return;
334
+ }
335
+ timeoutController.abort();
336
+ },
337
+ createTimeoutError: () => createAbortError(),
338
+ });
339
+ }
340
+ _trackProviderPromptTokens(iContent) {
341
+ const promptTokens = iContent.metadata?.usage?.promptTokens;
342
+ if (promptTokens === undefined) {
343
+ return;
344
+ }
345
+ const cacheReads = iContent.metadata?.usage?.cache_read_input_tokens ?? 0;
346
+ const cacheWrites = iContent.metadata?.usage?.cache_creation_input_tokens ?? 0;
347
+ this.lastPromptTokenCount = promptTokens + cacheReads + cacheWrites;
348
+ this.compressionHandler.lastPromptTokenCount = this.lastPromptTokenCount;
349
+ }
350
+ _selectRequestTools(params) {
351
+ return params.config?.tools ?? this.generationConfig.tools;
352
+ }
353
+ async _applyToolSelectionHook(configForHooks, tools) {
354
+ const toolsFromConfig = Array.isArray(tools)
355
+ ? tools
356
+ : [];
357
+ if (configForHooks === undefined ||
358
+ typeof configForHooks.getEnableHooks !== 'function' ||
359
+ configForHooks.getEnableHooks() !== true) {
360
+ return {
361
+ tools: toolsFromConfig,
362
+ allowedFunctionNames: undefined,
363
+ };
364
+ }
365
+ const hookSystem = configForHooks.getHookSystem();
366
+ if (hookSystem === undefined) {
367
+ return { tools: toolsFromConfig, allowedFunctionNames: undefined };
368
+ }
369
+ await hookSystem.initialize();
370
+ const toolSelectionResult = await hookSystem.fireBeforeToolSelectionEvent(toolsFromConfig);
371
+ const modifiedConfig = toolSelectionResult?.applyToolConfigModifications({
372
+ tools: toolsFromConfig,
373
+ });
374
+ const allowedFunctions = modifiedConfig?.toolConfig?.allowedFunctionNames;
375
+ if (!Array.isArray(allowedFunctions)) {
376
+ return { tools: toolsFromConfig, allowedFunctionNames: undefined };
377
+ }
378
+ const allowedNames = new Set(allowedFunctions.map(canonicalizeToolName));
379
+ const filteredTools = toolsFromConfig
380
+ .map((toolGroup) => ({
381
+ ...toolGroup,
382
+ functionDeclarations: toolGroup.functionDeclarations.filter((fn) => allowedNames.has(canonicalizeToolName(fn.name))),
383
+ }))
384
+ .filter((toolGroup) => toolGroup.functionDeclarations.length > 0);
385
+ return { tools: filteredTools, allowedFunctionNames: allowedFunctions };
386
+ }
387
+ _logToolDiagnostics(provider, tools, baseUrl) {
388
+ if (Array.isArray(tools)) {
389
+ const total = tools.reduce((sum, g) => {
390
+ if (typeof g === 'object' &&
391
+ g !== null &&
392
+ 'functionDeclarations' in g &&
393
+ Array.isArray(g.functionDeclarations))
394
+ return sum + g.functionDeclarations.length;
395
+ return sum;
396
+ }, 0);
397
+ if (total === 0)
398
+ this.logger.warn(() => `[TurnProcessor] Tools array exists but has 0 function declarations!`, { tools, provider: provider.name });
399
+ }
400
+ this.logger.debug(() => '[TurnProcessor] Calling provider.generateChatCompletion', {
401
+ providerName: provider.name,
402
+ model: this.runtimeContext.state.model,
403
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Turn processor runtime payloads.
404
+ toolCount: tools?.length ?? 0,
405
+ baseUrl,
406
+ });
407
+ }
408
+ /**
409
+ * Commits the send result to history: adds user and model content, syncs tokens.
410
+ */
411
+ async _commitSendResult(response, userContent, _params, _prompt_id) {
412
+ const currentModel = this.runtimeContext.state.model;
413
+ const afcHistory = response.automaticFunctionCallingHistory;
414
+ const allowedTools = getHookRestrictedAllowedTools(response);
415
+ const filteredAfcHistory = afcHistory && afcHistory.length > 0
416
+ ? filterHookRestrictedContents(afcHistory, allowedTools).filter((content) => (content.parts?.length ?? 0) > 0)
417
+ : undefined;
418
+ if (filteredAfcHistory && filteredAfcHistory.length > 0) {
419
+ this._recordAfcHistory(filteredAfcHistory, currentModel);
420
+ }
421
+ else {
422
+ this._recordUserContent(userContent, currentModel);
423
+ }
424
+ this._recordOutputContent(response, currentModel, filteredAfcHistory);
425
+ await this._syncTokenCounts(response);
426
+ }
427
+ _recordAfcHistory(afcHistory, currentModel) {
428
+ const curatedHistory = this.historyService.getCurated();
429
+ const index = ContentConverters.toGeminiContents(curatedHistory).length;
430
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Turn processor runtime payloads.
431
+ const newEntries = afcHistory.slice(index) ?? [];
432
+ const matcher = this.makePositionMatcher();
433
+ for (const content of newEntries) {
434
+ const turnKey = this.historyService.generateTurnKey();
435
+ const idGen = this.historyService.getIdGeneratorCallback(turnKey);
436
+ this.historyService.add(ContentConverters.toIContent(content, idGen, matcher, turnKey), currentModel);
437
+ }
438
+ }
439
+ _recordUserContent(userContent, currentModel) {
440
+ const contents = Array.isArray(userContent) ? userContent : [userContent];
441
+ const matcher = this.makePositionMatcher();
442
+ for (const content of contents) {
443
+ const turnKey = this.historyService.generateTurnKey();
444
+ const idGen = this.historyService.getIdGeneratorCallback(turnKey);
445
+ this.historyService.add(ContentConverters.toIContent(content, idGen, matcher, turnKey), currentModel);
446
+ }
447
+ }
448
+ _recordOutputContent(response, currentModel, afcHistory) {
449
+ const outputContent = response.candidates?.[0]?.content;
450
+ if (outputContent) {
451
+ const includeThoughts = this.runtimeContext.ephemerals.reasoning.includeInContext();
452
+ const filteredOutputContent = filterHookRestrictedContent(outputContent, getHookRestrictedAllowedTools(response));
453
+ const contentForHistory = includeThoughts
454
+ ? filteredOutputContent
455
+ : {
456
+ ...filteredOutputContent,
457
+ parts: (filteredOutputContent.parts ?? []).filter((p) => !isThoughtPart(p)),
458
+ };
459
+ if ((contentForHistory.parts?.length ?? 0) > 0) {
460
+ const turnKey = this.historyService.generateTurnKey();
461
+ const idGen = this.historyService.getIdGeneratorCallback(turnKey);
462
+ this.historyService.add(ContentConverters.toIContent(contentForHistory, idGen, undefined, turnKey), currentModel);
463
+ }
464
+ }
465
+ else if ((response.candidates?.length ?? 0) > 0 &&
466
+ (!afcHistory || afcHistory.length === 0)) {
467
+ const turnKey = this.historyService.generateTurnKey();
468
+ const idGen = this.historyService.getIdGeneratorCallback(turnKey);
469
+ this.historyService.add(ContentConverters.toIContent({ role: 'model', parts: [] }, idGen, undefined, turnKey), currentModel);
470
+ }
471
+ }
472
+ async _syncTokenCounts(response) {
473
+ await this.historyService.waitForTokenUpdates();
474
+ const usageMetadata = response.usageMetadata;
475
+ if (usageMetadata?.promptTokenCount !== undefined) {
476
+ const combined = usageMetadata.promptTokenCount +
477
+ (usageMetadata.cache_read_input_tokens ?? 0) +
478
+ (usageMetadata.cache_creation_input_tokens ?? 0);
479
+ if (combined > 0) {
480
+ this.historyService.syncTotalTokens(combined);
481
+ await this.historyService.waitForTokenUpdates();
482
+ }
483
+ }
484
+ else if (this.lastPromptTokenCount != null &&
485
+ this.lastPromptTokenCount > 0 &&
486
+ !Number.isNaN(this.lastPromptTokenCount)) {
487
+ // lastPromptTokenCount is already cache-adjusted (includes
488
+ // cache_read + cache_creation tokens) from the provider call path
489
+ this.historyService.syncTotalTokens(this.lastPromptTokenCount);
490
+ await this.historyService.waitForTokenUpdates();
491
+ }
492
+ }
493
+ /**
494
+ * Enriches schema depth errors with additional context for debugging.
495
+ */
496
+ _enrichSchemaDepthError(error) {
497
+ if (error instanceof ApiError &&
498
+ error.message !== '' &&
499
+ isSchemaDepthError(error.message)) {
500
+ const tools = this.generationConfig.tools;
501
+ if (!Array.isArray(tools)) {
502
+ return;
503
+ }
504
+ const toolNames = [];
505
+ const cyclicSchemaTools = [];
506
+ for (const toolGroup of tools) {
507
+ if (
508
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Tool groups can be malformed at runtime.
509
+ toolGroup !== null &&
510
+ typeof toolGroup === 'object' &&
511
+ 'functionDeclarations' in toolGroup &&
512
+ Array.isArray(toolGroup.functionDeclarations)) {
513
+ // eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
514
+ for (const funcDecl of toolGroup.functionDeclarations) {
515
+ const name = funcDecl.name ?? 'unknown';
516
+ toolNames.push(name);
517
+ const schema = funcDecl.parametersJsonSchema;
518
+ if (schema != null &&
519
+ typeof schema === 'object' &&
520
+ hasCycleInSchema(schema)) {
521
+ cyclicSchemaTools.push(name);
522
+ }
523
+ }
524
+ }
525
+ }
526
+ const metadata = {
527
+ totalTools: toolNames.length,
528
+ toolNames,
529
+ cyclicSchemaTools,
530
+ };
531
+ const extraDetails = cyclicSchemaTools.length > 0
532
+ ? `\n\nTools with cyclic schemas detected: ${cyclicSchemaTools.join(', ')}\n` +
533
+ `This is a known issue that can cause "maximum schema depth exceeded" errors.\n` +
534
+ `Please review the schema definitions for these tools.`
535
+ : '';
536
+ this.logger.error(() => `[TurnProcessor] Schema depth error encountered${extraDetails}`, metadata);
537
+ }
538
+ }
539
+ }
540
+ //# sourceMappingURL=TurnProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TurnProcessor.js","sourceRoot":"","sources":["../../../src/core/TurnProcessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAIL,QAAQ,GACT,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,wDAAwD,CAAC;AAUhE,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mEAAmE,CAAC;AAEtG,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EAEf,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,6BAA6B,GAE9B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,gCAAgC,EAChC,4BAA4B,EAC5B,2BAA2B,EAC3B,6BAA6B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;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