Files
gemini-cli/packages/sdk
Michael Bleigh c7866e6a92 feat(sdk): implement runtime hooks support in GeminiCliAgent
- Introduced a new Hook type and hook() helper for strongly-typed SDK hooks.
- Integrated runtime hooks into GeminiCliSession lifecycle (startup, close, and tool execution).
- Added hooks option to GeminiCliAgentOptions.
- Exported executeToolWithHooks from core to facilitate SDK integration.
- Updated SDK_DESIGN.md to reflect implemented features and remaining tasks.
- Added and re-recorded SDK integration tests for hooks.
2026-02-25 13:44:16 -08:00
..

@google/gemini-cli-sdk

The Gemini CLI SDK provides a programmatic interface to interact with Gemini models and tools.

Installation

npm install @google/gemini-cli-sdk

Usage

import { GeminiCliAgent } from '@google/gemini-cli-sdk';

async function main() {
  const agent = new GeminiCliAgent({
    instructions: 'You are a helpful assistant.',
  });

  const controller = new AbortController();
  const signal = controller.signal;

  // Stream responses from the agent
  const stream = agent.sendStream('Why is the sky blue?', signal);

  for await (const chunk of stream) {
    if (chunk.type === 'content') {
      process.stdout.write(chunk.value.text || '');
    }
  }
}

main().catch(console.error);