@estebanforge/pi-antigravity-bridge 1.17.2 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +5 -2
- package/extensions/index.ts +74 -100
- package/package.json +1 -1
- package/src/acp/connection.ts +25 -0
- package/src/acp/driver.ts +12 -2
- package/src/acp/events.ts +21 -5
- package/src/config.ts +25 -5
- package/src/engine-picker.ts +13 -10
- package/src/lean-agent.ts +134 -0
- package/src/provider.ts +39 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.18.0] - 2026-12-02
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- A lean agent mode for the ACP engine (off by default): `acp.leanAgent` (env `AGY_ACP_LEAN_AGENT`, `/agy lean on|off`, and a settings row) spawns agy with a staged custom agent whose frontmatter excludes the default components, so the model's only tool is the generic `call_mcp_tool` wrapper reaching the bridge MCP server instead of agy's full native tool set and default prompt — measured ~0.6-0.9k input tokens on a trivial first turn versus ~19.3k for the default agent on agy 1.5.22. The agent file stages per spawn inside the isolated ACP home (the staged agents junction is replaced by a real dir with the user's own agents re-linked entry by entry, never the lean agent's own name), so nothing lands in the global agents dir — a user agent named `pi-bridge-lean` is never linked or overwritten — and cleanup rides the staged-home sweep; the mcpServers entry carries only the server name because session/new supplies the url and credential header. The agent body is generated from the live bridge catalog at spawn: under `bridgeTools: "codemode"` it teaches the script path (one visible tool; scripts reach everything pi-side), under `"all"` it names the seven direct builtins plus the discovery pair, and it always teaches the STILL RUNNING poll discipline. Every provider prompt note asserts a typed per-tool surface a lean agent never has, so notes are suppressed in lean mode and the agent body is the sole protocol source. The `call_mcp_tool` frames the lean model produces (`{ServerName, ToolName, Arguments}`) are unwrapped in the ACP event mapping, so the pi-bridge display filter, poll folding and round-trip tracking keep working; `bridge_tool_info` serves the full authorized catalog under lean (typed per-tool definitions never reach the model). Session keys gain an `@lean` marker so flipping the setting never resumes a conversation recorded under the other agent mode. Caveats: verified on agy 1.5.22; `manage_task`, `list_resources` and `read_resource` stay model-visible above the bridge surface (agy keeps them under exclusion); changing the setting requires a pi restart (the agent file stages at spawn, and an unknown `--agent` name hangs session/new); lean is ACP-only — the stream-json carrier deliberately keeps agy defaults.
|
|
10
|
+
|
|
11
|
+
## [1.17.3] - 2026-12-02
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- The stream-json consent modal is paused: no path shows it any more. The warning was built on one fact, and that fact is gone: Google weighted custom-agent turns at 4x Gemini quota per token on agy 1.5.17 and then reverted the change server-side on 2026-11-30, before the modal shipped in 1.17.0. A reproduction on agy 1.5.20 measured the same quota rate for a custom agent and the default agent, and the vendor confirmed the revert. The modal therefore asked users to consent to a cost that was not being charged, on the first-run picker, at session_start, on `/agy engine stream-json` and on the settings row: all four call sites are unwired, and the copy no longer states a 4x rate as current. The gate itself (the modal, the copy, the `streamJsonAcknowledged` config flag) is kept, not deleted: the vendor said it will look for other ways to curb abuse, so a reweighting can return without notice, and the rewire is four call sites plus a copy update. The copy now states the history (weighted on 1.5.17, reverted on 2026-11-30) instead of a live rate, and the docs match. Users on stream-json see no change in behavior; users who had not answered the old modal are not asked again.
|
|
16
|
+
|
|
5
17
|
## [1.17.2] - 2026-11-30
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -16,9 +16,9 @@ Multi-turn works. The provider binds a pi session to an agy conversation id (per
|
|
|
16
16
|
Turns run through one of two engines behind the same provider surface (`config.engine`, default `acp`):
|
|
17
17
|
|
|
18
18
|
- **acp** (default): the ACP server built into the `agy` CLI (`agy acp`), JSON-RPC 2.0 over stdio. Verified live on agy 1.5.3: text streaming, exact token usage, multi-turn resume via `session/load`, bridge tools, separate model/thinking options, and notification-based cancellation. Client-side usage estimates remain as a fallback if the server omits usage.
|
|
19
|
-
- **stream-json** (fallback): the persistent `agy` CLI process. Live token usage; conversation resume via `--conversation`.
|
|
19
|
+
- **stream-json** (fallback): the persistent `agy` CLI process. Live token usage; conversation resume via `--conversation`. Its turns go through `--agent` (the staged system prompt), so they bill as custom-agent requests. Google weighted those at 4× Gemini quota per token on agy 1.5.17 and reverted the change server-side on 2026-11-30 ([google-antigravity/antigravity-cli#1890](https://github.com/google-antigravity/antigravity-cli/issues/1890)); the vendor said it will look for other ways to curb abuse, so check `/usage` before trusting a quota assumption. The acp engine never passes `--agent`.
|
|
20
20
|
|
|
21
|
-
The choice of engine is left to the user: a first-run picker asks once on a fresh install (acp preselected; `esc` defers), and `/agy engine` reopens it anytime.
|
|
21
|
+
The choice of engine is left to the user: a first-run picker asks once on a fresh install (acp preselected; `esc` defers), and `/agy engine` reopens it anytime. Both engines use the same `agy` installation and cached Google credentials. A restart applies an engine switch. Sessions are engine-scoped, so switching engines never crosses conversations.
|
|
22
22
|
|
|
23
23
|
Full capability comparison, switching, and setup/auth details: [docs/ENGINES.md](docs/ENGINES.md). Existing installs remove only old ACP builds with managed-install evidence under the bridge's old install root. Unmarked binaries and unrelated files stay untouched. Retired standalone credentials are reported for manual removal, never deleted automatically.
|
|
24
24
|
|
|
@@ -130,6 +130,7 @@ If `agy models` fails at load (binary missing, auth not done, network stall), a
|
|
|
130
130
|
| `inactivityTimeoutMin` | Silence cap, minutes, both engines: no stream-json stdout / no ACP session/update for this long fails the turn as a stall. `0` disables the guard. Parks (bridge calls, escalated calls, ACP permission dialogs) pause it; agy-native long steps such as builds do not. A false kill costs the whole turn, and on stream-json a stall kill with no result frame clears the conversation binding. Keep `5`; use `2`-`3` only when native steps are known to be short; do not use `1` | `5` |
|
|
131
131
|
| `acp.sessionTimeoutMs` | Timeout in ms for ACP `session/new`, `session/load`, `session/set_config_option`, and `session/close`. Valid range: `1000`-`300000`. Raise only on slow or proxied networks | `20000` |
|
|
132
132
|
| `acp.sessionRetryOnTimeout` | Advanced: transparently retry `session/new` once when it times out while `agy acp` is still alive. **Warning:** doubles total wait time on dead networks and may not recover if `agy`'s internal socket is wedged | `false` |
|
|
133
|
+
| `acp.leanAgent` | Lean agent mode for the ACP engine: spawns agy with a staged custom agent that excludes the default components, so the model's only tool is the generic `call_mcp_tool` wrapper reaching the bridge MCP server — no native read/command/subagent tools and a much smaller first-turn context (measured ~0.6-0.9k vs ~19.3k input tokens on agy 1.5.22). The agent body is generated from the live bridge catalog at spawn: under `bridgeTools: "codemode"` the model works through one codemode script tool; under `"all"` the seven pi builtins are callable by name and extension tools via `bridge_tool_info`. The agent file stages inside the isolated ACP home per spawn (nothing lands in the global agents dir; a global agent named `pi-bridge-lean` is never touched); the tool protocol rides the agent body (all provider prompt notes are suppressed); session keys gain an `@lean` marker so a flip starts a fresh conversation. Restart applies; bridge-surface changes after a spawn (`/agy bridge`, `/agy tools`) leave the staged body stale until the next pi start. `manage_task`/`list_resources`/`read_resource` stay model-visible (agy keeps them under exclusion). ACP only | `false` |
|
|
133
134
|
|
|
134
135
|
Boolean keys (`readOnly`, `skipPermissions`, `askTool`, `webTools`, `digest`, `systemPrompt`, `acp.sessionRetryOnTimeout`) take JSON booleans, the `/agy` vocabulary as strings (`on`/`off`, `1`/`0`, case and whitespace tolerated), and the JSON numbers `0`/`1`, so a hand-edited `"off"` means off instead of silently on (issue #23). Unrecognized values fall back to the key's default - `readOnly` falls closed to `true` - and surface a `config warnings:` row in `/agy doctor` plus a startup warning toast. The `AGY_*` env vars keep their own grammars: notably `AGY_SKIP_PERMISSIONS` does not accept `on` (only `1`/`true` enable there), and while an env var is set the matching file value is never parsed, so it emits no warning for the value it overrides.
|
|
135
136
|
|
|
@@ -153,6 +154,7 @@ The `activate_skill` catalog mirrors pi's directory-based skill discovery: the t
|
|
|
153
154
|
/agy thinking low|medium|high fallback thinking tier for the AskAntigravity tool; callers may override per call
|
|
154
155
|
/agy digest on|off ship pi-side context to agy when the delta is non-empty (default on; see table above)
|
|
155
156
|
/agy system-prompt on|off send pi's system prompt + AGENTS.md + the Pi Bridge tool-priority note to new agy conversations (default on)
|
|
157
|
+
/agy lean on|off lean ACP agent: bridge MCP tools only, no native agy tools (ACP engine only; restart applies; a flip starts a fresh conversation)
|
|
156
158
|
/agy bridge all|mcp|codemode|none which pi tools the MCP bridge exposes to agy (default all; codemode = scripts only; none = bridge off; a running server picks up the new catalog immediately, a stopped one on the next start)
|
|
157
159
|
/agy tools [hide|show <name>|reset] session-only bridge-catalog hides (multi-word names OK; reset restores the full set; bare lists exposed + hidden; never touches saved config)
|
|
158
160
|
/agy web on|off register the agy_web_search + agy_read_url pi tools for ANY provider's model (default off; applies on the next pi start or /reload; every call spawns agy and spends Antigravity quota)
|
|
@@ -195,6 +197,7 @@ For isolation when running any agent that executes commands without a confirmati
|
|
|
195
197
|
| `AGY_SKIP_PERMISSIONS` | `1`/`true` (default) to pass `--dangerously-skip-permissions` so commands don't hang on an unanswerable prompt in `-p` mode. `0`/`false` to prompt (hangs any `run_command` non-interactively). Wins over the config file. |
|
|
196
198
|
| `AGY_USAGE_ESTIMATE` | Fallback ACP token display when the server omits usage: `estimate` (default; live client-side per-delta estimates), `direct`, `off`. Exact server usage always wins. Wins over the config file. |
|
|
197
199
|
| `AGY_ACP_SESSION_TIMEOUT_MS` | Timeout in ms for ACP `session/new`, `session/load`, `session/set_config_option`, and `session/close` (`1000`-`300000`, default `20000`). Wins over `config.acp.sessionTimeoutMs`. |
|
|
200
|
+
| `AGY_ACP_LEAN_AGENT` | `1`/`true`/`on` spawns the ACP engine with the staged lean agent: bridge MCP tools only, no native agy tools (default off; restart applies). Wins over `config.acp.leanAgent`. |
|
|
198
201
|
| `AGY_ACP_SESSION_RETRY` | `1`/`true`/`on` to retry ACP `session/new` once on silent timeout while `agy acp` is alive (default off). Warning: doubles wait time on dead networks and may not clear a wedged socket. Wins over `config.acp.sessionRetryOnTimeout`. |
|
|
199
202
|
| `AGY_DEFAULT_MODEL` | Default model for the `AskAntigravity` tool: `flash`/`pro`/`gemini`, or an exact id such as `gemini-4-hydrogen`. Default `gemini-4-hydrogen`; the tier suffix rides `AGY_DEFAULT_THINKING`. Wins over the config file. |
|
|
200
203
|
| `AGY_DEFAULT_THINKING` | Default thinking tier for the `AskAntigravity` tool: `low`/`medium`/`high`. Anything else falls back to `medium`. Wins over the config file. |
|
package/extensions/index.ts
CHANGED
|
@@ -72,7 +72,7 @@ import { createAgySetupOffer } from "../src/agy-setup.js";
|
|
|
72
72
|
import { ensureQueuedMessagesDefaults } from "../src/queued-messages.js";
|
|
73
73
|
import type { TurnDriver, TurnOutcome } from "../src/driver-types.js";
|
|
74
74
|
import { configPath, configWarningsMessage, loadConfig, logsDir, MAX_TURN_CAP_MIN, migrateStaleDigestDefault, parseCapMinutes, removeLegacyAcpBin, saveConfig, type AcpConfig, type AgyMode, type BridgeTools, type Engine, type ThinkingTier } from "../src/config.js";
|
|
75
|
-
import { agyMissingMessage, ENGINE_SETTINGS_ROW_ID, engineSettingsRow, isAgyInstalled, savedEngineMessage, shouldOfferEnginePicker,
|
|
75
|
+
import { agyMissingMessage, ENGINE_SETTINGS_ROW_ID, engineSettingsRow, isAgyInstalled, savedEngineMessage, shouldOfferEnginePicker, showEnginePicker } from "../src/engine-picker.js";
|
|
76
76
|
import { agyVersionVerdict, agyUpdateMessage, checkAgyCliVersion, describeAgyVersionCheck, MIN_AGY_ACP_VERSION, MIN_AGY_VERSION, MIN_GEMINI_DIR_VERSION, probeGeminiDirFlag, resolveStreamHomeMode } from "../src/agy-version.js";
|
|
77
77
|
import { isValidAgyAgentName, listAgyAgents } from "../src/agents.js";
|
|
78
78
|
import { formatSubagentRoster, SubagentRoster } from "../src/subagent-roster.js";
|
|
@@ -85,6 +85,7 @@ import { showTasksBrowser } from "../src/tasks-ui.js";
|
|
|
85
85
|
import { agyConversationDir } from "../src/agy-paths.js";
|
|
86
86
|
import { armBackgroundWatch, rearmPlansFromEntries, type BackgroundWatchEntry, type BackgroundWatchHandle } from "../src/background-watch.js";
|
|
87
87
|
import { redactText } from "../src/redact.js";
|
|
88
|
+
import { leanAgentBody, LEAN_AGENT_NAME } from "../src/lean-agent.js";
|
|
88
89
|
import { createDailyLogger, type DailyLogger } from "../src/daily-log.js";
|
|
89
90
|
import { registerAskAntigravityTool, toolModelsFromRaw } from "../src/ask-tool.js";
|
|
90
91
|
import { registerWebTools } from "../src/web-tools.js";
|
|
@@ -163,6 +164,11 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
163
164
|
// config reads would let a mid-session flip leave ToolRoundTrips,
|
|
164
165
|
// kickIdle, and reentry pointing at the other engine (round-7 finding).
|
|
165
166
|
const engine: Engine = loadConfig().engine;
|
|
167
|
+
// Lean agent mode, LATCHED like the engine: the spawned agy process only
|
|
168
|
+
// sees the flag at spawn (agent file + --agent), so every lean-dependent
|
|
169
|
+
// surface (notes, catalog, session keys, the driver resolver) follows
|
|
170
|
+
// this value, never a live config read. Changing it is restart-applies.
|
|
171
|
+
const leanAgent = engine === "acp" && loadConfig().acp.leanAgent;
|
|
166
172
|
// Engine switching requires a restart, so the catalog-time engine read is
|
|
167
173
|
// authoritative for input advertising. Both engines accept images: ACP
|
|
168
174
|
// rides native content blocks; stream-json stages user attachments to
|
|
@@ -346,10 +352,31 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
346
352
|
const level = expectedExit ? "debug" : acpFailures.has(msg) ? "warn" : msg === "turn-start" ? "info" : "debug";
|
|
347
353
|
fileLog.log(msg, data, level);
|
|
348
354
|
};
|
|
355
|
+
let leanSkippedWarned = false;
|
|
349
356
|
const acpDriver = new AcpDriver({
|
|
350
357
|
bin: binary,
|
|
351
358
|
binArgs: ["acp"],
|
|
352
359
|
isolateHome: true,
|
|
360
|
+
// Lean agent mode (restart-applies, but resolved per spawn so a flip
|
|
361
|
+
// mid-session takes effect when the driver recycles instead of
|
|
362
|
+
// desyncing the staged agent file from the argv): one resolution per
|
|
363
|
+
// spawn supplies both the --agent name and the agent body, derived
|
|
364
|
+
// from the live bridge catalog (leanAgentBody). Off = default agent.
|
|
365
|
+
leanAgent: () => {
|
|
366
|
+
// Latched at factory time (see the const above): the flag and the
|
|
367
|
+
// staged file must move together per spawn.
|
|
368
|
+
if (!leanAgent) return undefined;
|
|
369
|
+
// No bridge, no lean: the body would teach a tool surface nothing
|
|
370
|
+
// exposes (bridgeTools none, or the listener never started).
|
|
371
|
+
if (!mcpHandle || getBridgeTools().length === 0) {
|
|
372
|
+
if (!leanSkippedWarned) {
|
|
373
|
+
leanSkippedWarned = true;
|
|
374
|
+
fileLog.log("lean-skipped", { reason: "no bridge tools" }, "warn");
|
|
375
|
+
}
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
return { name: LEAN_AGENT_NAME, body: leanAgentBody({ tools: getBridgeTools() }) };
|
|
379
|
+
},
|
|
353
380
|
// Resolved per turn: /agy and AGY_USAGE_ESTIMATE changes apply without
|
|
354
381
|
// a restart. Without this the driver defaults to "estimate" and the
|
|
355
382
|
// config knob (incl. "off") is dead.
|
|
@@ -715,7 +742,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
715
742
|
// omits getSessionId.
|
|
716
743
|
const sm = ctx.sessionManager as { getSessionId?: () => string };
|
|
717
744
|
const sid = sm.getSessionId?.();
|
|
718
|
-
const key = sessionKey(sid ? { sessionId: sid } : undefined, ctx.cwd, engine);
|
|
745
|
+
const key = sessionKey(sid ? { sessionId: sid } : undefined, ctx.cwd, engine, leanAgent);
|
|
719
746
|
const rotated = rotateSessionOnCompaction(store, key, pendingCompactionHandoff);
|
|
720
747
|
if (rotated) {
|
|
721
748
|
fileLog.log("session-compact-rotate", { key, previousConversation: rotated }, "info");
|
|
@@ -738,7 +765,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
738
765
|
// builds whose dts omits getSessionId.
|
|
739
766
|
const sm = ctx.sessionManager as { getSessionId?: () => string };
|
|
740
767
|
const sid = sm.getSessionId?.();
|
|
741
|
-
const key = sessionKey(sid ? { sessionId: sid } : undefined, ctx.cwd, engine);
|
|
768
|
+
const key = sessionKey(sid ? { sessionId: sid } : undefined, ctx.cwd, engine, leanAgent);
|
|
742
769
|
return store.get(key) !== null;
|
|
743
770
|
})(),
|
|
744
771
|
hasContext: ctx.sessionManager
|
|
@@ -765,6 +792,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
765
792
|
pendingCompactionHandoff,
|
|
766
793
|
hasActiveTool: (name) => pi.getActiveTools().includes(name),
|
|
767
794
|
engine,
|
|
795
|
+
leanAgent,
|
|
768
796
|
log: fileLog.log.bind(fileLog),
|
|
769
797
|
});
|
|
770
798
|
|
|
@@ -931,63 +959,15 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
931
959
|
try {
|
|
932
960
|
const picked = await showEnginePicker(ctx.ui);
|
|
933
961
|
if (picked) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
if (picked === "stream-json") {
|
|
938
|
-
const verdict = await showStreamJsonWarning(ctx.ui);
|
|
939
|
-
if (verdict === undefined) {
|
|
940
|
-
// Decide later: nothing persisted, this session runs the
|
|
941
|
-
// acp default, the picker re-asks next start.
|
|
942
|
-
ctx.ui.notify("Stream-json not confirmed; this session runs the acp default. Decide later with /agy engine.", "info");
|
|
943
|
-
chosen = undefined;
|
|
944
|
-
} else {
|
|
945
|
-
chosen = verdict === "acp" ? "acp" : "stream-json";
|
|
946
|
-
if (chosen === "stream-json") ctx.ui.notify(streamJsonKeptMessage(), "warning");
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
if (chosen) {
|
|
950
|
-
setupEngine = chosen;
|
|
951
|
-
saveConfig(streamJsonSavePatch(chosen, chosen === "stream-json"));
|
|
952
|
-
ctx.ui.notify(savedEngineMessage(chosen), "info");
|
|
953
|
-
}
|
|
962
|
+
setupEngine = picked;
|
|
963
|
+
saveConfig({ engine: picked });
|
|
964
|
+
ctx.ui.notify(savedEngineMessage(picked), "info");
|
|
954
965
|
}
|
|
955
966
|
} catch (err) {
|
|
956
967
|
fileLog.log("engine-picker", { error: String(err) }, "warn");
|
|
957
968
|
console.error(`[antigravity-bridge] engine picker failed: ${String(err)}`);
|
|
958
969
|
}
|
|
959
970
|
}
|
|
960
|
-
// stream-json consent migration (google-antigravity/antigravity-cli#1890):
|
|
961
|
-
// existing installs resolved to stream-json (the legacy silent fallback or
|
|
962
|
-
// an old explicit choice) see the warning once; esc re-asks next start,
|
|
963
|
-
// exactly like the first-run picker. AGY_ENGINE=stream-json skips the
|
|
964
|
-
// modal: typing the env var is the explicit act. The switch persists for
|
|
965
|
-
// the next start (drivers wire at load), like /agy engine.
|
|
966
|
-
try {
|
|
967
|
-
const cfg = loadConfig();
|
|
968
|
-
if (
|
|
969
|
-
(event.reason === "startup" || event.reason === "resume") &&
|
|
970
|
-
ctx.mode === "tui" &&
|
|
971
|
-
process.env.AGY_ENGINE === undefined &&
|
|
972
|
-
shouldWarnStreamJson(cfg.engine, cfg.streamJsonAcknowledged)
|
|
973
|
-
) {
|
|
974
|
-
const verdict = await showStreamJsonWarning(ctx.ui);
|
|
975
|
-
if (verdict === "keep") {
|
|
976
|
-
saveConfig(streamJsonSavePatch("stream-json", true));
|
|
977
|
-
ctx.ui.notify(streamJsonKeptMessage(), "warning");
|
|
978
|
-
} else if (verdict === "acp" && loadConfig().mode !== "plan") {
|
|
979
|
-
saveConfig(streamJsonSavePatch("acp", true));
|
|
980
|
-
ctx.ui.notify(savedEngineMessage("acp"), "info");
|
|
981
|
-
} else if (verdict === "acp") {
|
|
982
|
-
// Plan mode blocks ACP: refuse without persisting so the
|
|
983
|
-
// modal re-asks once the mode allows the switch.
|
|
984
|
-
ctx.ui.notify("mode is plan; provider plan turns are disabled on ACP. /agy mode accept-edits first.", "warning");
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
} catch (err) {
|
|
988
|
-
fileLog.log("streamjson-warning", { error: String(err) }, "warn");
|
|
989
|
-
console.error(`[antigravity-bridge] stream-json warning failed: ${String(err)}`);
|
|
990
|
-
}
|
|
991
971
|
// The retired acp.bin key heals itself in the config file; the env var
|
|
992
972
|
// lives outside our reach, so it is the only case that still warns.
|
|
993
973
|
// Independent once-flags: a failed cleanup must never suppress the
|
|
@@ -1145,7 +1125,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
1145
1125
|
inputSchema: serializeToolSchema(t.parameters),
|
|
1146
1126
|
}));
|
|
1147
1127
|
const tools = directDefs;
|
|
1148
|
-
const proxiedForInfo = codemode ? codemode.proxied : proxied;
|
|
1128
|
+
const proxiedForInfo = leanAgent ? authorized : codemode ? codemode.proxied : proxied;
|
|
1149
1129
|
if (mode !== "none" && proxiedForInfo.length > 0) {
|
|
1150
1130
|
tools.push(bridgeToolInfoDef(proxiedForInfo), bridgeCallToolDef());
|
|
1151
1131
|
}
|
|
@@ -1187,8 +1167,8 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
1187
1167
|
return answerPoll(roundTrips, wanted, signal, mcpLog);
|
|
1188
1168
|
}
|
|
1189
1169
|
if (name === TOOL_INFO_TOOL_NAME) {
|
|
1190
|
-
const
|
|
1191
|
-
return Promise.resolve(formatBridgeToolInfo(proxied, args.names));
|
|
1170
|
+
const authorized = getBridgeTools();
|
|
1171
|
+
return Promise.resolve(formatBridgeToolInfo(leanAgent ? authorized : partitionBridgeTools(authorized).proxied, args.names));
|
|
1192
1172
|
}
|
|
1193
1173
|
const dispatchPiTool = (targetName: string, targetArgs: Record<string, unknown>) =>
|
|
1194
1174
|
roundTrips.onToolCall(callId, targetName, targetArgs, signal).then((r) => {
|
|
@@ -1487,6 +1467,7 @@ function settingsRows(ctx: AgyCommandCtx): string[] {
|
|
|
1487
1467
|
row("AskAntigravity model:", config.defaultModel),
|
|
1488
1468
|
row("AskAntigravity thinking:", config.defaultThinking),
|
|
1489
1469
|
row("bridge tools:", config.bridgeTools),
|
|
1470
|
+
row("lean agent:", config.engine === "acp" ? (config.acp.leanAgent ? "on (restart applies to flip)" : "off") : "off (ACP engine only)"),
|
|
1490
1471
|
row("digest:", config.digest ? "on" : "off"),
|
|
1491
1472
|
row("system prompt:", config.systemPrompt ? "on" : "off"),
|
|
1492
1473
|
// issue #23: unparseable hand-edited values must not fail silently.
|
|
@@ -1505,7 +1486,7 @@ function statusText(ctx: AgyCommandCtx): string {
|
|
|
1505
1486
|
` sessions: ${ctx.store.size} bound`,
|
|
1506
1487
|
` config: ${configPath()}`,
|
|
1507
1488
|
"",
|
|
1508
|
-
"Subcommands: /agy auth, /agy auth-manual, /agy engine stream-json|acp, /agy mode plan|accept-edits, /agy readonly on|off, /agy permissions on|off, /agy ask on|off, /agy model <alias>, /agy thinking low|medium|high|xhigh, /agy agent <name|off>, /agy subagents, /agy quota, /agy artifacts [open <n|name>], /agy tasks [tail <id>], /agy bridge all|mcp|codemode|none, /agy tools [hide|show <name>|reset], /agy web on|off, /agy digest on|off, /agy system-prompt on|off, /agy timeout <1-1440|off>, /agy patch-cleanup, /agy clear, /agy doctor",
|
|
1489
|
+
"Subcommands: /agy auth, /agy auth-manual, /agy engine stream-json|acp, /agy mode plan|accept-edits, /agy readonly on|off, /agy permissions on|off, /agy ask on|off, /agy model <alias>, /agy thinking low|medium|high|xhigh, /agy agent <name|off>, /agy subagents, /agy quota, /agy artifacts [open <n|name>], /agy tasks [tail <id>], /agy bridge all|mcp|codemode|none, /agy lean on|off, /agy tools [hide|show <name>|reset], /agy web on|off, /agy digest on|off, /agy system-prompt on|off, /agy timeout <1-1440|off>, /agy patch-cleanup, /agy clear, /agy doctor",
|
|
1509
1490
|
].join("\n");
|
|
1510
1491
|
}
|
|
1511
1492
|
|
|
@@ -1513,7 +1494,7 @@ function statusText(ctx: AgyCommandCtx): string {
|
|
|
1513
1494
|
function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
1514
1495
|
pi.registerCommand("agy", {
|
|
1515
1496
|
description:
|
|
1516
|
-
"Antigravity provider: doctor (health + settings), settings picker, clear sessions. Usage: /agy [doctor|auth|auth-manual|engine stream-json|acp|mode plan|accept-edits|readonly on|off|permissions on|off|ask on|off|model <alias>|thinking low|medium|high|xhigh|agent <name|off>|subagents|quota|artifacts [open <n|name>]|tasks [tail <id>]|bridge all|mcp|codemode|none|tools [hide|show <name>|reset]|web on|off|digest on|off|system-prompt on|off|timeout <1-1440|off>|patch-cleanup|clear]",
|
|
1497
|
+
"Antigravity provider: doctor (health + settings), settings picker, clear sessions. Usage: /agy [doctor|auth|auth-manual|engine stream-json|acp|mode plan|accept-edits|readonly on|off|permissions on|off|ask on|off|model <alias>|thinking low|medium|high|xhigh|agent <name|off>|subagents|quota|artifacts [open <n|name>]|tasks [tail <id>]|bridge all|mcp|codemode|none|lean on|off|tools [hide|show <name>|reset]|web on|off|digest on|off|system-prompt on|off|timeout <1-1440|off>|patch-cleanup|clear]",
|
|
1517
1498
|
handler: async (args, cmdCtx: ExtensionCommandContext) => {
|
|
1518
1499
|
const ui = cmdCtx.ui;
|
|
1519
1500
|
if (ui) ctx.setActiveUi(ui);
|
|
@@ -1582,30 +1563,7 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
1582
1563
|
ui?.notify("mode is plan; provider plan turns are disabled on ACP. /agy mode accept-edits first.", "warning");
|
|
1583
1564
|
return;
|
|
1584
1565
|
}
|
|
1585
|
-
|
|
1586
|
-
// TUI warning modal runs once, before stream-json ever takes
|
|
1587
|
-
// effect. Headless has no modal surface: apply with the
|
|
1588
|
-
// one-line notice instead.
|
|
1589
|
-
let engineChoice: "acp" | "stream-json" = val;
|
|
1590
|
-
let warned = false;
|
|
1591
|
-
if (engineChoice === "stream-json" && shouldWarnStreamJson("stream-json", loadConfig().streamJsonAcknowledged)) {
|
|
1592
|
-
if (!ui || mode !== "tui") {
|
|
1593
|
-
ui?.notify(streamJsonKeptMessage(), "warning");
|
|
1594
|
-
} else {
|
|
1595
|
-
const verdict = await showStreamJsonWarning(ui);
|
|
1596
|
-
if (verdict === undefined) {
|
|
1597
|
-
ui.notify(`engine unchanged: ${loadConfig().engine}.`, "info");
|
|
1598
|
-
return;
|
|
1599
|
-
}
|
|
1600
|
-
if (verdict === "acp" && loadConfig().mode === "plan") {
|
|
1601
|
-
ui.notify("mode is plan; provider plan turns are disabled on ACP. /agy mode accept-edits first.", "warning");
|
|
1602
|
-
return;
|
|
1603
|
-
}
|
|
1604
|
-
engineChoice = verdict === "acp" ? "acp" : "stream-json";
|
|
1605
|
-
warned = true;
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
const next = saveConfig(streamJsonSavePatch(engineChoice, warned));
|
|
1566
|
+
const next = saveConfig({ engine: val });
|
|
1609
1567
|
if (next.engine !== "acp") {
|
|
1610
1568
|
ui?.notify("engine set to stream-json. Takes effect on the next pi start (or /reload).", "info");
|
|
1611
1569
|
return;
|
|
@@ -2076,6 +2034,24 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
2076
2034
|
return;
|
|
2077
2035
|
}
|
|
2078
2036
|
|
|
2037
|
+
if (sub === "lean") {
|
|
2038
|
+
if (val === "on" || val === "off") {
|
|
2039
|
+
const next = saveConfig({ acp: { leanAgent: val === "on" } });
|
|
2040
|
+
ui?.notify(
|
|
2041
|
+
next.acp.leanAgent
|
|
2042
|
+
? "lean on (ACP engine only). The spawned agent runs with the default components excluded: no native file/command/subagent tools, the bridge MCP surface only. Changing it requires a pi restart; a flip starts a fresh conversation."
|
|
2043
|
+
: "lean off. The spawned agent uses the default components. Changing it requires a pi restart; a flip starts a fresh conversation.",
|
|
2044
|
+
"info",
|
|
2045
|
+
);
|
|
2046
|
+
if (next.acp.leanAgent && ctx.engine !== "acp") {
|
|
2047
|
+
ui?.notify("lean is an ACP-engine setting and the active engine is stream-json: the flag is stored but inert until the engine switches.", "warning");
|
|
2048
|
+
}
|
|
2049
|
+
} else {
|
|
2050
|
+
ui?.notify(`lean: ${loadConfig().acp.leanAgent ? "on" : "off"} (ACP engine only)\nusage: /agy lean on|off — runs the spawned agent with the default components excluded (bridge MCP tools only). Restart applies.`, "info");
|
|
2051
|
+
}
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2079
2055
|
if (sub === "thinking") {
|
|
2080
2056
|
if (val === "low" || val === "medium" || val === "high" || val === "xhigh") {
|
|
2081
2057
|
const next = saveConfig({ defaultThinking: val as ThinkingTier });
|
|
@@ -2221,6 +2197,14 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
2221
2197
|
currentValue: config.acp.sessionRetryOnTimeout ? "on" : "off",
|
|
2222
2198
|
values: ["off", "on"],
|
|
2223
2199
|
},
|
|
2200
|
+
{
|
|
2201
|
+
id: "acp-lean-agent",
|
|
2202
|
+
label: "ACP lean agent",
|
|
2203
|
+
description:
|
|
2204
|
+
"ACP engine only. Spawn agy with a staged lean agent: default components excluded, no native file/command/subagent tools, the bridge MCP surface only (a much smaller first-turn context). Tool protocol rides the agent body; prompt notes are suppressed. Restart applies; a flip starts a fresh conversation. Bridge-surface changes after a spawn (/agy bridge, /agy tools) leave the staged body stale until the next pi start.",
|
|
2205
|
+
currentValue: config.acp.leanAgent ? "on" : "off",
|
|
2206
|
+
values: ["off", "on"],
|
|
2207
|
+
},
|
|
2224
2208
|
];
|
|
2225
2209
|
|
|
2226
2210
|
const resolved = await ui.custom<string | undefined>(
|
|
@@ -2266,6 +2250,11 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
2266
2250
|
...pending.acp,
|
|
2267
2251
|
sessionRetryOnTimeout: newValue === "on",
|
|
2268
2252
|
};
|
|
2253
|
+
} else if (id === "acp-lean-agent") {
|
|
2254
|
+
pending.acp = {
|
|
2255
|
+
...pending.acp,
|
|
2256
|
+
leanAgent: newValue === "on",
|
|
2257
|
+
};
|
|
2269
2258
|
}
|
|
2270
2259
|
},
|
|
2271
2260
|
},
|
|
@@ -2322,6 +2311,7 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
2322
2311
|
pending.acp?.sessionRetryOnTimeout !== undefined
|
|
2323
2312
|
? `ACP session/new retry=${next.acp.sessionRetryOnTimeout ? "on" : "off"}`
|
|
2324
2313
|
: null,
|
|
2314
|
+
pending.acp?.leanAgent !== undefined ? `ACP lean agent=${next.acp.leanAgent ? "on" : "off"} (restart applies)` : null,
|
|
2325
2315
|
]
|
|
2326
2316
|
.filter(Boolean)
|
|
2327
2317
|
.join(", ");
|
|
@@ -2341,7 +2331,7 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
2341
2331
|
* same semantics: plan blocks acp and restart applies the switch. */
|
|
2342
2332
|
async function runEngineModal(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promise<void> {
|
|
2343
2333
|
const current = loadConfig().engine;
|
|
2344
|
-
|
|
2334
|
+
const picked = await showEnginePicker(ui);
|
|
2345
2335
|
if (picked === undefined) {
|
|
2346
2336
|
ui.notify(`engine unchanged: ${current}.`, "info");
|
|
2347
2337
|
return;
|
|
@@ -2350,22 +2340,6 @@ async function runEngineModal(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promi
|
|
|
2350
2340
|
ui.notify(`engine is already ${current}. Restart applies it if set this session.`, "info");
|
|
2351
2341
|
return;
|
|
2352
2342
|
}
|
|
2353
|
-
// Consent gate: picking stream-json in the picker resolves only after the
|
|
2354
|
-
// warning; esc lands here as undefined above, so nothing is persisted.
|
|
2355
|
-
if (picked === "stream-json" && shouldWarnStreamJson("stream-json", loadConfig().streamJsonAcknowledged)) {
|
|
2356
|
-
const verdict = await showStreamJsonWarning(ui);
|
|
2357
|
-
if (verdict === undefined) {
|
|
2358
|
-
ui.notify(`engine unchanged: ${current}.`, "info");
|
|
2359
|
-
return;
|
|
2360
|
-
}
|
|
2361
|
-
if (verdict === "keep") {
|
|
2362
|
-
saveConfig({ engine: "stream-json", streamJsonAcknowledged: true });
|
|
2363
|
-
ui.notify(streamJsonKeptMessage(), "warning");
|
|
2364
|
-
ui.notify("Takes effect on the next pi start (or /reload).", "info");
|
|
2365
|
-
return;
|
|
2366
|
-
}
|
|
2367
|
-
picked = "acp";
|
|
2368
|
-
}
|
|
2369
2343
|
if (picked === "acp" && loadConfig().mode === "plan") {
|
|
2370
2344
|
ui.notify("mode is plan; provider plan turns are disabled on ACP. /agy mode accept-edits first.", "warning");
|
|
2371
2345
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estebanforge/pi-antigravity-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Gemini provider for Pi on the Antigravity ACP server (official Google ACP) or the stream-json agy CLI. Use antigravity/* models in Pi. Full /model picker support. Models runs Pi's tools. ToS safe to use.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/src/acp/connection.ts
CHANGED
|
@@ -20,6 +20,7 @@ import type { AgyUsage } from "../driver-types.js";
|
|
|
20
20
|
import { redactText } from "../redact.js";
|
|
21
21
|
import { JsonRpcResponseError, JsonRpcSession, JsonRpcTimeoutError } from "./jsonrpc.js";
|
|
22
22
|
import { mergeGateGroupIntoAcpHome } from "../approval-hook.js";
|
|
23
|
+
import { stageLeanAgentInHome } from "../lean-agent.js";
|
|
23
24
|
import { removeStagedAgyHome, stageAgyHome } from "./home.js";
|
|
24
25
|
|
|
25
26
|
export interface AcpMcpServer {
|
|
@@ -51,6 +52,11 @@ export interface AcpConnectionOptions {
|
|
|
51
52
|
binArgs?: string[];
|
|
52
53
|
/** Native agy only: filter per-pid bridges out of inherited global MCP. */
|
|
53
54
|
isolateHome?: boolean | { geminiHome?: string; parentDir?: string };
|
|
55
|
+
/** Lean agent mode: stage this agent file into the isolated home and run
|
|
56
|
+
* agy with `--agent <name>`. Undefined = off (the default agent). The
|
|
57
|
+
* file must exist before spawn (an unknown --agent makes session/new
|
|
58
|
+
* hang), so it is staged here, never lazily. */
|
|
59
|
+
leanAgent?: { name: string; body: string };
|
|
54
60
|
extraEnv?: Record<string, string>;
|
|
55
61
|
log: (msg: string, data?: unknown) => void;
|
|
56
62
|
/** Verified `session/update` payloads (post-suppression). */
|
|
@@ -184,6 +190,12 @@ export class AcpConnection {
|
|
|
184
190
|
async start(): Promise<void> {
|
|
185
191
|
if (this.#child) return;
|
|
186
192
|
const args = [...(this.#opts.binArgs ?? [])];
|
|
193
|
+
// The lean agent file can only be staged into a home we own. Without
|
|
194
|
+
// isolation --agent would name a file that does not exist, and agy
|
|
195
|
+
// hangs session/new forever on an unknown agent (fail closed instead).
|
|
196
|
+
if (this.#opts.leanAgent && !this.#opts.isolateHome) {
|
|
197
|
+
throw new Error("lean agent mode requires an isolated home (isolateHome)");
|
|
198
|
+
}
|
|
187
199
|
if (this.#opts.isolateHome) {
|
|
188
200
|
this.#stagedHome = stageAgyHome(typeof this.#opts.isolateHome === "object" ? this.#opts.isolateHome : {});
|
|
189
201
|
// Deliver this session's approval gate group into the staged home:
|
|
@@ -197,6 +209,19 @@ export class AcpConnection {
|
|
|
197
209
|
this.#releaseHome();
|
|
198
210
|
throw err;
|
|
199
211
|
}
|
|
212
|
+
if (this.#opts.leanAgent) {
|
|
213
|
+
try {
|
|
214
|
+
stageLeanAgentInHome({
|
|
215
|
+
stagedHome: this.#stagedHome,
|
|
216
|
+
name: this.#opts.leanAgent.name,
|
|
217
|
+
body: this.#opts.leanAgent.body,
|
|
218
|
+
geminiHome: typeof this.#opts.isolateHome === "object" ? this.#opts.isolateHome.geminiHome : undefined,
|
|
219
|
+
});
|
|
220
|
+
} catch (err) {
|
|
221
|
+
this.#releaseHome();
|
|
222
|
+
throw err;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
200
225
|
args.push("--gemini-dir", this.#stagedHome);
|
|
201
226
|
}
|
|
202
227
|
let child: ChildProcess;
|
package/src/acp/driver.ts
CHANGED
|
@@ -46,6 +46,11 @@ export interface AcpDriverOptions {
|
|
|
46
46
|
binArgs?: string[] | (() => string[]);
|
|
47
47
|
/** Native agy only: isolate inherited global MCP from other pi sessions. */
|
|
48
48
|
isolateHome?: boolean;
|
|
49
|
+
/** Lean agent mode, resolved once per spawn. When defined, the connection
|
|
50
|
+
* stages the agent file into the isolated home and `--agent <name>` is
|
|
51
|
+
* appended to the spawned argv. Undefined = off. Resolving HERE (not in
|
|
52
|
+
* binArgs) keeps the agent name and body from one config read. */
|
|
53
|
+
leanAgent?: () => { name: string; body: string } | undefined;
|
|
49
54
|
extraEnv?: Record<string, string>;
|
|
50
55
|
/** Bridge registration for session/new AND session/load. */
|
|
51
56
|
mcpServers?: () => AcpMcpServer[];
|
|
@@ -619,7 +624,9 @@ export class AcpDriver implements TurnDriver {
|
|
|
619
624
|
// Only native failures feed the silent-failure note: bridge tool
|
|
620
625
|
// errors are pi's own parking surface (the provider already surfaces
|
|
621
626
|
// them), not an agy-native tool the model failed to recover from.
|
|
622
|
-
|
|
627
|
+
// entry?.mcpServer covers lean update frames stripped of
|
|
628
|
+
// name/rawInput: the start frame's unwrapped server decides.
|
|
629
|
+
if (!(mapped.mcpServer ?? entry?.mcpServer)) {
|
|
623
630
|
turn.sawToolError = true;
|
|
624
631
|
turn.lastToolError = { name, message: mapped.message };
|
|
625
632
|
}
|
|
@@ -675,10 +682,13 @@ export class AcpDriver implements TurnDriver {
|
|
|
675
682
|
this.#generation += 1;
|
|
676
683
|
this.#state = "starting";
|
|
677
684
|
this.#stats.spawns += 1;
|
|
685
|
+
const lean = this.#opts.leanAgent?.();
|
|
686
|
+
const binArgs = typeof this.#opts.binArgs === "function" ? this.#opts.binArgs() : this.#opts.binArgs;
|
|
678
687
|
const conn = new AcpConnection({
|
|
679
688
|
bin: typeof this.#opts.bin === "function" ? this.#opts.bin() : this.#opts.bin,
|
|
680
|
-
binArgs:
|
|
689
|
+
binArgs: lean ? [...(binArgs ?? []), "--agent", lean.name] : binArgs,
|
|
681
690
|
isolateHome: this.#opts.isolateHome,
|
|
691
|
+
leanAgent: lean,
|
|
682
692
|
extraEnv: this.#opts.extraEnv,
|
|
683
693
|
cwd: request.cwd,
|
|
684
694
|
mcpServers: this.#opts.mcpServers,
|
package/src/acp/events.ts
CHANGED
|
@@ -65,12 +65,13 @@ export function mapUpdate(update: unknown): MappedUpdate {
|
|
|
65
65
|
const id = stringField(u.toolCallId);
|
|
66
66
|
if (!id) return null;
|
|
67
67
|
const nativeMcp = nativeMcpTool(u);
|
|
68
|
+
const lean = leanMcpTool(u);
|
|
68
69
|
return {
|
|
69
70
|
kind: "tool_start",
|
|
70
71
|
toolCallId: id,
|
|
71
|
-
name: metaToolName(u._meta) ?? nativeMcp?.name ?? stringField(u.name) ?? toolName(u.title, u.kind),
|
|
72
|
-
args: rawArguments(u.rawInput),
|
|
73
|
-
mcpServer: stringField(recordField(recordField(u._meta).mcp).server) ?? nativeMcp?.server,
|
|
72
|
+
name: metaToolName(u._meta) ?? lean?.name ?? nativeMcp?.name ?? stringField(u.name) ?? toolName(u.title, u.kind),
|
|
73
|
+
args: lean?.args ?? rawArguments(u.rawInput),
|
|
74
|
+
mcpServer: stringField(recordField(recordField(u._meta).mcp).server) ?? lean?.server ?? nativeMcp?.server,
|
|
74
75
|
// Edits carry their native diff HERE, on the pending tool_call
|
|
75
76
|
// frame (run 6:10) — the completed update carries only display
|
|
76
77
|
// text. contentDiff on the update stays as a future-build
|
|
@@ -89,7 +90,7 @@ export function mapUpdate(update: unknown): MappedUpdate {
|
|
|
89
90
|
// failure next to a successful edit.
|
|
90
91
|
const raw = stringField(u.rawOutput);
|
|
91
92
|
if (raw?.includes("approved but never executed")) return null;
|
|
92
|
-
const mcpServer = stringField(recordField(recordField(u._meta).mcp).server) ?? nativeMcpTool(u)?.server;
|
|
93
|
+
const mcpServer = stringField(recordField(recordField(u._meta).mcp).server) ?? leanMcpTool(u)?.server ?? nativeMcpTool(u)?.server;
|
|
93
94
|
return { kind: "tool_error", toolCallId: id, message: raw ?? "tool failed", ...(mcpServer ? { mcpServer } : {}) };
|
|
94
95
|
}
|
|
95
96
|
if (u.status === "completed") {
|
|
@@ -97,7 +98,7 @@ export function mapUpdate(update: unknown): MappedUpdate {
|
|
|
97
98
|
// often just the server's display title, not the result (probe
|
|
98
99
|
// 2026-09-03: completed MCP call, rawOutput "Call bridge_echo").
|
|
99
100
|
const diff = contentDiff(u.content);
|
|
100
|
-
const mcpServer = stringField(recordField(recordField(u._meta).mcp).server) ?? nativeMcpTool(u)?.server;
|
|
101
|
+
const mcpServer = stringField(recordField(recordField(u._meta).mcp).server) ?? leanMcpTool(u)?.server ?? nativeMcpTool(u)?.server;
|
|
101
102
|
return {
|
|
102
103
|
kind: "tool_done",
|
|
103
104
|
toolCallId: id,
|
|
@@ -132,6 +133,21 @@ function nativeMcpTool(update: Record<string, unknown>): { name: string; server:
|
|
|
132
133
|
return match ? { server: match[1]!, name: match[2]! } : undefined;
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/** Lean-agent frames (excludeDefaultComponents agents): the model's only tool
|
|
137
|
+
* is the generic call_mcp_tool wrapper and the real call hides in
|
|
138
|
+
* rawInput {ServerName, ToolName, Arguments} — no _meta.mcp, no
|
|
139
|
+
* mcp_<server>_<tool> name. Without this unwrap the pi-bridge display
|
|
140
|
+
* filter, poll folding and round-trip tracking all miss the call
|
|
141
|
+
* (live-captured fixture, agy 1.5.22, 2026-12-02). */
|
|
142
|
+
function leanMcpTool(update: Record<string, unknown>): { server: string; name: string; args: Record<string, unknown> } | undefined {
|
|
143
|
+
if (stringField(update.name) !== "call_mcp_tool") return undefined;
|
|
144
|
+
const raw = recordField(update.rawInput);
|
|
145
|
+
const server = stringField(raw.ServerName);
|
|
146
|
+
const name = stringField(raw.ToolName);
|
|
147
|
+
if (!server || !name) return undefined;
|
|
148
|
+
return { server, name, args: recordField(raw.Arguments) };
|
|
149
|
+
}
|
|
150
|
+
|
|
135
151
|
/** Clean tool name for MCP tools: the title is "<server>_<tool>" (e.g.
|
|
136
152
|
* "pi-bridge_bridge_echo") and the real name hides in _meta.mcp.tool. */
|
|
137
153
|
function metaToolName(meta: unknown): string | undefined {
|
package/src/config.ts
CHANGED
|
@@ -96,6 +96,11 @@ export interface AcpConfig {
|
|
|
96
96
|
* recover if the server process itself has a wedged socket.
|
|
97
97
|
* Env AGY_ACP_SESSION_RETRY wins over the file. */
|
|
98
98
|
sessionRetryOnTimeout: boolean;
|
|
99
|
+
/** Lean agent mode: spawn the ACP engine with a staged lean agent file
|
|
100
|
+
* (default components excluded) so the model's only tool is the bridge
|
|
101
|
+
* MCP surface. Default false; changing it requires a pi restart (the
|
|
102
|
+
* agent file stages at spawn). Env AGY_ACP_LEAN_AGENT wins over the file. */
|
|
103
|
+
leanAgent: boolean;
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
export interface AgyConfig {
|
|
@@ -146,10 +151,11 @@ export interface AgyConfig {
|
|
|
146
151
|
* always available. */
|
|
147
152
|
patchCleanupNotified?: boolean;
|
|
148
153
|
/** Consent record for the stream-json warning modal (google-antigravity/
|
|
149
|
-
* antigravity-cli#1890:
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
154
|
+
* antigravity-cli#1890: the staged prompt rides `--agent`, so turns bill
|
|
155
|
+
* as custom-agent requests; Google weighted those at 4x quota on agy
|
|
156
|
+
* 1.5.17 and reverted it server-side on 2026-11-30). The modal is PAUSED
|
|
157
|
+
* (no call site shows it), so this flag is written by nothing today and
|
|
158
|
+
* kept only for the rewire. */
|
|
153
159
|
streamJsonAcknowledged?: boolean;
|
|
154
160
|
/** config.json values that were present but unparseable and fell back or
|
|
155
161
|
* failed closed (issue #23). Surfaced by /agy doctor; undefined when
|
|
@@ -250,6 +256,7 @@ const DEFAULTS: AgyConfig = {
|
|
|
250
256
|
usageEstimate: "estimate",
|
|
251
257
|
sessionTimeoutMs: 20_000,
|
|
252
258
|
sessionRetryOnTimeout: false,
|
|
259
|
+
leanAgent: false,
|
|
253
260
|
},
|
|
254
261
|
};
|
|
255
262
|
|
|
@@ -524,7 +531,16 @@ export function loadConfig(configFile: string = configPath()): AgyConfig {
|
|
|
524
531
|
const sessionRetryOnTimeout = envSessionRetry !== undefined
|
|
525
532
|
? ["1", "true", "on"].includes(envSessionRetry.toLowerCase())
|
|
526
533
|
: parseBoolish(fileAcp.sessionRetryOnTimeout, "acp.sessionRetryOnTimeout", DEFAULTS.acp.sessionRetryOnTimeout, parseWarnings);
|
|
527
|
-
const
|
|
534
|
+
const envLeanRaw = process.env.AGY_ACP_LEAN_AGENT;
|
|
535
|
+
const leanAgent =
|
|
536
|
+
envLeanRaw === undefined
|
|
537
|
+
? parseBoolish(fileAcp.leanAgent, "acp.leanAgent", DEFAULTS.acp.leanAgent, parseWarnings)
|
|
538
|
+
: (parseBoolishLiteral(envLeanRaw) ?? (() => {
|
|
539
|
+
// Issue #23 convention: junk falls back to the default AND warns.
|
|
540
|
+
parseWarnings.push(`AGY_ACP_LEAN_AGENT: ${JSON.stringify(envLeanRaw)} is not a recognized boolean (true/false, on/off, 1/0); using default ${DEFAULTS.acp.leanAgent}`);
|
|
541
|
+
return DEFAULTS.acp.leanAgent;
|
|
542
|
+
})());
|
|
543
|
+
const acp: AcpConfig = { usageEstimate, sessionTimeoutMs, sessionRetryOnTimeout, leanAgent };
|
|
528
544
|
|
|
529
545
|
// Custom agent for stream-json turns (--agent). Env wins over the file
|
|
530
546
|
// (same pattern as mode). Normalized (trim/cap/control-strip); an empty
|
|
@@ -600,6 +616,10 @@ export function saveConfig(patch: ConfigPatch, configFile: string = configPath()
|
|
|
600
616
|
patchAcp?.sessionRetryOnTimeout
|
|
601
617
|
?? parseBoolishLiteral(fileAcp.sessionRetryOnTimeout)
|
|
602
618
|
?? DEFAULTS.acp.sessionRetryOnTimeout,
|
|
619
|
+
leanAgent:
|
|
620
|
+
patchAcp?.leanAgent
|
|
621
|
+
?? parseBoolishLiteral(fileAcp.leanAgent)
|
|
622
|
+
?? DEFAULTS.acp.leanAgent,
|
|
603
623
|
};
|
|
604
624
|
// The DEFAULTS 0 is a load-time placeholder (defaultTurnTimeoutMin resolves
|
|
605
625
|
// per TTY state); persisting it would flip absence into "cap disabled"
|
package/src/engine-picker.ts
CHANGED
|
@@ -85,21 +85,24 @@ export function engineSettingsRow(engine: Engine): DialogRow {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/** Consent gate for the stream-json engine (google-antigravity/antigravity-cli#1890)
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
88
|
+
/** Consent gate for the stream-json engine (google-antigravity/antigravity-cli#1890).
|
|
89
|
+
*
|
|
90
|
+
* PAUSED, no call site shows the modal. Google weighted custom-agent
|
|
91
|
+
* requests at 4x quota from agy 1.5.17 and reverted it server-side on
|
|
92
|
+
* 2026-11-30; the vendor said it will look for other ways to curb abuse,
|
|
93
|
+
* so the rate can move again without notice. Kept dormant on purpose: this
|
|
94
|
+
* is the ready response if it does. Rewire by restoring the four call sites
|
|
95
|
+
* in extensions/index.ts (first-run picker, session_start, /agy engine
|
|
96
|
+
* stream-json, the settings row). */
|
|
94
97
|
export const STREAM_JSON_WARNING_INTRO = [
|
|
95
|
-
"The stream-json engine stages your system prompt as a custom --agent file
|
|
98
|
+
"The stream-json engine stages your system prompt as a custom --agent file, so its turns bill as custom-agent requests. Google charged those at 4× Gemini quota per token from agy 1.5.17 until it reverted the change server-side on 2026-11-30 (google-antigravity/antigravity-cli#1890), and said it will look for other ways to curb abuse.",
|
|
96
99
|
"",
|
|
97
|
-
"It is also not a Google-documented integration path for third-party clients. ACP (agy acp) is the documented
|
|
100
|
+
"It is also not a Google-documented integration path for third-party clients. ACP (agy acp) is the documented path.",
|
|
98
101
|
].join("\n");
|
|
99
102
|
|
|
100
103
|
export const SHOW_STREAM_JSON_WARNING_ITEMS: ChoiceOption[] = [
|
|
101
104
|
{ value: "acp", label: "Switch to ACP (recommended)", description: "standard rate · Google's documented surface" },
|
|
102
|
-
{ value: "keep", label: "Keep stream-json", description: "
|
|
105
|
+
{ value: "keep", label: "Keep stream-json", description: "custom-agent rate · can change without notice" },
|
|
103
106
|
];
|
|
104
107
|
|
|
105
108
|
/** True when the engine in play is stream-json and the user has not yet made
|
|
@@ -111,7 +114,7 @@ export function shouldWarnStreamJson(engine: Engine, streamJsonAcknowledged?: bo
|
|
|
111
114
|
/** One-line copy for surfaces without the modal (headless /agy engine) and
|
|
112
115
|
* for the keep verdict's toast. */
|
|
113
116
|
export function streamJsonKeptMessage(): string {
|
|
114
|
-
return "stream-json selected: turns bill
|
|
117
|
+
return "stream-json selected: turns bill as custom-agent requests and this is not a Google-documented integration path (google-antigravity/antigravity-cli#1890).";
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
/** The saveConfig patch for an engine choice that went through the gate: the
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Lean ACP agent (off by default, config.acp.leanAgent): stage a minimal
|
|
2
|
+
// custom agent into the isolated agy home so the spawned engine runs with
|
|
3
|
+
// agy's default components excluded — the model's only tool becomes the
|
|
4
|
+
// generic call_mcp_tool wrapper reaching the bridge MCP server, instead of
|
|
5
|
+
// agy's full native tool set and default prompt (~19k tokens).
|
|
6
|
+
//
|
|
7
|
+
// Probe-verified on agy 1.5.22 (2026-12-02):
|
|
8
|
+
// - the frontmatter below yields the lean surface (689 input tokens vs
|
|
9
|
+
// ~19,300 default); ANY tools key — top-level or nested in an mcpServers
|
|
10
|
+
// entry — resurrects the default component set or invalidates the file;
|
|
11
|
+
// - the mcpServers entry needs only the server NAME: session/new carries the
|
|
12
|
+
// url and the credential header;
|
|
13
|
+
// - the agent file must exist before the agy process spawns (an unknown
|
|
14
|
+
// --agent name makes session/new hang);
|
|
15
|
+
// - agent files staged INSIDE the --gemini-dir home are discovered, so the
|
|
16
|
+
// lean agent never lands in the user's global agents dir.
|
|
17
|
+
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import os from "node:os";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
|
|
22
|
+
export const LEAN_AGENT_NAME = "pi-bridge-lean";
|
|
23
|
+
|
|
24
|
+
/** pi's seven default builtins, the direct-call surface under bridgeTools
|
|
25
|
+
* "all" on ACP (mirrors bridge-catalog PI_DEFAULT_TOOLS; kept in sync by
|
|
26
|
+
* the catalog tests). */
|
|
27
|
+
const DIRECT_TOOL_NAMES = ["read", "bash", "edit", "write", "grep", "find", "ls"] as const;
|
|
28
|
+
|
|
29
|
+
export interface LeanAgentTool {
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Body for the lean agent file, derived from the LIVE authorized bridge
|
|
35
|
+
* catalog at spawn time: the three runtime shapes (codemode bridged /
|
|
36
|
+
* defaults bridged / pair only) each get the protocol their surface needs.
|
|
37
|
+
* The default-agent prompt notes cannot serve here: they claim typed
|
|
38
|
+
* per-tool surfaces a lean agent never has. */
|
|
39
|
+
export function leanAgentBody({ tools }: { tools: ReadonlyArray<LeanAgentTool> }): string {
|
|
40
|
+
const available = new Set(tools.map((t) => t.name));
|
|
41
|
+
const direct = DIRECT_TOOL_NAMES.filter((n) => available.has(n));
|
|
42
|
+
const parts: string[] = [
|
|
43
|
+
'You run embedded in pi as a lean agent: your only tool is call_mcp_tool, and it reaches exactly one MCP server, "pi-bridge" (the pi extension bridge).',
|
|
44
|
+
'Call it with ServerName "pi-bridge", ToolName set to the pi tool name, and Arguments set to that tool\'s arguments object.',
|
|
45
|
+
];
|
|
46
|
+
if (direct.length > 0) {
|
|
47
|
+
parts.push(`Direct pi tools, call by ToolName with their arguments: ${direct.join(", ")}.`);
|
|
48
|
+
}
|
|
49
|
+
if (available.has("codemode")) {
|
|
50
|
+
parts.push(
|
|
51
|
+
'All pi tool work runs through ToolName "codemode": Arguments {"code": "<JavaScript source>"}. Scripts run pi-side as the body of an async function: top-level await and return work; call pi tools as tools.<name>(args) (tools.read, tools.bash, tools.edit, tools.write, tools.grep, tools.find, tools.ls, plus every extension tool); ALL_TOOLS lists every callable tool and searchTools("<query>") ranks them. Batch related steps into one script instead of many calls.',
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
parts.push(
|
|
55
|
+
'Other pi tools (extensions) are not advertised by name: call ToolName "bridge_tool_info" with Arguments {"names":["*"]} to list them, or {"names":["<tool>"]} for one tool\'s schema, then run the tool by its ToolName.',
|
|
56
|
+
);
|
|
57
|
+
parts.push(
|
|
58
|
+
'When a call answers STILL RUNNING with a callId, call ToolName "bridge_poll_result" with Arguments {"callId":"<id>"} until it settles. If the poll answer tells you to stop polling and end the turn, obey it: the settled result arrives as your next message.',
|
|
59
|
+
);
|
|
60
|
+
parts.push(
|
|
61
|
+
"Your native task and subagent tools are not pi's: never delegate through native subagent tools, do the work yourself through the pi tools above, and keep results in your reply. The pi read tool returns image files as visible images. When you need the user's input, ask through pi's ask_user_question tool (discover it with bridge_tool_info).",
|
|
62
|
+
);
|
|
63
|
+
return `${parts.join("\n\n")}\n`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Static frontmatter + body for the lean agent file. The mcpServers entry
|
|
67
|
+
* is deliberately NAME-ONLY: the bridge's session/new declaration carries
|
|
68
|
+
* the url and credential header; a url here would go stale per session. */
|
|
69
|
+
export function leanAgentMd(name: string, body: string): string {
|
|
70
|
+
return [
|
|
71
|
+
"---",
|
|
72
|
+
`name: ${name}`,
|
|
73
|
+
'description: "pi-bridge lean agent (pi tools only)"',
|
|
74
|
+
"mainAgent: true",
|
|
75
|
+
"model: inherit",
|
|
76
|
+
"subagent: false",
|
|
77
|
+
"agents: []",
|
|
78
|
+
"excludeDefaultComponents: true",
|
|
79
|
+
"inheritCustomizations: false",
|
|
80
|
+
"mcpServers:",
|
|
81
|
+
" - name: pi-bridge",
|
|
82
|
+
"---",
|
|
83
|
+
"",
|
|
84
|
+
body,
|
|
85
|
+
].join("\n");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface StageLeanAgentOptions {
|
|
89
|
+
/** The staged home (stageAgyHome output). */
|
|
90
|
+
stagedHome: string;
|
|
91
|
+
name: string;
|
|
92
|
+
body: string;
|
|
93
|
+
/** Override for tests; defaults to ~/.gemini. */
|
|
94
|
+
geminiHome?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Write the lean agent INSIDE the staged home. stageAgyHome junctions the
|
|
98
|
+
* global agents dir when it exists; that junction must become a REAL dir
|
|
99
|
+
* here (the lean agent file must not leak into the user's global agents
|
|
100
|
+
* dir) with the user's own agents re-linked entry by entry so they stay
|
|
101
|
+
* discoverable. Cleanup rides the staged-home sweep: nothing to unregister. */
|
|
102
|
+
export function stageLeanAgentInHome(opts: StageLeanAgentOptions): void {
|
|
103
|
+
const configDir = path.join(opts.stagedHome, "config");
|
|
104
|
+
const stagedAgents = path.join(configDir, "agents");
|
|
105
|
+
const globalAgents = path.join(opts.geminiHome ?? path.join(os.homedir(), ".gemini"), "config", "agents");
|
|
106
|
+
fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
107
|
+
try {
|
|
108
|
+
if (fs.lstatSync(stagedAgents).isSymbolicLink()) fs.unlinkSync(stagedAgents);
|
|
109
|
+
} catch (err) {
|
|
110
|
+
// ENOENT: stageAgyHome found no global agents dir, nothing was linked.
|
|
111
|
+
// Anything else (EPERM on a foreign junction) must fail the stage:
|
|
112
|
+
// writing through a live link would land in the user's global dir.
|
|
113
|
+
if ((err as NodeJS.ErrnoException).code !== "ENOENT") throw err;
|
|
114
|
+
}
|
|
115
|
+
fs.mkdirSync(stagedAgents, { recursive: true, mode: 0o700 });
|
|
116
|
+
let userEntries: fs.Dirent[] = [];
|
|
117
|
+
try {
|
|
118
|
+
userEntries = fs.readdirSync(globalAgents, { withFileTypes: true });
|
|
119
|
+
} catch {
|
|
120
|
+
// No global agents dir: nothing to preserve.
|
|
121
|
+
}
|
|
122
|
+
for (const entry of userEntries) {
|
|
123
|
+
// Never link our own name: the write below must land in the REAL dir
|
|
124
|
+
// we just created, not through a link into the user's global agent.
|
|
125
|
+
if (entry.name === opts.name) continue;
|
|
126
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
|
|
127
|
+
const target = path.join(stagedAgents, entry.name);
|
|
128
|
+
if (fs.existsSync(target)) continue;
|
|
129
|
+
fs.symlinkSync(path.join(globalAgents, entry.name), target, "junction");
|
|
130
|
+
}
|
|
131
|
+
const leanDir = path.join(stagedAgents, opts.name);
|
|
132
|
+
fs.mkdirSync(leanDir, { recursive: true, mode: 0o700 });
|
|
133
|
+
fs.writeFileSync(path.join(leanDir, "agent.md"), leanAgentMd(opts.name, opts.body), { mode: 0o600 });
|
|
134
|
+
}
|
package/src/provider.ts
CHANGED
|
@@ -277,11 +277,16 @@ export function buildFullPrompt(
|
|
|
277
277
|
systemPrompt: string | undefined,
|
|
278
278
|
digest: string,
|
|
279
279
|
prompt: string,
|
|
280
|
-
options?: { codemodeOnly?: boolean; acpToolsDirect?: boolean },
|
|
280
|
+
options?: { codemodeOnly?: boolean; acpToolsDirect?: boolean; lean?: boolean },
|
|
281
281
|
): string {
|
|
282
282
|
const parts: string[] = [];
|
|
283
283
|
if (systemPrompt) {
|
|
284
|
-
|
|
284
|
+
const notes = toolNotes(options);
|
|
285
|
+
parts.push(
|
|
286
|
+
notes.length > 0
|
|
287
|
+
? `${SYSTEM_PROMPT_PREAMBLE}\n\n${systemPrompt}\n\n${notes}\n\n${SYSTEM_PROMPT_END}`
|
|
288
|
+
: `${SYSTEM_PROMPT_PREAMBLE}\n\n${systemPrompt}\n\n${SYSTEM_PROMPT_END}`,
|
|
289
|
+
);
|
|
285
290
|
}
|
|
286
291
|
if (digest) {
|
|
287
292
|
parts.push(`${DIGEST_PREAMBLE}\n\n${digest}`);
|
|
@@ -293,8 +298,11 @@ export function buildFullPrompt(
|
|
|
293
298
|
}
|
|
294
299
|
|
|
295
300
|
/** Shared note composition for the system prompt block and the stream-json
|
|
296
|
-
* staged agent file (which concatenates the notes without buildFullPrompt).
|
|
297
|
-
|
|
301
|
+
* staged agent file (which concatenates the notes without buildFullPrompt).
|
|
302
|
+
* Lean sessions ship NO notes: every note asserts a typed per-tool surface
|
|
303
|
+
* a lean agent never has; the staged lean agent body is the protocol. */
|
|
304
|
+
function toolNotes(options?: { codemodeOnly?: boolean; acpToolsDirect?: boolean; lean?: boolean }): string {
|
|
305
|
+
if (options?.lean) return "";
|
|
298
306
|
const parts = [TOOL_PRIORITY_NOTE];
|
|
299
307
|
if (options?.acpToolsDirect) parts.push(ACP_TOOL_NOTE);
|
|
300
308
|
if (options?.codemodeOnly) parts.push(CODEMODE_NOTE);
|
|
@@ -625,13 +633,16 @@ export function sessionKey(
|
|
|
625
633
|
options: SimpleStreamOptions | undefined,
|
|
626
634
|
cwd: string,
|
|
627
635
|
engine: "stream-json" | "acp",
|
|
636
|
+
lean = false,
|
|
628
637
|
): string {
|
|
629
638
|
const sid = (options as { sessionId?: string } | undefined)?.sessionId;
|
|
630
639
|
const base = sid && sid.length > 0 ? `sid:${sid}` : `cwd:${cwd}`;
|
|
631
640
|
// Engine-scoped keys (plan 9.4): one ACP turn must never touch the stream
|
|
632
641
|
// binding and vice versa. Un-suffixed keys = stream-json, byte-compatible with
|
|
633
|
-
// every store that predates the ACP engine.
|
|
634
|
-
|
|
642
|
+
// every store that predates the ACP engine. The lean marker scopes agent
|
|
643
|
+
// modes apart the same way: a lean flip restarts into a fresh conversation
|
|
644
|
+
// instead of resuming history recorded under the other agent file.
|
|
645
|
+
return base + (engine === "acp" ? "@acp" : "") + (lean ? "@lean" : "");
|
|
635
646
|
}
|
|
636
647
|
|
|
637
648
|
/** Rotate the bound agy conversation after pi compacts the session.
|
|
@@ -701,6 +712,8 @@ export interface StreamSimpleDeps {
|
|
|
701
712
|
* read decides (tests); production wiring always passes it so a
|
|
702
713
|
* mid-session config flip cannot move one side of a parked turn. */
|
|
703
714
|
engine?: "stream-json" | "acp";
|
|
715
|
+
/** Lean agent mode, latched at extension load (see DriverDeps). */
|
|
716
|
+
leanAgent?: boolean;
|
|
704
717
|
/** Output-only ACP tool events; persisted as TUI entries, never sent to
|
|
705
718
|
* Antigravity or dispatched through Pi's executable tools. */
|
|
706
719
|
onNativeEvent?: (event: NativeDisplayEvent) => void;
|
|
@@ -1594,6 +1607,11 @@ export interface DriverDeps {
|
|
|
1594
1607
|
pendingCompactionHandoff?: Set<string>;
|
|
1595
1608
|
/** Active engine (config), for engine-scoped session keys. */
|
|
1596
1609
|
engine: "stream-json" | "acp";
|
|
1610
|
+
/** Lean agent mode, LATCHED at provider construction: the spawned process
|
|
1611
|
+
* only sees the flag at spawn, so notes/catalog/session keys must follow
|
|
1612
|
+
* the latched value, not a live config read (a mid-session flip is
|
|
1613
|
+
* restart-applies). */
|
|
1614
|
+
leanAgent?: boolean;
|
|
1597
1615
|
/** Live pi-side tool visibility (see StreamSimpleDeps). */
|
|
1598
1616
|
hasActiveTool?: (name: string) => boolean;
|
|
1599
1617
|
/** Per-provider handoff runtime (see StreamSimpleDeps). */
|
|
@@ -1852,7 +1870,7 @@ async function runTurnDriver(
|
|
|
1852
1870
|
const blocks: BlockState = { partial, textIdx: null, thinkingIdx: null, started: false };
|
|
1853
1871
|
|
|
1854
1872
|
const cwd = (options as { cwd?: string } | undefined)?.cwd ?? process.cwd();
|
|
1855
|
-
const key = sessionKey(options, cwd, deps.engine);
|
|
1873
|
+
const key = sessionKey(options, cwd, deps.engine, deps.leanAgent === true);
|
|
1856
1874
|
// Ephemeral helper calls (pi compaction / branch summarization set
|
|
1857
1875
|
// cacheRetention: "none"; cache warming / replay callers set
|
|
1858
1876
|
// disableContinuation: true) must run in a fresh, isolated agy
|
|
@@ -1864,6 +1882,9 @@ async function runTurnDriver(
|
|
|
1864
1882
|
const compactionHandoff =
|
|
1865
1883
|
!ephemeral && !existing?.conversationId && Boolean(deps.pendingCompactionHandoff?.has(key));
|
|
1866
1884
|
const messageCount = context.messages.length;
|
|
1885
|
+
// Re-read for the LATE-delivery path below: the fresh-pass `config` above
|
|
1886
|
+
// may predate a steer that landed mid-turn, and the late run wants the
|
|
1887
|
+
// then-current mode/timeout values.
|
|
1867
1888
|
const config = loadConfig();
|
|
1868
1889
|
// Settle bookkeeping shared by both store.set paths: the boundary
|
|
1869
1890
|
// fingerprint validates next turn's delta window, and the compaction
|
|
@@ -2041,6 +2062,9 @@ async function runTurnDriver(
|
|
|
2041
2062
|
acpBashActive = true;
|
|
2042
2063
|
}
|
|
2043
2064
|
const acpToolsDirect = deps.engine === "acp" && config.bridgeTools === "all" && acpBashActive;
|
|
2065
|
+
// Lean agent mode: notes suppressed (see toolNotes); latched at factory
|
|
2066
|
+
// time because the spawned process only saw the flag at spawn.
|
|
2067
|
+
const lean = deps.leanAgent === true;
|
|
2044
2068
|
// The sync orchestrator for THIS pass when the sync gate dispatched; the
|
|
2045
2069
|
// settle (and the park persist) sit outside the fresh-pass block, so the
|
|
2046
2070
|
// binding is function-level (the round-1 settle scope trap).
|
|
@@ -2239,7 +2263,7 @@ async function runTurnDriver(
|
|
|
2239
2263
|
// coordinator calls throw on invariants: both must fail the turn
|
|
2240
2264
|
// visibly, not surface as an unhandled rejection.
|
|
2241
2265
|
const input = turn.inputFor({
|
|
2242
|
-
prompt: buildFullPrompt(sys, "", userPrompt ?? "", { codemodeOnly: codemodeNote, acpToolsDirect }) + stageImageNote(syncImages),
|
|
2266
|
+
prompt: buildFullPrompt(sys, "", userPrompt ?? "", { codemodeOnly: codemodeNote, acpToolsDirect, lean }) + stageImageNote(syncImages),
|
|
2243
2267
|
images: syncImages,
|
|
2244
2268
|
});
|
|
2245
2269
|
turn.bound(key);
|
|
@@ -2269,7 +2293,7 @@ async function runTurnDriver(
|
|
|
2269
2293
|
// history to a fresh conversation; the gate re-opens there.
|
|
2270
2294
|
const fresh = turn.loadFailed({
|
|
2271
2295
|
prompt:
|
|
2272
|
-
buildFullPrompt(config.systemPrompt ? getCurrentSystemPrompt(context.messages) || undefined : undefined, "", userPrompt ?? "", { codemodeOnly: codemodeNote, acpToolsDirect }) +
|
|
2296
|
+
buildFullPrompt(config.systemPrompt ? getCurrentSystemPrompt(context.messages) || undefined : undefined, "", userPrompt ?? "", { codemodeOnly: codemodeNote, acpToolsDirect, lean }) +
|
|
2273
2297
|
stageImageNote(syncImages),
|
|
2274
2298
|
images: syncImages,
|
|
2275
2299
|
});
|
|
@@ -2386,7 +2410,7 @@ async function runTurnDriver(
|
|
|
2386
2410
|
const stagedBody = [
|
|
2387
2411
|
SYSTEM_PROMPT_PREAMBLE,
|
|
2388
2412
|
rawSysPrompt,
|
|
2389
|
-
toolNotes({ codemodeOnly: codemodeNote, acpToolsDirect }),
|
|
2413
|
+
toolNotes({ codemodeOnly: codemodeNote, acpToolsDirect, lean }),
|
|
2390
2414
|
].join("\n\n");
|
|
2391
2415
|
const stagedName = stageSyspromptAgent(stagedBody);
|
|
2392
2416
|
if (stagedName) {
|
|
@@ -2442,7 +2466,7 @@ async function runTurnDriver(
|
|
|
2442
2466
|
// Both features off: the variant would equal the plain prompt.
|
|
2443
2467
|
if (!fbSys && !freshDigest?.text) return undefined;
|
|
2444
2468
|
return {
|
|
2445
|
-
prompt: buildFullPrompt(fbSys, "", deliveredPrompt, { codemodeOnly: codemodeNote, acpToolsDirect }) + stageImageNote(runImages),
|
|
2469
|
+
prompt: buildFullPrompt(fbSys, "", deliveredPrompt, { codemodeOnly: codemodeNote, acpToolsDirect, lean }) + stageImageNote(runImages),
|
|
2446
2470
|
contextBlock: freshDigest?.text
|
|
2447
2471
|
? {
|
|
2448
2472
|
uri: `urn:pi-bridge:context-digest/fresh/${messageCount}`,
|
|
@@ -2459,7 +2483,7 @@ async function runTurnDriver(
|
|
|
2459
2483
|
const fullPrompt =
|
|
2460
2484
|
(late.length > 0 && !freshLate
|
|
2461
2485
|
? buildLateResultPrompt(late, deliveredPrompt || undefined)
|
|
2462
|
-
: buildFullPrompt(sysPrompt, embeddedDigest ? "" : digestFinal, deliveredPrompt, { codemodeOnly: codemodeNote, acpToolsDirect }) +
|
|
2486
|
+
: buildFullPrompt(sysPrompt, embeddedDigest ? "" : digestFinal, deliveredPrompt, { codemodeOnly: codemodeNote, acpToolsDirect, lean }) +
|
|
2463
2487
|
(freshLate ? `\n\n${buildLateResultPrompt(late)}` : "")) +
|
|
2464
2488
|
stageImageNote(runImages);
|
|
2465
2489
|
if (!syncTurn) {
|
|
@@ -2965,6 +2989,9 @@ export function createStreamSimple(
|
|
|
2965
2989
|
// and keying the session as @acp would store a stream
|
|
2966
2990
|
// conversationId under the wrong engine scope.
|
|
2967
2991
|
engine: selected === deps.acpDriver ? "acp" : "stream-json",
|
|
2992
|
+
// Lean rides the ACP driver only: on the stream fallback the
|
|
2993
|
+
// default-agent carrier surface is the contract.
|
|
2994
|
+
leanAgent: selected === deps.acpDriver ? deps.leanAgent : undefined,
|
|
2968
2995
|
log: deps.log,
|
|
2969
2996
|
});
|
|
2970
2997
|
} else {
|