@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,207 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { ideContext, } from '@vybestack/llxprt-code-ide-integration';
7
+ import { DebugLogger } from '@vybestack/llxprt-code-core/debug/index.js';
8
+ /**
9
+ * Tracks IDE context state and computes full vs incremental deltas
10
+ * for injecting editor state into model turns.
11
+ */
12
+ export class IdeContextTracker {
13
+ lastSentIdeContext;
14
+ forceFullIdeContext = true;
15
+ logger;
16
+ config;
17
+ constructor(config) {
18
+ this.config = config;
19
+ this.logger = new DebugLogger('llxprt:core:ideContextTracker');
20
+ }
21
+ /**
22
+ * Forces the next call to getContextParts to return a full context snapshot.
23
+ */
24
+ resetContext() {
25
+ this.forceFullIdeContext = true;
26
+ }
27
+ /**
28
+ * Returns the context parts (full or incremental delta) based on current state.
29
+ * Also returns the new IDE context so the caller can store it for diffing.
30
+ */
31
+ getContextParts(forceFullContext) {
32
+ const shouldSendFull = forceFullContext || this.forceFullIdeContext;
33
+ if (shouldSendFull || !this.lastSentIdeContext) {
34
+ return this.buildFullContext();
35
+ }
36
+ return this.buildIncrementalDelta();
37
+ }
38
+ /**
39
+ * Builds the complete IDE context (all open files, active file, cursor, selection).
40
+ */
41
+ buildFullContext() {
42
+ const currentIdeContext = ideContext.getIdeContext();
43
+ if (!currentIdeContext) {
44
+ return { contextParts: [], newIdeContext: undefined };
45
+ }
46
+ const openFiles = currentIdeContext.workspaceState?.openFiles ?? [];
47
+ const activeFile = openFiles.find((f) => f.isActive === true);
48
+ const otherOpenFiles = openFiles
49
+ .filter((f) => f.isActive !== true)
50
+ .map((f) => f.path);
51
+ const contextData = {};
52
+ if (activeFile) {
53
+ contextData.activeFile = {
54
+ path: activeFile.path,
55
+ cursor: activeFile.cursor
56
+ ? {
57
+ line: activeFile.cursor.line,
58
+ character: activeFile.cursor.character,
59
+ }
60
+ : undefined,
61
+ selectedText: activeFile.selectedText ?? undefined,
62
+ };
63
+ }
64
+ if (otherOpenFiles.length > 0) {
65
+ contextData.otherOpenFiles = otherOpenFiles;
66
+ }
67
+ if (Object.keys(contextData).length === 0) {
68
+ return { contextParts: [], newIdeContext: currentIdeContext };
69
+ }
70
+ const jsonString = JSON.stringify(contextData, null, 2);
71
+ const contextParts = [
72
+ "Here is the user's editor context as a JSON object. This is for your information only.",
73
+ '```json',
74
+ jsonString,
75
+ '```',
76
+ ];
77
+ if (this.config.getDebugMode()) {
78
+ this.logger.debug(() => 'IDE Context:', {
79
+ context: contextParts.join('\n'),
80
+ });
81
+ }
82
+ return { contextParts, newIdeContext: currentIdeContext };
83
+ }
84
+ /**
85
+ * Computes what changed in the IDE context since the last call.
86
+ */
87
+ buildIncrementalDelta() {
88
+ const currentIdeContext = ideContext.getIdeContext();
89
+ if (!currentIdeContext || !this.lastSentIdeContext) {
90
+ return { contextParts: [], newIdeContext: currentIdeContext };
91
+ }
92
+ const delta = {};
93
+ const changes = {};
94
+ const lastFiles = new Map((this.lastSentIdeContext.workspaceState?.openFiles ?? []).map((f) => [f.path, f]));
95
+ const currentFiles = new Map((currentIdeContext.workspaceState?.openFiles ?? []).map((f) => [
96
+ f.path,
97
+ f,
98
+ ]));
99
+ const openedFiles = [];
100
+ for (const [path] of currentFiles.entries()) {
101
+ if (!lastFiles.has(path)) {
102
+ openedFiles.push(path);
103
+ }
104
+ }
105
+ if (openedFiles.length > 0) {
106
+ changes.filesOpened = openedFiles;
107
+ }
108
+ const closedFiles = [];
109
+ for (const [path] of lastFiles.entries()) {
110
+ if (!currentFiles.has(path)) {
111
+ closedFiles.push(path);
112
+ }
113
+ }
114
+ if (closedFiles.length > 0) {
115
+ changes.filesClosed = closedFiles;
116
+ }
117
+ this.detectActiveFileChanges(currentIdeContext, this.lastSentIdeContext, changes);
118
+ if (Object.keys(changes).length === 0) {
119
+ return { contextParts: [], newIdeContext: currentIdeContext };
120
+ }
121
+ delta.changes = changes;
122
+ const jsonString = JSON.stringify(delta, null, 2);
123
+ const contextParts = [
124
+ "Here is a summary of changes in the user's editor context, in JSON format. This is for your information only.",
125
+ '```json',
126
+ jsonString,
127
+ '```',
128
+ ];
129
+ if (this.config.getDebugMode()) {
130
+ this.logger.debug(() => 'IDE Context:', {
131
+ context: contextParts.join('\n'),
132
+ });
133
+ }
134
+ return { contextParts, newIdeContext: currentIdeContext };
135
+ }
136
+ /**
137
+ * Detects and records changes to the active file (path, cursor, selection).
138
+ */
139
+ detectActiveFileChanges(currentIdeContext, lastIdeContext, changes) {
140
+ const lastActiveFile = (lastIdeContext.workspaceState?.openFiles ?? []).find((f) => f.isActive === true);
141
+ const currentActiveFile = (currentIdeContext.workspaceState?.openFiles ?? []).find((f) => f.isActive === true);
142
+ if (currentActiveFile) {
143
+ if (!lastActiveFile || lastActiveFile.path !== currentActiveFile.path) {
144
+ changes.activeFileChanged = {
145
+ path: currentActiveFile.path,
146
+ cursor: currentActiveFile.cursor
147
+ ? {
148
+ line: currentActiveFile.cursor.line,
149
+ character: currentActiveFile.cursor.character,
150
+ }
151
+ : undefined,
152
+ selectedText: currentActiveFile.selectedText ?? undefined,
153
+ };
154
+ }
155
+ else {
156
+ this.detectCursorAndSelectionChanges(currentActiveFile, lastActiveFile, changes);
157
+ }
158
+ }
159
+ else if (lastActiveFile) {
160
+ changes.activeFileChanged = {
161
+ path: null,
162
+ previousPath: lastActiveFile.path,
163
+ };
164
+ }
165
+ }
166
+ /**
167
+ * Detects cursor and selection changes for the same active file.
168
+ */
169
+ detectCursorAndSelectionChanges(currentActiveFile, lastActiveFile, changes) {
170
+ const lastCursor = lastActiveFile.cursor;
171
+ const currentCursor = currentActiveFile.cursor;
172
+ if (currentCursor &&
173
+ (!lastCursor ||
174
+ lastCursor.line !== currentCursor.line ||
175
+ lastCursor.character !== currentCursor.character)) {
176
+ changes.cursorMoved = {
177
+ path: currentActiveFile.path,
178
+ cursor: {
179
+ line: currentCursor.line,
180
+ character: currentCursor.character,
181
+ },
182
+ };
183
+ }
184
+ else if (!currentCursor && lastCursor) {
185
+ changes.cursorMoved = {
186
+ path: currentActiveFile.path,
187
+ cursor: null,
188
+ };
189
+ }
190
+ const lastSelectedText = lastActiveFile.selectedText ?? '';
191
+ const currentSelectedText = currentActiveFile.selectedText ?? '';
192
+ if (lastSelectedText !== currentSelectedText) {
193
+ changes.selectionChanged = {
194
+ path: currentActiveFile.path,
195
+ selectedText: currentSelectedText,
196
+ };
197
+ }
198
+ }
199
+ /**
200
+ * Records the IDE context that was last sent so the next call can compute a delta.
201
+ */
202
+ recordSentContext(ideCtx) {
203
+ this.lastSentIdeContext = ideCtx;
204
+ this.forceFullIdeContext = false;
205
+ }
206
+ }
207
+ //# sourceMappingURL=IdeContextTracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IdeContextTracker.js","sourceRoot":"","sources":["../../../src/core/IdeContextTracker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,UAAU,GAGX,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAGzE;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACpB,kBAAkB,CAAyB;IAC3C,mBAAmB,GAAG,IAAI,CAAC;IAElB,MAAM,CAAc;IACpB,MAAM,CAAS;IAEhC,YAAY,MAAc;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,CAAC,+BAA+B,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,YAAY;QACV,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,gBAAyB;QAIvC,MAAM,cAAc,GAAG,gBAAgB,IAAI,IAAI,CAAC,mBAAmB,CAAC;QACpE,IAAI,cAAc,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC,gBAAgB,EAAE,CAAC;Q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,CAAC;IACH,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,MAA8B;QAC9C,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC;QACjC,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC;IACnC,CAAC;CACF"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * MessageConverter - Pure functions for Gemini SDK ↔ IContent format translation.
8
+ * Handles format conversion, speaker semantics, finish-reason mapping, and validation.
9
+ */
10
+ import type { GenerateContentResponse } from '@google/genai';
11
+ import { type Content, type Part, type PartListUnion } from '@google/genai';
12
+ import type { IContent, ContentBlock } from '@vybestack/llxprt-code-core/services/history/IContent.js';
13
+ /**
14
+ * Aggregates text from content blocks while preserving spacing around non-text blocks.
15
+ */
16
+ export declare function aggregateTextWithSpacing(blocks: ContentBlock[], currentText: string, lastBlockWasNonText: boolean): {
17
+ text: string;
18
+ lastBlockWasNonText: boolean;
19
+ };
20
+ /**
21
+ * Custom createUserContent that properly handles function response arrays.
22
+ * Each response must be a separate Part in the same Content, not nested arrays.
23
+ */
24
+ export declare function createUserContentWithFunctionResponseFix(message: PartListUnion): Content;
25
+ /**
26
+ * Normalizes tool interaction input for the provider.
27
+ * Packages tool responses as user messages.
28
+ */
29
+ export declare function normalizeToolInteractionInput(message: PartListUnion): Content | Content[];
30
+ /**
31
+ * Checks if a part contains valid non-thought text content.
32
+ */
33
+ export declare function isValidNonThoughtTextPart(part: Part): boolean;
34
+ /**
35
+ * Returns true if the response is valid, false otherwise.
36
+ */
37
+ export declare function isValidResponse(response: GenerateContentResponse): boolean;
38
+ /**
39
+ * Validates if Content has valid parts.
40
+ */
41
+ export declare function isValidContent(content: Content): boolean;
42
+ /**
43
+ * Validates the history contains the correct roles.
44
+ */
45
+ export declare function validateHistory(history: Content[]): void;
46
+ /**
47
+ * Extracts valid history turns from comprehensive history.
48
+ * Filters out invalid or empty contents from safety filters or recitation.
49
+ */
50
+ export declare function extractCuratedHistory(comprehensiveHistory: Content[]): Content[];
51
+ /**
52
+ * Checks if a Content has text content in the first part.
53
+ */
54
+ export declare function hasTextContent(content: Content | undefined): content is Content & {
55
+ parts: [{
56
+ text: string;
57
+ }, ...Part[]];
58
+ };
59
+ /**
60
+ * Convert PartListUnion (user input) to IContent format.
61
+ */
62
+ export declare function convertPartListUnionToIContent(input: PartListUnion): IContent;
63
+ /**
64
+ * Converts mixed Parts (function calls, responses, text, thoughts) to IContent.
65
+ */
66
+ export declare function convertMixedPartsToIContent(parts: Part[]): IContent;
67
+ /**
68
+ * Converts IContent blocks to Gemini Parts array.
69
+ */
70
+ export declare function convertBlocksToParts(blocks: ContentBlock[]): Part[];
71
+ /**
72
+ * Convert IContent to GenerateContentResponse for SDK compatibility.
73
+ */
74
+ export declare function convertIContentToResponse(input: IContent): GenerateContentResponse;
75
+ /**
76
+ * Adds usage metadata, finish reason, and data property to the response.
77
+ */
78
+ export declare function applyResponseMetadata(response: GenerateContentResponse, input: IContent, _parts: Part[]): GenerateContentResponse;