npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

antigravity-sdk-ts

v0.1.1

Published

TypeScript SDK for Google Antigravity

Readme

Google Antigravity TypeScript SDK

The Google Antigravity SDK is a TypeScript/JavaScript SDK for building AI agents powered by Antigravity and Gemini. It provides a secure, scalable, and stateful infrastructure layer that abstracts the agentic loop, letting you focus on what your agent does rather than how it runs.

Installation

npm install antigravity-sdk-ts

[!IMPORTANT] The Google Antigravity SDK relies on a compiled runtime binary (localharness) to orchestrate agent loops. Ensure this runtime is installed and accessible on your system PATH before running the SDK.

Quickstart

Get started by running one of the examples or running the hello world script:

import { Agent, LocalAgentConfig } from 'antigravity-sdk-ts';

async function main() {
  const config = new LocalAgentConfig({
    systemInstructions: 'You are an expert assistant for codebase navigation.',
  });
  
  const agent = new Agent(config);
  await agent.start();
  
  try {
    const response = await agent.chat('What files are in the current directory?');
    console.log(await response.text());
  } finally {
    await agent.close();
  }
}

main().catch(console.error);

Concepts

Simple Agent

The Agent class is the easiest way to get started. It manages the full lifecycle — binary discovery, tool wiring, hook registration, and policy defaults.

You can also use modern Explicit Resource Management (using statements with Symbol.asyncDispose) if your environment supports it:

import { Agent, LocalAgentConfig } from 'antigravity-sdk-ts';

async function main() {
  const config = new LocalAgentConfig();
  
  // Uses Symbol.asyncDispose to automatically clean up resources when exiting block
  await using agent = await new Agent(config).start();
  
  const response = await agent.chat('Hello!');
  console.log(await response.text());
}

Streaming Responses

To stream agent output in real-time (e.g., for fluid UI or console applications), iterate over the ChatResponse object using a for await...of loop:

import { Agent, LocalAgentConfig } from 'antigravity-sdk-ts';

async function main() {
  const config = new LocalAgentConfig();
  const agent = new Agent(config);
  await agent.start();
  
  try {
    const response = await agent.chat('Write a short poem about space.');
    
    for await (const token of response) {
      process.stdout.write(token);
    }
    console.log();
  } finally {
    await agent.close();
  }
}

Sugared Thoughts & Tool Call Streams (Advanced)

For more complex use cases, you can also stream internal model reasoning/thinking or intercept tool call dispatches in real-time using dedicated async generator methods:

// 1. Stream reasoning/thinking deltas
for await (const thought of response.thoughts()) {
  showThinkingBubble(thought);
}

// 2. Stream strongly-typed ToolCall events
for await (const call of response.toolCalls()) {
  showExecutingSpinner(call.name);
}

By default, Agent runs in read-only mode for safety. Pass a custom CapabilitiesConfig to enable write tools or other modifications.

Interactive Loop

import { Agent, LocalAgentConfig, CapabilitiesConfig, runInteractiveLoop } from 'antigravity-sdk-ts';

const config = new LocalAgentConfig({
  capabilities: new CapabilitiesConfig(),
});
const agent = new Agent(config);
await agent.start();

try {
  await runInteractiveLoop(agent);
} finally {
  await agent.close();
}

Advanced Usage with Conversation

For full control over the connection lifecycle, use Conversation with a ConnectionStrategy directly. Conversation is a stateful session that accumulates step history, provides a chat() convenience method, and exposes state introspection:

import {
  LocalConnectionStrategy,
  Conversation,
  ToolRunner,
} from 'antigravity-sdk-ts';

async function main() {
  const toolRunner = new ToolRunner();
  const strategy = new LocalConnectionStrategy(toolRunner);
  
  // Setup strategy connection
  await strategy.__aenter__();
  
  try {
    const connection = strategy.connect();
    const conversation = new Conversation(connection);
    
    // High-level: one-call send + collect
    const response = await conversation.chat('What files are here?');
    console.log(await response.text());
    
    // Step history accumulates automatically
    console.log(`Turns: ${conversation.turnCount}`);
    
    // Low-level: streaming steps
    await conversation.send('Tell me more.');
    for await (const step of conversation.receiveSteps()) {
      if (step.isCompleteResponse) {
        console.log(step.content);
      }
    }
  } finally {
    await strategy.__aexit__();
  }
}

