@google/gemini-cli 0.46.0-preview.0 → 0.46.0-preview.2

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 (67) hide show
  1. package/bundle/{chunk-4AGOZ7LL.js → chunk-22XWYJCL.js} +7 -7
  2. package/bundle/{chunk-2GMVQS2Q.js → chunk-27JE2WT6.js} +1 -1
  3. package/bundle/{chunk-TDYUKPZH.js → chunk-2K6L5FOH.js} +1 -1
  4. package/bundle/{chunk-QFEJQS5X.js → chunk-3RBWPCUC.js} +1 -1
  5. package/bundle/{chunk-MFYAVF7Y.js → chunk-5IDNG2OG.js} +67 -54
  6. package/bundle/{chunk-BOJOJVNV.js → chunk-7JQYEHGG.js} +1 -1
  7. package/bundle/{chunk-J444UQD3.js → chunk-7PDJUYG7.js} +1 -1
  8. package/bundle/{chunk-ZXN4VW7M.js → chunk-B5F4VQB4.js} +1 -1
  9. package/bundle/{chunk-HZNEV3DS.js → chunk-CRQJBWDY.js} +1 -1
  10. package/bundle/{chunk-5LUCCXOB.js → chunk-CWVF4ZTK.js} +1 -1
  11. package/bundle/{chunk-HHFFICNK.js → chunk-E5QEVDYZ.js} +48 -25
  12. package/bundle/{chunk-FIM2LOYZ.js → chunk-EI75YPWJ.js} +42 -25
  13. package/bundle/chunk-IPUQ7EE3.js +81685 -0
  14. package/bundle/{chunk-S2ICEQVC.js → chunk-J5LPI3LE.js} +3 -3
  15. package/bundle/{chunk-RXG3JOOZ.js → chunk-LEOT5EUQ.js} +1 -1
  16. package/bundle/chunk-NV6UIB5A.js +1571 -0
  17. package/bundle/{chunk-XRDSBRG4.js → chunk-O6PTG534.js} +7560 -14072
  18. package/bundle/{chunk-F2LLVPPS.js → chunk-PE7HOVW5.js} +2 -2
  19. package/bundle/chunk-PIZZXDDG.js +154 -0
  20. package/bundle/{chunk-LBE2WKE7.js → chunk-PRRK6JDC.js} +3 -3
  21. package/bundle/{chunk-773AJHDP.js → chunk-QB7YVNGV.js} +7 -7
  22. package/bundle/{chunk-4K3E3G6Z.js → chunk-QW5AOX4N.js} +8 -5
  23. package/bundle/{chunk-HMR43ZX2.js → chunk-R4U5N4EA.js} +2 -2
  24. package/bundle/{chunk-SHFHGDWR.js → chunk-R4UEOSDC.js} +2 -2
  25. package/bundle/{chunk-GTRQQGSJ.js → chunk-RHCHEKOW.js} +1 -1
  26. package/bundle/{chunk-YMNECODB.js → chunk-RS7XVABE.js} +9 -8
  27. package/bundle/{chunk-ZQGZKIDD.js → chunk-SIKHBFAN.js} +3 -3
  28. package/bundle/chunk-UEE43LJM.js +118 -0
  29. package/bundle/chunk-UHZJ6CQN.js +17320 -0
  30. package/bundle/chunk-USOBCNPR.js +394545 -0
  31. package/bundle/chunk-WUZJ6YCQ.js +398 -0
  32. package/bundle/chunk-ZXFPRK6W.js +512 -0
  33. package/bundle/{cleanup-2WXD6UQP.js → cleanup-I5FUY2UQ.js} +2 -2
  34. package/bundle/{cleanup-L3CLNVX6.js → cleanup-OIBS4TJ5.js} +2 -2
  35. package/bundle/{cleanup-SUDL37MT.js → cleanup-RODT76X7.js} +2 -2
  36. package/bundle/cleanup-WY7MMPH7.js +32 -0
  37. package/bundle/{core-VVRQ2GQD.js → core-DU2UPBEJ.js} +3 -1
  38. package/bundle/{devtoolsService-GLW7S6PS.js → devtoolsService-C64GR2SQ.js} +2 -2
  39. package/bundle/{devtoolsService-ZYCBBAV3.js → devtoolsService-EJVCNXD4.js} +2 -2
  40. package/bundle/{devtoolsService-E62WA3CY.js → devtoolsService-LQXWZBCZ.js} +4 -3
  41. package/bundle/devtoolsService-U7Z6S7CA.js +856 -0
  42. package/bundle/{dist-GPCRVPKS.js → dist-CEGGZCD6.js} +3 -1
  43. package/bundle/{core-MOYKPEYV.js → dist-F4ZLD67R.js} +3 -1
  44. package/bundle/dist-XLM4ONR2.js +2140 -0
  45. package/bundle/docs/reference/configuration.md +3 -1
  46. package/bundle/{gemini-KV5CHM4H.js → gemini-3AA27X7W.js} +18 -15
  47. package/bundle/{gemini-2JTOIMGM.js → gemini-D5Y26G7I.js} +18 -15
  48. package/bundle/{gemini-R5NCXCEL.js → gemini-EEFZ4W4N.js} +216 -197
  49. package/bundle/gemini-TPWWVYVB.js +16409 -0
  50. package/bundle/gemini.js +7 -7
  51. package/bundle/{interactiveCli-RMWTSIEN.js → interactiveCli-5L4XUO4D.js} +18 -12
  52. package/bundle/{interactiveCli-HVAQTBJK.js → interactiveCli-B5QE2YQH.js} +18 -12
  53. package/bundle/{interactiveCli-7SIMXKNU.js → interactiveCli-CFKGEXFE.js} +324 -299
  54. package/bundle/interactiveCli-S4W3W3HM.js +34742 -0
  55. package/bundle/{liteRtServerManager-FY23PYSD.js → liteRtServerManager-2IHVDPV4.js} +4 -4
  56. package/bundle/{liteRtServerManager-LDS45QKP.js → liteRtServerManager-7CA6UZB6.js} +4 -4
  57. package/bundle/{liteRtServerManager-BP7XKGNU.js → liteRtServerManager-P4UUE4PT.js} +4 -4
  58. package/bundle/liteRtServerManager-YN3VGMDA.js +65 -0
  59. package/bundle/{oauth2-provider-VVNBQH45.js → oauth2-provider-5IAYEVTS.js} +1 -1
  60. package/bundle/{oauth2-provider-4SSSEI6P.js → oauth2-provider-NQK2KDLL.js} +38 -72
  61. package/bundle/{oauth2-provider-KL44D6HV.js → oauth2-provider-WD62E6UF.js} +1 -1
  62. package/bundle/oauth2-provider-WGTNZKF7.js +235 -0
  63. package/bundle/{start-FRM2XDGC.js → start-AAWVXW3L.js} +6 -6
  64. package/bundle/{start-OEPJINIW.js → start-EHQUCJL4.js} +6 -6
  65. package/bundle/{start-DLEOBFRC.js → start-EJWSTD4L.js} +6 -6
  66. package/bundle/start-LAOVDDQF.js +18 -0
  67. package/package.json +1 -1
