@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.
- package/dist/.last_build +0 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/src/agents/executor-prompt-builder.d.ts +19 -0
- package/dist/src/agents/executor-prompt-builder.js +44 -0
- package/dist/src/agents/executor-prompt-builder.js.map +1 -0
- package/dist/src/agents/executor-termination.d.ts +22 -0
- package/dist/src/agents/executor-termination.js +44 -0
- package/dist/src/agents/executor-termination.js.map +1 -0
- package/dist/src/agents/executor-validation.d.ts +17 -0
- package/dist/src/agents/executor-validation.js +35 -0
- package/dist/src/agents/executor-validation.js.map +1 -0
- package/dist/src/agents/executor.d.ts +136 -0
- package/dist/src/agents/executor.js +874 -0
- package/dist/src/agents/executor.js.map +1 -0
- package/dist/src/agents/invocation.d.ts +45 -0
- package/dist/src/agents/invocation.js +118 -0
- package/dist/src/agents/invocation.js.map +1 -0
- package/dist/src/agents/recovery.d.ts +75 -0
- package/dist/src/agents/recovery.js +107 -0
- package/dist/src/agents/recovery.js.map +1 -0
- package/dist/src/agents/types.d.ts +149 -0
- package/dist/src/agents/types.js +18 -0
- package/dist/src/agents/types.js.map +1 -0
- package/dist/src/agents/utils.d.ts +15 -0
- package/dist/src/agents/utils.js +28 -0
- package/dist/src/agents/utils.js.map +1 -0
- package/dist/src/compression/CompressionHandler.d.ts +178 -0
- package/dist/src/compression/CompressionHandler.js +630 -0
- package/dist/src/compression/CompressionHandler.js.map +1 -0
- package/dist/src/compression/HighDensityStrategy.d.ts +113 -0
- package/dist/src/compression/HighDensityStrategy.js +769 -0
- package/dist/src/compression/HighDensityStrategy.js.map +1 -0
- package/dist/src/compression/MiddleOutStrategy.d.ts +27 -0
- package/dist/src/compression/MiddleOutStrategy.js +347 -0
- package/dist/src/compression/MiddleOutStrategy.js.map +1 -0
- package/dist/src/compression/OneShotStrategy.d.ts +22 -0
- package/dist/src/compression/OneShotStrategy.js +235 -0
- package/dist/src/compression/OneShotStrategy.js.map +1 -0
- package/dist/src/compression/TopDownTruncationStrategy.d.ts +13 -0
- package/dist/src/compression/TopDownTruncationStrategy.js +74 -0
- package/dist/src/compression/TopDownTruncationStrategy.js.map +1 -0
- package/dist/src/compression/compressionBudgeting.d.ts +34 -0
- package/dist/src/compression/compressionBudgeting.js +139 -0
- package/dist/src/compression/compressionBudgeting.js.map +1 -0
- package/dist/src/compression/compressionStrategyFactory.d.ts +23 -0
- package/dist/src/compression/compressionStrategyFactory.js +40 -0
- package/dist/src/compression/compressionStrategyFactory.js.map +1 -0
- package/dist/src/compression/index.d.ts +16 -0
- package/dist/src/compression/index.js +17 -0
- package/dist/src/compression/index.js.map +1 -0
- package/dist/src/compression/reasoningUtils.d.ts +18 -0
- package/dist/src/compression/reasoningUtils.js +22 -0
- package/dist/src/compression/reasoningUtils.js.map +1 -0
- package/dist/src/compression/utils.d.ts +114 -0
- package/dist/src/compression/utils.js +316 -0
- package/dist/src/compression/utils.js.map +1 -0
- package/dist/src/core/AgentHookManager.d.ts +41 -0
- package/dist/src/core/AgentHookManager.js +65 -0
- package/dist/src/core/AgentHookManager.js.map +1 -0
- package/dist/src/core/ChatSessionFactory.d.ts +50 -0
- package/dist/src/core/ChatSessionFactory.js +216 -0
- package/dist/src/core/ChatSessionFactory.js.map +1 -0
- package/dist/src/core/ConversationManager.d.ts +113 -0
- package/dist/src/core/ConversationManager.js +311 -0
- package/dist/src/core/ConversationManager.js.map +1 -0
- package/dist/src/core/DirectMessageProcessor.d.ts +79 -0
- package/dist/src/core/DirectMessageProcessor.js +478 -0
- package/dist/src/core/DirectMessageProcessor.js.map +1 -0
- package/dist/src/core/IdeContextTracker.d.ts +56 -0
- package/dist/src/core/IdeContextTracker.js +207 -0
- package/dist/src/core/IdeContextTracker.js.map +1 -0
- package/dist/src/core/MessageConverter.d.ts +78 -0
- package/dist/src/core/MessageConverter.js +492 -0
- package/dist/src/core/MessageConverter.js.map +1 -0
- package/dist/src/core/MessageStreamOrchestrator.d.ts +85 -0
- package/dist/src/core/MessageStreamOrchestrator.js +448 -0
- package/dist/src/core/MessageStreamOrchestrator.js.map +1 -0
- package/dist/src/core/MessageStreamTerminalHandler.d.ts +16 -0
- package/dist/src/core/MessageStreamTerminalHandler.js +170 -0
- package/dist/src/core/MessageStreamTerminalHandler.js.map +1 -0
- package/dist/src/core/StreamProcessor.d.ts +105 -0
- package/dist/src/core/StreamProcessor.js +660 -0
- package/dist/src/core/StreamProcessor.js.map +1 -0
- package/dist/src/core/TodoContinuationService.d.ts +74 -0
- package/dist/src/core/TodoContinuationService.js +312 -0
- package/dist/src/core/TodoContinuationService.js.map +1 -0
- package/dist/src/core/TurnProcessor.d.ts +91 -0
- package/dist/src/core/TurnProcessor.js +540 -0
- package/dist/src/core/TurnProcessor.js.map +1 -0
- package/dist/src/core/baseLlmClient.d.ts +115 -0
- package/dist/src/core/baseLlmClient.js +231 -0
- package/dist/src/core/baseLlmClient.js.map +1 -0
- package/dist/src/core/bucketFailoverIntegration.d.ts +62 -0
- package/dist/src/core/bucketFailoverIntegration.js +186 -0
- package/dist/src/core/bucketFailoverIntegration.js.map +1 -0
- package/dist/src/core/chatSession.d.ts +121 -0
- package/dist/src/core/chatSession.js +720 -0
- package/dist/src/core/chatSession.js.map +1 -0
- package/dist/src/core/client.d.ts +132 -0
- package/dist/src/core/client.js +524 -0
- package/dist/src/core/client.js.map +1 -0
- package/dist/src/core/clientHelpers.d.ts +15 -0
- package/dist/src/core/clientHelpers.js +122 -0
- package/dist/src/core/clientHelpers.js.map +1 -0
- package/dist/src/core/clientLlmUtilities.d.ts +30 -0
- package/dist/src/core/clientLlmUtilities.js +125 -0
- package/dist/src/core/clientLlmUtilities.js.map +1 -0
- package/dist/src/core/clientToolGovernance.d.ts +37 -0
- package/dist/src/core/clientToolGovernance.js +104 -0
- package/dist/src/core/clientToolGovernance.js.map +1 -0
- package/dist/src/core/compression-config.d.ts +12 -0
- package/dist/src/core/compression-config.js +21 -0
- package/dist/src/core/compression-config.js.map +1 -0
- package/dist/src/core/coreToolScheduler.d.ts +105 -0
- package/dist/src/core/coreToolScheduler.js +453 -0
- package/dist/src/core/coreToolScheduler.js.map +1 -0
- package/dist/src/core/hookToolRestrictions.d.ts +18 -0
- package/dist/src/core/hookToolRestrictions.js +187 -0
- package/dist/src/core/hookToolRestrictions.js.map +1 -0
- package/dist/src/core/nonInteractiveToolExecutor.d.ts +17 -0
- package/dist/src/core/nonInteractiveToolExecutor.js +102 -0
- package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
- package/dist/src/core/subagent.d.ts +105 -0
- package/dist/src/core/subagent.js +650 -0
- package/dist/src/core/subagent.js.map +1 -0
- package/dist/src/core/subagentExecution.d.ts +104 -0
- package/dist/src/core/subagentExecution.js +275 -0
- package/dist/src/core/subagentExecution.js.map +1 -0
- package/dist/src/core/subagentOrchestrator.d.ts +84 -0
- package/dist/src/core/subagentOrchestrator.js +503 -0
- package/dist/src/core/subagentOrchestrator.js.map +1 -0
- package/dist/src/core/subagentRuntimeSetup.d.ts +75 -0
- package/dist/src/core/subagentRuntimeSetup.js +387 -0
- package/dist/src/core/subagentRuntimeSetup.js.map +1 -0
- package/dist/src/core/subagentScheduler.d.ts +17 -0
- package/dist/src/core/subagentScheduler.js +7 -0
- package/dist/src/core/subagentScheduler.js.map +1 -0
- package/dist/src/core/subagentToolProcessing.d.ts +51 -0
- package/dist/src/core/subagentToolProcessing.js +359 -0
- package/dist/src/core/subagentToolProcessing.js.map +1 -0
- package/dist/src/core/toolGovernance.d.ts +18 -0
- package/dist/src/core/toolGovernance.js +50 -0
- package/dist/src/core/toolGovernance.js.map +1 -0
- package/dist/src/core/turn.d.ts +47 -0
- package/dist/src/core/turn.js +455 -0
- package/dist/src/core/turn.js.map +1 -0
- package/dist/src/core/turnLogging.d.ts +35 -0
- package/dist/src/core/turnLogging.js +80 -0
- package/dist/src/core/turnLogging.js.map +1 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.js +44 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scheduler/confirmation-coordinator.d.ts +139 -0
- package/dist/src/scheduler/confirmation-coordinator.js +443 -0
- package/dist/src/scheduler/confirmation-coordinator.js.map +1 -0
- package/dist/src/scheduler/result-aggregator.d.ts +127 -0
- package/dist/src/scheduler/result-aggregator.js +302 -0
- package/dist/src/scheduler/result-aggregator.js.map +1 -0
- package/dist/src/scheduler/status-transitions.d.ts +39 -0
- package/dist/src/scheduler/status-transitions.js +184 -0
- package/dist/src/scheduler/status-transitions.js.map +1 -0
- package/dist/src/scheduler/tool-dispatcher.d.ts +40 -0
- package/dist/src/scheduler/tool-dispatcher.js +120 -0
- package/dist/src/scheduler/tool-dispatcher.js.map +1 -0
- package/dist/src/scheduler/tool-executor.d.ts +44 -0
- package/dist/src/scheduler/tool-executor.js +117 -0
- package/dist/src/scheduler/tool-executor.js.map +1 -0
- package/dist/src/scheduler/utils.d.ts +11 -0
- package/dist/src/scheduler/utils.js +19 -0
- package/dist/src/scheduler/utils.js.map +1 -0
- package/dist/src/tools/task.d.ts +128 -0
- package/dist/src/tools/task.js +932 -0
- package/dist/src/tools/task.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { createUserContent, FinishReason, } from '@google/genai';
|
|
7
|
+
import { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
|
|
8
|
+
import { isThoughtPart, } from '@vybestack/llxprt-code-core/core/chatSessionTypes.js';
|
|
9
|
+
import { getResponseTextFromParts } from '@vybestack/llxprt-code-core/utils/generateContentResponseUtilities.js';
|
|
10
|
+
const logger = new DebugLogger('llxprt:core:message-converter');
|
|
11
|
+
/**
|
|
12
|
+
* Aggregates text from content blocks while preserving spacing around non-text blocks.
|
|
13
|
+
*/
|
|
14
|
+
export function aggregateTextWithSpacing(blocks, currentText, lastBlockWasNonText) {
|
|
15
|
+
let aggregatedText = currentText;
|
|
16
|
+
let wasNonText = lastBlockWasNonText;
|
|
17
|
+
for (const block of blocks) {
|
|
18
|
+
if (block.type === 'text') {
|
|
19
|
+
if (wasNonText && aggregatedText.length > 0) {
|
|
20
|
+
aggregatedText += ' ';
|
|
21
|
+
}
|
|
22
|
+
aggregatedText += block.text;
|
|
23
|
+
wasNonText = false;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
wasNonText = true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return { text: aggregatedText, lastBlockWasNonText: wasNonText };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Custom createUserContent that properly handles function response arrays.
|
|
33
|
+
* Each response must be a separate Part in the same Content, not nested arrays.
|
|
34
|
+
*/
|
|
35
|
+
export function createUserContentWithFunctionResponseFix(message) {
|
|
36
|
+
if (typeof message === 'string') {
|
|
37
|
+
return createUserContent(message);
|
|
38
|
+
}
|
|
39
|
+
// Handle array of parts or nested function response arrays
|
|
40
|
+
const parts = [];
|
|
41
|
+
// If the message is an array, process each element
|
|
42
|
+
if (Array.isArray(message)) {
|
|
43
|
+
// First check if this is an array of functionResponse Parts
|
|
44
|
+
// This happens when multiple tool responses are sent together
|
|
45
|
+
const allFunctionResponses = message.every((item) =>
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
47
|
+
item !== null && typeof item === 'object' && 'functionResponse' in item);
|
|
48
|
+
if (allFunctionResponses) {
|
|
49
|
+
// This is already a properly formatted array of function response Parts
|
|
50
|
+
// Just use them directly without any wrapping
|
|
51
|
+
// Cast is safe here because we've checked all items are objects with functionResponse
|
|
52
|
+
parts.push(...message);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Process mixed content
|
|
56
|
+
for (const item of message) {
|
|
57
|
+
// eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
58
|
+
if (typeof item === 'string') {
|
|
59
|
+
parts.push({ text: item });
|
|
60
|
+
}
|
|
61
|
+
else if (Array.isArray(item)) {
|
|
62
|
+
// Nested array case - flatten it
|
|
63
|
+
for (const subItem of item) {
|
|
64
|
+
parts.push(subItem);
|
|
65
|
+
}
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
67
|
+
}
|
|
68
|
+
else if (item !== null && typeof item === 'object') {
|
|
69
|
+
// Individual part (function response, text, etc.)
|
|
70
|
+
parts.push(item);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// Not an array, pass through to original createUserContent
|
|
77
|
+
return createUserContent(message);
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
role: 'user',
|
|
81
|
+
parts,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Normalizes tool interaction input for the provider.
|
|
86
|
+
* Packages tool responses as user messages.
|
|
87
|
+
*/
|
|
88
|
+
export function normalizeToolInteractionInput(message) {
|
|
89
|
+
// Handle simple string input
|
|
90
|
+
if (typeof message === 'string') {
|
|
91
|
+
return createUserContent(message);
|
|
92
|
+
}
|
|
93
|
+
// Handle single Part (not an array)
|
|
94
|
+
if (!Array.isArray(message)) {
|
|
95
|
+
return createUserContentWithFunctionResponseFix(message);
|
|
96
|
+
}
|
|
97
|
+
// Now we have an array of parts - check if it contains tool interactions
|
|
98
|
+
const parts = message;
|
|
99
|
+
// Detect if this is a tool response sequence (functionResponse parts only)
|
|
100
|
+
const hasFunctionResponses = parts.some((part) =>
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
102
|
+
part !== null && typeof part === 'object' && 'functionResponse' in part);
|
|
103
|
+
// If no function responses, fall back to original behavior
|
|
104
|
+
if (!hasFunctionResponses) {
|
|
105
|
+
return createUserContentWithFunctionResponseFix(message);
|
|
106
|
+
}
|
|
107
|
+
// Tool responses go in a user message
|
|
108
|
+
return createUserContentWithFunctionResponseFix(parts);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a part contains valid non-thought text content.
|
|
112
|
+
*/
|
|
113
|
+
export function isValidNonThoughtTextPart(part) {
|
|
114
|
+
return (
|
|
115
|
+
// eslint-disable-next-line sonarjs/expression-complexity -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
116
|
+
typeof part.text === 'string' &&
|
|
117
|
+
part.thought !== true &&
|
|
118
|
+
// Technically, the model should never generate parts that have text and
|
|
119
|
+
// any of these but we don't trust them so check anyways.
|
|
120
|
+
!part.functionCall &&
|
|
121
|
+
!part.functionResponse &&
|
|
122
|
+
!part.inlineData &&
|
|
123
|
+
!part.fileData);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns true if the response is valid, false otherwise.
|
|
127
|
+
*/
|
|
128
|
+
export function isValidResponse(response) {
|
|
129
|
+
if (response.candidates === undefined || response.candidates.length === 0) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const content = response.candidates[0]?.content;
|
|
133
|
+
if (content === undefined) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
return isValidContent(content);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Validates if Content has valid parts.
|
|
140
|
+
*/
|
|
141
|
+
export function isValidContent(content) {
|
|
142
|
+
if (content.parts === undefined || content.parts.length === 0) {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
for (const part of content.parts) {
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
147
|
+
if (part === undefined || Object.keys(part).length === 0) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (part.thought !== true && part.text !== undefined && part.text === '') {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validates the history contains the correct roles.
|
|
158
|
+
*/
|
|
159
|
+
export function validateHistory(history) {
|
|
160
|
+
for (const content of history) {
|
|
161
|
+
if (content.role !== 'user' && content.role !== 'model') {
|
|
162
|
+
throw new Error(`Role must be user or model, but got ${content.role}.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Extracts valid history turns from comprehensive history.
|
|
168
|
+
* Filters out invalid or empty contents from safety filters or recitation.
|
|
169
|
+
*/
|
|
170
|
+
export function extractCuratedHistory(comprehensiveHistory) {
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
172
|
+
if (comprehensiveHistory === undefined || comprehensiveHistory.length === 0) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
const curatedHistory = [];
|
|
176
|
+
const length = comprehensiveHistory.length;
|
|
177
|
+
let i = 0;
|
|
178
|
+
while (i < length) {
|
|
179
|
+
if (comprehensiveHistory[i].role === 'user') {
|
|
180
|
+
curatedHistory.push(comprehensiveHistory[i]);
|
|
181
|
+
i++;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const modelOutput = [];
|
|
185
|
+
let isValid = true;
|
|
186
|
+
while (i < length && comprehensiveHistory[i].role === 'model') {
|
|
187
|
+
modelOutput.push(comprehensiveHistory[i]);
|
|
188
|
+
// eslint-disable-next-line sonarjs/nested-control-flow -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
189
|
+
if (isValid && !isValidContent(comprehensiveHistory[i])) {
|
|
190
|
+
isValid = false;
|
|
191
|
+
}
|
|
192
|
+
i++;
|
|
193
|
+
}
|
|
194
|
+
if (isValid) {
|
|
195
|
+
curatedHistory.push(...modelOutput);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return curatedHistory;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Checks if a Content has text content in the first part.
|
|
203
|
+
*/
|
|
204
|
+
export function hasTextContent(content) {
|
|
205
|
+
return Boolean(
|
|
206
|
+
// eslint-disable-next-line sonarjs/expression-complexity -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
207
|
+
content &&
|
|
208
|
+
content.role === 'model' &&
|
|
209
|
+
content.parts &&
|
|
210
|
+
content.parts.length > 0 &&
|
|
211
|
+
typeof content.parts[0].text === 'string' &&
|
|
212
|
+
content.parts[0].text !== '');
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Convert PartListUnion (user input) to IContent format.
|
|
216
|
+
*/
|
|
217
|
+
export function convertPartListUnionToIContent(input) {
|
|
218
|
+
if (typeof input === 'string') {
|
|
219
|
+
// Simple string input from user
|
|
220
|
+
return {
|
|
221
|
+
speaker: 'human',
|
|
222
|
+
blocks: [{ type: 'text', text: input }],
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// Handle Part or Part[] - delegate to helper
|
|
226
|
+
// After filtering out string case, input is PartUnion[] | PartUnion = (Part | string)[] | Part | string
|
|
227
|
+
// But we know strings are already handled, so cast to Part[]
|
|
228
|
+
const parts = (Array.isArray(input) ? input : [input]);
|
|
229
|
+
return convertMixedPartsToIContent(parts);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Converts mixed Parts (function calls, responses, text, thoughts) to IContent.
|
|
233
|
+
*/
|
|
234
|
+
export function convertMixedPartsToIContent(parts) {
|
|
235
|
+
// Fast path: all function responses → tool message
|
|
236
|
+
const allFunctionResponses = parts.every((part) =>
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider/runtime parts can be malformed at this boundary despite static Part typing.
|
|
238
|
+
part !== null && typeof part === 'object' && 'functionResponse' in part);
|
|
239
|
+
if (allFunctionResponses) {
|
|
240
|
+
return convertAllFunctionResponses(parts);
|
|
241
|
+
}
|
|
242
|
+
// Mixed content: classify parts and determine speaker
|
|
243
|
+
const { blocks, hasAIContent, hasToolContent } = classifyMixedParts(parts);
|
|
244
|
+
return {
|
|
245
|
+
// eslint-disable-next-line sonarjs/no-nested-conditional -- Existing structure is intentionally preserved; refactoring this boundary is outside the lint slice.
|
|
246
|
+
speaker: hasToolContent ? 'tool' : hasAIContent ? 'ai' : 'human',
|
|
247
|
+
blocks,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function convertAllFunctionResponses(parts) {
|
|
251
|
+
const blocks = [];
|
|
252
|
+
for (const part of parts) {
|
|
253
|
+
if (
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Provider/runtime parts can be malformed at this boundary despite static Part typing.
|
|
255
|
+
part !== null &&
|
|
256
|
+
typeof part === 'object' &&
|
|
257
|
+
'functionResponse' in part &&
|
|
258
|
+
part.functionResponse) {
|
|
259
|
+
blocks.push({
|
|
260
|
+
type: 'tool_response',
|
|
261
|
+
callId: part.functionResponse.id ?? '',
|
|
262
|
+
toolName: part.functionResponse.name ?? '',
|
|
263
|
+
result:
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
265
|
+
part.functionResponse.response ?? {},
|
|
266
|
+
error: undefined,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return { speaker: 'tool', blocks };
|
|
271
|
+
}
|
|
272
|
+
function classifyMixedParts(parts) {
|
|
273
|
+
const blocks = [];
|
|
274
|
+
let hasAIContent = false;
|
|
275
|
+
let hasToolContent = false;
|
|
276
|
+
for (const part of parts) {
|
|
277
|
+
if (typeof part === 'string') {
|
|
278
|
+
blocks.push({ type: 'text', text: part });
|
|
279
|
+
}
|
|
280
|
+
else if (isThoughtPart(part)) {
|
|
281
|
+
const thinkingBlock = {
|
|
282
|
+
type: 'thinking',
|
|
283
|
+
thought: part.text ?? '',
|
|
284
|
+
isHidden: true,
|
|
285
|
+
sourceField: part.llxprtSourceField ?? 'thought',
|
|
286
|
+
};
|
|
287
|
+
if (part.thoughtSignature) {
|
|
288
|
+
thinkingBlock.signature = part.thoughtSignature;
|
|
289
|
+
}
|
|
290
|
+
blocks.push(thinkingBlock);
|
|
291
|
+
hasAIContent = true;
|
|
292
|
+
}
|
|
293
|
+
else if ('text' in part && part.text !== undefined) {
|
|
294
|
+
blocks.push({ type: 'text', text: part.text });
|
|
295
|
+
}
|
|
296
|
+
else if ('functionCall' in part && part.functionCall) {
|
|
297
|
+
hasAIContent = true;
|
|
298
|
+
blocks.push({
|
|
299
|
+
type: 'tool_call',
|
|
300
|
+
id: part.functionCall.id ?? '',
|
|
301
|
+
name: part.functionCall.name ?? '',
|
|
302
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
303
|
+
parameters: part.functionCall.args ?? {},
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else if ('functionResponse' in part && part.functionResponse) {
|
|
307
|
+
hasToolContent = true;
|
|
308
|
+
blocks.push({
|
|
309
|
+
type: 'tool_response',
|
|
310
|
+
callId: part.functionResponse.id ?? '',
|
|
311
|
+
toolName: part.functionResponse.name ?? '',
|
|
312
|
+
result:
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
314
|
+
part.functionResponse.response ?? {},
|
|
315
|
+
error: undefined,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return { blocks, hasAIContent, hasToolContent };
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Converts IContent blocks to Gemini Parts array.
|
|
323
|
+
*/
|
|
324
|
+
export function convertBlocksToParts(blocks) {
|
|
325
|
+
const parts = [];
|
|
326
|
+
for (const block of blocks) {
|
|
327
|
+
switch (block.type) {
|
|
328
|
+
case 'text':
|
|
329
|
+
parts.push({ text: block.text });
|
|
330
|
+
break;
|
|
331
|
+
case 'tool_call': {
|
|
332
|
+
const toolCall = block;
|
|
333
|
+
parts.push({
|
|
334
|
+
functionCall: {
|
|
335
|
+
id: toolCall.id,
|
|
336
|
+
name: toolCall.name,
|
|
337
|
+
args: toolCall.parameters,
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
break;
|
|
341
|
+
}
|
|
342
|
+
case 'tool_response': {
|
|
343
|
+
const toolResponse = block;
|
|
344
|
+
parts.push({
|
|
345
|
+
functionResponse: {
|
|
346
|
+
id: toolResponse.callId,
|
|
347
|
+
name: toolResponse.toolName,
|
|
348
|
+
response: toolResponse.result,
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case 'thinking': {
|
|
354
|
+
const thinkingBlock = block;
|
|
355
|
+
const thoughtPart = {
|
|
356
|
+
thought: true,
|
|
357
|
+
text: thinkingBlock.thought,
|
|
358
|
+
};
|
|
359
|
+
if (thinkingBlock.signature) {
|
|
360
|
+
thoughtPart.thoughtSignature = thinkingBlock.signature;
|
|
361
|
+
}
|
|
362
|
+
if (thinkingBlock.sourceField) {
|
|
363
|
+
thoughtPart.llxprtSourceField = thinkingBlock.sourceField;
|
|
364
|
+
}
|
|
365
|
+
parts.push(thoughtPart);
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return parts;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Convert IContent to GenerateContentResponse for SDK compatibility.
|
|
376
|
+
*/
|
|
377
|
+
export function convertIContentToResponse(input) {
|
|
378
|
+
const parts = convertBlocksToParts(input.blocks);
|
|
379
|
+
const response = {
|
|
380
|
+
candidates: [
|
|
381
|
+
{
|
|
382
|
+
content: {
|
|
383
|
+
role: 'model',
|
|
384
|
+
parts,
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
],
|
|
388
|
+
get text() {
|
|
389
|
+
return getResponseTextFromParts(parts) ?? '';
|
|
390
|
+
},
|
|
391
|
+
functionCalls: parts
|
|
392
|
+
.filter((p) => 'functionCall' in p)
|
|
393
|
+
.map((p) => p.functionCall),
|
|
394
|
+
executableCode: undefined,
|
|
395
|
+
codeExecutionResult: undefined,
|
|
396
|
+
};
|
|
397
|
+
return applyResponseMetadata(response, input, parts);
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Maps termination reason (stopReason/finishReason) to Gemini FinishReason
|
|
401
|
+
* and applies it to the first candidate. Logs warnings for unmapped or
|
|
402
|
+
* missing-candidate cases.
|
|
403
|
+
*/
|
|
404
|
+
function applyFinishReasonMapping(response, input) {
|
|
405
|
+
const terminationReason = input.metadata?.stopReason ?? input.metadata?.finishReason;
|
|
406
|
+
if (terminationReason && response.candidates?.[0]) {
|
|
407
|
+
const finishReasonByTerminationReason = {
|
|
408
|
+
// Anthropic/Gemini-style values
|
|
409
|
+
end_turn: FinishReason.STOP,
|
|
410
|
+
max_tokens: FinishReason.MAX_TOKENS,
|
|
411
|
+
stop_sequence: FinishReason.STOP,
|
|
412
|
+
tool_use: FinishReason.STOP,
|
|
413
|
+
pause_turn: FinishReason.STOP,
|
|
414
|
+
refusal: FinishReason.STOP,
|
|
415
|
+
model_context_window_exceeded: FinishReason.MAX_TOKENS,
|
|
416
|
+
// OpenAI Chat Completions-style values
|
|
417
|
+
stop: FinishReason.STOP,
|
|
418
|
+
length: FinishReason.MAX_TOKENS,
|
|
419
|
+
tool_calls: FinishReason.STOP,
|
|
420
|
+
function_call: FinishReason.STOP,
|
|
421
|
+
content_filter: FinishReason.SAFETY,
|
|
422
|
+
// OpenAI Responses API status values
|
|
423
|
+
completed: FinishReason.STOP,
|
|
424
|
+
incomplete: FinishReason.MAX_TOKENS,
|
|
425
|
+
failed: FinishReason.STOP,
|
|
426
|
+
};
|
|
427
|
+
const mappedReason = finishReasonByTerminationReason[terminationReason];
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
429
|
+
if (mappedReason !== undefined) {
|
|
430
|
+
response.candidates[0].finishReason = mappedReason;
|
|
431
|
+
logger.debug(() => `[stream:message-converter] applied terminal metadata`, {
|
|
432
|
+
speaker: input.speaker,
|
|
433
|
+
blockCount: input.blocks.length,
|
|
434
|
+
stopReason: input.metadata?.stopReason,
|
|
435
|
+
finishReason: input.metadata?.finishReason,
|
|
436
|
+
terminationReason,
|
|
437
|
+
mappedFinishReason: mappedReason,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
logger.warn(() => `[stream:message-converter] terminal metadata did not map to Gemini finishReason`, {
|
|
442
|
+
speaker: input.speaker,
|
|
443
|
+
blockCount: input.blocks.length,
|
|
444
|
+
stopReason: input.metadata?.stopReason,
|
|
445
|
+
finishReason: input.metadata?.finishReason,
|
|
446
|
+
terminationReason,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
else if (input.metadata?.stopReason || input.metadata?.finishReason) {
|
|
451
|
+
logger.warn(() => `[stream:message-converter] terminal metadata present but response candidate missing`, {
|
|
452
|
+
speaker: input.speaker,
|
|
453
|
+
blockCount: input.blocks.length,
|
|
454
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
455
|
+
stopReason: input.metadata?.stopReason,
|
|
456
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
457
|
+
finishReason: input.metadata?.finishReason,
|
|
458
|
+
hasCandidate: Boolean(response.candidates?.[0]),
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Adds usage metadata, finish reason, and data property to the response.
|
|
464
|
+
*/
|
|
465
|
+
export function applyResponseMetadata(response, input, _parts) {
|
|
466
|
+
// Add data property that returns self-reference
|
|
467
|
+
// Make it non-enumerable to avoid circular reference in JSON.stringify
|
|
468
|
+
Object.defineProperty(response, 'data', {
|
|
469
|
+
get() {
|
|
470
|
+
return response;
|
|
471
|
+
},
|
|
472
|
+
enumerable: false,
|
|
473
|
+
configurable: true,
|
|
474
|
+
});
|
|
475
|
+
// Add usage metadata if present
|
|
476
|
+
if (input.metadata?.usage) {
|
|
477
|
+
const usageMetadata = {
|
|
478
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
479
|
+
promptTokenCount: input.metadata.usage.promptTokens ?? 0,
|
|
480
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
481
|
+
candidatesTokenCount: input.metadata.usage.completionTokens ?? 0,
|
|
482
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- BN4-C-P01: preserve defensive runtime boundary guard despite current static types.
|
|
483
|
+
totalTokenCount: input.metadata.usage.totalTokens ?? 0,
|
|
484
|
+
cache_read_input_tokens: input.metadata.usage.cache_read_input_tokens ?? 0,
|
|
485
|
+
cache_creation_input_tokens: input.metadata.usage.cache_creation_input_tokens ?? 0,
|
|
486
|
+
};
|
|
487
|
+
response.usageMetadata = usageMetadata;
|
|
488
|
+
}
|
|
489
|
+
applyFinishReasonMapping(response, input);
|
|
490
|
+
return response;
|
|
491
|
+
}
|
|
492
|
+
//# sourceMappingURL=MessageConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageConverter.js","sourceRoot":"","sources":["../../../src/core/MessageConverter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,EAGL,iBAAiB,EAEjB,YAAY,GACb,MAAM,eAAe,CAAC;AAQvB,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AACzE,OAAO,EAEL,aAAa,GAEd,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uEAAuE,CAAC;AAEjH,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,+BAA+B,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAsB,EACtB,WAAmB,EACnB,mBAA4B;IAE5B,IAAI,cAAc,GAAG,WAAW,CAAC;IACjC,IAAI,UAAU,GAAG,mBAAmB,CAAC;IAErC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC1B,IAAI,UAAU,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,cAAc,IAAI,GAAG,CAAC;YACxB,CAAC;YACD,cAAc,IAAI,KAAK,CAAC,IAAI,CAAC;YAC7B,UAAU,GAAG,KAAK,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,UAAU,GAAG,IAAI,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,mBAAmB,EAAE,UAAU,EAAE,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wCAAwC,CACtD,OAAsB;IAEtB,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,2DAA2D;IAC3D,MAAM,KAAK,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QAAQ,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC;YAChE,6JAA6J;YAC7J,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,IAAI,CAAC;YACtD,uBAAuB,EACrB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,uBAAuB,IAAI,CAAC;YACnD,2BAA2B,EACzB,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,2BAA2B,IAAI,CAAC;SACxD,CAAC;QACF,QAAQ,CAAC,aAAa,GAAG,aAAa,CAAC;IACzC,CAAC;IAED,wBAAwB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAE1C,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type PartListUnion, type Content } from '@google/genai';
|
|
7
|
+
import { Turn, type ServerGeminiStreamEvent, type ServerGeminiFinishedOutcome } from './turn.js';
|
|
8
|
+
import type { Config } from '@vybestack/llxprt-code-core/config/config.js';
|
|
9
|
+
import type { ChatSession } from './chatSession.js';
|
|
10
|
+
import type { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
|
|
11
|
+
import type { LoopDetectionService } from '@vybestack/llxprt-code-core/services/loopDetectionService.js';
|
|
12
|
+
import type { TodoContinuationService } from './TodoContinuationService.js';
|
|
13
|
+
import type { IdeContextTracker } from './IdeContextTracker.js';
|
|
14
|
+
import type { AgentHookManager } from './AgentHookManager.js';
|
|
15
|
+
import type { ComplexityAnalyzer } from '@vybestack/llxprt-code-core/services/complexity-analyzer.js';
|
|
16
|
+
export interface MessageStreamDeps {
|
|
17
|
+
config: Config;
|
|
18
|
+
getChat: () => ChatSession;
|
|
19
|
+
logger: DebugLogger;
|
|
20
|
+
loopDetector: LoopDetectionService;
|
|
21
|
+
todoContinuationService: TodoContinuationService;
|
|
22
|
+
ideContextTracker: IdeContextTracker;
|
|
23
|
+
agentHookManager: AgentHookManager;
|
|
24
|
+
getEffectiveModel: () => string;
|
|
25
|
+
getHistory: () => Promise<Content[]>;
|
|
26
|
+
getSessionTurnCount: () => number;
|
|
27
|
+
incrementSessionTurnCount: () => void;
|
|
28
|
+
lazyInitialize: () => Promise<void>;
|
|
29
|
+
startChat: (extraHistory?: Content[]) => Promise<ChatSession>;
|
|
30
|
+
getPreviousHistory: () => Content[] | undefined;
|
|
31
|
+
setChat: (chat: ChatSession) => void;
|
|
32
|
+
hasChat: () => boolean;
|
|
33
|
+
complexityAnalyzer: ComplexityAnalyzer;
|
|
34
|
+
getLastPromptId: () => string | undefined;
|
|
35
|
+
setLastPromptId: (id: string) => void;
|
|
36
|
+
resetCurrentSequenceModel: () => void;
|
|
37
|
+
updateTelemetryTokenCount: () => void;
|
|
38
|
+
sendMessageStream: (initialRequest: PartListUnion, signal: AbortSignal, prompt_id: string, turns?: number, isInvalidStreamRetry?: boolean, is413Retry?: boolean) => AsyncGenerator<ServerGeminiStreamEvent, Turn>;
|
|
39
|
+
}
|
|
40
|
+
export interface StreamContext {
|
|
41
|
+
prompt_id: string;
|
|
42
|
+
promptText: string;
|
|
43
|
+
responseChunks: string[];
|
|
44
|
+
signal: AbortSignal;
|
|
45
|
+
turns: number;
|
|
46
|
+
isInvalidStreamRetry: boolean;
|
|
47
|
+
is413Retry: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface IterationResult {
|
|
50
|
+
earlyReturn: boolean;
|
|
51
|
+
hadToolCallsThisTurn: boolean;
|
|
52
|
+
todoPauseSeen: boolean;
|
|
53
|
+
hadThinking: boolean;
|
|
54
|
+
hadContent: boolean;
|
|
55
|
+
deferredEvents: ServerGeminiStreamEvent[];
|
|
56
|
+
outcome?: ServerGeminiFinishedOutcome;
|
|
57
|
+
}
|
|
58
|
+
export declare const MAX_TURNS = 100;
|
|
59
|
+
export declare class MessageStreamOrchestrator {
|
|
60
|
+
private readonly deps;
|
|
61
|
+
constructor(deps: MessageStreamDeps);
|
|
62
|
+
execute(initialRequest: PartListUnion, signal: AbortSignal, prompt_id: string, turns: number, isInvalidStreamRetry: boolean, is413Retry?: boolean): AsyncGenerator<ServerGeminiStreamEvent, Turn>;
|
|
63
|
+
private _ensureChatInitialized;
|
|
64
|
+
private _preflight;
|
|
65
|
+
private _checkSessionLimits;
|
|
66
|
+
private _injectIdeContext;
|
|
67
|
+
private _runRetryLoop;
|
|
68
|
+
private _processStreamIteration;
|
|
69
|
+
private _earlyIterResult;
|
|
70
|
+
private _evaluatePostTurn;
|
|
71
|
+
private _evaluateTodoContinuation;
|
|
72
|
+
private _finishWithToolCalls;
|
|
73
|
+
private _buildFollowUpRequest;
|
|
74
|
+
private _applyComplexityAnalysis;
|
|
75
|
+
private _handleTodoToolCall;
|
|
76
|
+
private _getProviderName;
|
|
77
|
+
private _resetTodoState;
|
|
78
|
+
private _fireAfterHook;
|
|
79
|
+
/**
|
|
80
|
+
* If the AfterAgent hook requested context clearing, emit an
|
|
81
|
+
* AgentExecutionStopped event with contextCleared=true so the UI
|
|
82
|
+
* can react. Returns the hook output for further caller checks.
|
|
83
|
+
*/
|
|
84
|
+
private _fireAfterHookAndEmitClearContext;
|
|
85
|
+
}
|