@google/gemini-cli 0.36.0-preview.2 → 0.36.0-preview.4

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 (39) hide show
  1. package/bundle/{chunk-SV2TJWFU.js → chunk-GCWRR5FX.js} +250 -177
  2. package/bundle/{chunk-6F64DR53.js → chunk-GUQQGCYU.js} +71090 -70973
  3. package/bundle/{chunk-EUXACAGL.js → chunk-L6SWRWOY.js} +250 -177
  4. package/bundle/{chunk-NKTSTYJO.js → chunk-LA7NTE7R.js} +71090 -70973
  5. package/bundle/{chunk-NT4MG3B6.js → chunk-NB2KVK55.js} +71090 -70973
  6. package/bundle/{chunk-KGPUJGU6.js → chunk-PCRNOH75.js} +71090 -70973
  7. package/bundle/{chunk-WHT3ZS7S.js → chunk-QG3DE2NC.js} +250 -177
  8. package/bundle/{chunk-25V3TYNR.js → chunk-RCVLWPH6.js} +253 -175
  9. package/bundle/{core-7GUY3XKQ.js → core-UDWC3JHH.js} +5 -1
  10. package/bundle/{devtoolsService-LU3DLIVB.js → devtoolsService-5KPG7MTO.js} +2 -2
  11. package/bundle/{devtoolsService-RGAOIVMN.js → devtoolsService-F3HNCJ5J.js} +2 -2
  12. package/bundle/{devtoolsService-B7OD724C.js → devtoolsService-JP7KYM7O.js} +2 -2
  13. package/bundle/{devtoolsService-JGPJ2GN4.js → devtoolsService-WMTAFNHI.js} +2 -2
  14. package/bundle/{dist-DTCLJTHN.js → dist-6YQTL2TU.js} +5 -1
  15. package/bundle/{dist-X3ESBKEG.js → dist-FZZRWINS.js} +5 -1
  16. package/bundle/{dist-YQXQRQYA.js → dist-WZ5ZCWLQ.js} +5 -1
  17. package/bundle/gemini.js +14442 -13
  18. package/bundle/{interactiveCli-2EVI7UVZ.js → interactiveCli-2MHB7PL6.js} +6 -8
  19. package/bundle/{interactiveCli-2OAVBJCC.js → interactiveCli-3FPUSZZF.js} +6 -8
  20. package/bundle/{interactiveCli-CRDA6GQ7.js → interactiveCli-HKHDILWJ.js} +6 -8
  21. package/bundle/{interactiveCli-SHFDAMKC.js → interactiveCli-MNSUUMCD.js} +6 -8
  22. package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
  23. package/bundle/{oauth2-provider-D6HJJAVX.js → oauth2-provider-GU6JSDXE.js} +1 -1
  24. package/bundle/{oauth2-provider-ZT3CIEZO.js → oauth2-provider-NNYNDNHB.js} +1 -1
  25. package/bundle/{oauth2-provider-KEZJCOYM.js → oauth2-provider-U2Y3KMJH.js} +1 -1
  26. package/bundle/{oauth2-provider-TSEQG63I.js → oauth2-provider-UFMHKHVW.js} +1 -1
  27. package/package.json +1 -1
  28. package/bundle/chunk-IOJJTEIC.js +0 -137
  29. package/bundle/chunk-MRJRXC63.js +0 -137
  30. package/bundle/chunk-MXNIJ4RK.js +0 -137
  31. package/bundle/chunk-OOZG4FMQ.js +0 -137
  32. package/bundle/cleanup-2WKEMFXG.js +0 -29
  33. package/bundle/cleanup-B67M5WAO.js +0 -29
  34. package/bundle/cleanup-PJ323T24.js +0 -29
  35. package/bundle/cleanup-PKVUY3XO.js +0 -29
  36. package/bundle/gemini-7BPDTLSV.js +0 -14440
  37. package/bundle/gemini-CJ5HU32O.js +0 -14455
  38. package/bundle/gemini-GA5SXGI6.js +0 -14455
  39. package/bundle/gemini-RFUB3W5S.js +0 -14455
