Skip to content

A "pure java" gemini-cli implementation, shell, files, google search and all that but ALSO the model can write and run any java code on the fly on the very jvm where this library is running. JIT compilation of java code written by the model and a child-first classloader. Model can decide the classpath of the code to be executed. Has a swing GUI .

License

Notifications You must be signed in to change notification settings

anahata-os/gemini-java-client

Repository files navigation

Sponsor anahata-os Maven Central Javadoc

gemini-java-client

Website | Anahata TV (YouTube) | Discord | v2 on its way!

Autonomous JVM Execution

The engine for Autonomous JVM Agents. The gemini-java-client is a pure-Java platform specially engineered to exploit the full power of the Google Gemini API. It provides the infrastructure for an AI to write, compile, and execute Java code in-process, turning your application into a host for autonomous agents that don't just suggest code—they live inside your JVM.

🚀 The Killer Advantage: Autonomous JVM Execution

While other AI tools are external observers, Anahata is an insider. It operates as an autonomous agent within your application's runtime, capable of executing any Java logic with any required classpath.

The "Any Classpath" Superpower

The agent isn't restricted to the libraries already in your project. It can:

  1. Identify a need for a specific library (e.g., Apache Commons, Jackson, or a specialized MIDI API).
  2. Download the JARs from Maven Central at runtime.
  3. Compile a Java class (Anahata.java) that implements java.util.concurrent.Callable.
  4. Execute the logic directly within the running JVM.

🏠 Real-World Agency: Beyond the IDE

Because the agent has full access to the host's shell and network, it can interact with the physical world. It's not just a coding assistant; it's a Hardware Orchestrator.

🎯 Prompts that prove the power:

  • "Explore my LAN and find any Smart TVs connected to the network." (Network discovery)
  • "Take a screenshot of the Lounge TV and show it to me." (Remote device introspection via ADB)
  • "Turn down the volume on the TV and play a Gal Gadot video." (IoT control)
  • "Perform a security assessment of my network and find open ports on local devices." (Security auditing)

🖼️ Visual Showcase

Deep Context & Token Precision

Augmented Context Token Heatmap Live Workspace
Context Providers Context Heatmap Live Workspace

Actionable Intelligence

Integrated Radio Google Search Tool Live Screen Capture
Radio Tool Google Search Screen Capture

Developer Experience

Embeddable Chat Panel Tool Documentation Java to Schema
Chat Panel Tools Java2Schema

Advanced Features

Schema Annotations Easy RAG Easy Tools
Schema Annotations Easy RAG Easy Tools

Why Choose the gemini-java-client?

1. Unmatched Local Tooling (Functions)

Our core innovation is the annotation-driven local tool system, which transforms your Java methods into powerful, AI-callable functions.

Feature Description Benefit
@AIToolMethod Define tools using simple Java annotations. Zero boilerplate for API schema generation.
Dynamic Code Execution (RunningJVM) The AI can compile and execute arbitrary Java code directly within the host JVM. Enables hot-reload development and complex calculations.
JIT & Maven Integration Download and use any library from Maven at runtime. Infinite extensibility for your AI assistant.
Context-Aware File I/O (LocalFiles) Tools for reading, writing, and managing files with built-in version checks. Ensures the AI always works with valid, up-to-date local files.
Shell Access (LocalShell) Execute native shell commands (bash -c) and capture output. Provides full control over the host operating system and network.

2. Superior Context & Session Management

We solve the token limit problem with intelligent, dependency-aware context management.

Feature Description Benefit
Prune-As-You-Go (PAYG) v2 Automatically removes old or stale tool calls and responses. Maximizes context window efficiency and reduces costs.
Stateful Resource Tracking Tracks resources loaded into context, marking them as STALE if changed on disk. Prevents the AI from working with outdated information.
Session Persistence (Kryo) Saves and loads the entire chat history using fast Kryo serialization. Instant session resume across application restarts.

Getting Started: Simple Integration

Integrating the AI agent into your Java application is now easier than ever.

import uno.anahata.ai.swing.ChatPanel;
import javax.swing.JFrame;

public class SimpleAiApp {
    public static void main(String[] args) {
        JFrame frame = new JFrame("My AI App");
        
        // 1. Create the ChatPanel (zero boilerplate!)
        ChatPanel chatPanel = new ChatPanel();

        // 2. Build the UI and add to frame
        frame.add(chatPanel);
        frame.setSize(800, 600);
        frame.setVisible(true);

        // 3. Start the session
        chatPanel.checkAutobackupOrStartupContent();
    }
}

Support the Project

Licensing

About

A "pure java" gemini-cli implementation, shell, files, google search and all that but ALSO the model can write and run any java code on the fly on the very jvm where this library is running. JIT compilation of java code written by the model and a child-first classloader. Model can decide the classpath of the code to be executed. Has a swing GUI .

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages