[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-77622":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":15,"forks30d":15,"starsTrendScore":19,"compositeScore":20,"rankGlobal":9,"rankLanguage":9,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":9,"pushedAt":9,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":15,"starSnapshotCount":15,"syncStatus":29,"lastSyncTime":30,"discoverSource":31},77622,"antigravity-sdk-python","google-antigravity\u002Fantigravity-sdk-python","google-antigravity","A Python library for building AI agents that leverage the full power of Google Antigravity.",null,"Python",1614,480,60,3,0,120,326,1141,360,21.05,"Apache License 2.0",false,"main",true,[],"2026-06-12 02:03:43","# Google Antigravity SDK\n\nThe Google Antigravity SDK is a Python SDK for building AI agents powered by\nAntigravity and Gemini. It provides a secure, scalable, and stateful\ninfrastructure layer that abstracts the agentic loop, letting you focus on what\nyour agent *does* rather than how it runs.\n\n## Installation\n\n```sh\npip install google-antigravity\n```\n\n> [!IMPORTANT]\n> The Google Antigravity SDK relies on a compiled runtime binary that is\n> included in the platform-specific wheels published to\n> [PyPI](https:\u002F\u002Fpypi.org\u002Fproject\u002Fgoogle-antigravity\u002F). **Cloning this\n> repository alone is not sufficient to run the SDK.** Always install from\n> PyPI with `pip install google-antigravity` to obtain the binary.\n\n## Quickstart\n\nGet started by running one of the [`examples\u002F`](examples\u002F), such as the\n`hello_world` example with:\n\n```sh\nexport GEMINI_API_KEY=\"your_api_key_here\"\npython .\u002Fexamples\u002Fgetting_started\u002Fhello_world.py\n```\n## Concepts\n\n### Simple Agent\n\nThe `Agent` class is the easiest way to get started. It manages the full\nlifecycle — binary discovery, tool wiring, hook registration, and policy\ndefaults — behind a single async context manager.\n\nThe `system_instructions` parameter is optional.\n\n```python\nimport asyncio\nfrom google.antigravity import Agent, LocalAgentConfig\n\nasync def main():\n    config = LocalAgentConfig(\n        system_instructions=\"You are an expert assistant for codebase navigation.\",\n        # api_key=\"your_api_key_here\",\n    )\n    async with Agent(config) as agent:\n        response = await agent.chat(\"What files are in the current directory?\")\n        print(await response.text())\n\nasync def run():\n    await main()\n\nif __name__ == \"__main__\":\n    asyncio.run(run())\n```\n\n### Streaming Responses\n\nTo stream agent output in real-time (e.g., for fluid UI or console applications), simply iterate over the `ChatResponse` object using an `async for` loop. The stream wrapper natively yields conversational `str` text tokens as they arrive, with zero network overhead:\n\n```python\nimport asyncio\nimport sys\nfrom google.antigravity import Agent, LocalAgentConfig\n\nasync def main():\n    config = LocalAgentConfig()\n    async with Agent(config) as agent:\n        # Returns instantly — does not block\n        response = await agent.chat(\"Write a short poem about space.\")\n        \n        async for token in response:\n            sys.stdout.write(token)\n            sys.stdout.flush()\n        print()\n\nasyncio.run(main())\n```\n\n### Sugared Thoughts & Tool Call Streams (Advanced)\n\nFor more complex use cases, you can also stream internal model reasoning\u002Fthinking or intercept tool call dispatches in real-time using dedicated async stream properties:\n\n```python\n# 1. Stream reasoning\u002Fthinking deltas\nasync for thought in response.thoughts:\n    show_thinking_bubble(thought)\n\n# 2. Stream strongly-typed ToolCall events\nasync for call in response.tool_calls:\n    show_executing_spinner(call.name)\n```\n\nBy default, `Agent` runs in **read-only mode** for safety. Pass\n`capabilities=CapabilitiesConfig()` to enable all tools (including writes).\n\n### Interactive Loop\n\n```python\nfrom google.antigravity import Agent, LocalAgentConfig, CapabilitiesConfig\nfrom google.antigravity.utils.interactive import run_interactive_loop\n\nconfig = LocalAgentConfig(\n    # api_key=\"your_api_key_here\",\n    capabilities=CapabilitiesConfig(),\n)\nasync with Agent(config) as agent:\n    await run_interactive_loop(agent)\n```\n\n### Advanced Usage with Conversation\n\nFor full control over the connection lifecycle, use `Conversation` with a\n`ConnectionStrategy` directly. `Conversation` is a stateful session that\naccumulates step history, provides a `chat()` convenience method, and exposes\nstate introspection:\n\n```python\nimport asyncio\nfrom google.antigravity.connections.local import LocalConnectionStrategy\nfrom google.antigravity.conversation.conversation import Conversation\nfrom google.antigravity.tools.tool_runner import ToolRunner\nfrom google.antigravity.types import GeminiConfig\n\nasync def main():\n    tool_runner = ToolRunner()\n    strategy = LocalConnectionStrategy(\n        tool_runner=tool_runner,\n        # gemini_config=GeminiConfig(api_key=\"your_api_key_here\"),\n    )\n    \n    async with Conversation.create(strategy) as conversation:\n        # High-level: one-call send + collect\n        response = await conversation.chat(\"What files are here?\")\n        print(await response.text())\n        \n        # Step history accumulates automatically\n        print(f\"Total steps: {len(conversation.history)}\")\n        print(f\"Turns: {conversation.turn_count}\")\n        print(f\"Last response: {conversation.last_response}\")\n        \n        # Low-level: streaming steps\n        await conversation.send(\"Tell me more.\")\n        async for step in conversation.receive_steps():\n            if step.is_complete_response:\n                print(step.content)\n\nasyncio.run(main())\n```\n\n## Features\n\n### Multimodal Ingestion\n\nPass rich multimedia file attachments (images, videos, audio, and documents) to the agent alongside textual instruction prompt lists.\n\nYou 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):\n\n```python\nfrom google.antigravity import Agent, LocalAgentConfig\nfrom google.antigravity.types import Image, from_file\n\nconfig = LocalAgentConfig(system_instructions=\"You are an expert software architect.\")\nasync with Agent(config) as agent:\n    # 1. Flat filesystem shortcut (automatically resolves as types.Document)\n    pdf_spec = from_file(\"spec.pdf\")\n    \n    # 2. Direct constructor instantiation (perfect for in-memory raw bytes)\n    chart_image = Image(\n        data=b\"raw_png_bytes_here\", \n        mime_type=\"image\u002Fpng\", \n        description=\"Architecture blueprint\"\n    )\n    \n    # Send a mixed list of text instructions and content classes\n    prompt = [\n        \"Analyze this chart against the specification and list three security vulnerabilities:\",\n        chart_image,\n        pdf_spec\n    ]\n    response = await agent.chat(prompt)\n    print(await response.text())\n```\n\n### Custom Tools\n\nRegister Python functions as tools that the agent can call:\n\n```python\ndef get_weather(city: str) -> str:\n    \"\"\"Returns the current weather for a city.\"\"\"\n    return f\"It's sunny in {city}.\"\n\nconfig = LocalAgentConfig(\n    tools=[get_weather],\n)\nasync with Agent(config) as agent:\n    response = await agent.chat(\"What's the weather in Tokyo?\")\n```\n\n### MCP Integration\n\nConnect to external [MCP](https:\u002F\u002Fmodelcontextprotocol.io\u002F) servers and expose\ntheir tools to the agent:\n\n```python\nfrom google.antigravity import Agent, LocalAgentConfig\nfrom google.antigravity.types import McpStdioServer\n\nconfig = LocalAgentConfig(\n    mcp_servers=[McpStdioServer(command=\"npx\", args=[\"my-mcp-server\"])],\n)\nasync with Agent(config) as agent:\n    response = await agent.chat(\"Use the MCP tools to help me.\")\n```\n\n### Hooks and Policies\n\nControl agent behavior with a declarative policy system:\n\n```python\nfrom google.antigravity import Agent, LocalAgentConfig, CapabilitiesConfig\nfrom google.antigravity.hooks.policy import deny, allow, ask_user, enforce\nfrom google.antigravity.utils.interactive import run_interactive_loop\n\npolicies = [\n    deny(\"*\"),                          # Block all tools by default\n    allow(\"view_file\"),                 # Allow reading files\n    ask_user(\"run_command\", handler=my_handler),  # Ask before running commands\n]\n\nconfig = LocalAgentConfig(\n    capabilities=CapabilitiesConfig(),\n    policies=policies,\n)\nasync with Agent(config) as agent:\n    await run_interactive_loop(agent)\n```\n\n### Triggers\n\nRun background tasks that react to external events and push messages into the\nagent:\n\n```python\nfrom google.antigravity import Agent, LocalAgentConfig\nfrom google.antigravity.triggers import every\nfrom google.antigravity.utils.interactive import run_interactive_loop\n\nasync def check_status(ctx):\n    await ctx.send(\"Check the deployment status.\")\n\nconfig = LocalAgentConfig(\n    triggers=[every(60, check_status)],\n)\nasync with Agent(config) as agent:\n    await run_interactive_loop(agent)\n```\n\n## Architecture\n\nThe SDK follows a three-layer architecture:\n\n| Layer | Purpose | Key Classes |\n|:------|:--------|:------------|\n| **Layer 1** — Simplified | High-level, batteries-included entry point | `Agent` |\n| **Layer 2** — Session | Stateful session with history and convenience methods | `Conversation`, `ChatResponse`, `Step`, `ToolCall`, `AgentConfig`, `HookRunner`, `ToolRunner`, `TriggerRunner` |\n| **Layer 3** — Adapter | Transport and backend abstraction | `Connection`, `ConnectionStrategy`, `LocalConnection` |\n\n## Component Documentation\n\nFor more detailed documentation on specific components, see:\n\n-   [Agent](google\u002Fantigravity\u002Fagent.py) — High-level, batteries-included entry point.\n-   [Connections](google\u002Fantigravity\u002Fconnections\u002FREADME.md) — Transport and backend abstraction.\n-   [Conversation](google\u002Fantigravity\u002Fconversation\u002FREADME.md) — Stateful session management.\n-   [Hooks](google\u002Fantigravity\u002Fhooks\u002FREADME.md) — Agent lifecycle interception and policies.\n-   [MCP](google\u002Fantigravity\u002Fmcp\u002FREADME.md) — Model Context Protocol integration.\n-   [Tools](google\u002Fantigravity\u002Ftools\u002FREADME.md) — In-process tool execution.\n-   [Triggers](google\u002Fantigravity\u002Ftriggers\u002FREADME.md) — Background tasks and external events.\n\n## License\n\n[Apache License 2.0](LICENSE)\n","Google Antigravity SDK 是一个用于构建基于Antigravity和Gemini的AI代理的Python开发工具包。它提供了一个安全、可扩展且具备状态管理能力的基础架构层，抽象了代理循环机制，使开发者可以专注于代理的功能实现而非其运行细节。该SDK支持通过简单的`Agent`类快速创建和管理AI代理，并提供了实时流式响应的能力，适合需要高效处理对话或命令的应用场景，如代码库导航助手等。此外，还允许高级用户通过异步流属性监控模型内部推理过程或工具调用事件，进一步增强了灵活性。适用于任何希望利用强大AI能力提升用户体验的开发项目。",2,"2026-06-11 03:55:41","CREATED_QUERY"]