@google/gemini-cli 0.42.0 → 0.44.0-nightly.20260513.g5ee05c775
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/{chunk-COQP2M4D.js → chunk-27SPXGT2.js} +562 -437
- package/bundle/{chunk-EDKX67D6.js → chunk-2VH3SA6M.js} +43 -23
- package/bundle/{chunk-PUDLNWHE.js → chunk-3KOQHVJU.js} +3 -3
- package/bundle/{chunk-COKAF5GM.js → chunk-4QQ5AHZP.js} +2 -2
- package/bundle/{chunk-KVEAHIIV.js → chunk-5EEEHNEE.js} +3 -3
- package/bundle/{chunk-G2VTSEZ6.js → chunk-5SMSFUPB.js} +1 -1
- package/bundle/{chunk-7VVHSNDQ.js → chunk-AC2EWTF7.js} +1970 -731
- package/bundle/{chunk-GA527JB7.js → chunk-ATSNFRDF.js} +1 -1
- package/bundle/{chunk-3IS7GD6D.js → chunk-BA752AEU.js} +3 -3
- package/bundle/{chunk-CYEIWMZJ.js → chunk-FGYOOMPI.js} +1 -1
- package/bundle/{chunk-QOZSZYL7.js → chunk-FK45PHSI.js} +3 -3
- package/bundle/{chunk-I7AME6VC.js → chunk-FTY6BJEY.js} +9 -8
- package/bundle/{chunk-NTOPH4WG.js → chunk-GCWBZXBS.js} +2 -2
- package/bundle/chunk-I2JHD4D3.js +512 -0
- package/bundle/{chunk-7C6GGDK6.js → chunk-IZJOLGNO.js} +3 -3
- package/bundle/{chunk-4SLGT6YD.js → chunk-J4YAW3P3.js} +1 -1
- package/bundle/chunk-KADNKBXT.js +118 -0
- package/bundle/{chunk-DN4XSYRG.js → chunk-LF33N5QM.js} +8696 -13355
- package/bundle/{chunk-CHERUG6W.js → chunk-LO22NRY4.js} +502 -390
- package/bundle/{chunk-JEW7ZIWE.js → chunk-M7OUJJZ2.js} +5270 -5234
- package/bundle/{chunk-WIXUKOZA.js → chunk-MFNKZZOB.js} +1 -1
- package/bundle/chunk-MLPM54XD.js +357247 -0
- package/bundle/{chunk-ECNYAST2.js → chunk-N22WUHJE.js} +5419 -5378
- package/bundle/chunk-OC7XGTLV.js +81656 -0
- package/bundle/{chunk-ZNMQA242.js → chunk-QDEK3TQ6.js} +3 -3
- package/bundle/{chunk-BCYBA52D.js → chunk-QMXQUBC4.js} +43 -23
- package/bundle/chunk-TBHMNRI3.js +1571 -0
- package/bundle/{chunk-LATVEETM.js → chunk-TOOOS4HD.js} +2 -2
- package/bundle/{chunk-XUMRUXOT.js → chunk-UHSQLPNG.js} +50 -27
- package/bundle/chunk-USS2A6NQ.js +156 -0
- package/bundle/chunk-WMTLLWRC.js +391 -0
- package/bundle/chunk-XDWZDV7C.js +17250 -0
- package/bundle/{chunk-DMWX7UP6.js → chunk-YBYQH75I.js} +2252 -829
- package/bundle/{chunk-FCAODPNO.js → chunk-ZZN56QZ3.js} +502 -390
- package/bundle/{cleanup-3RILFNVM.js → cleanup-2H3SANYB.js} +3 -3
- package/bundle/{cleanup-SVRKYBR6.js → cleanup-7GY7BVC6.js} +3 -3
- package/bundle/{cleanup-XFVHHDVO.js → cleanup-FERREFU6.js} +3 -3
- package/bundle/cleanup-VIITMMDH.js +33 -0
- package/bundle/{core-FRVSDP2C.js → core-GS6NXK7Y.js} +30 -2
- package/bundle/{devtoolsService-VM2WTHBX.js → devtoolsService-FKC6Y4OE.js} +3 -3
- package/bundle/{devtoolsService-TRDGMQLJ.js → devtoolsService-K2DRCZEY.js} +5 -4
- package/bundle/{devtoolsService-RUEO5PGP.js → devtoolsService-PS6RYICL.js} +3 -3
- package/bundle/devtoolsService-ZDXC2NPD.js +857 -0
- package/bundle/{dist-6BN2CJPN.js → dist-S3YUNQKP.js} +30 -2
- package/bundle/{core-B5S6HZJT.js → dist-TBGNMYU2.js} +30 -2
- package/bundle/dist-ZEW43MLQ.js +2124 -0
- package/bundle/docs/changelogs/index.md +30 -0
- package/bundle/docs/changelogs/latest.md +261 -166
- package/bundle/docs/changelogs/preview.md +178 -103
- package/bundle/docs/cli/auto-memory.md +60 -38
- package/bundle/docs/cli/settings.md +1 -1
- package/bundle/docs/cli/tutorials/memory-management.md +1 -1
- package/bundle/docs/extensions/releasing.md +58 -24
- package/bundle/docs/reference/configuration.md +14 -1
- package/bundle/docs/reference/keyboard-shortcuts.md +23 -0
- package/bundle/{gemini-QSTQ2DBG.js → gemini-6YGVETF3.js} +165 -61
- package/bundle/{gemini-GHUELHBF.js → gemini-7FCGNXOV.js} +350 -232
- package/bundle/gemini-IXZUGRVP.js +16360 -0
- package/bundle/{gemini-NQPVX5JC.js → gemini-WYTY4CD5.js} +165 -61
- package/bundle/gemini.js +8 -8
- package/bundle/{interactiveCli-AG2YWL2O.js → interactiveCli-A2FV6NYD.js} +1721 -1472
- package/bundle/{interactiveCli-MZFG35NB.js → interactiveCli-DWNRHVIB.js} +2003 -1736
- package/bundle/{interactiveCli-453M2IVE.js → interactiveCli-H7N4UXVQ.js} +1720 -1472
- package/bundle/interactiveCli-XRZEELCX.js +34754 -0
- package/bundle/{liteRtServerManager-G4Q7OVBX.js → liteRtServerManager-5C5EONBK.js} +5 -5
- package/bundle/{liteRtServerManager-S7WL25VD.js → liteRtServerManager-NQKPNCLR.js} +5 -5
- package/bundle/{liteRtServerManager-BXQ6VVWP.js → liteRtServerManager-UJBPII3P.js} +5 -5
- package/bundle/liteRtServerManager-UZCAJJCS.js +66 -0
- package/bundle/{memoryDiscovery-KSYZVCWF.js → memoryDiscovery-ALKMYAPP.js} +1 -1
- package/bundle/{memoryDiscovery-FB7MMKTA.js → memoryDiscovery-XFCKEF3F.js} +1 -1
- package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
- package/bundle/{oauth2-provider-VR4DL6AL.js → oauth2-provider-JNOY6NUI.js} +2 -2
- package/bundle/{oauth2-provider-H7G6RSFW.js → oauth2-provider-O6OA5EMU.js} +2 -2
- package/bundle/{oauth2-provider-5UF5WEE2.js → oauth2-provider-QYCLASEA.js} +39 -73
- package/bundle/oauth2-provider-VWLTUFO7.js +237 -0
- package/bundle/{start-CQBSKFYB.js → start-6FV3VPPH.js} +7 -7
- package/bundle/{start-NIMXQJYB.js → start-IWAUTCYF.js} +7 -7
- package/bundle/{start-2SKRN43X.js → start-L4DAQUQM.js} +7 -7
- package/bundle/start-XTXUKP77.js +19 -0
- package/package.json +1 -1
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
isTelemetrySdkInitialized,
|
|
5
5
|
resetBrowserSession,
|
|
6
6
|
shutdownTelemetry
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MLPM54XD.js";
|
|
8
8
|
import {
|
|
9
9
|
Storage
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M7OUJJZ2.js";
|
|
11
11
|
|
|
12
12
|
// packages/cli/src/utils/cleanup.ts
|
|
13
13
|
import { promises as fs } from "node:fs";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
|
|
2
2
|
import {
|
|
3
3
|
AuthProviderType,
|
|
4
|
+
AuthType,
|
|
5
|
+
CoreToolCallStatus,
|
|
4
6
|
DEFAULT_MODEL_CONFIGS,
|
|
5
7
|
DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
|
|
6
8
|
SESSION_FILE_PREFIX,
|
|
@@ -20,8 +22,9 @@ import {
|
|
|
20
22
|
require_strip_json_comments,
|
|
21
23
|
sanitizeFilenamePart,
|
|
22
24
|
stripAnsi
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-AC2EWTF7.js";
|
|
24
26
|
import {
|
|
27
|
+
CoreEvent,
|
|
25
28
|
FatalConfigError,
|
|
26
29
|
GEMINI_DIR,
|
|
27
30
|
Storage,
|
|
@@ -30,7 +33,7 @@ import {
|
|
|
30
33
|
external_exports,
|
|
31
34
|
getErrorMessage,
|
|
32
35
|
homedir
|
|
33
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-M7OUJJZ2.js";
|
|
34
37
|
import {
|
|
35
38
|
__commonJS,
|
|
36
39
|
__require,
|
|
@@ -9959,9 +9962,13 @@ var getAllSessionFiles = async (chatsDir, currentSessionId, options = {}) => {
|
|
|
9959
9962
|
if (!content) {
|
|
9960
9963
|
return { fileName: file, sessionInfo: null };
|
|
9961
9964
|
}
|
|
9962
|
-
if (!content.sessionId
|
|
9965
|
+
if (!content.sessionId) {
|
|
9963
9966
|
return { fileName: file, sessionInfo: null };
|
|
9964
9967
|
}
|
|
9968
|
+
const fileTimestamp = !content.startTime || !content.lastUpdated ? (await fs.stat(filePath).catch(() => void 0))?.mtime.toISOString() : void 0;
|
|
9969
|
+
const fallbackTimestamp = fileTimestamp ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
9970
|
+
const startTime = content.startTime || content.lastUpdated || fallbackTimestamp;
|
|
9971
|
+
const lastUpdated = content.lastUpdated || content.startTime || fallbackTimestamp;
|
|
9965
9972
|
if (!content.hasUserOrAssistantMessage) {
|
|
9966
9973
|
return { fileName: file, sessionInfo: null };
|
|
9967
9974
|
}
|
|
@@ -9983,8 +9990,8 @@ var getAllSessionFiles = async (chatsDir, currentSessionId, options = {}) => {
|
|
|
9983
9990
|
id: content.sessionId,
|
|
9984
9991
|
file: file.replace(/\.jsonl?$/, ""),
|
|
9985
9992
|
fileName: file,
|
|
9986
|
-
startTime
|
|
9987
|
-
lastUpdated
|
|
9993
|
+
startTime,
|
|
9994
|
+
lastUpdated,
|
|
9988
9995
|
messageCount: content.messageCount ?? content.messages.length,
|
|
9989
9996
|
displayName: content.summary ? stripUnsafeCharacters(content.summary) : firstUserMessage,
|
|
9990
9997
|
firstUserMessage,
|
|
@@ -10138,10 +10145,15 @@ var SessionSelector = class {
|
|
|
10138
10145
|
if (!sessionData) {
|
|
10139
10146
|
throw new Error("Failed to load session data");
|
|
10140
10147
|
}
|
|
10148
|
+
const normalizedSessionData = {
|
|
10149
|
+
...sessionData,
|
|
10150
|
+
startTime: sessionData.startTime || sessionInfo.startTime,
|
|
10151
|
+
lastUpdated: sessionData.lastUpdated || sessionInfo.lastUpdated
|
|
10152
|
+
};
|
|
10141
10153
|
const displayInfo = `Session ${sessionInfo.index}: ${sessionInfo.firstUserMessage} (${sessionInfo.messageCount} messages, ${formatRelativeTime(sessionInfo.lastUpdated)})`;
|
|
10142
10154
|
return {
|
|
10143
10155
|
sessionPath,
|
|
10144
|
-
sessionData,
|
|
10156
|
+
sessionData: normalizedSessionData,
|
|
10145
10157
|
displayInfo
|
|
10146
10158
|
};
|
|
10147
10159
|
} catch (error) {
|
|
@@ -10205,7 +10217,7 @@ function convertSessionToHistoryFormats(messages) {
|
|
|
10205
10217
|
args: tool.args,
|
|
10206
10218
|
description: tool.description || "",
|
|
10207
10219
|
renderOutputAsMarkdown: tool.renderOutputAsMarkdown ?? true,
|
|
10208
|
-
status: tool.status === "success" ?
|
|
10220
|
+
status: tool.status === "success" ? CoreToolCallStatus.Success : CoreToolCallStatus.Error,
|
|
10209
10221
|
resultDisplay: tool.resultDisplay,
|
|
10210
10222
|
confirmationDetails: void 0
|
|
10211
10223
|
}))
|
|
@@ -10528,8 +10540,8 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
10528
10540
|
files.map(async (file) => {
|
|
10529
10541
|
try {
|
|
10530
10542
|
const filePath = path2.join(toolOutputDir, file.name);
|
|
10531
|
-
const
|
|
10532
|
-
return { name: file.name, mtime:
|
|
10543
|
+
const stat3 = await fs2.stat(filePath);
|
|
10544
|
+
return { name: file.name, mtime: stat3.mtime };
|
|
10533
10545
|
} catch (error) {
|
|
10534
10546
|
debugLogger.debug(
|
|
10535
10547
|
`Failed to stat file ${file.name}: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
@@ -10582,12 +10594,12 @@ async function cleanupToolOutputFiles(settings, debugMode = false, projectTempDi
|
|
|
10582
10594
|
continue;
|
|
10583
10595
|
}
|
|
10584
10596
|
const subdirPath = path2.join(toolOutputDir, subdir.name);
|
|
10585
|
-
const
|
|
10597
|
+
const stat3 = await fs2.stat(subdirPath);
|
|
10586
10598
|
let shouldDelete = false;
|
|
10587
10599
|
if (retentionConfig.maxAge) {
|
|
10588
10600
|
const maxAgeMs = parseRetentionPeriod(retentionConfig.maxAge);
|
|
10589
10601
|
const cutoffDate = new Date(now.getTime() - maxAgeMs);
|
|
10590
|
-
if (
|
|
10602
|
+
if (stat3.mtime < cutoffDate) {
|
|
10591
10603
|
shouldDelete = true;
|
|
10592
10604
|
}
|
|
10593
10605
|
}
|
|
@@ -14265,7 +14277,7 @@ var SETTINGS_SCHEMA = {
|
|
|
14265
14277
|
label: "Voice Stop Grace Period (ms)",
|
|
14266
14278
|
category: "Experimental",
|
|
14267
14279
|
requiresRestart: false,
|
|
14268
|
-
default:
|
|
14280
|
+
default: 4e3,
|
|
14269
14281
|
description: "How long to wait for final transcription after stopping recording.",
|
|
14270
14282
|
showInDialog: true
|
|
14271
14283
|
}
|
|
@@ -15611,17 +15623,19 @@ function resolveEnvVarsInObjectInternal(obj, visited, customEnv) {
|
|
|
15611
15623
|
}
|
|
15612
15624
|
if (Array.isArray(obj)) {
|
|
15613
15625
|
if (visited.has(obj)) {
|
|
15614
|
-
|
|
15626
|
+
const copy = [...obj];
|
|
15627
|
+
const isTArray2 = (val) => Array.isArray(val);
|
|
15628
|
+
if (isTArray2(copy)) return copy;
|
|
15629
|
+
throw new Error("Unreachable");
|
|
15615
15630
|
}
|
|
15616
15631
|
visited.add(obj);
|
|
15617
|
-
const
|
|
15618
|
-
(item) => (
|
|
15619
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
15620
|
-
resolveEnvVarsInObjectInternal(item, visited, customEnv)
|
|
15621
|
-
)
|
|
15632
|
+
const mapped = obj.map(
|
|
15633
|
+
(item) => resolveEnvVarsInObjectInternal(item, visited, customEnv)
|
|
15622
15634
|
);
|
|
15623
15635
|
visited.delete(obj);
|
|
15624
|
-
|
|
15636
|
+
const isTArray = (val) => Array.isArray(val);
|
|
15637
|
+
if (isTArray(mapped)) return mapped;
|
|
15638
|
+
throw new Error("Unreachable");
|
|
15625
15639
|
}
|
|
15626
15640
|
if (typeof obj === "object") {
|
|
15627
15641
|
if (visited.has(obj)) {
|
|
@@ -16172,6 +16186,14 @@ var LoadedSettings = class {
|
|
|
16172
16186
|
get merged() {
|
|
16173
16187
|
return this._merged;
|
|
16174
16188
|
}
|
|
16189
|
+
/**
|
|
16190
|
+
* Returns a merged settings object as if the folder were trusted.
|
|
16191
|
+
* This is useful for commands like 'mcp list' that want to show
|
|
16192
|
+
* what's configured even if it's currently disabled for security reasons.
|
|
16193
|
+
*/
|
|
16194
|
+
getMergedSettingsAsIfTrusted() {
|
|
16195
|
+
return this.computeMergedSettings(true);
|
|
16196
|
+
}
|
|
16175
16197
|
setTrusted(isTrusted) {
|
|
16176
16198
|
if (this.isTrusted === isTrusted) {
|
|
16177
16199
|
return;
|
|
@@ -16188,13 +16210,15 @@ var LoadedSettings = class {
|
|
|
16188
16210
|
originalSettings: {}
|
|
16189
16211
|
};
|
|
16190
16212
|
}
|
|
16191
|
-
computeMergedSettings() {
|
|
16213
|
+
computeMergedSettings(forceTrusted = false) {
|
|
16214
|
+
const isTrusted = forceTrusted || this.isTrusted;
|
|
16215
|
+
const workspace = forceTrusted ? this._workspaceFile : this.workspace;
|
|
16192
16216
|
const merged = mergeSettings(
|
|
16193
16217
|
this.system.settings,
|
|
16194
16218
|
this.systemDefaults.settings,
|
|
16195
16219
|
this.user.settings,
|
|
16196
|
-
|
|
16197
|
-
|
|
16220
|
+
workspace.settings,
|
|
16221
|
+
isTrusted
|
|
16198
16222
|
);
|
|
16199
16223
|
const adminSettingSchema = getSettingsSchema().admin;
|
|
16200
16224
|
if (adminSettingSchema?.properties) {
|
|
@@ -16210,8 +16234,7 @@ var LoadedSettings = class {
|
|
|
16210
16234
|
}
|
|
16211
16235
|
computeSnapshot() {
|
|
16212
16236
|
const cloneSettingsFile = (file) => ({
|
|
16213
|
-
|
|
16214
|
-
rawJson: file.rawJson,
|
|
16237
|
+
...file,
|
|
16215
16238
|
settings: structuredClone(file.settings),
|
|
16216
16239
|
originalSettings: structuredClone(file.originalSettings)
|
|
16217
16240
|
});
|
|
@@ -16229,8 +16252,8 @@ var LoadedSettings = class {
|
|
|
16229
16252
|
// React will pass a listener fn into this subscribe fn
|
|
16230
16253
|
// that listener fn will perform an object identity check on the snapshot and trigger a React re render if the snapshot has changed
|
|
16231
16254
|
subscribe(listener) {
|
|
16232
|
-
coreEvents.on(
|
|
16233
|
-
return () => coreEvents.off(
|
|
16255
|
+
coreEvents.on(CoreEvent.SettingsChanged, listener);
|
|
16256
|
+
return () => coreEvents.off(CoreEvent.SettingsChanged, listener);
|
|
16234
16257
|
}
|
|
16235
16258
|
getSnapshot() {
|
|
16236
16259
|
return this._snapshot;
|
|
@@ -16333,7 +16356,7 @@ function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed, selecte
|
|
|
16333
16356
|
}
|
|
16334
16357
|
}
|
|
16335
16358
|
let value = "cloudshell-gca";
|
|
16336
|
-
if (selectedAuthType ===
|
|
16359
|
+
if (selectedAuthType === AuthType.USE_VERTEX_AI) {
|
|
16337
16360
|
value = process2.env[USER_GCP_PROJECT];
|
|
16338
16361
|
}
|
|
16339
16362
|
if (envFilePath && fs4.existsSync(envFilePath)) {
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
|
|
2
|
+
import {
|
|
3
|
+
ExitCodes,
|
|
4
|
+
isTelemetrySdkInitialized,
|
|
5
|
+
resetBrowserSession,
|
|
6
|
+
shutdownTelemetry
|
|
7
|
+
} from "./chunk-LF33N5QM.js";
|
|
8
|
+
import {
|
|
9
|
+
Storage
|
|
10
|
+
} from "./chunk-M7OUJJZ2.js";
|
|
11
|
+
|
|
12
|
+
// packages/cli/src/utils/cleanup.ts
|
|
13
|
+
import { promises as fs } from "node:fs";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
var cleanupFunctions = [];
|
|
16
|
+
var syncCleanupFunctions = [];
|
|
17
|
+
var configForTelemetry = null;
|
|
18
|
+
var isShuttingDown = false;
|
|
19
|
+
function registerCleanup(fn) {
|
|
20
|
+
cleanupFunctions.push(fn);
|
|
21
|
+
}
|
|
22
|
+
function removeCleanup(fn) {
|
|
23
|
+
const index = cleanupFunctions.indexOf(fn);
|
|
24
|
+
if (index !== -1) {
|
|
25
|
+
cleanupFunctions.splice(index, 1);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function registerSyncCleanup(fn) {
|
|
29
|
+
syncCleanupFunctions.push(fn);
|
|
30
|
+
}
|
|
31
|
+
function removeSyncCleanup(fn) {
|
|
32
|
+
const index = syncCleanupFunctions.indexOf(fn);
|
|
33
|
+
if (index !== -1) {
|
|
34
|
+
syncCleanupFunctions.splice(index, 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function resetCleanupForTesting() {
|
|
38
|
+
cleanupFunctions.length = 0;
|
|
39
|
+
syncCleanupFunctions.length = 0;
|
|
40
|
+
configForTelemetry = null;
|
|
41
|
+
isShuttingDown = false;
|
|
42
|
+
}
|
|
43
|
+
function runSyncCleanup() {
|
|
44
|
+
for (const fn of syncCleanupFunctions) {
|
|
45
|
+
try {
|
|
46
|
+
fn();
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
syncCleanupFunctions.length = 0;
|
|
51
|
+
}
|
|
52
|
+
function registerTelemetryConfig(config) {
|
|
53
|
+
configForTelemetry = config;
|
|
54
|
+
}
|
|
55
|
+
async function runExitCleanup() {
|
|
56
|
+
await drainStdin();
|
|
57
|
+
runSyncCleanup();
|
|
58
|
+
for (const fn of cleanupFunctions) {
|
|
59
|
+
try {
|
|
60
|
+
await fn();
|
|
61
|
+
} catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
cleanupFunctions.length = 0;
|
|
65
|
+
try {
|
|
66
|
+
await resetBrowserSession();
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
if (configForTelemetry) {
|
|
70
|
+
try {
|
|
71
|
+
await configForTelemetry.dispose();
|
|
72
|
+
} catch {
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (configForTelemetry && isTelemetrySdkInitialized()) {
|
|
76
|
+
try {
|
|
77
|
+
await shutdownTelemetry(configForTelemetry);
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function drainStdin() {
|
|
83
|
+
if (!process.stdin?.isTTY) return;
|
|
84
|
+
process.stdin.resume().removeAllListeners("data").on("data", () => {
|
|
85
|
+
});
|
|
86
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
87
|
+
}
|
|
88
|
+
async function gracefulShutdown(_reason) {
|
|
89
|
+
if (isShuttingDown) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
isShuttingDown = true;
|
|
93
|
+
await runExitCleanup();
|
|
94
|
+
process.exit(ExitCodes.SUCCESS);
|
|
95
|
+
}
|
|
96
|
+
function setupSignalHandlers() {
|
|
97
|
+
process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
|
|
98
|
+
process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
|
|
99
|
+
process.on("SIGINT", () => gracefulShutdown("SIGINT"));
|
|
100
|
+
}
|
|
101
|
+
function setupTtyCheck() {
|
|
102
|
+
let intervalId = null;
|
|
103
|
+
let isCheckingTty = false;
|
|
104
|
+
intervalId = setInterval(async () => {
|
|
105
|
+
if (isCheckingTty || isShuttingDown) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (process.env["SANDBOX"]) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (!process.stdin.isTTY && !process.stdout.isTTY) {
|
|
112
|
+
isCheckingTty = true;
|
|
113
|
+
if (intervalId) {
|
|
114
|
+
clearInterval(intervalId);
|
|
115
|
+
intervalId = null;
|
|
116
|
+
}
|
|
117
|
+
await gracefulShutdown("TTY loss");
|
|
118
|
+
}
|
|
119
|
+
}, 5e3);
|
|
120
|
+
intervalId.unref();
|
|
121
|
+
return () => {
|
|
122
|
+
if (intervalId) {
|
|
123
|
+
clearInterval(intervalId);
|
|
124
|
+
intervalId = null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
async function cleanupCheckpoints() {
|
|
129
|
+
const storage = new Storage(process.cwd());
|
|
130
|
+
await storage.initialize();
|
|
131
|
+
const tempDir = storage.getProjectTempDir();
|
|
132
|
+
const checkpointsDir = join(tempDir, "checkpoints");
|
|
133
|
+
try {
|
|
134
|
+
await fs.rm(checkpointsDir, { recursive: true, force: true });
|
|
135
|
+
} catch {
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
registerCleanup,
|
|
141
|
+
removeCleanup,
|
|
142
|
+
registerSyncCleanup,
|
|
143
|
+
removeSyncCleanup,
|
|
144
|
+
resetCleanupForTesting,
|
|
145
|
+
runSyncCleanup,
|
|
146
|
+
registerTelemetryConfig,
|
|
147
|
+
runExitCleanup,
|
|
148
|
+
setupSignalHandlers,
|
|
149
|
+
setupTtyCheck,
|
|
150
|
+
cleanupCheckpoints
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* @license
|
|
154
|
+
* Copyright 2025 Google LLC
|
|
155
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
156
|
+
*/
|