Commit Graph

302 Commits

Author SHA1 Message Date
Jacob Richman aa386d135b Jacob314/memory fixes (#754)
Address multiple possible memory leaks found bystatic analysis of the codebase. The primary source of the leaks was event listeners on child processes and global objects that were not being properly removed, potentially causing their closures to be retained in memory indefinitely particularly for processes that did not exit.

There are two commits. A larger one made by gemini CLI and a smaller one by me to make sure we always disconnect child processes as part of the cleanup methods. These changes may not actually fix any leaks but do look like reasonable defensive coding to avoid leaking event listeners or child processes.

The following files were fixed:
This is Gemini's somewhat overconfident description of what it did.

packages/core/src/tools/shell.ts: Fixed a leak where an abortSignal listener was not being reliably removed.
packages/cli/src/utils/readStdin.ts: Fixed a significant leak where listeners on process.stdin were never removed.
packages/cli/src/utils/sandbox.ts: Fixed leaks in the imageExists and pullImage helper functions where listeners on spawned child processes were not being removed.
packages/core/src/tools/grep.ts: Fixed three separate leaks in the isCommandAvailable check and the git grep and system grep strategies due to un-removed listeners on child processes.
packages/core/src/tools/tool-registry.ts: Corrected a leak in the execute method of the DiscoveredTool class where listeners on the spawned tool process were not being removed.
2025-06-05 06:40:33 -07:00
Tolik Malibroda 4b2af10b04 fix: Fix piped input mode in sandbox (#739) 2025-06-04 08:24:33 +02:00
Olcan 12059eb4ca fix BUILD_SANDBOX env var for updating sandbox while running linked binary (#729) 2025-06-03 14:02:00 -07:00
Brandon Keiji e96fd677ee fix: do not try to pull development sandbox image from the internet (#725) 2025-06-03 19:32:17 +00:00
Allen Hutchison 7f20425c98 feat(cli): add pro model availability check and fallback to flash (#608) 2025-06-02 13:55:54 -07:00
Tommaso Sciortino 21fba832d1 Rename server->core (#638) 2025-05-30 18:25:47 -07:00
Brandon Keiji 0869fd168f fix(sandbox): pull sandbox image if it doesnt exist locally (#628) 2025-05-30 20:49:47 +00:00
Brandon Keiji 31a7affb74 feat(sandbox): use package config to dictate sandbox image name (#624) 2025-05-30 19:28:46 +00:00
Olcan 4b7248fc46 allow writing to user cache directory on macos (fixes use of lyria mcp server [to generate songs] under seatbelt) (#600) 2025-05-29 15:06:09 -07:00
Olcan 70277591c4 update email to gemini-cli-dev (#510) 2025-05-23 08:35:16 -07:00
Olcan 564a213ebe allow write to ~/.gitconfig in seatbelt profiles (#509) 2025-05-23 07:56:43 -07:00
Olcan 17e28036fa fix HOME in sandbox on cloudtops (linux) (#454) 2025-05-20 15:30:49 -07:00
Olcan 76cf5e9fc1 rename env vars GEMINI_CODE_{MODEL,SANDBOX,SANDBOX_IMAGE} (#411) 2025-05-17 17:28:44 -07:00
Olcan f3d9a499dd move sandbox-related messages to stderr (#363) 2025-05-15 10:54:30 -07:00
Brandon Keiji 7116ab9c29 fix: pass startup warnings to app as prop (#342) 2025-05-13 17:12:04 -07:00
Brandon Keiji 3be8b6dc34 fix(sandbox): default to current user profile for debian/ubuntu env (#337) 2025-05-13 21:13:54 +00:00
Brandon Keiji 8da7a71d9a refactor: shorten 'gemini' binary name (#329) 2025-05-13 10:49:45 -07:00
Taylor Mullen cf91f72c5c Remove terminal tool and dependencies.
- We now solely use the shell tool. This deletes all content around the legacy terminal tool so we can focus on improving the new Shell tool.
- Remove instances from sandboxing, tests, utilities etc.
2025-05-11 12:35:55 -07:00
Olcan 92c1279de6 sandbox/seatbelt-aware system prompt, support for custom seatbelt profiles under project settings (#304) 2025-05-09 11:33:05 -07:00
Olcan c58f879026 fix MCP under seatbelt, improve error handling (#301) 2025-05-09 09:02:14 -07:00
Olcan b35a3856a2 fix debugging with seatbelt, including in strict profile (#300) 2025-05-09 08:44:40 -07:00
Brandon Keiji 4741c9a6eb fix(sandbox): set --inspect-brk in production sandbox when env DEBUG is truthy (#295) 2025-05-08 21:12:19 -07:00
Olcan 6b0ac084b8 allow SEATBELT_PROFILE=none to disable seatbelt on macos (#296) 2025-05-08 15:52:04 -07:00
Olcan b1c449d11c refined sandbox/seatbelt log message, pass NODE_OPTIONS along to sandboxed node (#292) 2025-05-08 14:50:35 -07:00
Olcan 06e5dfd538 minor comment fix (#290) 2025-05-08 11:31:12 -07:00
Olcan b59a940057 adjust seatbelt to allow write into specific dirs under user home (#289) 2025-05-08 11:28:45 -07:00
Olcan 327bd5f836 rename SANDBOX_EXEC_PROFILE as SEATBELT_PROFILE, and fix another accidental rephrasing (#285) 2025-05-07 21:31:30 -07:00
Olcan d524309e3c use seatbelt on macos, with two profiles: minimal (default) which only restricts writes, and strict, which is deny-by-default and only allows specific operations (#283) 2025-05-07 20:03:29 -07:00
Brandon Keiji 739654bb25 fix(sandbox): consolidate dev and prod sandbox (#273) 2025-05-07 07:23:13 -07:00
Olcan cfdbea4dc2 make sandbox venv support more robust, allowing arbitrary venv path, and ignoring venv outside workdir (instead of erroring out) (#254) 2025-05-03 09:12:44 -07:00
Olcan 3a1abb07bf enable recreating a python virtual env (.venv folder) inside sandbox (#253) 2025-05-03 00:39:31 -07:00
Olcan 69d1c644d9 custom sandboxing via sandbox.Dockerfile and sandbox.bashrc in project settings (#249) 2025-05-02 14:07:40 -07:00
Olcan f237082c37 pass PATH and PYTHONPATH into sandbox, let sandbox scripts recognize user settings for sandbox (#247) 2025-05-02 12:04:22 -07:00
Olcan a7679db6e9 sandbox setting and argument (#243) 2025-05-02 08:15:46 -07:00
Olcan a386841947 mount user settings in sandbox (#239) 2025-05-01 12:08:24 -07:00
Olcan a18eea8c23 remove start_sandbox.sh script (#238) 2025-05-01 09:16:33 -07:00
Brandon Keiji 3aef883f4b refactor: make parseImageName more readable (#228) 2025-04-30 10:16:29 -07:00
Brandon Keiji 28fc2d0de3 refactor(sandbox): make cli path agnostic of docker container build rules (#226) 2025-04-30 00:39:00 -07:00
Brandon Keiji cb8a7f01ae refactor: move sandbox js code to its own module (#225) 2025-04-29 17:38:25 -07:00
Allen Hutchison 1a167b2ea5 Piped input (#104)
* New method for handling stdin. Bypass Ink, and output to stdout. Makes the CLI work like a typical Unix application when called with piped input.

* Fixing a few post-merge errors.

* Format code.

* Clean up lint and format errors.
2025-04-21 17:41:44 -07:00
Taylor Mullen 81f0f618f7 Fix Gemini Code's (GC) smarts.
- The tl;dr; is that GC couldn't see what the user was saying when tool call events happened in response. The rason why this was happening was because we were instantly invoking tools that the model told us to invoke and then instantly re-requesting. This resulted in the bug because the genai APIs can't update the chat history before a full response has been completed (doesn't know how to update if it's incomplete).
- To address the above issue I had to do quite the large refactor. The gist is that now turns truly drive everything on the server (vs. a server client split). This ensured that when we got tool invocations we could control when/how re-requesting would happen and then also ensure that history was updated. This change also meant that the server would act as an event publisher to enable the client to react to events rather than try and weave in complex logic between the events.
- A BIG change that this changeset incudes is the removal of all of the CLI tools in favor of the server tools.
- Removed some dead code as part of this
- **NOTE: Confirmations are still broken (they were broken prior to this); however, I've set them up to be able to work in the future, I'll dot hat in a follow up to be less breaking to others.**

Fixes https://b.corp.google.com/issues/412320087
2025-04-21 11:07:09 -04:00
Evan Senter 3fce6cea27 Starting to modularize into separate cli / server packages. (#55)
* Starting to move a lot of code into packages/server

* More of the massive refactor, builds and runs, some issues though.

* Fixing outstanding issue with double messages.

* Fixing a minor UI issue.

* Fixing the build post-merge.

* Running formatting.

* Addressing comments.
2025-04-19 19:45:42 +01:00
Tyler 4354458cad Add apache2 SPDX headers to all source files (#48) 2025-04-18 17:44:24 -07:00
Taylor Mullen 383b917784 Run npm run format
- This has the entirety of the changes.

Part of https://b.corp.google.com/issues/411720532
2025-04-18 18:10:57 -04:00
Taylor Mullen e7fa39112a Manually fix hooks and utils linting errors (partial)
- More changes are to come, this is truly a partial change in order to not disrupt as many people as possible.

Part of https://b.corp.google.com/issues/411384603
2025-04-18 17:51:16 -04:00
Jaana Dogan 3afaa8033b Introduce a config module to manage configuration (#22)
* Introduce a config module to manage configuration

* Remove public modifier
2025-04-18 11:12:18 -07:00
Taylor Mullen 7cd3b95317 Fix linting errors in a number of core and tool files (partial)
- As part of this work I also started building out errors.ts which will be a cumulation of error helpers to better handle the challenging `catch (error: unknown)` requirement.
- More changes are to come, this is truly a partial change in order to not disrupt as many people as possible.

Part of https://b.corp.google.com/issues/411384603
2025-04-18 14:02:09 -04:00
Taylor Mullen e0339993ae Initial auto-fixing of linting errors.
- This is the result of runing `npm lint -- -fix`
2025-04-18 12:41:02 -04:00
Evan Senter cb30351403 Adding a new parameter for model, and updating the default to 2.5 Flash. (#18) 2025-04-18 17:06:16 +01:00
Taylor Mullen cfc697a96d Run npm run format
- Also updated README.md accordingly.

Part of https://b.corp.google.com/issues/411384603
2025-04-17 15:29:34 -07:00