@@ -1,13 +1,13 @@
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
  runExitCleanup
4
- } from "./chunk-QFEJQS5X.js";
4
+ } from "./chunk-LEOT5EUQ.js";
5
5
  import {
6
6
  RELEASE_CHANNEL_STABILITY,
7
7
  debugLogger,
8
8
  getChannelFromVersion,
9
9
  isGitRepository
10
- } from "./chunk-XRDSBRG4.js";
10
+ } from "./chunk-O6PTG534.js";
11
11
 
12
12
  // packages/cli/src/utils/installationInfo.ts
13
13
  import * as fs from "node:fs";
@@ -0,0 +1,154 @@
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
+ Storage,
5
+ isTelemetrySdkInitialized,
6
+ resetBrowserSession,
7
+ shutdownTelemetry
8
+ } from "./chunk-E5QEVDYZ.js";
9
+
10
+ // packages/cli/src/utils/cleanup.ts
11
+ import { promises as fs } from "node:fs";
12
+ import { join } from "node:path";
13
+ var cleanupFunctions = [];
14
+ var syncCleanupFunctions = [];
15
+ var configForTelemetry = null;
16
+ var isShuttingDown = false;
17
+ function registerCleanup(fn) {
18
+ cleanupFunctions.push(fn);
19
+ }
20
+ function removeCleanup(fn) {
21
+ const index = cleanupFunctions.indexOf(fn);
22
+ if (index !== -1) {
23
+ cleanupFunctions.splice(index, 1);
24
+ }
25
+ }
26
+ function registerSyncCleanup(fn) {
27
+ syncCleanupFunctions.push(fn);
28
+ }
29
+ function removeSyncCleanup(fn) {
30
+ const index = syncCleanupFunctions.indexOf(fn);
31
+ if (index !== -1) {
32
+ syncCleanupFunctions.splice(index, 1);
33
+ }
34
+ }
35
+ function resetCleanupForTesting() {
36
+ cleanupFunctions.length = 0;
37
+ syncCleanupFunctions.length = 0;
38
+ configForTelemetry = null;
39
+ isShuttingDown = false;
40
+ }
41
+ function runSyncCleanup() {
42
+ for (const fn of syncCleanupFunctions) {
43
+ try {
44
+ fn();
45
+ } catch {
46
+ }
47
+ }
48
+ syncCleanupFunctions.length = 0;
49
+ }
50
+ function registerTelemetryConfig(config) {
51
+ configForTelemetry = config;
52
+ }
53
+ async function runExitCleanup() {
54
+ await drainStdin();
55
+ runSyncCleanup();
56
+ for (const fn of cleanupFunctions) {
57
+ try {
58
+ await fn();
59
+ } catch {
60
+ }
61
+ }
62
+ cleanupFunctions.length = 0;
63
+ try {
64
+ await resetBrowserSession();
65
+ } catch {
66
+ }
67
+ if (configForTelemetry) {
68
+ try {
69
+ await configForTelemetry.dispose();
70
+ } catch {
71
+ }
72
+ }
73
+ if (configForTelemetry && isTelemetrySdkInitialized()) {
74
+ try {
75
+ await shutdownTelemetry(configForTelemetry);
76
+ } catch {
77
+ }
78
+ }
79
+ }
80
+ async function drainStdin() {
81
+ if (!process.stdin?.isTTY) return;
82
+ process.stdin.resume().removeAllListeners("data").on("data", () => {
83
+ });
84
+ await new Promise((resolve) => setTimeout(resolve, 50));
85
+ }
86
+ async function gracefulShutdown(_reason) {
87
+ if (isShuttingDown) {
88
+ return;
89
+ }
90
+ isShuttingDown = true;
91
+ await runExitCleanup();
92
+ process.exit(ExitCodes.SUCCESS);
93
+ }
94
+ function setupSignalHandlers() {
95
+ process.on("SIGHUP", () => gracefulShutdown("SIGHUP"));
96
+ process.on("SIGTERM", () => gracefulShutdown("SIGTERM"));
97
+ process.on("SIGINT", () => gracefulShutdown("SIGINT"));
98
+ }
99
+ function setupTtyCheck() {
100
+ let intervalId = null;
101
+ let isCheckingTty = false;
102
+ intervalId = setInterval(async () => {
103
+ if (isCheckingTty || isShuttingDown) {
104
+ return;
105
+ }
106
+ if (process.env["SANDBOX"]) {
107
+ return;
108
+ }
109
+ if (!process.stdin.isTTY && !process.stdout.isTTY) {
110
+ isCheckingTty = true;
111
+ if (intervalId) {
112
+ clearInterval(intervalId);
113
+ intervalId = null;
114
+ }
115
+ await gracefulShutdown("TTY loss");
116
+ }
117
+ }, 5e3);
118
+ intervalId.unref();
119
+ return () => {
120
+ if (intervalId) {
121
+ clearInterval(intervalId);
122
+ intervalId = null;
123
+ }
124
+ };
125
+ }
126
+ async function cleanupCheckpoints() {
127
+ const storage = new Storage(process.cwd());
128
+ await storage.initialize();
129
+ const tempDir = storage.getProjectTempDir();
130
+ const checkpointsDir = join(tempDir, "checkpoints");
131
+ try {
132
+ await fs.rm(checkpointsDir, { recursive: true, force: true });
133
+ } catch {
134
+ }
135
+ }
136
+
137
+ export {
138
+ registerCleanup,
139
+ removeCleanup,
140
+ registerSyncCleanup,
141
+ removeSyncCleanup,
142
+ resetCleanupForTesting,
143
+ runSyncCleanup,
144
+ registerTelemetryConfig,
145
+ runExitCleanup,
146
+ setupSignalHandlers,
147
+ setupTtyCheck,
148
+ cleanupCheckpoints
149
+ };
150
+ /**
151
+ * @license
152
+ * Copyright 2025 Google LLC
153
+ * SPDX-License-Identifier: Apache-2.0
154
+ */
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  exitCli,
4
4
  require_source
