محیطها، سندباکسهای لینوکس مدیریتشدهای هستند که به عاملها مکانی ایزوله برای اجرای کد و ذخیره فایلها میدهند. آنها از زمینه تعامل جدا هستند، بنابراین میتوانید از همان محیط در چندین تعامل استفاده مجدد کنید یا در هر زمان از نو شروع کنید.
مثال زیر نحوه ایجاد تعامل با یک محیط ریموت جدید و بازیابی شناسه آن را نشان میدهد:
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Install pandas and matplotlib, verify the imports, and print the versions.",
environment="remote",
)
print(f"Environment ID: {interaction.environment_id}")
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Install pandas and matplotlib, verify the imports, and print the versions.",
environment: "remote",
});
console.log(`Environment ID: ${interaction.environment_id}`);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Install pandas and matplotlib, verify the imports, and print the versions.",
"environment": "remote"
}'
پارامتر environment
پارامتر environment سه حالت را میپذیرد:
| فرم | مثال | چه زمانی استفاده شود |
|---|---|---|
"remote" | environment="remote" | یک گودال ماسهای تازه تهیه کنید. |
| شناسه محیط | environment="env_abc123" | استفاده مجدد از یک سندباکس موجود به همراه تمام فایلها و بستههای آن. |
| شیء پیکربندی | environment={...} | یک سندباکس جدید با منابع، قوانین شبکه یا هر دو فراهم کنید. |
مثالهای زیر سه روش استفاده از پارامتر environment را نشان میدهند.
پایتون
from google import genai
client = genai.Client()
# Fresh sandbox
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a hello world script.",
environment="remote",
)
# Reuse an existing sandbox
interaction_2 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Modify the script to accept a name argument.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# New sandbox with sources
interaction_3 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List all files and summarize the project.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
}
],
},
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// Fresh sandbox
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Write a hello world script.",
environment: "remote",
});
// Reuse an existing sandbox
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Modify the script to accept a name argument.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
// New sandbox with sources
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List all files and summarize the project.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
],
},
});
console.log(interaction.output_text);
استراحت
# Fresh sandbox
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": [{"type": "text", "text": "Write a hello world script."}],
"environment": "remote"
}'
# Reuse an existing sandbox (replace $ENV_ID and $INTERACTION_ID with values from the previous response)
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d "{
\"agent\": \"antigravity-preview-05-2026\",
\"input\": [{\"type\": \"text\", \"text\": \"Modify the script to accept a name argument.\"}],
\"environment\": \"$ENV_ID\",
\"previous_interaction_id\": \"$INTERACTION_ID\"
}"
# New sandbox with sources
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": [{"type": "text", "text": "List all files and summarize the project."}],
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
}
]
}
}'
پیکربندی یک محیط
یک راه برای راهاندازی یک محیط این است که به عامل بگویید چه چیزی را میخواهید نصب کنید. این عامل، تجزیه و تحلیل وابستگیها و عیبیابی را مدیریت میکند. پس از آماده شدن محیط، environment_id ذخیره کرده و دوباره از آن استفاده کنید.
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment="remote",
)
# Reuse the configured environment
interaction_2 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment=interaction.environment_id,
previous_interaction_id=interaction.id,
)
# Reuse the configured environment
interaction_3 = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Using the tools in /workspace/tools, list the files.",
environment=interaction.environment_id,
previous_interaction_id=interaction_2.id,
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
environment: "remote",
});
const interaction2 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Clone https://github.com/octocat/Spoon-Knife into /workspace/tools. Run the test suite and fix any missing dependencies.",
environment: interaction.environment_id,
previous_interaction_id: interaction.id,
});
const interaction3 = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Using the tools in /workspace/tools, list the files.",
environment: interaction.environment_id,
previous_interaction_id: interaction2.id,
});
console.log(interaction.output_text);
استراحت
# Create interaction
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Install pandas, matplotlib, and seaborn. Verify all imports work and print the installed versions.",
"environment": "remote"
}'
از یک منبع نصب کنید
اگر دقیقاً میدانید که عامل به چه فایلهایی نیاز دارد، میتوانید به جای تکرار، آنها را در یک فراخوانی واحد mount کنید. شیء پیکربندی environment ، آرایهای sources با سه نوع را میپذیرد:
| نوع منبع | type مقدار | توضیحات | حد |
|---|---|---|---|
| مخزن گیت | repository | یک مخزن را از یک URL در sandbox در target کپی میکند. | ۵۰۰ مگابایت |
| فضای ذخیرهسازی ابری | gcs | یک فایل یا دایرکتوری را از فضای ذخیرهسازی ابری به داخل سندباکس در target کپی میکند. | ۲ گیگابایت |
| محتوای درونخطی | inline | محتوای متنی خام را در فایلی در sandbox در target مینویسد. | ۱ مگابایت برای هر فایل، مجموعاً ۲ مگابایت |
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List all files under /workspace and describe what you find.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife",
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data",
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md",
},
],
},
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List all files under /workspace and describe what you find.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/octocat/Spoon-Knife",
target: "/workspace/spoon-knife",
},
{
type: "gcs",
source: "gs://cloud-samples-data/bigquery/us-states/",
target: "/workspace/gcs-data",
},
{
type: "inline",
content: "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
target: "/workspace/notes/readme.md",
},
],
},
});
console.log(interaction.output_text);
استراحت
# Create interaction with sources
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "List all files under /workspace and describe what you find.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/octocat/Spoon-Knife",
"target": "/workspace/spoon-knife"
},
{
"type": "gcs",
"source": "gs://cloud-samples-data/bigquery/us-states/",
"target": "/workspace/gcs-data"
},
{
"type": "inline",
"content": "# Project Notes\n\n- Analyze state population data\n- Create visualizations\n",
"target": "/workspace/notes/readme.md"
}
]
}
}'
شما میتوانید هر دو رویکرد را با هم ترکیب کنید: منابع شناخته شده را به صورت اعلانی mount کنید، سپس با تعاملات بعدی برای نصب بستهها یا اجرای اسکریپتهای راهاندازی، تکرار کنید. هنگام افزودن یک منبع سفارشی، نمیتوانید root ( / ) را به عنوان هدف تعیین کنید، همیشه باید یک زیرشاخه مشخص کنید.
منابع خصوصی
همچنین میتوانید با اضافه کردن اعتبارنامهها در پیکربندی شبکه، از مخازن خصوصی گیتهاب یا مخازن خصوصی ذخیرهسازی ابری دانلود کنید:
برای مخازن خصوصی گیت ، از احراز هویت Basic با توکن دسترسی شخصی گیتهاب (PAT) خود استفاده کنید. توکن را با استفاده از x-oauth-basic به عنوان نام کاربری رمزگذاری کنید:
echo -n "x-oauth-basic:ghp_YourPATHere" | base64
پایتون
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Run the test for my backend app and fix any issue.",
environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Run the test for my backend app and fix any issue.",
environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/your-org/backend",
target: "/backend-app"
}
],
network: {
allowlist: [
{
domain: "github.com",
transform: {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Run the test for my backend app and fix any issue.",
"environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/your-org/backend",
"target": "/backend-app"
}
],
"network": {
"allowlist": [
{
"domain": "github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
برای مخازن ذخیرهسازی ابری خصوصی ، از یک توکن استاندارد OAuth 2.0 Bearer استفاده کنید:
gcloud auth print-access-token
پایتون
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the discrepancies across the data in workspace",
environment={
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace",
}
],
"network": {
"allowlist": [
{
"domain": "*.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
},
)
جاوا اسکریپت
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the discrepancies across the data in workspace",
environment: {
type: "remote",
sources: [
{
type: "gcs",
source: "gs://my-private-bucket/data",
target: "/workspace",
}
],
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
domain: "*"
}
]
}
},
});
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Analyze the discrepancies across the data in workspace",
"environment": {
"type": "remote",
"sources": [
{
"type": "gcs",
"source": "gs://my-private-bucket/data",
"target": "/workspace"
}
],
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer YOUR_GCS_TOKEN"
}
},
{
"domain": "*"
}
]
}
}
}'
نرمافزارهای از پیش نصبشده
این سندباکس روی اوبونتو اجرا میشود و با زمانهای اجرا و بستههای رایج از پیش نصب شده ارائه میشود. عامل میتواند بستههای اضافی را در زمان اجرا با استفاده از pip install یا npm install نصب کند. بستههای نصب شده در طول یک تعامل، هنگام استفاده مجدد از همان environment_id ، همچنان باقی میمانند.
| دسته بندی | بستههای از پیش نصبشده |
|---|---|
| ابزارهای یونیکس | curl ، wget ، git ، rsync ، unzip ، ripgrep ، fd-find ، gawk ، bc ، tree ، which ، lsof ، htop ، jq ، iproute2 ، procps ، gcloud CLI |
| پایتون ۳.۱۲ | numpy ، pandas ، requests ، google-genai ، beautifulsoup4 ، pyyaml ، ast-grep-cli |
| نود جی اس ۲۲ | create-next-app ، create-vite ، typescript |
پیکربندی شبکه
به طور پیشفرض، محیطها دسترسی نامحدود به شبکه خروجی دارند. از فیلد network برای محدود کردن ترافیک خروجی به دامنههای خاص استفاده کنید. هر قانون یک domain و یک شیء transform اختیاری را برای تزریق هدرها به درخواستهای منطبق مشخص میکند. این هدرها میتوانند برای هر تعامل منحصر به فرد باشند و شما میتوانید آنها را برای همان محیط بهروزرسانی کنید.
| میدان | نوع | توضیحات |
|---|---|---|
domain | string | دامنه مورد نظر. از نام میزبان دقیق یا * برای همه دامنهها استفاده کنید. |
transform | object | شیء حاوی جفتهای کلید-مقدار مسطح که نشاندهندهی هدرهایی برای تزریق به درخواستهای منطبق هستند، مثلاً {"Authorization": "Bearer ..."} . |
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
},
},
{"domain": "pypi.org"},
{"domain": "*"},
]
},
},
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Fetch the latest issues from the GitHub API for my-org/my-repo.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Bearer ghp_your_github_token"
},
},
{ domain: "pypi.org" },
{ domain: "*" },
]
}
},
});
console.log(interaction.output_text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": [{"type": "text", "text": "Fetch the latest issues from the GitHub API for my-org/my-repo."}],
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_your_github_token"
}
},
{"domain": "pypi.org"},
{"domain": "*"}
]
}
}
}'
وقتی یک لیست مجاز تنظیم میشود، فقط درخواستها به دامنههایی که صریحاً فهرست شدهاند مجاز هستند. میتوانید از کاراکترهای جایگزین برای تطبیق زیر دامنهها استفاده کنید (مثلاً {"domain": "*.example.com"} )، اما توجه داشته باشید که این با دامنه ریشه example.com که باید جداگانه اضافه شود، مطابقت ندارد. برای مجاز کردن سایر ترافیکها، مانند مسیریابی دامنههای فهرست نشده بدون هدرهای تزریق شده، {"domain": "*"} را به عنوان یک ورودی catch-all اضافه کنید.
مدارک تحصیلی
شما میتوانید با اضافه کردن تبدیلهای هدر، اعتبارنامههایی را برای استفادهی عامل خود اضافه کنید. اعتبارنامهها توسط یک پروکسی خروجی در هدرهای HTTP مربوطه تزریق میشوند و هرگز به عنوان متغیرهای محیطی یا فایلها در داخل sandbox نمایش داده نمیشوند.
پایتون
import subprocess
from google import genai
# Fetch a short-lived access token from your local gcloud CLI
gcloud_token = subprocess.check_output(
["gcloud", "auth", "print-access-token"], text=True
).strip()
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": f"Bearer {gcloud_token}"
},
}
]
},
},
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
const gcloudToken = execSync("gcloud auth print-access-token").toString().trim();
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "storage.googleapis.com",
transform: {
"Authorization": `Bearer ${gcloudToken}`
},
}
]
}
},
});
console.log(interaction.output_text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "List the files in gs://my-bucket/reports/ using the GCS JSON API.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "storage.googleapis.com",
"transform": {
"Authorization": "Bearer <YOUR_GCLOUD_TOKEN>"
}
}
]
}
}
}'
دسترسی به شبکه را غیرفعال کنید
برای مسدود کردن تمام دسترسیهای شبکهی خروجی، network را disabled کنید:
پایتون
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the local files only.",
environment={
"type": "remote",
"network": "disabled",
},
)
print(interaction.output_text)
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the local files only.",
environment: {
type: "remote",
network: "disabled",
},
});
console.log(interaction.output_text);
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Analyze the local files only.",
"environment": {
"type": "remote",
"network": "disabled"
}
}'
چرخه حیات محیط زیست
محیطها از این چرخه حیات پیروی میکنند:
| ایالت | رفتار |
|---|---|
| ایجاد شده | زمانی فراهم میشود که یک تعامل، environment: "remote" یا یک شیء پیکربندی. |
| فعال | دویدن در حین انجام یک تعامل. |
| بیکار | عکس فوری خودکار و پس از ۱۵ دقیقه عدم فعالیت متوقف میشود. |
| آفلاین | از آخرین فعالیت به مدت ۷ روز نگهداری میشود. با وارد کردن شناسهاش میتوان آن را از سر گرفت. |
| حذف شده | از سیستم حذف شد. |
دانلود فایلها از محیط
عامل در حین اجرا، فایلهایی را درون جعبه شنی ایجاد میکند. میتوانید با استفاده از API فایلها، تصویر لحظهای کامل محیط را به صورت یک فایل tar دانلود کنید:
پایتون
import os
import requests
import tarfile
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Write a file environments_test.txt with content 'Environments' inside the sandbox.",
environment="remote",
)
env_id = interaction.environment_id
api_key = os.environ.get("GEMINI_API_KEY")
response = requests.get(
f"https://generativelanguage.googleapis.com/v1beta/files/environment-{env_id}:download",
params={"alt": "media"},
headers={"x-goog-api-key": api_key},
allow_redirects=True,
)
with open("snapshot_env.tar", "wb") as f:
f.write(response.content)
os.makedirs("extracted_env_snapshot", exist_ok=True)
with tarfile.open("snapshot_env.tar") as tar:
tar.extractall(path="extracted_env_snapshot")
print(os.listdir("extracted_env_snapshot"))
جاوا اسکریپت
import { GoogleGenAI } from "@google/genai";
import { execSync } from "child_process";
import * as fs from "fs";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Write a file environments_test.txt with content 'Environments' inside the sandbox.",
environment: "remote",
});
const envId = interaction.environment_id;
const apiKey = process.env.GEMINI_API_KEY || "";
const url = `https://generativelanguage.googleapis.com/v1beta/files/environment-${envId}:download?alt=media`;
const response = await fetch(url, {
headers: {
"x-goog-api-key": apiKey,
},
});
if (!response.ok) {
throw new Error(`Failed to download file: ${response.statusText}`);
}
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("snapshot_env.tar", buffer);
if (!fs.existsSync("extracted_env_snapshot")) {
fs.mkdirSync("extracted_env_snapshot");
}
execSync("tar -xf snapshot_env.tar -C extracted_env_snapshot");
console.log(fs.readdirSync("extracted_env_snapshot"));
استراحت
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Write a file environments_test.txt with content '\''Environments'\'' inside the sandbox.",
"environment": "remote"
}'
# Step 2: Download snapshot (reusing environment ID from Step 1)
# curl -L -X GET "https://generativelanguage.googleapis.com/v1beta/files/environment-$ENV_ID:download?alt=media" \
# -H "x-goog-api-key: $API_KEY" \
# -o snapshot.tar
قیمتگذاری و منابع
هر محیط با تخصیص منابع ثابت اجرا میشود:
| منبع | ارزش |
|---|---|
| پردازنده | ۴ هسته |
| حافظه | ۱۶ گیگابایت |
محاسبات محیطی (پردازنده، حافظه، اجرای سندباکس) در طول دوره پیشنمایش هزینهای ندارد . برای اطلاع از هزینههای توکن عامل، به بخش قیمتگذاری مراجعه کنید.
محدودیتها
- وضعیت پیشنمایش: محیطها و عاملهای مدیریتشده در پیشنمایش هستند. ویژگیها و طرحوارهها ممکن است تغییر کنند.
- اندازه منبع درونخطی: منابع درونخطی به ۱ مگابایت برای هر فایل و ۲ مگابایت در مجموع برای همه فایلها محدود میشوند.
- اندازه منبع : مخازن گیت به ۵۰۰ مگابایت و مخازن ذخیرهسازی ابری به ۲ گیگابایت محدود شدهاند.
- راهاندازی محیط: آمادهسازی یک محیط جدید تا حدود ۵ ثانیه طول میکشد. مخازن منبع بزرگ ممکن است این زمان را افزایش دهند.
- پشتیبانی فایل: این عامل در حال حاضر محدود به خواندن فایلهای متنی و تصویری است. پشتیبانی از فایلهای باینری هنوز در دسترس نیست.
- عدم نصب از ریشه: هنگام افزودن یک منبع سفارشی، نمیتوانید ریشه (
/) را به عنوان هدف تنظیم کنید، همیشه باید یک زیرشاخه مشخص کنید.
قدم بعدی چیست؟
- مرور کلی عاملها : با مفاهیم اصلی عاملهای مدیریتشده آشنا شوید.
- شروع سریع : شروع به ساختن با مکالمات و پخش جریانی چند نوبته کنید.
- عامل ضد جاذبه : قابلیتها، ابزارها و قیمتگذاری عامل پیشفرض را بررسی کنید.
- ساخت عاملهای سفارشی : عاملهای خودتان را با استفاده از
AGENTS.mdوSKILL.mdتعریف کنید.