Features

Multimodal Ingestion

Pass rich multimedia file attachments (images, videos, audio, and documents) to the agent alongside textual instructions.

You can attach assets directly using content classes (perfect for in-memory bytes) or conveniently from a filesystem path (which automatically resolves types and guesses MIME formats):

import { Agent, LocalAgentConfig, Image, fromFile } from 'antigravity-sdk-ts';

const config = new LocalAgentConfig();
const agent = new Agent(config);
await agent.start();

try {
  // 1. Filesystem shortcut (automatically resolves file extension and reads contents)
  const pdfSpec = fromFile('spec.pdf');
  
  // 2. Direct constructor instantiation (perfect for in-memory raw bytes)
  const chartImage = new Image(
    new Uint8Array([/* raw PNG bytes */]), 
    'image/png', 
    'Architecture blueprint'
  );
  
  // Send a mixed list of text instructions and content classes
  const prompt = [
    'Analyze this chart against the specification and list three security vulnerabilities:',
    chartImage,
    pdfSpec
  ];
  
  const response = await agent.chat(prompt);
  console.log(await response.text());
} finally {
  await agent.close();
}

Custom Tools

Register TypeScript functions wrapped in ToolWithSchema as tools that the agent can call:

import { Agent, LocalAgentConfig, ToolWithSchema } from 'antigravity-sdk-ts';

function getWeatherFn(args: { city: string }): string {
  return `It's sunny in ${args.city}.`;
}

const getWeather = new ToolWithSchema(
  getWeatherFn,
  {
    type: 'object',
    properties: {
      city: { type: 'string', description: 'The city to get weather for' }
    },
    required: ['city']
  },
  'get_weather',
  'Returns the current weather for a city.'
);

const config = new LocalAgentConfig({
  tools: [getWeather],
});
const agent = new Agent(config);
await agent.start();

try {
  const response = await agent.chat("What's the weather in Tokyo?");
  console.log(await response.text());
} finally {
  await agent.close();
}

MCP Integration

Connect to external MCP servers and expose their tools to the agent:

import { Agent, LocalAgentConfig } from 'antigravity-sdk-ts';

const config = new LocalAgentConfig({
  mcpServers: [
    {
      type: 'stdio',
      command: 'npx',
      args: ['-y', '@modelcontextprotocol/server-postgres', 'postgresql://localhost/mydb']
    }
  ],
});
const agent = new Agent(config);
await agent.start();

try {
  const response = await agent.chat('Query the database.');
} finally {
  await agent.close();
}

Hooks and Policies

Control agent behavior with a declarative policy system:

import { Agent, LocalAgentConfig, CapabilitiesConfig, policy } from 'antigravity-sdk-ts';

const policies = [
  policy.denyAll(),                    // Block all tools by default
  policy.allow('view_file'),           // Allow reading files
  policy.askUser('run_command', myApprovalHandler), // Ask before running commands
];

const config = new LocalAgentConfig({
  capabilities: new CapabilitiesConfig(),
  policies: policies,
});

Triggers

Run background tasks that react to external events and push messages into the agent:

import { Agent, LocalAgentConfig, every, runInteractiveLoop } from 'antigravity-sdk-ts';

async function checkStatus(ctx: any) {
  await ctx.send('Check the deployment status.');
}

const config = new LocalAgentConfig({
  triggers: [every(60, checkStatus)],
});
const agent = new Agent(config);
await agent.start();

try {
  await runInteractiveLoop(agent);
} finally {
  await agent.close();
}

Architecture

The SDK follows a three-layer architecture:

| Layer | Purpose | Key Classes | |:------|:--------|:------------| | Layer 1 — Simplified | High-level, batteries-included entry point | Agent | | Layer 2 — Session | Stateful session with history and convenience methods | Conversation, ChatResponse, Step, ToolCall, AgentConfig, HookRunner, ToolRunner, TriggerRunner | | Layer 3 — Adapter | Transport and backend abstraction | Connection, ConnectionStrategy, LocalConnection |

License

MIT License