5
- } from "./chunk-HZNEV3DS.js";
5
+ } from "./chunk-7JQYEHGG.js";
6
6
  import {
7
7
  DEFAULT_PORT,
8
8
  SERVER_START_WAIT_MS,
@@ -14,10 +14,10 @@ import {
14
14
  isServerRunning,
15
15
  resolveGemmaConfig,
16
16
  writeServerProcessInfo
17
- } from "./chunk-ZXN4VW7M.js";
17
+ } from "./chunk-QW5AOX4N.js";
18
18
  import {
19
19
  debugLogger
20
- } from "./chunk-XRDSBRG4.js";
20
+ } from "./chunk-EI75YPWJ.js";
21
21
  import {
22
22
  __toESM
23
23
  } from "./chunk-34MYV7JD.js";
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  exitCli,
8
8
  require_source
9
- } from "./chunk-BOJOJVNV.js";
9
+ } from "./chunk-NV6UIB5A.js";
10
10
  import {
11
11
  DEFAULT_BACKGROUND_OPACITY,
12
12
  DEFAULT_BORDER_OPACITY,
@@ -58,14 +58,14 @@ import {
58
58
  stripUnsafeCharacters,
59
59
  toCodePoints,
60
60
  validateCustomTheme
61
- } from "./chunk-4K3E3G6Z.js";
61
+ } from "./chunk-B5F4VQB4.js";
62
62
  import {
63
63
  isDevelopment
64
- } from "./chunk-SHFHGDWR.js";
64
+ } from "./chunk-WUZJ6YCQ.js";
65
65
  import {
66
66
  emptyIcon,
67
67
  require_react
68
- } from "./chunk-TDYUKPZH.js";
68
+ } from "./chunk-2K6L5FOH.js";
69
69
  import {
70
70
  ALL_EDITORS,
71
71
  ApprovalMode,
@@ -230,7 +230,7 @@ import {
230
230
  tokenLimit,
231
231
  uiTelemetryService,
232
232
  unescapePath
233
- } from "./chunk-HHFFICNK.js";
233
+ } from "./chunk-E5QEVDYZ.js";
234
234
  import {
235
235
  require_src
236
236
  } from "./chunk-TUDYL3X4.js";