@@ -131,6 +131,7 @@ import {
131
131
  persistentState,
132
132
  pickDefaultThemeName,
133
133
  profiler,
134
+ registerCleanup,
134
135
  relaunchApp,
135
136
  render_default,
136
137
  requestConsentInteractive,
@@ -140,9 +141,11 @@ import {
140
141
  require_source,
141
142
  require_tinygradient,
142
143
  resolveColor,
144
+ runExitCleanup,
143
145
  sanitizeForDisplay,
144
146
  saveClipboardImage,
145
147
  setUpdateHandler,
148
+ setupTtyCheck,
146
149
  shouldSwitchTheme,
147
150
  stringWidth,
148
151
  stripUnsafeCharacters,
@@ -178,12 +181,7 @@ import {
178
181
  widestLineFromStyledChars,
179
182
  wordBreakStyledChars,
180
183
  wrapStyledChars
181
- } from "./chunk-NT4MG3B6.js";
182
- import {
183
- registerCleanup,
184
- runExitCleanup,
185
- setupTtyCheck
186
- } from "./chunk-MXNIJ4RK.js";
184
+ } from "./chunk-GUQQGCYU.js";
187
185
  import {
188
186
  ApiKeyUpdatedEvent,
189
187
  AsyncFzf,
@@ -302,7 +300,7 @@ import {
302
300
  validatePlanContent,
303
301
  validatePlanPath,
304
302
  writeToStdout
305
- } from "./chunk-WHT3ZS7S.js";
303
+ } from "./chunk-L6SWRWOY.js";
306
304
  import {
307
305
  ACTIVATE_SKILL_TOOL_NAME,
308
306
  ASK_USER_TOOL_NAME,
@@ -48385,7 +48383,7 @@ ${queuedText}` : queuedText;
48385
48383
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
48386
48384
  if (settings.merged.general.devtools) {
48387
48385
  void (async () => {
48388
- const { toggleDevToolsPanel } = await import("./devtoolsService-RGAOIVMN.js");
48386
+ const { toggleDevToolsPanel } = await import("./devtoolsService-JP7KYM7O.js");
48389
48387
  await toggleDevToolsPanel(
48390
48388
  config,
48391
48389
  showErrorDetails,
@@ -131,6 +131,7 @@ import {
131
131
  persistentState,
132
132
  pickDefaultThemeName,
133
133
  profiler,
134
+ registerCleanup,
134
135
  relaunchApp,
135
136
  render_default,
136
137
  requestConsentInteractive,
@@ -140,9 +141,11 @@ import {
140
141
  require_source,
141
142
  require_tinygradient,
142
143
  resolveColor,
144
+ runExitCleanup,
143
145
  sanitizeForDisplay,
144
146
  saveClipboardImage,
145
147
  setUpdateHandler,
148
+ setupTtyCheck,
146
149
  shouldSwitchTheme,
147
150
  stringWidth,
148
151
  stripUnsafeCharacters,
@@ -178,12 +181,7 @@ import {
178
181
  widestLineFromStyledChars,
179
182
  wordBreakStyledChars,
180
183
  wrapStyledChars
181
- } from "./chunk-NKTSTYJO.js";
182
- import {
183
- registerCleanup,
184
- runExitCleanup,
185
- setupTtyCheck
186
- } from "./chunk-MRJRXC63.js";
184
+ } from "./chunk-NB2KVK55.js";
187
185
  import {
188
186
  ApiKeyUpdatedEvent,
189
187
  AsyncFzf,
@@ -302,7 +300,7 @@ import {
302
300
  validatePlanContent,
303
301
  validatePlanPath,
304
302
  writeToStdout
305
- } from "./chunk-EUXACAGL.js";
303
+ } from "./chunk-GCWRR5FX.js";
306
304
  import {
307
305
  ACTIVATE_SKILL_TOOL_NAME,
308
306
  ASK_USER_TOOL_NAME,
@@ -48385,7 +48383,7 @@ ${queuedText}` : queuedText;
48385
48383
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
48386
48384
  if (settings.merged.general.devtools) {
48387
48385
  void (async () => {
48388
- const { toggleDevToolsPanel } = await import("./devtoolsService-B7OD724C.js");
48386
+ const { toggleDevToolsPanel } = await import("./devtoolsService-F3HNCJ5J.js");
48389
48387
  await toggleDevToolsPanel(
48390
48388
  config,
48391
48389
  showErrorDetails,
@@ -131,6 +131,7 @@ import {
131
131
  persistentState,
132
132
  pickDefaultThemeName,
133
133
  profiler,
134
+ registerCleanup,
134
135
  relaunchApp,
135
136
  render_default,
136
137
  requestConsentInteractive,
@@ -140,9 +141,11 @@ import {
140
141
  require_source,
141
142
  require_tinygradient,
142
143
  resolveColor,
144
+ runExitCleanup,
143
145
  sanitizeForDisplay,
144
146
  saveClipboardImage,
145
147
  setUpdateHandler,
148
+ setupTtyCheck,
146
149
  shouldSwitchTheme,
147
150
  stringWidth,
148
151
  stripUnsafeCharacters,
@@ -178,12 +181,7 @@ import {
178
181
  widestLineFromStyledChars,
179
182
  wordBreakStyledChars,
180
183
  wrapStyledChars
181
- } from "./chunk-KGPUJGU6.js";
182
- import {
183
- registerCleanup,
184
- runExitCleanup,
185
- setupTtyCheck
186
- } from "./chunk-OOZG4FMQ.js";
184
+ } from "./chunk-PCRNOH75.js";
187
185
  import {
188
186
  ApiKeyUpdatedEvent,
189
187
  AsyncFzf,
@@ -292,7 +290,7 @@ import {
292
290
  validatePlanContent,
293
291
  validatePlanPath,
294
292
  writeToStdout
295
- } from "./chunk-25V3TYNR.js";
293
+ } from "./chunk-RCVLWPH6.js";
296
294
  import {
297
295
  ACTIVATE_SKILL_TOOL_NAME,
298
296
  ASK_USER_TOOL_NAME,
@@ -48368,7 +48366,7 @@ ${queuedText}` : queuedText;
48368
48366
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
48369
48367
  if (settings.merged.general.devtools) {
48370
48368
  void (async () => {
48371
- const { toggleDevToolsPanel } = await import("./devtoolsService-LU3DLIVB.js");
48369
+ const { toggleDevToolsPanel } = await import("./devtoolsService-5KPG7MTO.js");
48372
48370
  await toggleDevToolsPanel(
48373
48371
  config,
48374
48372
  showErrorDetails,
@@ -131,6 +131,7 @@ import {
131
131
  persistentState,
132
132
  pickDefaultThemeName,
133
133
  profiler,
134
+ registerCleanup,
134
135
  relaunchApp,
135
136
  render_default,
136
137
  requestConsentInteractive,
@@ -140,9 +141,11 @@ import {
140
141
  require_source,
141
142
  require_tinygradient,
142
143
  resolveColor,
144
+ runExitCleanup,
143
145
  sanitizeForDisplay,
144
146
  saveClipboardImage,
145
147
  setUpdateHandler,
148
+ setupTtyCheck,
146
149
  shouldSwitchTheme,
147
150
  stringWidth,
148
151
  stripUnsafeCharacters,
@@ -178,12 +181,7 @@ import {
178
181
  widestLineFromStyledChars,
179
182
  wordBreakStyledChars,
180
183
  wrapStyledChars
181
- } from "./chunk-6F64DR53.js";
182
- import {
183
- registerCleanup,
184
- runExitCleanup,
185
- setupTtyCheck
186
- } from "./chunk-IOJJTEIC.js";
184
+ } from "./chunk-LA7NTE7R.js";
187
185
  import {
188
186
  ApiKeyUpdatedEvent,
189
187
  AsyncFzf,
@@ -302,7 +300,7 @@ import {
302
300
  validatePlanContent,
303
301
  validatePlanPath,
304
302
  writeToStdout
305
- } from "./chunk-SV2TJWFU.js";
303
+ } from "./chunk-QG3DE2NC.js";
306
304
  import {
307
305
  ACTIVATE_SKILL_TOOL_NAME,
308
306
  ASK_USER_TOOL_NAME,
@@ -48385,7 +48383,7 @@ ${queuedText}` : queuedText;
48385
48383
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
48386
48384
  if (settings.merged.general.devtools) {
48387
48385
  void (async () => {
48388
- const { toggleDevToolsPanel } = await import("./devtoolsService-JGPJ2GN4.js");
48386
+ const { toggleDevToolsPanel } = await import("./devtoolsService-WMTAFNHI.js");
48389
48387
  await toggleDevToolsPanel(
48390
48388
  config,
48391
48389
  showErrorDetails,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/gemini-cli-devtools",
3
- "version": "0.36.0-preview.2",
3
+ "version": "0.36.0-preview.4",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -11,7 +11,7 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-EUXACAGL.js";
14
+ } from "./chunk-QG3DE2NC.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
@@ -11,7 +11,7 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-25V3TYNR.js";
14
+ } from "./chunk-RCVLWPH6.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
@@ -11,7 +11,7 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-SV2TJWFU.js";
14
+ } from "./chunk-GCWRR5FX.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
@@ -11,7 +11,7 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-WHT3ZS7S.js";
14
+ } from "./chunk-L6SWRWOY.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/gemini-cli",
3
- "version": "0.36.0-preview.2",
3
+ "version": "0.36.0-preview.4",
4
4
  "description": "Gemini CLI",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,137 +0,0 @@
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
- shutdownTelemetry
6
- } from "./chunk-SV2TJWFU.js";
7
- import {
8
- Storage
9
- } from "./chunk-HLML5SVJ.js";
10
-
11
- // packages/cli/src/utils/cleanup.ts
12
- import { promises as fs } from "node:fs";
13
- import { join } from "node:path";
14
- var cleanupFunctions = [];
15
- var syncCleanupFunctions = [];
16
- var configForTelemetry = null;
17
- var isShuttingDown = false;
18
- function registerCleanup(fn) {
19
- cleanupFunctions.push(fn);
20
- }
21
- function registerSyncCleanup(fn) {
22
- syncCleanupFunctions.push(fn);
23
- }
24
- function resetCleanupForTesting() {
25
- cleanupFunctions.length = 0;
26
- syncCleanupFunctions.length = 0;
27
- configForTelemetry = null;
28
- isShuttingDown = false;
29
- }
30
- function runSyncCleanup() {
31
- for (const fn of syncCleanupFunctions) {
32
- try {
33
- fn();
34
- } catch (_) {
35
- }
36
- }
37
- syncCleanupFunctions.length = 0;
38
- }
39
- function registerTelemetryConfig(config) {
40
- configForTelemetry = config;
41
- }
42
- async function runExitCleanup() {
43
- await drainStdin();
44
- runSyncCleanup();
45
- for (const fn of cleanupFunctions) {
46
- try {
47
- await fn();
48
- } catch (_) {
49
- }
50
- }
51
- cleanupFunctions.length = 0;
52
- if (configForTelemetry) {
53
- try {
54
- await configForTelemetry.dispose();
55
- } catch (_) {
56
- }
57
- }
58
- if (configForTelemetry && isTelemetrySdkInitialized()) {
59
- try {
60
- await shutdownTelemetry(configForTelemetry);
61
- } catch (_) {
62
- }
63
- }
64
- }
65
- async function drainStdin() {
66
- if (!process.stdin?.isTTY) return;
67
- process.stdin.resume().removeAllListeners("data").on("data", () => {
68
- });
69
- await new Promise((resolve) => setTimeout(resolve, 50));
70
- }
71
- async function gracefulShutdown(_reason) {
72
- if (isShuttingDown) {
73
- return;
74
- }
75
- isShuttingDown = true;
76
- await runExitCleanup();
77
- process.exit(ExitCodes.SUCCESS);
78
- }
79
- function setupSignalHandlers() {
80
- process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
81
- process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
82
- process.on("SIGINT", () => gracefulShutdown("SIGINT"));
83
- }
84
- function setupTtyCheck() {
85
- let intervalId = null;
86
- let isCheckingTty = false;
87
- intervalId = setInterval(async () => {
88
- if (isCheckingTty || isShuttingDown) {
89
- return;
90
- }
91
- if (process.env["SANDBOX"]) {
92
- return;
93
- }
94
- if (!process.stdin.isTTY && !process.stdout.isTTY) {
95
- isCheckingTty = true;
96
- if (intervalId) {
97
- clearInterval(intervalId);
98
- intervalId = null;
99
- }
100
- await gracefulShutdown("TTY loss");
101
- }
102
- }, 5e3);
103
- intervalId.unref();
104
- return () => {
105
- if (intervalId) {
106
- clearInterval(intervalId);
107
- intervalId = null;
108
- }
109
- };
110
- }
111
- async function cleanupCheckpoints() {
112
- const storage = new Storage(process.cwd());
113
- await storage.initialize();
114
- const tempDir = storage.getProjectTempDir();
115
- const checkpointsDir = join(tempDir, "checkpoints");
116
- try {
117
- await fs.rm(checkpointsDir, { recursive: true, force: true });
118
- } catch {
119
- }
120
- }
121
-
122
- export {
123
- registerCleanup,
124
- registerSyncCleanup,
125
- resetCleanupForTesting,
126
- runSyncCleanup,
127
- registerTelemetryConfig,
128
- runExitCleanup,
129
- setupSignalHandlers,
130
- setupTtyCheck,
131
- cleanupCheckpoints
132
- };
133
- /**
134
- * @license
135
- * Copyright 2025 Google LLC
136
- * SPDX-License-Identifier: Apache-2.0
137
- */
@@ -1,137 +0,0 @@
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
- shutdownTelemetry
6
- } from "./chunk-EUXACAGL.js";
7
- import {
8
- Storage
9
- } from "./chunk-HLML5SVJ.js";
10
-
11
- // packages/cli/src/utils/cleanup.ts
12
- import { promises as fs } from "node:fs";
13
- import { join } from "node:path";
14
- var cleanupFunctions = [];
15
- var syncCleanupFunctions = [];
16
- var configForTelemetry = null;
17
- var isShuttingDown = false;
18
- function registerCleanup(fn) {
19
- cleanupFunctions.push(fn);
20
- }
21
- function registerSyncCleanup(fn) {
22
- syncCleanupFunctions.push(fn);
23
- }
24
- function resetCleanupForTesting() {
25
- cleanupFunctions.length = 0;
26
- syncCleanupFunctions.length = 0;
27
- configForTelemetry = null;
28
- isShuttingDown = false;
29
- }
30
- function runSyncCleanup() {
31
- for (const fn of syncCleanupFunctions) {
32
- try {
33
- fn();
34
- } catch (_) {
35
- }
36
- }
37
- syncCleanupFunctions.length = 0;
38
- }
39
- function registerTelemetryConfig(config) {
40
- configForTelemetry = config;
41
- }
42
- async function runExitCleanup() {
43
- await drainStdin();
44
- runSyncCleanup();
45
- for (const fn of cleanupFunctions) {
46
- try {
47
- await fn();
48
- } catch (_) {
49
- }
50
- }
51
- cleanupFunctions.length = 0;
52
- if (configForTelemetry) {
53
- try {
54
- await configForTelemetry.dispose();
55
- } catch (_) {
56
- }
57
- }
58
- if (configForTelemetry && isTelemetrySdkInitialized()) {
59
- try {
60
- await shutdownTelemetry(configForTelemetry);
61
- } catch (_) {
62
- }
63
- }
64
- }
65
- async function drainStdin() {
66
- if (!process.stdin?.isTTY) return;
67
- process.stdin.resume().removeAllListeners("data").on("data", () => {
68
- });
69
- await new Promise((resolve) => setTimeout(resolve, 50));
70
- }
71
- async function gracefulShutdown(_reason) {
72
- if (isShuttingDown) {
73
- return;
74
- }
75
- isShuttingDown = true;
76
- await runExitCleanup();
77
- process.exit(ExitCodes.SUCCESS);
78
- }
79
- function setupSignalHandlers() {
80
- process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
81
- process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
82
- process.on("SIGINT", () => gracefulShutdown("SIGINT"));
83
- }
84
- function setupTtyCheck() {
85
- let intervalId = null;
86
- let isCheckingTty = false;
87
- intervalId = setInterval(async () => {
88
- if (isCheckingTty || isShuttingDown) {
89
- return;
90
- }
91
- if (process.env["SANDBOX"]) {
92
- return;
93
- }
94
- if (!process.stdin.isTTY && !process.stdout.isTTY) {
95
- isCheckingTty = true;
96
- if (intervalId) {
97
- clearInterval(intervalId);
98
- intervalId = null;
99
- }
100
- await gracefulShutdown("TTY loss");
101
- }
102
- }, 5e3);
103
- intervalId.unref();
104
- return () => {
105
- if (intervalId) {
106
- clearInterval(intervalId);
107
- intervalId = null;
108
- }
109
- };
110
- }
111
- async function cleanupCheckpoints() {
112
- const storage = new Storage(process.cwd());
113
- await storage.initialize();
114
- const tempDir = storage.getProjectTempDir();
115
- const checkpointsDir = join(tempDir, "checkpoints");
116
- try {
117
- await fs.rm(checkpointsDir, { recursive: true, force: true });
118
- } catch {
119
- }
120
- }
121
-
122
- export {
123
- registerCleanup,
124
- registerSyncCleanup,
125
- resetCleanupForTesting,
126
- runSyncCleanup,
127
- registerTelemetryConfig,
128
- runExitCleanup,
129
- setupSignalHandlers,
130
- setupTtyCheck,
131
- cleanupCheckpoints
132
- };
133
- /**
134
- * @license
135
- * Copyright 2025 Google LLC
136
- * SPDX-License-Identifier: Apache-2.0
137
- */
@@ -1,137 +0,0 @@
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
- shutdownTelemetry
6
- } from "./chunk-WHT3ZS7S.js";
7
- import {
8
- Storage
9
- } from "./chunk-HLML5SVJ.js";
10
-
11
- // packages/cli/src/utils/cleanup.ts
12
- import { promises as fs } from "node:fs";
13
- import { join } from "node:path";
14
- var cleanupFunctions = [];
15
- var syncCleanupFunctions = [];
16
- var configForTelemetry = null;
17
- var isShuttingDown = false;
18
- function registerCleanup(fn) {
19
- cleanupFunctions.push(fn);
20
- }
21
- function registerSyncCleanup(fn) {
22
- syncCleanupFunctions.push(fn);
23
- }
24
- function resetCleanupForTesting() {
25
- cleanupFunctions.length = 0;
26
- syncCleanupFunctions.length = 0;
27
- configForTelemetry = null;
28
- isShuttingDown = false;
29
- }
30
- function runSyncCleanup() {
31
- for (const fn of syncCleanupFunctions) {
32
- try {
33
- fn();
34
- } catch (_) {
35
- }
36
- }
37
- syncCleanupFunctions.length = 0;
38
- }
39
- function registerTelemetryConfig(config) {
40
- configForTelemetry = config;
41
- }
42
- async function runExitCleanup() {
43
- await drainStdin();
44
- runSyncCleanup();
45
- for (const fn of cleanupFunctions) {
46
- try {
47
- await fn();
48
- } catch (_) {
49
- }
50
- }
51
- cleanupFunctions.length = 0;
52
- if (configForTelemetry) {
53
- try {
54
- await configForTelemetry.dispose();
55
- } catch (_) {
56
- }
57
- }
58
- if (configForTelemetry && isTelemetrySdkInitialized()) {
59
- try {
60
- await shutdownTelemetry(configForTelemetry);
61
- } catch (_) {
62
- }
63
- }
64
- }
65
- async function drainStdin() {
66
- if (!process.stdin?.isTTY) return;
67
- process.stdin.resume().removeAllListeners("data").on("data", () => {
68
- });
69
- await new Promise((resolve) => setTimeout(resolve, 50));
70
- }
71
- async function gracefulShutdown(_reason) {
72
- if (isShuttingDown) {
73
- return;
74
- }
75
- isShuttingDown = true;
76
- await runExitCleanup();
77
- process.exit(ExitCodes.SUCCESS);
78
- }
79
- function setupSignalHandlers() {
80
- process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
81
- process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
82
- process.on("SIGINT", () => gracefulShutdown("SIGINT"));
83
- }
84
- function setupTtyCheck() {
85
- let intervalId = null;
86
- let isCheckingTty = false;
87
- intervalId = setInterval(async () => {
88
- if (isCheckingTty || isShuttingDown) {
89
- return;
90
- }
91
- if (process.env["SANDBOX"]) {
92
- return;
93
- }
94
- if (!process.stdin.isTTY && !process.stdout.isTTY) {
95
- isCheckingTty = true;
96
- if (intervalId) {
97
- clearInterval(intervalId);
98
- intervalId = null;
99
- }
100
- await gracefulShutdown("TTY loss");
101
- }
102
- }, 5e3);
103
- intervalId.unref();
104
- return () => {
105
- if (intervalId) {
106
- clearInterval(intervalId);
107
- intervalId = null;
108
- }
109
- };
110
- }
111
- async function cleanupCheckpoints() {
112
- const storage = new Storage(process.cwd());
113
- await storage.initialize();
114
- const tempDir = storage.getProjectTempDir();
115
- const checkpointsDir = join(tempDir, "checkpoints");
116
- try {
117
- await fs.rm(checkpointsDir, { recursive: true, force: true });
118
- } catch {
119
- }
120
- }
121
-
122
- export {
123
- registerCleanup,
124
- registerSyncCleanup,
125
- resetCleanupForTesting,
126
- runSyncCleanup,
127
- registerTelemetryConfig,
128
- runExitCleanup,
129
- setupSignalHandlers,
130
- setupTtyCheck,
131
- cleanupCheckpoints
132
- };
133
- /**
134
- * @license
135
- * Copyright 2025 Google LLC
136
- * SPDX-License-Identifier: Apache-2.0
137
- */