minovative-mind-cli 2.11.2 → 2.11.3
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/services/ai.d.ts +7 -1
- package/dist/services/ai.js +65 -3
- package/dist/services/proxyClient.js +3 -2
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/services/ai.d.ts
CHANGED
|
@@ -114,7 +114,13 @@ export declare function createInvestigationSemanticSession(): any;
|
|
|
114
114
|
export declare function createWebSearchAgentSession(): any;
|
|
115
115
|
export declare function createHistorySummarizerSession(): any;
|
|
116
116
|
/**
|
|
117
|
-
*
|
|
117
|
+
* Sanitizes and formats raw conversation history entries into a structured text transcript
|
|
118
|
+
* for safe consumption by the History Summarizer without requiring tool declarations or
|
|
119
|
+
* risking multi-turn schema rejections from the API.
|
|
120
|
+
*/
|
|
121
|
+
export declare function formatHistoryForSummarization(history: Content[]): string;
|
|
122
|
+
/**
|
|
123
|
+
* Summarizes an array of Content history entries using Gemini Flash.
|
|
118
124
|
*/
|
|
119
125
|
export declare function summarizeChatHistory(history: Content[], abortSignal?: AbortSignal): Promise<string>;
|
|
120
126
|
export declare function createUserProfileExtractorSession(): any;
|
package/dist/services/ai.js
CHANGED
|
@@ -836,7 +836,65 @@ export function createHistorySummarizerSession() {
|
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
838
|
/**
|
|
839
|
-
*
|
|
839
|
+
* Sanitizes and formats raw conversation history entries into a structured text transcript
|
|
840
|
+
* for safe consumption by the History Summarizer without requiring tool declarations or
|
|
841
|
+
* risking multi-turn schema rejections from the API.
|
|
842
|
+
*/
|
|
843
|
+
export function formatHistoryForSummarization(history) {
|
|
844
|
+
if (!history || history.length === 0)
|
|
845
|
+
return '';
|
|
846
|
+
const lines = [];
|
|
847
|
+
for (const entry of history) {
|
|
848
|
+
if (!entry || !Array.isArray(entry.parts))
|
|
849
|
+
continue;
|
|
850
|
+
const roleLabel = entry.role === 'model' ? 'Assistant' : 'User';
|
|
851
|
+
const textPieces = [];
|
|
852
|
+
for (const part of entry.parts) {
|
|
853
|
+
if (!part)
|
|
854
|
+
continue;
|
|
855
|
+
if (typeof part.text === 'string' && part.text.trim()) {
|
|
856
|
+
textPieces.push(part.text.trim());
|
|
857
|
+
}
|
|
858
|
+
else if (part.functionCall) {
|
|
859
|
+
const name = part.functionCall.name || 'unknown_tool';
|
|
860
|
+
const argsStr = part.functionCall.args ? JSON.stringify(part.functionCall.args) : '';
|
|
861
|
+
const compactArgs = argsStr.length > 500 ? argsStr.substring(0, 500) + '...' : argsStr;
|
|
862
|
+
textPieces.push(`[Tool Invoked: ${name}(${compactArgs})]`);
|
|
863
|
+
}
|
|
864
|
+
else if (part.functionResponse) {
|
|
865
|
+
const name = part.functionResponse.name || 'unknown_tool';
|
|
866
|
+
const respObj = part.functionResponse.response;
|
|
867
|
+
let respStr = '';
|
|
868
|
+
if (respObj) {
|
|
869
|
+
if (typeof respObj.output === 'string') {
|
|
870
|
+
respStr = respObj.output;
|
|
871
|
+
}
|
|
872
|
+
else if (typeof respObj.result === 'string') {
|
|
873
|
+
respStr = respObj.result;
|
|
874
|
+
}
|
|
875
|
+
else if (typeof respObj.error === 'string') {
|
|
876
|
+
respStr = `Error: ${respObj.error}`;
|
|
877
|
+
}
|
|
878
|
+
else {
|
|
879
|
+
respStr = JSON.stringify(respObj);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
const compactResp = respStr.length > 1000 ? respStr.substring(0, 1000) + '...' : respStr;
|
|
883
|
+
textPieces.push(`[Tool Output (${name})]: ${compactResp}`);
|
|
884
|
+
}
|
|
885
|
+
else if (part.inlineData) {
|
|
886
|
+
textPieces.push(`[Inline Data Attachment: ${part.inlineData.mimeType || 'unknown'}]`);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
const turnText = textPieces.join('\n').trim();
|
|
890
|
+
if (turnText) {
|
|
891
|
+
lines.push(`[${roleLabel}]:\n${turnText}`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return lines.join('\n\n');
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Summarizes an array of Content history entries using Gemini Flash.
|
|
840
898
|
*/
|
|
841
899
|
export async function summarizeChatHistory(history, abortSignal) {
|
|
842
900
|
if (!history || history.length === 0) {
|
|
@@ -848,9 +906,13 @@ export async function summarizeChatHistory(history, abortSignal) {
|
|
|
848
906
|
throw err;
|
|
849
907
|
}
|
|
850
908
|
try {
|
|
909
|
+
const formattedTranscript = formatHistoryForSummarization(history);
|
|
910
|
+
if (!formattedTranscript || !formattedTranscript.trim()) {
|
|
911
|
+
return '';
|
|
912
|
+
}
|
|
851
913
|
const session = createHistorySummarizerSession();
|
|
852
|
-
|
|
853
|
-
const result = await session.sendMessage(
|
|
914
|
+
const prompt = `Summarize the preceding conversation history following your compression rules:\n\n<conversation_history>\n${formattedTranscript}\n</conversation_history>`;
|
|
915
|
+
const result = await session.sendMessage(prompt, undefined, abortSignal);
|
|
854
916
|
return result.response.text() || '';
|
|
855
917
|
}
|
|
856
918
|
catch (error) {
|
|
@@ -359,11 +359,12 @@ export class ProxyClient {
|
|
|
359
359
|
// ignore parsing error
|
|
360
360
|
}
|
|
361
361
|
const errorMsg = errorData.error?.message || response.statusText;
|
|
362
|
-
if (response.status ===
|
|
363
|
-
response.status === 401 ||
|
|
362
|
+
if (response.status === 401 ||
|
|
364
363
|
response.status === 403 ||
|
|
365
364
|
errorMsg.includes('API_KEY_INVALID') ||
|
|
365
|
+
errorMsg.includes('API_KEY_EXPIRED') ||
|
|
366
366
|
errorMsg.includes('quota') ||
|
|
367
|
+
errorMsg.includes('RESOURCE_EXHAUSTED') ||
|
|
367
368
|
errorMsg.includes('PERMISSION_DENIED')) {
|
|
368
369
|
throw new Error('AI_BYOK_ERROR: Your API key or quota is invalid. Please run /config-key to update your settings.');
|
|
369
370
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED