@google/gemini-cli 0.47.0-nightly.20260609.g0567b25a2 → 0.47.0
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/bundle/builtin/antigravity-support/SKILL.md +58 -0
- package/bundle/{chunk-2CIX5Q6A.js → chunk-2KWNCPLL.js} +2 -2
- package/bundle/{chunk-EMUTS6IK.js → chunk-2Q4476DN.js} +1 -1
- package/bundle/{chunk-WKBFPVMG.js → chunk-4GCG36AT.js} +1 -1
- package/bundle/{chunk-DCTGU54Z.js → chunk-6KE4CNFS.js} +1 -1
- package/bundle/{chunk-GCIN3SBW.js → chunk-6LT65VVT.js} +1 -1
- package/bundle/{chunk-2QJY5FON.js → chunk-BBNWCBRR.js} +1 -1
- package/bundle/{chunk-EHNTNNG7.js → chunk-CNIL75JT.js} +2 -2
- package/bundle/{chunk-UWRWOGGE.js → chunk-DXBHZ3TN.js} +8 -9
- package/bundle/{chunk-PL643LQI.js → chunk-FBADLP6O.js} +1 -1
- package/bundle/{chunk-AAUTETSH.js → chunk-FXI4U6PC.js} +2 -2
- package/bundle/{chunk-HP476PBA.js → chunk-HQ3WN6AK.js} +2 -2
- package/bundle/{chunk-I5A5X2DX.js → chunk-HR72IGHE.js} +165 -114
- package/bundle/{chunk-C6JF7KUM.js → chunk-JW7ZLS43.js} +474 -369
- package/bundle/{chunk-LUEQKTRO.js → chunk-L2MPIDNJ.js} +1 -1
- package/bundle/{chunk-LRU4AG5Z.js → chunk-LYEXSPQM.js} +6 -9
- package/bundle/{chunk-IZHHDHX6.js → chunk-M6POVUEU.js} +2 -2
- package/bundle/{chunk-BN4LGSIP.js → chunk-OF4FXFRD.js} +165 -114
- package/bundle/{chunk-QRLOGZOF.js → chunk-QIXRZAM6.js} +14529 -7889
- package/bundle/{chunk-AEYK5HWH.js → chunk-SBG6CUNK.js} +453 -355
- package/bundle/{chunk-4HDJHI5R.js → chunk-TG7JXYWL.js} +3 -3
- package/bundle/{chunk-IZ2I7Q2U.js → chunk-VIAOQQWI.js} +3 -3
- package/bundle/{chunk-2T3UO3GD.js → chunk-WSPZQ6DG.js} +212 -174
- package/bundle/{chunk-J3HLXOXQ.js → chunk-YYVEOJOI.js} +1 -1
- package/bundle/{chunk-BQBAQ2Q3.js → chunk-ZH37ZXAY.js} +3 -3
- package/bundle/{cleanup-FLYMRJHN.js → cleanup-3B3REU73.js} +2 -2
- package/bundle/{cleanup-MGYBYNJH.js → cleanup-GEKT3TY7.js} +2 -2
- package/bundle/{cleanup-Q3IUYRFR.js → cleanup-YLDEE5FO.js} +2 -2
- package/bundle/{core-HEUZ5HF5.js → core-HFORMEVY.js} +9 -1
- package/bundle/{dist-CE4H7NUW.js → core-ZX62TRQZ.js} +9 -1
- package/bundle/{devtoolsService-2HWL5NFR.js → devtoolsService-PHAD4RFS.js} +2 -2
- package/bundle/{devtoolsService-G6QHDK2R.js → devtoolsService-VQNGMCMU.js} +2 -2
- package/bundle/{devtoolsService-6L5OLG5H.js → devtoolsService-XFCKGUDN.js} +3 -4
- package/bundle/{dist-I7YW7PD5.js → dist-UINE5I5P.js} +9 -1
- package/bundle/{gemini-HILUTGAC.js → gemini-FOEJAXHE.js} +14 -14
- package/bundle/{gemini-COTZTFOT.js → gemini-PDNY7O5B.js} +14 -14
- package/bundle/{gemini-JJPFCGRS.js → gemini-VTIJURKH.js} +196 -212
- package/bundle/gemini.js +7 -7
- package/bundle/{interactiveCli-LZI7JXIK.js → interactiveCli-5LZR6JYR.js} +44 -20
- package/bundle/{interactiveCli-ZLNOSGX5.js → interactiveCli-EEVGQBIN.js} +44 -20
- package/bundle/{interactiveCli-4HTU7R6H.js → interactiveCli-ZHNRZVK3.js} +331 -326
- package/bundle/{liteRtServerManager-3E5GRFLO.js → liteRtServerManager-CCZNRFEE.js} +4 -4
- package/bundle/{liteRtServerManager-76QFKETH.js → liteRtServerManager-L63JEWQK.js} +4 -4
- package/bundle/{liteRtServerManager-OJD3HSWN.js → liteRtServerManager-QEGKNHBK.js} +4 -4
- package/bundle/{oauth2-provider-XWGCFTD2.js → oauth2-provider-7VJY4VWP.js} +1 -1
- package/bundle/{oauth2-provider-HPJFIAG6.js → oauth2-provider-D3K72R73.js} +1 -1
- package/bundle/{oauth2-provider-HWRKMSF7.js → oauth2-provider-NJB6EG2W.js} +72 -38
- package/bundle/{start-3DT6X44L.js → start-EDWM2AMD.js} +6 -6
- package/bundle/{start-BX2QHAEC.js → start-RGSZYXG3.js} +6 -6
- package/bundle/{start-Q4WEY7Z6.js → start-TZSG66O4.js} +6 -6
- package/package.json +1 -1
- package/bundle/chunk-3JPECJG6.js +0 -398
- package/bundle/chunk-DCUISZSY.js +0 -118
- package/bundle/chunk-H6BD5ZKD.js +0 -512
- package/bundle/chunk-MSM65VWS.js +0 -17320
- package/bundle/chunk-OT53DK2V.js +0 -154
- package/bundle/chunk-SO6BWWGF.js +0 -81685
- package/bundle/chunk-WVAJOJDO.js +0 -1571
- package/bundle/chunk-ZZMWIUE5.js +0 -394571
- package/bundle/cleanup-UN4WQ3DJ.js +0 -32
- package/bundle/devtoolsService-LPQTHDXY.js +0 -856
- package/bundle/dist-SYYTVWDP.js +0 -2140
- package/bundle/gemini-NQMNY7AW.js +0 -16409
- package/bundle/interactiveCli-6NPEXVAG.js +0 -34742
- package/bundle/liteRtServerManager-OXYRVBA4.js +0 -65
- package/bundle/oauth2-provider-WJGZJ73D.js +0 -235
- package/bundle/start-Z54XBIIY.js +0 -18
|
@@ -276503,6 +276503,9 @@ function isActiveModel(model, useGemini3_1 = false, useCustomToolModel = false,
|
|
|
276503
276503
|
return model !== PREVIEW_GEMINI_3_1_MODEL && model !== PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL;
|
|
276504
276504
|
}
|
|
276505
276505
|
}
|
|
276506
|
+
var CCPA_AI_MODEL_MAPPINGS = {
|
|
276507
|
+
[DEFAULT_GEMINI_3_5_FLASH_MODEL]: SECONDARY_GEMINI_3_5_FLASH_MODEL
|
|
276508
|
+
};
|
|
276506
276509
|
|
|
276507
276510
|
// packages/core/src/billing/billing.ts
|
|
276508
276511
|
var G1_CREDIT_TYPE = "GOOGLE_ONE_AI";
|
|
@@ -279559,8 +279562,8 @@ function isValidToolName(name3, options = {}) {
|
|
|
279559
279562
|
}
|
|
279560
279563
|
|
|
279561
279564
|
// packages/core/src/generated/git-commit.ts
|
|
279562
|
-
var GIT_COMMIT_INFO = "
|
|
279563
|
-
var CLI_VERSION = "0.47.0
|
|
279565
|
+
var GIT_COMMIT_INFO = "74c6d8e02";
|
|
279566
|
+
var CLI_VERSION = "0.47.0";
|
|
279564
279567
|
|
|
279565
279568
|
// packages/core/src/ide/detect-ide.ts
|
|
279566
279569
|
var IDE_DEFINITIONS = {
|
|
@@ -281956,6 +281959,328 @@ async function deleteStoredSession(config2, sessionIdOrBasename) {
|
|
|
281956
281959
|
// packages/core/src/services/chatRecordingService.ts
|
|
281957
281960
|
import readline4 from "node:readline";
|
|
281958
281961
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
281962
|
+
|
|
281963
|
+
// packages/core/src/utils/partUtils.ts
|
|
281964
|
+
function partToString(value, options) {
|
|
281965
|
+
if (!value) {
|
|
281966
|
+
return "";
|
|
281967
|
+
}
|
|
281968
|
+
if (typeof value === "string") {
|
|
281969
|
+
return value;
|
|
281970
|
+
}
|
|
281971
|
+
if (Array.isArray(value)) {
|
|
281972
|
+
return value.map((part2) => partToString(part2, options)).join("");
|
|
281973
|
+
}
|
|
281974
|
+
const part = value;
|
|
281975
|
+
if (options?.verbose) {
|
|
281976
|
+
if (part.videoMetadata !== void 0) {
|
|
281977
|
+
return `[Video Metadata]`;
|
|
281978
|
+
}
|
|
281979
|
+
if (part.thought !== void 0) {
|
|
281980
|
+
return `[Thought: ${part.thought}]`;
|
|
281981
|
+
}
|
|
281982
|
+
if (part.codeExecutionResult !== void 0) {
|
|
281983
|
+
return `[Code Execution Result]`;
|
|
281984
|
+
}
|
|
281985
|
+
if (part.executableCode !== void 0) {
|
|
281986
|
+
return `[Executable Code]`;
|
|
281987
|
+
}
|
|
281988
|
+
if (part.fileData !== void 0) {
|
|
281989
|
+
return `[File Data]`;
|
|
281990
|
+
}
|
|
281991
|
+
if (part.functionCall !== void 0) {
|
|
281992
|
+
return `[Function Call: ${part.functionCall.name}]`;
|
|
281993
|
+
}
|
|
281994
|
+
if (part.functionResponse !== void 0) {
|
|
281995
|
+
return `[Function Response: ${part.functionResponse.name}]`;
|
|
281996
|
+
}
|
|
281997
|
+
if (part.inlineData !== void 0) {
|
|
281998
|
+
const mimeType = part.inlineData.mimeType ?? "unknown";
|
|
281999
|
+
const data = part.inlineData.data ?? "";
|
|
282000
|
+
const bytes = Math.ceil(data.length * 3 / 4);
|
|
282001
|
+
const kb = (bytes / 1024).toFixed(1);
|
|
282002
|
+
const category = mimeType.startsWith("audio/") ? "Audio" : mimeType.startsWith("video/") ? "Video" : mimeType.startsWith("image/") ? "Image" : "Media";
|
|
282003
|
+
return `[${category}: ${mimeType}, ${kb} KB]`;
|
|
282004
|
+
}
|
|
282005
|
+
}
|
|
282006
|
+
return part.text ?? "";
|
|
282007
|
+
}
|
|
282008
|
+
function clonePart(part) {
|
|
282009
|
+
return { ...part };
|
|
282010
|
+
}
|
|
282011
|
+
function updatePart(part, updates) {
|
|
282012
|
+
return { ...part, ...updates };
|
|
282013
|
+
}
|
|
282014
|
+
function cloneFunctionResponse(resp) {
|
|
282015
|
+
return { ...resp };
|
|
282016
|
+
}
|
|
282017
|
+
function cloneFunctionCall(call) {
|
|
282018
|
+
return { ...call };
|
|
282019
|
+
}
|
|
282020
|
+
function getResponseText(response) {
|
|
282021
|
+
if (response.candidates && response.candidates.length > 0) {
|
|
282022
|
+
const candidate = response.candidates[0];
|
|
282023
|
+
if (candidate.content && candidate.content.parts && candidate.content.parts.length > 0) {
|
|
282024
|
+
return candidate.content.parts.filter((part) => part.text && !part.thought).map((part) => part.text).join("");
|
|
282025
|
+
}
|
|
282026
|
+
}
|
|
282027
|
+
return null;
|
|
282028
|
+
}
|
|
282029
|
+
async function flatMapTextParts(parts2, transform2) {
|
|
282030
|
+
const result2 = [];
|
|
282031
|
+
const partArray = Array.isArray(parts2) ? parts2 : typeof parts2 === "string" ? [{ text: parts2 }] : [parts2];
|
|
282032
|
+
for (const part of partArray) {
|
|
282033
|
+
let textToProcess;
|
|
282034
|
+
if (typeof part === "string") {
|
|
282035
|
+
textToProcess = part;
|
|
282036
|
+
} else if ("text" in part) {
|
|
282037
|
+
textToProcess = part.text;
|
|
282038
|
+
}
|
|
282039
|
+
if (textToProcess !== void 0) {
|
|
282040
|
+
const transformedParts = await transform2(textToProcess);
|
|
282041
|
+
result2.push(...transformedParts);
|
|
282042
|
+
} else {
|
|
282043
|
+
result2.push(part);
|
|
282044
|
+
}
|
|
282045
|
+
}
|
|
282046
|
+
return result2;
|
|
282047
|
+
}
|
|
282048
|
+
function appendToLastTextPart(prompt, textToAppend, separator = "\n\n") {
|
|
282049
|
+
if (!textToAppend) {
|
|
282050
|
+
return prompt;
|
|
282051
|
+
}
|
|
282052
|
+
if (prompt.length === 0) {
|
|
282053
|
+
return [{ text: textToAppend }];
|
|
282054
|
+
}
|
|
282055
|
+
const newPrompt = [...prompt];
|
|
282056
|
+
const lastPart = newPrompt.at(-1);
|
|
282057
|
+
if (typeof lastPart === "string") {
|
|
282058
|
+
newPrompt[newPrompt.length - 1] = `${lastPart}${separator}${textToAppend}`;
|
|
282059
|
+
} else if (lastPart && "text" in lastPart) {
|
|
282060
|
+
newPrompt[newPrompt.length - 1] = {
|
|
282061
|
+
...lastPart,
|
|
282062
|
+
text: `${lastPart.text}${separator}${textToAppend}`
|
|
282063
|
+
};
|
|
282064
|
+
} else {
|
|
282065
|
+
newPrompt.push({ text: `${separator}${textToAppend}` });
|
|
282066
|
+
}
|
|
282067
|
+
return newPrompt;
|
|
282068
|
+
}
|
|
282069
|
+
function isTextPart(part) {
|
|
282070
|
+
return typeof part === "object" && part !== null && "text" in part && typeof part.text === "string";
|
|
282071
|
+
}
|
|
282072
|
+
|
|
282073
|
+
// packages/core/src/core/geminiRequest.ts
|
|
282074
|
+
function partListUnionToString(value) {
|
|
282075
|
+
return partToString(value, { verbose: true });
|
|
282076
|
+
}
|
|
282077
|
+
|
|
282078
|
+
// packages/core/src/core/agentChatHistory.ts
|
|
282079
|
+
var AgentChatHistory = class {
|
|
282080
|
+
history = [];
|
|
282081
|
+
constructor(initialTurns = []) {
|
|
282082
|
+
this.history = [...initialTurns];
|
|
282083
|
+
}
|
|
282084
|
+
/**
|
|
282085
|
+
* Adds a new turn to the history.
|
|
282086
|
+
* Every turn must have a durable ID, usually provided by the ChatRecordingService.
|
|
282087
|
+
*/
|
|
282088
|
+
push(turn) {
|
|
282089
|
+
this.history.push(turn);
|
|
282090
|
+
}
|
|
282091
|
+
/**
|
|
282092
|
+
* Overwrites the entire history with a new list of turns.
|
|
282093
|
+
*/
|
|
282094
|
+
set(turns) {
|
|
282095
|
+
this.history = [...turns];
|
|
282096
|
+
}
|
|
282097
|
+
clear() {
|
|
282098
|
+
this.history = [];
|
|
282099
|
+
}
|
|
282100
|
+
get() {
|
|
282101
|
+
return this.history;
|
|
282102
|
+
}
|
|
282103
|
+
/**
|
|
282104
|
+
* Returns a copy of the raw Gemini Content[] for API consumption.
|
|
282105
|
+
*/
|
|
282106
|
+
getContents() {
|
|
282107
|
+
return this.history.map((h3) => h3.content);
|
|
282108
|
+
}
|
|
282109
|
+
map(callback) {
|
|
282110
|
+
return this.history.map(callback);
|
|
282111
|
+
}
|
|
282112
|
+
flatMap(callback) {
|
|
282113
|
+
return this.history.flatMap(callback);
|
|
282114
|
+
}
|
|
282115
|
+
get length() {
|
|
282116
|
+
return this.history.length;
|
|
282117
|
+
}
|
|
282118
|
+
};
|
|
282119
|
+
|
|
282120
|
+
// packages/core/src/utils/cryptoUtils.ts
|
|
282121
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
282122
|
+
function deriveStableId(sourceIds) {
|
|
282123
|
+
const sortedIds = [...sourceIds].sort();
|
|
282124
|
+
return createHash4("sha256").update(sortedIds.join("|")).digest("hex").slice(0, 32);
|
|
282125
|
+
}
|
|
282126
|
+
|
|
282127
|
+
// packages/core/src/utils/sessionUtils.ts
|
|
282128
|
+
function ensureStableToolIds(history) {
|
|
282129
|
+
for (let i4 = 0; i4 < history.length; i4++) {
|
|
282130
|
+
const turn = history[i4];
|
|
282131
|
+
const parts2 = turn.content.parts || [];
|
|
282132
|
+
for (let partIdx = 0; partIdx < parts2.length; partIdx++) {
|
|
282133
|
+
const part = parts2[partIdx];
|
|
282134
|
+
if (part.functionCall && !part.functionCall.id) {
|
|
282135
|
+
const name3 = part.functionCall.name;
|
|
282136
|
+
const nextTurn = history[i4 + 1];
|
|
282137
|
+
let pairedId;
|
|
282138
|
+
if (nextTurn?.content.role === "user") {
|
|
282139
|
+
const matchingResp = nextTurn.content.parts?.find(
|
|
282140
|
+
(p2) => p2.functionResponse && p2.functionResponse.name === name3 && !p2.functionResponse.id
|
|
282141
|
+
);
|
|
282142
|
+
if (matchingResp) {
|
|
282143
|
+
pairedId = `synth_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
282144
|
+
part.functionCall.id = pairedId;
|
|
282145
|
+
matchingResp.functionResponse.id = pairedId;
|
|
282146
|
+
}
|
|
282147
|
+
}
|
|
282148
|
+
if (!part.functionCall.id) {
|
|
282149
|
+
part.functionCall.id = `synth_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
282150
|
+
}
|
|
282151
|
+
}
|
|
282152
|
+
if (part.functionResponse && !part.functionResponse.id) {
|
|
282153
|
+
const name3 = part.functionResponse.name;
|
|
282154
|
+
const prevTurn = history[i4 - 1];
|
|
282155
|
+
if (prevTurn?.content.role === "model") {
|
|
282156
|
+
const matchingCall = prevTurn.content.parts?.find(
|
|
282157
|
+
(p2) => p2.functionCall && p2.functionCall.name === name3 && !p2.functionCall.id
|
|
282158
|
+
);
|
|
282159
|
+
if (matchingCall) {
|
|
282160
|
+
const pairedId = `synth_${name3}_${deriveStableId([prevTurn.id, (i4 - 1).toString(), partIdx.toString()])}`;
|
|
282161
|
+
matchingCall.functionCall.id = pairedId;
|
|
282162
|
+
part.functionResponse.id = pairedId;
|
|
282163
|
+
}
|
|
282164
|
+
}
|
|
282165
|
+
if (!part.functionResponse.id) {
|
|
282166
|
+
part.functionResponse.id = `synth_orph_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
282167
|
+
}
|
|
282168
|
+
}
|
|
282169
|
+
}
|
|
282170
|
+
}
|
|
282171
|
+
}
|
|
282172
|
+
function ensurePartArray(content) {
|
|
282173
|
+
if (Array.isArray(content)) {
|
|
282174
|
+
return content.map(
|
|
282175
|
+
(part) => typeof part === "string" ? { text: part } : part
|
|
282176
|
+
);
|
|
282177
|
+
}
|
|
282178
|
+
if (typeof content === "string") {
|
|
282179
|
+
return [{ text: content }];
|
|
282180
|
+
}
|
|
282181
|
+
return [content];
|
|
282182
|
+
}
|
|
282183
|
+
function isIgnoredUserContent(trimmedContent) {
|
|
282184
|
+
return trimmedContent.length === 0 || trimmedContent.startsWith("/") || trimmedContent.startsWith("?") || trimmedContent.startsWith("<session_context>") || trimmedContent.startsWith("<hook_context>");
|
|
282185
|
+
}
|
|
282186
|
+
function convertSessionToClientHistory(messages) {
|
|
282187
|
+
const clientHistory = [];
|
|
282188
|
+
for (const msg of messages) {
|
|
282189
|
+
if (msg.type === "info" || msg.type === "error" || msg.type === "warning") {
|
|
282190
|
+
continue;
|
|
282191
|
+
}
|
|
282192
|
+
if (msg.type === "user") {
|
|
282193
|
+
const contentString = partListUnionToString(msg.content);
|
|
282194
|
+
const trimmedContent = contentString.trim();
|
|
282195
|
+
if (isIgnoredUserContent(trimmedContent)) {
|
|
282196
|
+
continue;
|
|
282197
|
+
}
|
|
282198
|
+
clientHistory.push({
|
|
282199
|
+
id: msg.id,
|
|
282200
|
+
content: {
|
|
282201
|
+
role: "user",
|
|
282202
|
+
parts: ensurePartArray(msg.content)
|
|
282203
|
+
}
|
|
282204
|
+
});
|
|
282205
|
+
} else if (msg.type === "gemini") {
|
|
282206
|
+
const modelParts = [];
|
|
282207
|
+
const contentParts = msg.content ? ensurePartArray(msg.content) : [];
|
|
282208
|
+
const hasCallsInContent = contentParts.some((p2) => !!p2.functionCall);
|
|
282209
|
+
const hasThoughtsInContent = contentParts.some((p2) => p2.thought);
|
|
282210
|
+
if (hasCallsInContent || hasThoughtsInContent) {
|
|
282211
|
+
modelParts.push(...contentParts);
|
|
282212
|
+
} else {
|
|
282213
|
+
if (msg.thoughts && msg.thoughts.length > 0) {
|
|
282214
|
+
for (const thought of msg.thoughts) {
|
|
282215
|
+
const thoughtText = thought.subject ? `**${thought.subject}** ${thought.description}` : thought.description;
|
|
282216
|
+
modelParts.push({
|
|
282217
|
+
text: thoughtText,
|
|
282218
|
+
thought: true
|
|
282219
|
+
});
|
|
282220
|
+
}
|
|
282221
|
+
}
|
|
282222
|
+
modelParts.push(...contentParts);
|
|
282223
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
282224
|
+
for (const toolCall of msg.toolCalls) {
|
|
282225
|
+
modelParts.push({
|
|
282226
|
+
functionCall: {
|
|
282227
|
+
id: toolCall.id,
|
|
282228
|
+
name: toolCall.name,
|
|
282229
|
+
args: toolCall.args
|
|
282230
|
+
}
|
|
282231
|
+
});
|
|
282232
|
+
}
|
|
282233
|
+
}
|
|
282234
|
+
}
|
|
282235
|
+
if (modelParts.length > 0) {
|
|
282236
|
+
clientHistory.push({
|
|
282237
|
+
id: msg.id,
|
|
282238
|
+
content: {
|
|
282239
|
+
role: "model",
|
|
282240
|
+
parts: modelParts
|
|
282241
|
+
}
|
|
282242
|
+
});
|
|
282243
|
+
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
282244
|
+
const functionResponseParts = [];
|
|
282245
|
+
for (const toolCall of msg.toolCalls) {
|
|
282246
|
+
if (toolCall.result) {
|
|
282247
|
+
let responseData;
|
|
282248
|
+
if (typeof toolCall.result === "string") {
|
|
282249
|
+
responseData = {
|
|
282250
|
+
functionResponse: {
|
|
282251
|
+
id: toolCall.id,
|
|
282252
|
+
name: toolCall.name,
|
|
282253
|
+
response: {
|
|
282254
|
+
output: toolCall.result
|
|
282255
|
+
}
|
|
282256
|
+
}
|
|
282257
|
+
};
|
|
282258
|
+
} else if (Array.isArray(toolCall.result)) {
|
|
282259
|
+
functionResponseParts.push(...ensurePartArray(toolCall.result));
|
|
282260
|
+
continue;
|
|
282261
|
+
} else {
|
|
282262
|
+
responseData = toolCall.result;
|
|
282263
|
+
}
|
|
282264
|
+
functionResponseParts.push(responseData);
|
|
282265
|
+
}
|
|
282266
|
+
}
|
|
282267
|
+
if (functionResponseParts.length > 0) {
|
|
282268
|
+
clientHistory.push({
|
|
282269
|
+
id: `${msg.id}_response`,
|
|
282270
|
+
content: {
|
|
282271
|
+
role: "user",
|
|
282272
|
+
parts: functionResponseParts
|
|
282273
|
+
}
|
|
282274
|
+
});
|
|
282275
|
+
}
|
|
282276
|
+
}
|
|
282277
|
+
}
|
|
282278
|
+
}
|
|
282279
|
+
}
|
|
282280
|
+
return clientHistory;
|
|
282281
|
+
}
|
|
282282
|
+
|
|
282283
|
+
// packages/core/src/services/chatRecordingService.ts
|
|
281959
282284
|
var ENOSPC_WARNING_MESSAGE = "Chat recording disabled: No space left on device. The conversation will continue but will not be saved to disk. Free up disk space and restart to enable recording.";
|
|
281960
282285
|
function hasProperty(obj, prop) {
|
|
281961
282286
|
return obj !== null && typeof obj === "object" && prop in obj;
|
|
@@ -281978,9 +282303,22 @@ function isMetadataUpdateRecord(record2) {
|
|
|
281978
282303
|
function isPartialMetadataRecord(record2) {
|
|
281979
282304
|
return isStringProperty(record2, "sessionId") && isStringProperty(record2, "projectHash");
|
|
281980
282305
|
}
|
|
281981
|
-
function
|
|
282306
|
+
function isTextPart2(part) {
|
|
281982
282307
|
return isStringProperty(part, "text");
|
|
281983
282308
|
}
|
|
282309
|
+
function isResumableMessageRecord(message) {
|
|
282310
|
+
const contentString = message.content ? partListUnionToString(message.content) : "";
|
|
282311
|
+
if (message.type === "user") {
|
|
282312
|
+
return !isIgnoredUserContent(contentString.trim());
|
|
282313
|
+
}
|
|
282314
|
+
if (message.type === "gemini") {
|
|
282315
|
+
return contentString.trim().length > 0 || (message.toolCalls?.length ?? 0) > 0 || (message.thoughts?.length ?? 0) > 0;
|
|
282316
|
+
}
|
|
282317
|
+
return false;
|
|
282318
|
+
}
|
|
282319
|
+
function hasResumableConversationContent(messages) {
|
|
282320
|
+
return messages.some((message) => isResumableMessageRecord(message));
|
|
282321
|
+
}
|
|
281984
282322
|
async function loadConversationRecord(filePath, options) {
|
|
281985
282323
|
if (!fs30.existsSync(filePath)) {
|
|
281986
282324
|
return null;
|
|
@@ -282039,15 +282377,15 @@ async function loadConversationRecord(filePath, options) {
|
|
|
282039
282377
|
}
|
|
282040
282378
|
const id = record2.id;
|
|
282041
282379
|
const isUser = hasProperty(record2, "type") && record2.type === "user";
|
|
282042
|
-
const
|
|
282380
|
+
const isResumable = isResumableMessageRecord(record2);
|
|
282043
282381
|
if (options?.metadataOnly) {
|
|
282044
282382
|
messageIds.push(id);
|
|
282045
|
-
messageKinds.set(id, { isUser,
|
|
282383
|
+
messageKinds.set(id, { isUser, isResumable });
|
|
282046
282384
|
}
|
|
282047
|
-
if (!firstUserMessageStr && isUser && hasProperty(record2, "content") && record2["content"]) {
|
|
282385
|
+
if (!firstUserMessageStr && isUser && hasProperty(record2, "content") && record2["content"] && isResumable) {
|
|
282048
282386
|
const rawContent = record2["content"];
|
|
282049
282387
|
if (Array.isArray(rawContent)) {
|
|
282050
|
-
firstUserMessageStr = rawContent.map((p2) =>
|
|
282388
|
+
firstUserMessageStr = rawContent.map((p2) => isTextPart2(p2) ? p2["text"] : "").join("");
|
|
282051
282389
|
} else if (typeof rawContent === "string") {
|
|
282052
282390
|
firstUserMessageStr = rawContent;
|
|
282053
282391
|
}
|
|
@@ -282076,16 +282414,19 @@ async function loadConversationRecord(filePath, options) {
|
|
|
282076
282414
|
if (isMessageRecord(msg)) {
|
|
282077
282415
|
const id = msg.id;
|
|
282078
282416
|
const isUser = msg.type === "user";
|
|
282079
|
-
const
|
|
282417
|
+
const isResumable = isResumableMessageRecord(msg);
|
|
282080
282418
|
if (options?.metadataOnly) {
|
|
282081
282419
|
messageIds.push(id);
|
|
282082
|
-
messageKinds.set(id, {
|
|
282420
|
+
messageKinds.set(id, {
|
|
282421
|
+
isUser,
|
|
282422
|
+
isResumable
|
|
282423
|
+
});
|
|
282083
282424
|
} else {
|
|
282084
282425
|
messagesMap.set(id, msg);
|
|
282085
282426
|
}
|
|
282086
|
-
if (!firstUserMessageStr && isUser && msg.content && (Array.isArray(msg.content) || typeof msg.content === "string")) {
|
|
282427
|
+
if (!firstUserMessageStr && isUser && isResumable && msg.content && (Array.isArray(msg.content) || typeof msg.content === "string")) {
|
|
282087
282428
|
if (Array.isArray(msg.content)) {
|
|
282088
|
-
firstUserMessageStr = msg.content.map((p2) =>
|
|
282429
|
+
firstUserMessageStr = msg.content.map((p2) => isTextPart2(p2) ? p2.text : "").join("");
|
|
282089
282430
|
} else {
|
|
282090
282431
|
firstUserMessageStr = msg.content;
|
|
282091
282432
|
}
|
|
@@ -282104,16 +282445,19 @@ async function loadConversationRecord(filePath, options) {
|
|
|
282104
282445
|
if (isMessageRecord(msg)) {
|
|
282105
282446
|
const id = msg.id;
|
|
282106
282447
|
const isUser = msg.type === "user";
|
|
282107
|
-
const
|
|
282448
|
+
const isResumable = isResumableMessageRecord(msg);
|
|
282108
282449
|
if (options?.metadataOnly) {
|
|
282109
282450
|
messageIds.push(id);
|
|
282110
|
-
messageKinds.set(id, {
|
|
282451
|
+
messageKinds.set(id, {
|
|
282452
|
+
isUser,
|
|
282453
|
+
isResumable
|
|
282454
|
+
});
|
|
282111
282455
|
} else {
|
|
282112
282456
|
messagesMap.set(id, msg);
|
|
282113
282457
|
}
|
|
282114
|
-
if (!firstUserMessageStr && isUser && msg.content && (Array.isArray(msg.content) || typeof msg.content === "string")) {
|
|
282458
|
+
if (!firstUserMessageStr && isUser && isResumable && msg.content && (Array.isArray(msg.content) || typeof msg.content === "string")) {
|
|
282115
282459
|
if (Array.isArray(msg.content)) {
|
|
282116
|
-
firstUserMessageStr = msg.content.map((p2) =>
|
|
282460
|
+
firstUserMessageStr = msg.content.map((p2) => isTextPart2(p2) ? p2.text : "").join("");
|
|
282117
282461
|
} else {
|
|
282118
282462
|
firstUserMessageStr = msg.content;
|
|
282119
282463
|
}
|
|
@@ -282129,18 +282473,20 @@ async function loadConversationRecord(filePath, options) {
|
|
|
282129
282473
|
return await parseLegacyRecordFallback(filePath, options);
|
|
282130
282474
|
}
|
|
282131
282475
|
const loadedMessages = Array.from(messagesMap.values());
|
|
282132
|
-
const metadataFirstUserMessage = loadedMessages.find(
|
|
282476
|
+
const metadataFirstUserMessage = loadedMessages.find(
|
|
282477
|
+
(message) => message.type === "user" && isResumableMessageRecord(message)
|
|
282478
|
+
) ?? null;
|
|
282133
282479
|
let fallbackFirstUserMessage = firstUserMessageStr;
|
|
282134
282480
|
if (!fallbackFirstUserMessage && metadataFirstUserMessage) {
|
|
282135
282481
|
const rawContent = metadataFirstUserMessage.content;
|
|
282136
282482
|
if (Array.isArray(rawContent)) {
|
|
282137
|
-
fallbackFirstUserMessage = rawContent.map((part) =>
|
|
282483
|
+
fallbackFirstUserMessage = rawContent.map((part) => isTextPart2(part) ? part["text"] : "").join("");
|
|
282138
282484
|
} else if (typeof rawContent === "string") {
|
|
282139
282485
|
fallbackFirstUserMessage = rawContent;
|
|
282140
282486
|
}
|
|
282141
282487
|
}
|
|
282142
282488
|
const userMessageCount = options?.metadataOnly ? Array.from(messageKinds.values()).filter((m) => m.isUser).length : loadedMessages.filter((m) => m.type === "user").length;
|
|
282143
|
-
const
|
|
282489
|
+
const hasResumableContent = options?.metadataOnly ? Array.from(messageKinds.values()).some((m) => m.isResumable) : hasResumableConversationContent(loadedMessages);
|
|
282144
282490
|
return {
|
|
282145
282491
|
sessionId: metadata2.sessionId,
|
|
282146
282492
|
projectHash: metadata2.projectHash,
|
|
@@ -282155,7 +282501,7 @@ async function loadConversationRecord(filePath, options) {
|
|
|
282155
282501
|
userMessageCount,
|
|
282156
282502
|
memoryScratchpadIsStale: isTrackingMemoryScratchpadFreshness ? memoryScratchpadIsStale : void 0,
|
|
282157
282503
|
firstUserMessage: fallbackFirstUserMessage,
|
|
282158
|
-
|
|
282504
|
+
hasResumableContent
|
|
282159
282505
|
};
|
|
282160
282506
|
} catch (error40) {
|
|
282161
282507
|
debugLogger.error("Error loading conversation record from JSONL:", error40);
|
|
@@ -282507,6 +282853,20 @@ var ChatRecordingService = class {
|
|
|
282507
282853
|
throw error40;
|
|
282508
282854
|
}
|
|
282509
282855
|
}
|
|
282856
|
+
/**
|
|
282857
|
+
* Deletes the current session only if it has no resumable conversation
|
|
282858
|
+
* content. This removes abandoned startup-only sessions while preserving any
|
|
282859
|
+
* session with a real user prompt, model response, or tool activity.
|
|
282860
|
+
*/
|
|
282861
|
+
async deleteCurrentSessionIfNotResumableAsync() {
|
|
282862
|
+
if (!this.conversationFile || !this.cachedConversation) {
|
|
282863
|
+
return;
|
|
282864
|
+
}
|
|
282865
|
+
if (hasResumableConversationContent(this.cachedConversation.messages)) {
|
|
282866
|
+
return;
|
|
282867
|
+
}
|
|
282868
|
+
await this.deleteCurrentSessionAsync();
|
|
282869
|
+
}
|
|
282510
282870
|
/**
|
|
282511
282871
|
* Rewinds the conversation to the state just before the specified message ID.
|
|
282512
282872
|
* All messages from (and including) the specified ID onwards are removed.
|
|
@@ -282600,12 +282960,12 @@ async function parseLegacyRecordFallback(filePath, options) {
|
|
|
282600
282960
|
if (options?.metadataOnly) {
|
|
282601
282961
|
let fallbackFirstUserMessageStr;
|
|
282602
282962
|
const firstUserMessage = legacyRecord.messages?.find(
|
|
282603
|
-
(m) => m.type === "user"
|
|
282963
|
+
(m) => m.type === "user" && isResumableMessageRecord(m)
|
|
282604
282964
|
);
|
|
282605
282965
|
if (firstUserMessage) {
|
|
282606
282966
|
const rawContent = firstUserMessage.content;
|
|
282607
282967
|
if (Array.isArray(rawContent)) {
|
|
282608
|
-
fallbackFirstUserMessageStr = rawContent.map((p2) =>
|
|
282968
|
+
fallbackFirstUserMessageStr = rawContent.map((p2) => isTextPart2(p2) ? p2["text"] : "").join("");
|
|
282609
282969
|
} else if (typeof rawContent === "string") {
|
|
282610
282970
|
fallbackFirstUserMessageStr = rawContent;
|
|
282611
282971
|
}
|
|
@@ -282616,17 +282976,13 @@ async function parseLegacyRecordFallback(filePath, options) {
|
|
|
282616
282976
|
messageCount: legacyRecord.messages?.length || 0,
|
|
282617
282977
|
userMessageCount: legacyRecord.messages?.filter((m) => m.type === "user").length || 0,
|
|
282618
282978
|
firstUserMessage: fallbackFirstUserMessageStr,
|
|
282619
|
-
|
|
282620
|
-
(m) => m.type === "user" || m.type === "gemini"
|
|
282621
|
-
) || false
|
|
282979
|
+
hasResumableContent: legacyRecord.messages?.some((m) => isResumableMessageRecord(m)) || false
|
|
282622
282980
|
};
|
|
282623
282981
|
}
|
|
282624
282982
|
return {
|
|
282625
282983
|
...legacyRecord,
|
|
282626
282984
|
userMessageCount: legacyRecord.messages?.filter((m) => m.type === "user").length || 0,
|
|
282627
|
-
|
|
282628
|
-
(m) => m.type === "user" || m.type === "gemini"
|
|
282629
|
-
) || false
|
|
282985
|
+
hasResumableContent: legacyRecord.messages?.some((m) => isResumableMessageRecord(m)) || false
|
|
282630
282986
|
};
|
|
282631
282987
|
}
|
|
282632
282988
|
} catch {
|
|
@@ -285334,116 +285690,6 @@ function toVertexGenerationConfig(config2) {
|
|
|
285334
285690
|
};
|
|
285335
285691
|
}
|
|
285336
285692
|
|
|
285337
|
-
// packages/core/src/utils/partUtils.ts
|
|
285338
|
-
function partToString(value, options) {
|
|
285339
|
-
if (!value) {
|
|
285340
|
-
return "";
|
|
285341
|
-
}
|
|
285342
|
-
if (typeof value === "string") {
|
|
285343
|
-
return value;
|
|
285344
|
-
}
|
|
285345
|
-
if (Array.isArray(value)) {
|
|
285346
|
-
return value.map((part2) => partToString(part2, options)).join("");
|
|
285347
|
-
}
|
|
285348
|
-
const part = value;
|
|
285349
|
-
if (options?.verbose) {
|
|
285350
|
-
if (part.videoMetadata !== void 0) {
|
|
285351
|
-
return `[Video Metadata]`;
|
|
285352
|
-
}
|
|
285353
|
-
if (part.thought !== void 0) {
|
|
285354
|
-
return `[Thought: ${part.thought}]`;
|
|
285355
|
-
}
|
|
285356
|
-
if (part.codeExecutionResult !== void 0) {
|
|
285357
|
-
return `[Code Execution Result]`;
|
|
285358
|
-
}
|
|
285359
|
-
if (part.executableCode !== void 0) {
|
|
285360
|
-
return `[Executable Code]`;
|
|
285361
|
-
}
|
|
285362
|
-
if (part.fileData !== void 0) {
|
|
285363
|
-
return `[File Data]`;
|
|
285364
|
-
}
|
|
285365
|
-
if (part.functionCall !== void 0) {
|
|
285366
|
-
return `[Function Call: ${part.functionCall.name}]`;
|
|
285367
|
-
}
|
|
285368
|
-
if (part.functionResponse !== void 0) {
|
|
285369
|
-
return `[Function Response: ${part.functionResponse.name}]`;
|
|
285370
|
-
}
|
|
285371
|
-
if (part.inlineData !== void 0) {
|
|
285372
|
-
const mimeType = part.inlineData.mimeType ?? "unknown";
|
|
285373
|
-
const data = part.inlineData.data ?? "";
|
|
285374
|
-
const bytes = Math.ceil(data.length * 3 / 4);
|
|
285375
|
-
const kb = (bytes / 1024).toFixed(1);
|
|
285376
|
-
const category = mimeType.startsWith("audio/") ? "Audio" : mimeType.startsWith("video/") ? "Video" : mimeType.startsWith("image/") ? "Image" : "Media";
|
|
285377
|
-
return `[${category}: ${mimeType}, ${kb} KB]`;
|
|
285378
|
-
}
|
|
285379
|
-
}
|
|
285380
|
-
return part.text ?? "";
|
|
285381
|
-
}
|
|
285382
|
-
function clonePart(part) {
|
|
285383
|
-
return { ...part };
|
|
285384
|
-
}
|
|
285385
|
-
function updatePart(part, updates) {
|
|
285386
|
-
return { ...part, ...updates };
|
|
285387
|
-
}
|
|
285388
|
-
function cloneFunctionResponse(resp) {
|
|
285389
|
-
return { ...resp };
|
|
285390
|
-
}
|
|
285391
|
-
function cloneFunctionCall(call) {
|
|
285392
|
-
return { ...call };
|
|
285393
|
-
}
|
|
285394
|
-
function getResponseText(response) {
|
|
285395
|
-
if (response.candidates && response.candidates.length > 0) {
|
|
285396
|
-
const candidate = response.candidates[0];
|
|
285397
|
-
if (candidate.content && candidate.content.parts && candidate.content.parts.length > 0) {
|
|
285398
|
-
return candidate.content.parts.filter((part) => part.text && !part.thought).map((part) => part.text).join("");
|
|
285399
|
-
}
|
|
285400
|
-
}
|
|
285401
|
-
return null;
|
|
285402
|
-
}
|
|
285403
|
-
async function flatMapTextParts(parts2, transform2) {
|
|
285404
|
-
const result2 = [];
|
|
285405
|
-
const partArray = Array.isArray(parts2) ? parts2 : typeof parts2 === "string" ? [{ text: parts2 }] : [parts2];
|
|
285406
|
-
for (const part of partArray) {
|
|
285407
|
-
let textToProcess;
|
|
285408
|
-
if (typeof part === "string") {
|
|
285409
|
-
textToProcess = part;
|
|
285410
|
-
} else if ("text" in part) {
|
|
285411
|
-
textToProcess = part.text;
|
|
285412
|
-
}
|
|
285413
|
-
if (textToProcess !== void 0) {
|
|
285414
|
-
const transformedParts = await transform2(textToProcess);
|
|
285415
|
-
result2.push(...transformedParts);
|
|
285416
|
-
} else {
|
|
285417
|
-
result2.push(part);
|
|
285418
|
-
}
|
|
285419
|
-
}
|
|
285420
|
-
return result2;
|
|
285421
|
-
}
|
|
285422
|
-
function appendToLastTextPart(prompt, textToAppend, separator = "\n\n") {
|
|
285423
|
-
if (!textToAppend) {
|
|
285424
|
-
return prompt;
|
|
285425
|
-
}
|
|
285426
|
-
if (prompt.length === 0) {
|
|
285427
|
-
return [{ text: textToAppend }];
|
|
285428
|
-
}
|
|
285429
|
-
const newPrompt = [...prompt];
|
|
285430
|
-
const lastPart = newPrompt.at(-1);
|
|
285431
|
-
if (typeof lastPart === "string") {
|
|
285432
|
-
newPrompt[newPrompt.length - 1] = `${lastPart}${separator}${textToAppend}`;
|
|
285433
|
-
} else if (lastPart && "text" in lastPart) {
|
|
285434
|
-
newPrompt[newPrompt.length - 1] = {
|
|
285435
|
-
...lastPart,
|
|
285436
|
-
text: `${lastPart.text}${separator}${textToAppend}`
|
|
285437
|
-
};
|
|
285438
|
-
} else {
|
|
285439
|
-
newPrompt.push({ text: `${separator}${textToAppend}` });
|
|
285440
|
-
}
|
|
285441
|
-
return newPrompt;
|
|
285442
|
-
}
|
|
285443
|
-
function isTextPart2(part) {
|
|
285444
|
-
return typeof part === "object" && part !== null && "text" in part && typeof part.text === "string";
|
|
285445
|
-
}
|
|
285446
|
-
|
|
285447
285693
|
// packages/core/src/utils/generateContentResponseUtilities.ts
|
|
285448
285694
|
var BINARY_INJECTION_KEY = "__binary_injection__";
|
|
285449
285695
|
function createFunctionResponsePart(callId, toolName, output) {
|
|
@@ -304029,7 +304275,7 @@ function getVersion() {
|
|
|
304029
304275
|
}
|
|
304030
304276
|
versionPromise = (async () => {
|
|
304031
304277
|
const pkgJson = await getPackageJson(__dirname4);
|
|
304032
|
-
return "0.47.0
|
|
304278
|
+
return "0.47.0";
|
|
304033
304279
|
})();
|
|
304034
304280
|
return versionPromise;
|
|
304035
304281
|
}
|
|
@@ -304541,7 +304787,7 @@ ${errorMessage}`,
|
|
|
304541
304787
|
};
|
|
304542
304788
|
|
|
304543
304789
|
// packages/core/src/utils/llm-edit-fixer.ts
|
|
304544
|
-
import { createHash as
|
|
304790
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
304545
304791
|
|
|
304546
304792
|
// packages/core/src/utils/secure-browser-launcher.ts
|
|
304547
304793
|
import { execFile as execFile6 } from "node:child_process";
|
|
@@ -306121,7 +306367,7 @@ async function generateJsonWithTimeout(client, params, timeoutMs) {
|
|
|
306121
306367
|
}
|
|
306122
306368
|
async function FixLLMEditWithInstruction(instruction, old_string, new_string, error40, current_content, baseLlmClient, abortSignal) {
|
|
306123
306369
|
const promptId = getPromptIdWithFallback("llm-fixer");
|
|
306124
|
-
const cacheKey =
|
|
306370
|
+
const cacheKey = createHash5("sha256").update(
|
|
306125
306371
|
JSON.stringify([
|
|
306126
306372
|
current_content,
|
|
306127
306373
|
old_string,
|
|
@@ -309267,6 +309513,58 @@ var LoggingContentGenerator = class {
|
|
|
309267
309513
|
}
|
|
309268
309514
|
};
|
|
309269
309515
|
|
|
309516
|
+
// packages/core/src/core/modelMappingContentGenerator.ts
|
|
309517
|
+
var ModelMappingContentGenerator = class {
|
|
309518
|
+
constructor(wrapped, mappings) {
|
|
309519
|
+
this.wrapped = wrapped;
|
|
309520
|
+
this.mappings = mappings;
|
|
309521
|
+
}
|
|
309522
|
+
getWrapped() {
|
|
309523
|
+
return this.wrapped;
|
|
309524
|
+
}
|
|
309525
|
+
get userTier() {
|
|
309526
|
+
return this.wrapped.userTier;
|
|
309527
|
+
}
|
|
309528
|
+
get userTierName() {
|
|
309529
|
+
return this.wrapped.userTierName;
|
|
309530
|
+
}
|
|
309531
|
+
get paidTier() {
|
|
309532
|
+
return this.wrapped.paidTier;
|
|
309533
|
+
}
|
|
309534
|
+
mapModel(req) {
|
|
309535
|
+
if (req.model) {
|
|
309536
|
+
const normalizedModel = normalizeModelId(req.model);
|
|
309537
|
+
if (this.mappings[normalizedModel]) {
|
|
309538
|
+
return {
|
|
309539
|
+
...req,
|
|
309540
|
+
model: req.model.startsWith("models/") ? `models/${this.mappings[normalizedModel]}` : this.mappings[normalizedModel]
|
|
309541
|
+
};
|
|
309542
|
+
}
|
|
309543
|
+
}
|
|
309544
|
+
return req;
|
|
309545
|
+
}
|
|
309546
|
+
generateContent(request, userPromptId, role) {
|
|
309547
|
+
return this.wrapped.generateContent(
|
|
309548
|
+
this.mapModel(request),
|
|
309549
|
+
userPromptId,
|
|
309550
|
+
role
|
|
309551
|
+
);
|
|
309552
|
+
}
|
|
309553
|
+
generateContentStream(request, userPromptId, role) {
|
|
309554
|
+
return this.wrapped.generateContentStream(
|
|
309555
|
+
this.mapModel(request),
|
|
309556
|
+
userPromptId,
|
|
309557
|
+
role
|
|
309558
|
+
);
|
|
309559
|
+
}
|
|
309560
|
+
countTokens(request) {
|
|
309561
|
+
return this.wrapped.countTokens(this.mapModel(request));
|
|
309562
|
+
}
|
|
309563
|
+
embedContent(request) {
|
|
309564
|
+
return this.wrapped.embedContent(this.mapModel(request));
|
|
309565
|
+
}
|
|
309566
|
+
};
|
|
309567
|
+
|
|
309270
309568
|
// packages/core/src/code_assist/codeAssist.ts
|
|
309271
309569
|
async function createCodeAssistContentGenerator(httpOptions, authType, config2, sessionId) {
|
|
309272
309570
|
if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ || authType === "compute-default-credentials" /* COMPUTE_ADC */) {
|
|
@@ -309287,8 +309585,14 @@ async function createCodeAssistContentGenerator(httpOptions, authType, config2,
|
|
|
309287
309585
|
}
|
|
309288
309586
|
function getCodeAssistServer(config2) {
|
|
309289
309587
|
let server = config2.getContentGenerator();
|
|
309290
|
-
|
|
309291
|
-
server
|
|
309588
|
+
while (true) {
|
|
309589
|
+
if (server instanceof LoggingContentGenerator) {
|
|
309590
|
+
server = server.getWrapped();
|
|
309591
|
+
} else if (server instanceof ModelMappingContentGenerator) {
|
|
309592
|
+
server = server.getWrapped();
|
|
309593
|
+
} else {
|
|
309594
|
+
break;
|
|
309595
|
+
}
|
|
309292
309596
|
}
|
|
309293
309597
|
if (!(server instanceof CodeAssistServer)) {
|
|
309294
309598
|
return void 0;
|
|
@@ -309684,11 +309988,14 @@ async function createContentGenerator(config2, gcConfig, sessionId) {
|
|
|
309684
309988
|
if (config2.authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ || config2.authType === "compute-default-credentials" /* COMPUTE_ADC */) {
|
|
309685
309989
|
const httpOptions = { headers: baseHeaders };
|
|
309686
309990
|
return new LoggingContentGenerator(
|
|
309687
|
-
|
|
309688
|
-
|
|
309689
|
-
|
|
309690
|
-
|
|
309691
|
-
|
|
309991
|
+
new ModelMappingContentGenerator(
|
|
309992
|
+
await createCodeAssistContentGenerator(
|
|
309993
|
+
httpOptions,
|
|
309994
|
+
config2.authType,
|
|
309995
|
+
gcConfig,
|
|
309996
|
+
sessionId
|
|
309997
|
+
),
|
|
309998
|
+
CCPA_AI_MODEL_MAPPINGS
|
|
309692
309999
|
),
|
|
309693
310000
|
gcConfig
|
|
309694
310001
|
);
|
|
@@ -329462,48 +329769,6 @@ var TopicState = class {
|
|
|
329462
329769
|
// packages/core/src/agents/local-executor.ts
|
|
329463
329770
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
329464
329771
|
|
|
329465
|
-
// packages/core/src/core/agentChatHistory.ts
|
|
329466
|
-
var AgentChatHistory = class {
|
|
329467
|
-
history = [];
|
|
329468
|
-
constructor(initialTurns = []) {
|
|
329469
|
-
this.history = [...initialTurns];
|
|
329470
|
-
}
|
|
329471
|
-
/**
|
|
329472
|
-
* Adds a new turn to the history.
|
|
329473
|
-
* Every turn must have a durable ID, usually provided by the ChatRecordingService.
|
|
329474
|
-
*/
|
|
329475
|
-
push(turn) {
|
|
329476
|
-
this.history.push(turn);
|
|
329477
|
-
}
|
|
329478
|
-
/**
|
|
329479
|
-
* Overwrites the entire history with a new list of turns.
|
|
329480
|
-
*/
|
|
329481
|
-
set(turns) {
|
|
329482
|
-
this.history = [...turns];
|
|
329483
|
-
}
|
|
329484
|
-
clear() {
|
|
329485
|
-
this.history = [];
|
|
329486
|
-
}
|
|
329487
|
-
get() {
|
|
329488
|
-
return this.history;
|
|
329489
|
-
}
|
|
329490
|
-
/**
|
|
329491
|
-
* Returns a copy of the raw Gemini Content[] for API consumption.
|
|
329492
|
-
*/
|
|
329493
|
-
getContents() {
|
|
329494
|
-
return this.history.map((h3) => h3.content);
|
|
329495
|
-
}
|
|
329496
|
-
map(callback) {
|
|
329497
|
-
return this.history.map(callback);
|
|
329498
|
-
}
|
|
329499
|
-
flatMap(callback) {
|
|
329500
|
-
return this.history.flatMap(callback);
|
|
329501
|
-
}
|
|
329502
|
-
get length() {
|
|
329503
|
-
return this.history.length;
|
|
329504
|
-
}
|
|
329505
|
-
};
|
|
329506
|
-
|
|
329507
329772
|
// packages/core/src/core/geminiChat.ts
|
|
329508
329773
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
329509
329774
|
|
|
@@ -329515,13 +329780,6 @@ function isFunctionCall(content) {
|
|
|
329515
329780
|
return content.role === "model" && !!content.parts && content.parts.every((part) => !!part.functionCall);
|
|
329516
329781
|
}
|
|
329517
329782
|
|
|
329518
|
-
// packages/core/src/utils/cryptoUtils.ts
|
|
329519
|
-
import { createHash as createHash6 } from "node:crypto";
|
|
329520
|
-
function deriveStableId(sourceIds) {
|
|
329521
|
-
const sortedIds = [...sourceIds].sort();
|
|
329522
|
-
return createHash6("sha256").update(sortedIds.join("|")).digest("hex").slice(0, 32);
|
|
329523
|
-
}
|
|
329524
|
-
|
|
329525
329783
|
// packages/core/src/utils/historyHardening.ts
|
|
329526
329784
|
var SYNTHETIC_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
|
|
329527
329785
|
var DEFAULT_SENTINELS = {
|
|
@@ -329796,164 +330054,6 @@ function scrubPart(part) {
|
|
|
329796
330054
|
return scrubbed;
|
|
329797
330055
|
}
|
|
329798
330056
|
|
|
329799
|
-
// packages/core/src/core/geminiRequest.ts
|
|
329800
|
-
function partListUnionToString(value) {
|
|
329801
|
-
return partToString(value, { verbose: true });
|
|
329802
|
-
}
|
|
329803
|
-
|
|
329804
|
-
// packages/core/src/utils/sessionUtils.ts
|
|
329805
|
-
function ensureStableToolIds(history) {
|
|
329806
|
-
for (let i4 = 0; i4 < history.length; i4++) {
|
|
329807
|
-
const turn = history[i4];
|
|
329808
|
-
const parts2 = turn.content.parts || [];
|
|
329809
|
-
for (let partIdx = 0; partIdx < parts2.length; partIdx++) {
|
|
329810
|
-
const part = parts2[partIdx];
|
|
329811
|
-
if (part.functionCall && !part.functionCall.id) {
|
|
329812
|
-
const name3 = part.functionCall.name;
|
|
329813
|
-
const nextTurn = history[i4 + 1];
|
|
329814
|
-
let pairedId;
|
|
329815
|
-
if (nextTurn?.content.role === "user") {
|
|
329816
|
-
const matchingResp = nextTurn.content.parts?.find(
|
|
329817
|
-
(p2) => p2.functionResponse && p2.functionResponse.name === name3 && !p2.functionResponse.id
|
|
329818
|
-
);
|
|
329819
|
-
if (matchingResp) {
|
|
329820
|
-
pairedId = `synth_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
329821
|
-
part.functionCall.id = pairedId;
|
|
329822
|
-
matchingResp.functionResponse.id = pairedId;
|
|
329823
|
-
}
|
|
329824
|
-
}
|
|
329825
|
-
if (!part.functionCall.id) {
|
|
329826
|
-
part.functionCall.id = `synth_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
329827
|
-
}
|
|
329828
|
-
}
|
|
329829
|
-
if (part.functionResponse && !part.functionResponse.id) {
|
|
329830
|
-
const name3 = part.functionResponse.name;
|
|
329831
|
-
const prevTurn = history[i4 - 1];
|
|
329832
|
-
if (prevTurn?.content.role === "model") {
|
|
329833
|
-
const matchingCall = prevTurn.content.parts?.find(
|
|
329834
|
-
(p2) => p2.functionCall && p2.functionCall.name === name3 && !p2.functionCall.id
|
|
329835
|
-
);
|
|
329836
|
-
if (matchingCall) {
|
|
329837
|
-
const pairedId = `synth_${name3}_${deriveStableId([prevTurn.id, (i4 - 1).toString(), partIdx.toString()])}`;
|
|
329838
|
-
matchingCall.functionCall.id = pairedId;
|
|
329839
|
-
part.functionResponse.id = pairedId;
|
|
329840
|
-
}
|
|
329841
|
-
}
|
|
329842
|
-
if (!part.functionResponse.id) {
|
|
329843
|
-
part.functionResponse.id = `synth_orph_${name3}_${deriveStableId([turn.id, i4.toString(), partIdx.toString()])}`;
|
|
329844
|
-
}
|
|
329845
|
-
}
|
|
329846
|
-
}
|
|
329847
|
-
}
|
|
329848
|
-
}
|
|
329849
|
-
function ensurePartArray(content) {
|
|
329850
|
-
if (Array.isArray(content)) {
|
|
329851
|
-
return content.map(
|
|
329852
|
-
(part) => typeof part === "string" ? { text: part } : part
|
|
329853
|
-
);
|
|
329854
|
-
}
|
|
329855
|
-
if (typeof content === "string") {
|
|
329856
|
-
return [{ text: content }];
|
|
329857
|
-
}
|
|
329858
|
-
return [content];
|
|
329859
|
-
}
|
|
329860
|
-
function convertSessionToClientHistory(messages) {
|
|
329861
|
-
const clientHistory = [];
|
|
329862
|
-
for (const msg of messages) {
|
|
329863
|
-
if (msg.type === "info" || msg.type === "error" || msg.type === "warning") {
|
|
329864
|
-
continue;
|
|
329865
|
-
}
|
|
329866
|
-
if (msg.type === "user") {
|
|
329867
|
-
const contentString = partListUnionToString(msg.content);
|
|
329868
|
-
const trimmedContent = contentString.trim();
|
|
329869
|
-
if (trimmedContent.startsWith("/") || trimmedContent.startsWith("?") || trimmedContent.startsWith("<session_context>") || trimmedContent.startsWith("<hook_context>")) {
|
|
329870
|
-
continue;
|
|
329871
|
-
}
|
|
329872
|
-
clientHistory.push({
|
|
329873
|
-
id: msg.id,
|
|
329874
|
-
content: {
|
|
329875
|
-
role: "user",
|
|
329876
|
-
parts: ensurePartArray(msg.content)
|
|
329877
|
-
}
|
|
329878
|
-
});
|
|
329879
|
-
} else if (msg.type === "gemini") {
|
|
329880
|
-
const modelParts = [];
|
|
329881
|
-
const contentParts = msg.content ? ensurePartArray(msg.content) : [];
|
|
329882
|
-
const hasCallsInContent = contentParts.some((p2) => !!p2.functionCall);
|
|
329883
|
-
const hasThoughtsInContent = contentParts.some((p2) => p2.thought);
|
|
329884
|
-
if (hasCallsInContent || hasThoughtsInContent) {
|
|
329885
|
-
modelParts.push(...contentParts);
|
|
329886
|
-
} else {
|
|
329887
|
-
if (msg.thoughts && msg.thoughts.length > 0) {
|
|
329888
|
-
for (const thought of msg.thoughts) {
|
|
329889
|
-
const thoughtText = thought.subject ? `**${thought.subject}** ${thought.description}` : thought.description;
|
|
329890
|
-
modelParts.push({
|
|
329891
|
-
text: thoughtText,
|
|
329892
|
-
thought: true
|
|
329893
|
-
});
|
|
329894
|
-
}
|
|
329895
|
-
}
|
|
329896
|
-
modelParts.push(...contentParts);
|
|
329897
|
-
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
329898
|
-
for (const toolCall of msg.toolCalls) {
|
|
329899
|
-
modelParts.push({
|
|
329900
|
-
functionCall: {
|
|
329901
|
-
id: toolCall.id,
|
|
329902
|
-
name: toolCall.name,
|
|
329903
|
-
args: toolCall.args
|
|
329904
|
-
}
|
|
329905
|
-
});
|
|
329906
|
-
}
|
|
329907
|
-
}
|
|
329908
|
-
}
|
|
329909
|
-
if (modelParts.length > 0) {
|
|
329910
|
-
clientHistory.push({
|
|
329911
|
-
id: msg.id,
|
|
329912
|
-
content: {
|
|
329913
|
-
role: "model",
|
|
329914
|
-
parts: modelParts
|
|
329915
|
-
}
|
|
329916
|
-
});
|
|
329917
|
-
if (msg.toolCalls && msg.toolCalls.length > 0) {
|
|
329918
|
-
const functionResponseParts = [];
|
|
329919
|
-
for (const toolCall of msg.toolCalls) {
|
|
329920
|
-
if (toolCall.result) {
|
|
329921
|
-
let responseData;
|
|
329922
|
-
if (typeof toolCall.result === "string") {
|
|
329923
|
-
responseData = {
|
|
329924
|
-
functionResponse: {
|
|
329925
|
-
id: toolCall.id,
|
|
329926
|
-
name: toolCall.name,
|
|
329927
|
-
response: {
|
|
329928
|
-
output: toolCall.result
|
|
329929
|
-
}
|
|
329930
|
-
}
|
|
329931
|
-
};
|
|
329932
|
-
} else if (Array.isArray(toolCall.result)) {
|
|
329933
|
-
functionResponseParts.push(...ensurePartArray(toolCall.result));
|
|
329934
|
-
continue;
|
|
329935
|
-
} else {
|
|
329936
|
-
responseData = toolCall.result;
|
|
329937
|
-
}
|
|
329938
|
-
functionResponseParts.push(responseData);
|
|
329939
|
-
}
|
|
329940
|
-
}
|
|
329941
|
-
if (functionResponseParts.length > 0) {
|
|
329942
|
-
clientHistory.push({
|
|
329943
|
-
id: `${msg.id}_response`,
|
|
329944
|
-
content: {
|
|
329945
|
-
role: "user",
|
|
329946
|
-
parts: functionResponseParts
|
|
329947
|
-
}
|
|
329948
|
-
});
|
|
329949
|
-
}
|
|
329950
|
-
}
|
|
329951
|
-
}
|
|
329952
|
-
}
|
|
329953
|
-
}
|
|
329954
|
-
return clientHistory;
|
|
329955
|
-
}
|
|
329956
|
-
|
|
329957
330057
|
// packages/core/src/core/geminiChat.ts
|
|
329958
330058
|
var StreamEventType = /* @__PURE__ */ ((StreamEventType2) => {
|
|
329959
330059
|
StreamEventType2["CHUNK"] = "chunk";
|
|
@@ -338373,7 +338473,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
|
|
|
338373
338473
|
return provider;
|
|
338374
338474
|
}
|
|
338375
338475
|
case "oauth2": {
|
|
338376
|
-
const { OAuth2AuthProvider } = await import("./oauth2-provider-
|
|
338476
|
+
const { OAuth2AuthProvider } = await import("./oauth2-provider-7VJY4VWP.js");
|
|
338377
338477
|
const provider = new OAuth2AuthProvider(
|
|
338378
338478
|
authConfig,
|
|
338379
338479
|
options.agentName ?? "unknown",
|
|
@@ -370313,6 +370413,7 @@ async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfi
|
|
|
370313
370413
|
error40,
|
|
370314
370414
|
mcpServerName
|
|
370315
370415
|
);
|
|
370416
|
+
throw error40;
|
|
370316
370417
|
}
|
|
370317
370418
|
return [];
|
|
370318
370419
|
}
|
|
@@ -381481,7 +381582,7 @@ ${sections.join("\n")}
|
|
|
381481
381582
|
if (authType === "gemini-api-key" /* USE_GEMINI */) {
|
|
381482
381583
|
setFlashModels("gemini-3-flash-preview", "gemini-3.5-flash");
|
|
381483
381584
|
} else {
|
|
381484
|
-
setFlashModels("gemini-3-flash", "gemini-3-flash");
|
|
381585
|
+
setFlashModels("gemini-3.5-flash", "gemini-3.5-flash");
|
|
381485
381586
|
}
|
|
381486
381587
|
} else {
|
|
381487
381588
|
setFlashModels("gemini-3-flash-preview", "gemini-2.5-flash");
|
|
@@ -399946,6 +400047,7 @@ export {
|
|
|
399946
400047
|
isAutoModel,
|
|
399947
400048
|
supportsMultimodalFunctionResponse,
|
|
399948
400049
|
isActiveModel,
|
|
400050
|
+
CCPA_AI_MODEL_MAPPINGS,
|
|
399949
400051
|
G1_CREDIT_TYPE,
|
|
399950
400052
|
OVERAGE_ELIGIBLE_MODELS,
|
|
399951
400053
|
isOverageEligibleModel,
|
|
@@ -400081,6 +400183,22 @@ export {
|
|
|
400081
400183
|
getMatchingSessionFiles,
|
|
400082
400184
|
deleteSessionFileAndArtifacts,
|
|
400083
400185
|
deleteStoredSession,
|
|
400186
|
+
partToString,
|
|
400187
|
+
clonePart,
|
|
400188
|
+
updatePart,
|
|
400189
|
+
cloneFunctionResponse,
|
|
400190
|
+
cloneFunctionCall,
|
|
400191
|
+
getResponseText,
|
|
400192
|
+
flatMapTextParts,
|
|
400193
|
+
appendToLastTextPart,
|
|
400194
|
+
isTextPart,
|
|
400195
|
+
partListUnionToString,
|
|
400196
|
+
AgentChatHistory,
|
|
400197
|
+
ensureStableToolIds,
|
|
400198
|
+
isIgnoredUserContent,
|
|
400199
|
+
convertSessionToClientHistory,
|
|
400200
|
+
isResumableMessageRecord,
|
|
400201
|
+
hasResumableConversationContent,
|
|
400084
400202
|
loadConversationRecord,
|
|
400085
400203
|
ChatRecordingService,
|
|
400086
400204
|
UiTelemetryService,
|
|
@@ -400156,15 +400274,6 @@ export {
|
|
|
400156
400274
|
logOnboardingStart,
|
|
400157
400275
|
logOnboardingSuccess,
|
|
400158
400276
|
logBillingEvent,
|
|
400159
|
-
partToString,
|
|
400160
|
-
clonePart,
|
|
400161
|
-
updatePart,
|
|
400162
|
-
cloneFunctionResponse,
|
|
400163
|
-
cloneFunctionCall,
|
|
400164
|
-
getResponseText,
|
|
400165
|
-
flatMapTextParts,
|
|
400166
|
-
appendToLastTextPart,
|
|
400167
|
-
isTextPart2 as isTextPart,
|
|
400168
400277
|
BINARY_INJECTION_KEY,
|
|
400169
400278
|
convertToFunctionResponse,
|
|
400170
400279
|
getResponseTextFromParts,
|
|
@@ -400358,10 +400467,6 @@ export {
|
|
|
400358
400467
|
AskUserTool,
|
|
400359
400468
|
AskUserInvocation,
|
|
400360
400469
|
isCompletedAskUserTool,
|
|
400361
|
-
AgentChatHistory,
|
|
400362
|
-
partListUnionToString,
|
|
400363
|
-
ensureStableToolIds,
|
|
400364
|
-
convertSessionToClientHistory,
|
|
400365
400470
|
StreamEventType,
|
|
400366
400471
|
SYNTHETIC_THOUGHT_SIGNATURE2 as SYNTHETIC_THOUGHT_SIGNATURE,
|
|
400367
400472
|
isValidNonThoughtTextPart,
|