@@ -56501,7 +56501,7 @@ var authCommand = {
56501
56501
  import process28 from "node:process";
56502
56502
 
56503
56503
  // packages/cli/src/generated/git-commit.ts
56504
- var GIT_COMMIT_INFO = "cfcecebe8";
56504
+ var GIT_COMMIT_INFO = "310cae233";
56505
56505
 
56506
56506
  // packages/cli/src/ui/utils/historyExportUtils.ts
56507
56507
  import * as fsPromises from "node:fs/promises";
@@ -62262,7 +62262,7 @@ Use /mcp auth <server-name> to authenticate.`
62262
62262
  type: "info",
62263
62263
  text: `Starting OAuth authentication for MCP server '${serverName}'...`
62264
62264
  });
62265
- const { MCPOAuthProvider } = await import("./core-VVRQ2GQD.js");
62265
+ const { MCPOAuthProvider } = await import("./core-DU2UPBEJ.js");
62266
62266
  let oauthConfig = server.oauth;
62267
62267
  if (!oauthConfig) {
62268
62268
  oauthConfig = { enabled: false };
@@ -1,6 +1,9 @@
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
+ CoreEvent,
6
+ CoreToolCallStatus,
4
7
  DEFAULT_MODEL_CONFIGS,
5
8
  DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
6
9
  EDITOR_OPTIONS,
@@ -29,7 +32,7 @@ import {
29
32
  require_strip_json_comments,
30
33
  sanitizeFilenamePart,
31
34
  stripAnsi
32
- } from "./chunk-HHFFICNK.js";
35
+ } from "./chunk-EI75YPWJ.js";
33
36
  import {
34
37
  __commonJS,
35
38
  __require,
@@ -10217,7 +10220,7 @@ function convertSessionToHistoryFormats(messages) {
10217
10220
  args: tool.args,
10218
10221
  description: tool.description || "",
10219
10222
  renderOutputAsMarkdown: tool.renderOutputAsMarkdown ?? true,
10220
- status: tool.status === "success" ? "success" /* Success */ : "error" /* Error */,
10223
+ status: tool.status === "success" ? CoreToolCallStatus.Success : CoreToolCallStatus.Error,
10221
10224
  resultDisplay: tool.resultDisplay,
10222
10225
  confirmationDetails: void 0
10223
10226
  }))
@@ -16278,8 +16281,8 @@ var LoadedSettings = class {
16278
16281
  // React will pass a listener fn into this subscribe fn
16279
16282
  // that listener fn will perform an object identity check on the snapshot and trigger a React re render if the snapshot has changed
16280
16283
  subscribe(listener) {
16281
- coreEvents.on("settings-changed" /* SettingsChanged */, listener);
16282
- return () => coreEvents.off("settings-changed" /* SettingsChanged */, listener);
16284
+ coreEvents.on(CoreEvent.SettingsChanged, listener);
16285
+ return () => coreEvents.off(CoreEvent.SettingsChanged, listener);
16283
16286
  }
16284
16287
  getSnapshot() {
16285
16288
  return this._snapshot;
@@ -16423,7 +16426,7 @@ function setUpCloudShellEnvironment(envFilePath, isTrusted, isSandboxed, selecte
16423
16426
  }
16424
16427
  }
16425
16428
  let value = "cloudshell-gca";
16426
- if (selectedAuthType === "vertex-ai" /* USE_VERTEX_AI */) {
16429
+ if (selectedAuthType === AuthType.USE_VERTEX_AI) {
16427
16430
  value = process2.env[USER_GCP_PROJECT];
16428
16431
  }
16429
16432
  if (envFilePath && fs4.existsSync(envFilePath)) {
@@ -1,13 +1,13 @@
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
  runExitCleanup
4
- } from "./chunk-RXG3JOOZ.js";
4
+ } from "./chunk-3RBWPCUC.js";
5
5
  import {
6
6
  RELEASE_CHANNEL_STABILITY,
7
7
  debugLogger,
8
8
  getChannelFromVersion,
9
9
  isGitRepository
10
- } from "./chunk-FIM2LOYZ.js";
10
+ } from "./chunk-USOBCNPR.js";
11
11
 
12
12
  // packages/cli/src/utils/installationInfo.ts
13
13
  import * as fs from "node:fs";
@@ -1,13 +1,13 @@
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
  runExitCleanup
4
- } from "./chunk-2GMVQS2Q.js";
4
+ } from "./chunk-27JE2WT6.js";
5
5
  import {
6
6
  RELEASE_CHANNEL_STABILITY,
7
7
  debugLogger,
8
8
  getChannelFromVersion,
9
9
  isGitRepository
10
- } from "./chunk-HHFFICNK.js";
10
+ } from "./chunk-EI75YPWJ.js";
11
11
 
12
12
  // packages/cli/src/utils/installationInfo.ts
13
13
  import * as fs from "node:fs";
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  CoreToolCallStatus,
4
4
  checkExhaustive
5
- } from "./chunk-FIM2LOYZ.js";
5
+ } from "./chunk-EI75YPWJ.js";
6
6
  import {
7
7
  __commonJS,
8
8
  __toESM
@@ -1,7 +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
+ CoreToolCallStatus,
3
4
  checkExhaustive
4
- } from "./chunk-XRDSBRG4.js";
5
+ } from "./chunk-O6PTG534.js";
5
6
  import {
6
7
  __commonJS,
7
8
  __toESM
@@ -464,19 +465,19 @@ var require_react = __commonJS({
464
465
  var import_react = __toESM(require_react(), 1);
465
466
  function mapCoreStatusToDisplayStatus(coreStatus) {
466
467
  switch (coreStatus) {
467
- case "validating" /* Validating */:
468
+ case CoreToolCallStatus.Validating:
468
469
  return "Pending" /* Pending */;
469
- case "awaiting_approval" /* AwaitingApproval */:
470
+ case CoreToolCallStatus.AwaitingApproval:
470
471
  return "Confirming" /* Confirming */;
471
- case "executing" /* Executing */:
472
+ case CoreToolCallStatus.Executing:
472
473
  return "Executing" /* Executing */;
473
- case "success" /* Success */:
474
+ case CoreToolCallStatus.Success:
474
475
  return "Success" /* Success */;
475
- case "cancelled" /* Cancelled */:
476
+ case CoreToolCallStatus.Cancelled:
476
477
  return "Canceled" /* Canceled */;
477
- case "error" /* Error */:
478
+ case CoreToolCallStatus.Error:
478
479
  return "Error" /* Error */;
479
- case "scheduled" /* Scheduled */:
480
+ case CoreToolCallStatus.Scheduled:
480
481
  return "Pending" /* Pending */;
481
482
  default:
482
483
  return checkExhaustive(coreStatus);
@@ -2,7 +2,7 @@ const require = (await import('node:module')).createRequire(import.meta.url); co
2
2
  import {
3
3
  exitCli,
4
4
  require_source
5
- } from "./chunk-5LUCCXOB.js";
5
+ } from "./chunk-CRQJBWDY.js";
6
6
  import {
7
7
  DEFAULT_PORT,
8
8
  SERVER_START_WAIT_MS,
@@ -14,10 +14,10 @@ import {
14
14
  isServerRunning,
15
15
  resolveGemmaConfig,
16
16
  writeServerProcessInfo
17
- } from "./chunk-J444UQD3.js";
17
+ } from "./chunk-7PDJUYG7.js";
18
18
  import {
19
19
  debugLogger
20
- } from "./chunk-FIM2LOYZ.js";
20
+ } from "./chunk-USOBCNPR.js";
21
21
  import {
22
22
  __toESM
23
23
  } from "./chunk-34MYV7JD.js";
@@ -0,0 +1,118 @@
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
+ exitCli,
4
+ require_source
5
+ } from "./chunk-NV6UIB5A.js";
6
+ import {
7
+ DEFAULT_PORT,
8
+ SERVER_START_WAIT_MS,
9
+ getBinaryPath,
10
+ getLiteRtBinDir,
11
+ getLogFilePath,
12
+ getPidFilePath,
13
+ isBinaryInstalled,
14
+ isServerRunning,
15
+ resolveGemmaConfig,
16
+ writeServerProcessInfo
17
+ } from "./chunk-B5F4VQB4.js";
18
+ import {
19
+ debugLogger
20
+ } from "./chunk-E5QEVDYZ.js";
21
+ import {
22
+ __toESM
23
+ } from "./chunk-34MYV7JD.js";
24
+
25
+ // packages/cli/src/commands/gemma/start.ts
26
+ var import_chalk = __toESM(require_source(), 1);
27
+ import fs from "node:fs";
28
+ import path from "node:path";
29
+ import { spawn } from "node:child_process";
30
+ async function startServer(binaryPath, port) {
31
+ const alreadyRunning = await isServerRunning(port);
32
+ if (alreadyRunning) {
33
+ debugLogger.log(`LiteRT server already running on port ${port}`);
34
+ return true;
35
+ }
36
+ const logPath = getLogFilePath();
37
+ fs.mkdirSync(getLiteRtBinDir(), { recursive: true });
38
+ const tmpDir = path.dirname(getPidFilePath());
39
+ fs.mkdirSync(tmpDir, { recursive: true });
40
+ const logFd = fs.openSync(logPath, "a");
41
+ try {
42
+ const child = spawn(binaryPath, ["serve", `--port=${port}`, "--verbose"], {
43
+ detached: true,
44
+ stdio: ["ignore", logFd, logFd]
45
+ });
46
+ if (child.pid) {
47
+ writeServerProcessInfo({
48
+ pid: child.pid,
49
+ binaryPath,
50
+ port
51
+ });
52
+ }
53
+ child.unref();
54
+ } finally {
55
+ fs.closeSync(logFd);
56
+ }
57
+ await new Promise((resolve) => setTimeout(resolve, SERVER_START_WAIT_MS));
58
+ return isServerRunning(port);
59
+ }
60
+ var startCommand = {
61
+ command: "start",
62
+ describe: "Start the LiteRT-LM server",
63
+ builder: (yargs) => yargs.option("port", {
64
+ type: "number",
65
+ description: "Port for the LiteRT server"
66
+ }),
67
+ handler: async (argv) => {
68
+ let port;
69
+ if (argv["port"] !== void 0) {
70
+ port = Number(argv["port"]);
71
+ }
72
+ if (!port) {
73
+ const { configuredPort } = resolveGemmaConfig(DEFAULT_PORT);
74
+ port = configuredPort;
75
+ }
76
+ const binaryPath = getBinaryPath();
77
+ if (!binaryPath || !isBinaryInstalled(binaryPath)) {
78
+ debugLogger.error(
79
+ import_chalk.default.red(
80
+ 'LiteRT-LM binary not found. Run "gemini gemma setup" first.'
81
+ )
82
+ );
83
+ await exitCli(1);
84
+ return;
85
+ }
86
+ const alreadyRunning = await isServerRunning(port);
87
+ if (alreadyRunning) {
88
+ debugLogger.log(
89
+ import_chalk.default.green(`LiteRT server is already running on port ${port}.`)
90
+ );
91
+ await exitCli(0);
92
+ return;
93
+ }
94
+ debugLogger.log(`Starting LiteRT server on port ${port}...`);
95
+ const started = await startServer(binaryPath, port);
96
+ if (started) {
97
+ debugLogger.log(import_chalk.default.green(`LiteRT server started on port ${port}.`));
98
+ debugLogger.log(import_chalk.default.dim(`Logs: ${getLogFilePath()}`));
99
+ await exitCli(0);
100
+ } else {
101
+ debugLogger.error(
102
+ import_chalk.default.red("Server may not have started correctly. Check logs:")
103
+ );
104
+ debugLogger.error(import_chalk.default.dim(` ${getLogFilePath()}`));
105
+ await exitCli(1);
106
+ }
107
+ }
108
+ };
109
+
110
+ export {
111
+ startServer,
112
+ startCommand
113
+ };
114
+ /**
115
+ * @license
116
+ * Copyright 2026 Google LLC
117
+ * SPDX-License-Identifier: Apache-2.0
118
+ */