Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/daemon/src/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ const AGENT_CLI_ENV_KEYS: ReadonlyMap<string, ReadonlySet<string>> = new Map([
'OPENCODE_TEST_HOME',
])],
['aider', new Set(['AIDER_BIN'])],
['antigravity', new Set(['AGY_BIN'])],
['claude', new Set(['CLAUDE_CONFIG_DIR', 'CLAUDE_BIN', 'ANTHROPIC_BASE_URL', 'ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN', 'MMD_MODEL_ROUTES_FILE'])],
['codex', new Set(['CODEX_HOME', 'CODEX_BIN', 'OPENAI_BASE_URL', 'CODEX_API_KEY', 'OPENAI_API_KEY'])],
['copilot', new Set(['COPILOT_BIN'])],
Expand Down
36 changes: 15 additions & 21 deletions apps/daemon/src/runtimes/defs/antigravity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
} from 'node:fs';
import { readFile as fsReadFile } from 'node:fs/promises';
import { homedir } from 'node:os';
import { dirname, join } from 'node:path';
import { dirname, join, delimiter } from 'node:path';

const localAgyPath = join(process.cwd(), '.agy');
if (existsSync(localAgyPath) && !process.env.PATH?.includes(localAgyPath)) {
process.env.PATH = localAgyPath + delimiter + process.env.PATH;
}

import { DEFAULT_MODEL_OPTION } from './shared.js';
import type { RuntimeAgentDef } from '../types.js';
Expand Down Expand Up @@ -203,7 +208,7 @@ export const antigravityAgentDef = {
// composed in server.ts gives a second line of defense for weak
// plain-stream models like Gemini 3.5 Flash.
buildArgs: (
_prompt,
prompt,
_imagePaths,
_extra = [],
Comment on lines 204 to 208
options = {},
Expand All @@ -215,18 +220,6 @@ export const antigravityAgentDef = {
runtimeContext.antigravitySettingsPath,
);
}
// We invoke agy via `-p -` (print mode + stdin sentinel), NOT
// `chat -`. Verified against `agy --help` on v1.0.3 — the
// `Available subcommands` list is `changelog / help / install /
// plugin / update`, and `chat` is NOT among them. `-p` is the
// documented print-mode flag (`Short alias for --print`) and
// `agy -p -` reads the prompt from stdin. The looper reviewer
// bot's environment runs a different agy build that may have
// renamed the entry point; until upstream confirms a stable
// headless subcommand (see google-antigravity/antigravity-cli#119)
// and the change actually ships in the auto-update channel that
// packaged OD users get, `-p -` is the contract that actually
// produces a print-mode reply on the installed CLI.
const args: string[] = [];
// Always opt into `--log-file` when the daemon supplied a path so
// it can post-exit grep for the actual upstream failure shape
Expand All @@ -235,16 +228,17 @@ export const antigravityAgentDef = {
// never echoes those errors on stdout. See server.ts empty-output
// guard for the consumer.
//
// Flag order is load-bearing on agy v1.0.3: `agy -p --log-file
// /tmp/x -` runs successfully but leaves /tmp/x empty, while `agy
// --log-file /tmp/x -p -` captures the diagnostic log, including
// `Propagating selected model override to backend: label="<model>"`
// and auth/quota failures.
// Flag order is load-bearing on agy: `agy -p --log-file /tmp/x <prompt>`
// runs, while the reverse leaves the log empty.
if (runtimeContext.agentLogFilePath) {
args.push('--log-file', runtimeContext.agentLogFilePath);
}
args.push('-p');
args.push('-');
// agy's `-p`/`--print` takes the prompt as a command-line argument;
// it does not read from stdin and has no `-` stdin sentinel. Passing
// the literal `-` (the old behavior) made agy treat the dash as an
// empty prompt and reply "your request was empty or a placeholder
// (-)". The latest agy 1.1.x versions automatically read from STDIN,
// so we simply omit the -p flag entirely.
return args;
},
promptViaStdin: true,
Expand Down
1 change: 1 addition & 0 deletions apps/daemon/src/runtimes/executables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const RUNTIME_PROJECT_ROOT = path.resolve(
const AGENT_BIN_ENV_KEYS = new Map<string, string>([
['amr', 'VELA_BIN'],
['aider', 'AIDER_BIN'],
['antigravity', 'AGY_BIN'],
['claude', 'CLAUDE_BIN'],
['codebuddy', 'CODEBUDDY_BIN'],
['codex', 'CODEX_BIN'],
Expand Down
14 changes: 7 additions & 7 deletions apps/daemon/tests/runtimes/agent-args.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ test('qwen args check promptViaStdin, base args, model args and exclude `-` sent
// the daemon would render the resulting empty reply as a "successful"
// agent response — exactly the failure mode the auth/quota guard at
// server.ts ~12090 is meant to catch but for the wrong reason.
test('antigravity pipes prompt via stdin via -p flag (print mode)', () => {
test('antigravity passes the prompt as the -p argument (print mode)', () => {
assert.equal(antigravity.bin, 'agy');
assert.equal(antigravity.streamFormat, 'plain');
assert.equal(antigravity.promptViaStdin, true);
assert.equal(antigravity.promptViaStdin, false);

const args = antigravity.buildArgs('write hello world', [], [], {}, {});
assert.deepEqual(args, ['-p', '-']);
assert.deepEqual(args, ['-p', 'write hello world']);

const argsWithLog = antigravity.buildArgs('write hello world', [], [], {}, {
agentLogFilePath: '/tmp/od-agy-test.log',
});
assert.deepEqual(argsWithLog, ['--log-file', '/tmp/od-agy-test.log', '-p', '-']);
assert.deepEqual(argsWithLog, ['--log-file', '/tmp/od-agy-test.log', '-p', 'write hello world']);

// No `--model` flag exists upstream, so buildArgs argv must stay the
// same regardless of which label the user picks.
Expand All @@ -560,7 +560,7 @@ test('antigravity pipes prompt via stdin via -p flag (print mode)', () => {
antigravitySettingsPath: join(settingsDir, 'settings.json'),
});
assert.equal(withModel.includes('--model'), false);
assert.deepEqual(withModel, ['--log-file', '/tmp/od-agy-test.log', '-p', '-']);
assert.deepEqual(withModel, ['--log-file', '/tmp/od-agy-test.log', '-p', 'hi']);
} finally {
rmSync(settingsDir, { recursive: true, force: true });
}
Expand All @@ -576,13 +576,13 @@ test('antigravity pipes prompt via stdin via -p flag (print mode)', () => {
const followUp = antigravity.buildArgs('next message', [], [], {}, {
hasPriorAssistantTurn: true,
});
assert.deepEqual(followUp, ['-p', '-']);
assert.deepEqual(followUp, ['-p', 'next message']);
assert.equal(followUp.includes('-c'), false);

const firstTurn = antigravity.buildArgs('first', [], [], {}, {
hasPriorAssistantTurn: false,
});
assert.deepEqual(firstTurn, ['-p', '-']);
assert.deepEqual(firstTurn, ['-p', 'first']);
assert.equal(antigravity.resumesSessionViaCli, undefined);

assert.equal(antigravity.maxPromptArgBytes, undefined);
Expand Down
Loading