@estebanforge/pi-antigravity-bridge 1.14.0 → 1.15.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 +2 -2
- package/extensions/index.ts +34 -17
- package/package.json +2 -2
- package/src/acp/driver.ts +52 -5
- package/src/acp/history-sync.ts +221 -0
- package/src/ask-tool.ts +1 -1
- package/src/bridge-catalog.ts +23 -3
- package/src/config.ts +20 -5
- package/src/driver-types.ts +26 -0
- package/src/history-projection.ts +188 -0
- package/src/history-sync.ts +299 -0
- package/src/models.ts +16 -11
- package/src/provider.ts +313 -62
- package/src/sessions.ts +12 -0
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.15.0] - 2026-11-24
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- Opt-in canonical-history handoff (`config.handoff: "sync"`, env `AGY_HANDOFF=sync`; ACP-only, digest stays the default): a rolling sha256 prefix chain over the projected transcript drives a per-turn plan, so warm sessions ship only the owed delta as an `urn:pi-bridge:history:v1` block and a session/load failure re-plans as a lossless rebuild (the settle re-arms; no blind turn, no double rebuild). The settle persists the zeroed contract plus the confirmed checkpoint, the churn gate falls back to digest after 3 consecutive `changed-prefix` rebuilds (the latch rides the record so digest turns keep it), and the framed delta hard-fails past the 3 MiB outbound frame budget (the engine silently truncates resources near 3.82 MiB, so bigger frames would checkpoint content it never read). Mode flips are safe both directions. Design: `docs/designs/history-sync-mode.md` (including implementation deviations); live proof: `scripts/smoke-handoff.mjs` scenario 4 and `scripts/probe-acp-frame.mjs` on agy 1.5.16.
|
|
10
|
+
- Codemode-only bridge mode (`/agy bridge codemode`, env `AGY_BRIDGE_TOOLS=codemode`): the engine's catalog shrinks to pi's `codemode` tool (the one direct tool) plus `bridge_tool_info`/`bridge_call_tool` and `bridge_poll_result`, so multi-step work runs as scripts pi-side and nested tool calls never re-enter the engine's context (spike: `scripts/probe-codemode.mjs`, one wire call carried two nested sandbox calls; session/load on a fresh engine process kept the registration; ~2.5k input tokens over a plain baseline turn; live round trip through a real pi session: `scripts/smoke-codemode.mjs` - the engine called the advertised codemode tool and its script executed pi-side read/write on a planted secret, proven end to end). Prerequisite: pi's codemode tool must be ACTIVE (`--tools codemode`, the `defaultTools` setting, or `/tools`) - without it the mode degrades to `all` behavior; the flip warns and `/agy doctor` reports it. The provider system prompt gains a codemode note redirecting the file-tool instruction into scripts, shipped only when the catalog actually has the tool (`buildFullPrompt` `codemodeOnly` gated on live tool visibility).
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The provider tool-priority note's bridge-tool enumeration names the real pi tools (`write`, `bash`) instead of the nonexistent `execute`: fresh conversations get the corrected text, and each stream-json staged agent re-stages under a new content hash (harmless one-time cache bust per conversation).
|
|
15
|
+
- Native xhigh thinking tier: the catalog splits `gemini-4-{hydrogen,neon}-xhigh` slugs into base + tier, pi's `xhigh` thinking level passes through to the engine when the base lists it (clamps to the nearest tier below otherwise; pi's own clamp now resolves `max` to xhigh on bases that ship it, so provider turns get the top tier - the direct `max`→`high` clamp remains only in `toAgyEffort` for direct callers), the model toggle shows the xhigh stop only for bases that ship it, and `/agy thinking` plus the AskAntigravity `thinking` param and the config default (`defaultThinking` / `AGY_DEFAULT_THINKING`) accept `xhigh` end to end (probe: `scripts/probe-xhigh.mjs`, agy 1.5.16 accepted the qualified xhigh slug). Requires `@estebanforge/pi-ask-shared` `^0.1.7` (floor bump: the resolver vocabulary widens first; publish shared before this package).
|
|
16
|
+
|
|
5
17
|
## [1.14.0] - 2026-11-24
|
|
6
18
|
|
|
7
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ If `agy models` fails at load (binary missing, auth not done, network stall), a
|
|
|
117
117
|
| --- | --- | --- |
|
|
118
118
|
| `askTool` | `true` (register the AskAntigravity delegation tool), `false` (no delegation tool; provider and models only) | `true` |
|
|
119
119
|
| `webTools` | `false` (no web tools), `true` (register `agy_web_search` + `agy_read_url` as Pi tools, usable by ANY provider's model). Each call spawns a one-shot search-only `agy` agent (plan mode, bridge MCP inheritance off), gates the answer on an observed native `search_web`/`read_url_content` step, and spends Antigravity quota. Off by default: Antigravity sessions already have native web tools on both engines; these serve other providers | `false` |
|
|
120
|
-
| `bridgeTools` | `none` (bridge off), `all` (every non-builtin tool, incl. other `Ask*` delegations), `mcp` (pi-mcp-adapter tools + skills bridge only) | `all` |
|
|
120
|
+
| `bridgeTools` | `none` (bridge off), `all` (every non-builtin tool, incl. other `Ask*` delegations), `mcp` (pi-mcp-adapter tools + skills bridge only), `codemode` (pi's `codemode` tool + the info/call pair only; requires pi's codemode tool to be active, e.g. `--tools codemode`) | `all` |
|
|
121
121
|
| `digest` | Self-gating delta of pi-side context (compaction summaries, other-provider turns, handoffs after a mid-session switch) shipped to agy only when the delta is non-empty, each piece once. Pure antigravity sessions get byte-stable prompts and an intact prompt cache. `false` = agy prompts contain only your message; a conversation opened mid-session starts without prior pi-side context | `true` |
|
|
122
122
|
| `systemPrompt` | `on` (send pi's system prompt - operating instructions plus the global agent-dir `AGENTS.md` and ancestor `AGENTS.md`/`CLAUDE.md` - to the first prompt of each new agy conversation, plus a tool-priority note: Pi Bridge tools win over agy's native interactive ones, which never reach the user. Delivery: stream-json stages it as an agy agent file via `--agent`, off the prompt line - the CLI silently drops single prompts past a ~25KB cap and the dropped turn kills the conversation; the carrier declares the productive toolset explicitly (omitting `tools:` reads as a read-only set upstream, issue #13) plus `subagent: false` + `agents: []` so the native subagent tools stay masked (ACP carries no agent file, so its natives remain and the tool-priority note steers the model to pi delegation). ACP prepends it to the first prompt) or `false` (agy-native behavior) | `true` |
|
|
123
123
|
| `readOnly` | `true`: fail-closed kill switch - every provider turn and the `AskAntigravity` tool are refused with a visible error (the CLI has no review-only enforcement, see [Permissions](#permissions) and [readOnly](#readonly)). In the file, any value that is not a recognized boolean spelling (or an explicit blank) also fails closed to `true` | `false` |
|
|
@@ -149,7 +149,7 @@ The `activate_skill` catalog mirrors pi's directory-based skill discovery: the t
|
|
|
149
149
|
/agy thinking low|medium|high fallback thinking tier for the AskAntigravity tool; callers may override per call
|
|
150
150
|
/agy digest on|off ship pi-side context to agy when the delta is non-empty (default on; see table above)
|
|
151
151
|
/agy system-prompt on|off send pi's system prompt + AGENTS.md + the Pi Bridge tool-priority note to new agy conversations (default on)
|
|
152
|
-
/agy bridge all|mcp|none which pi tools the MCP bridge exposes to agy (default all; none = bridge off; a running server picks up the new catalog immediately, a stopped one on the next start)
|
|
152
|
+
/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)
|
|
153
153
|
/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)
|
|
154
154
|
/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)
|
|
155
155
|
/agy engine acp|stream-json switch the turn engine (restart to apply; default acp, stream-json is the fallback; both use the agy CLI). No arguments opens the engine picker modal (TUI)
|
package/extensions/index.ts
CHANGED
|
@@ -117,6 +117,7 @@ import {
|
|
|
117
117
|
formatBridgeToolInfo,
|
|
118
118
|
parseBridgeCallRequest,
|
|
119
119
|
partitionBridgeTools,
|
|
120
|
+
codemodeCatalog,
|
|
120
121
|
serializeToolSchema,
|
|
121
122
|
} from "../src/bridge-catalog.js";
|
|
122
123
|
import { Type } from "typebox";
|
|
@@ -686,6 +687,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
686
687
|
onNativeBackground: (info) => armConversationWatcher(info.conversationId, info.turnStartMs),
|
|
687
688
|
roster,
|
|
688
689
|
pendingCompactionHandoff,
|
|
690
|
+
hasActiveTool: (name) => pi.getActiveTools().includes(name),
|
|
689
691
|
engine,
|
|
690
692
|
log: fileLog.log.bind(fileLog),
|
|
691
693
|
});
|
|
@@ -994,14 +996,20 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
994
996
|
// /mcp and pi.setActiveTools() update the same live catalog. ACP gets
|
|
995
997
|
// this endpoint through session/new or session/load; no global config write.
|
|
996
998
|
const mode = loadConfig().bridgeTools;
|
|
997
|
-
const
|
|
998
|
-
const
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
999
|
+
const authorized = getBridgeTools();
|
|
1000
|
+
const codemode = mode === "codemode" ? codemodeCatalog(authorized) : null;
|
|
1001
|
+
const { direct, proxied } = partitionBridgeTools(authorized);
|
|
1002
|
+
const directDefs = codemode
|
|
1003
|
+
? codemode.direct
|
|
1004
|
+
: direct.map((t) => ({
|
|
1005
|
+
name: t.name,
|
|
1006
|
+
description: t.description ?? t.name,
|
|
1007
|
+
inputSchema: serializeToolSchema(t.parameters),
|
|
1008
|
+
}));
|
|
1009
|
+
const tools = directDefs;
|
|
1010
|
+
const proxiedForInfo = codemode ? codemode.proxied : proxied;
|
|
1011
|
+
if (mode !== "none" && proxiedForInfo.length > 0) {
|
|
1012
|
+
tools.push(bridgeToolInfoDef(proxiedForInfo), bridgeCallToolDef());
|
|
1005
1013
|
}
|
|
1006
1014
|
if (skills.length > 0 && mode !== "none") {
|
|
1007
1015
|
tools.push({
|
|
@@ -1359,7 +1367,7 @@ function statusText(ctx: AgyCommandCtx): string {
|
|
|
1359
1367
|
` sessions: ${ctx.store.size} bound`,
|
|
1360
1368
|
` config: ${configPath()}`,
|
|
1361
1369
|
"",
|
|
1362
|
-
"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, /agy agent <name|off>, /agy subagents, /agy quota, /agy artifacts [open <n|name>], /agy tasks [tail <id>], /agy bridge all|mcp|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",
|
|
1370
|
+
"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",
|
|
1363
1371
|
].join("\n");
|
|
1364
1372
|
}
|
|
1365
1373
|
|
|
@@ -1367,7 +1375,7 @@ function statusText(ctx: AgyCommandCtx): string {
|
|
|
1367
1375
|
function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
1368
1376
|
pi.registerCommand("agy", {
|
|
1369
1377
|
description:
|
|
1370
|
-
"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|agent <name|off>|subagents|quota|artifacts [open <n|name>]|tasks [tail <id>]|bridge all|mcp|none|tools [hide|show <name>|reset]|web on|off|digest on|off|system-prompt on|off|timeout <1-1440|off>|patch-cleanup|clear]",
|
|
1378
|
+
"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]",
|
|
1371
1379
|
handler: async (args, cmdCtx: ExtensionCommandContext) => {
|
|
1372
1380
|
const ui = cmdCtx.ui;
|
|
1373
1381
|
if (ui) ctx.setActiveUi(ui);
|
|
@@ -1487,6 +1495,9 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
1487
1495
|
"Antigravity doctor (no tokens spent)",
|
|
1488
1496
|
` engine: ${engine}`,
|
|
1489
1497
|
` bridge: ${config.bridgeTools}${port ? ` (port ${port})` : " (not running)"}`,
|
|
1498
|
+
...(config.bridgeTools === "codemode" && !pi.getActiveTools().includes("codemode")
|
|
1499
|
+
? [" bridge: codemode tool INACTIVE in pi; the engine sees an all-mode catalog without the codemode note. Activate with --tools codemode or the defaultTools setting."]
|
|
1500
|
+
: []),
|
|
1490
1501
|
` driver: ${snap.state}${snap.pid ? ` pid=${snap.pid}` : ""}${snap.conversationId ? ` session=${snap.conversationId.slice(0, 8)}` : ""}`,
|
|
1491
1502
|
` driver stats: spawns=${snap.stats.spawns} turns=${snap.stats.turns} reused=${snap.stats.reused} recycles=${snap.stats.recycles}${snap.stats.lastRecycleReason ? ` (last: ${snap.stats.lastRecycleReason})` : ""}`,
|
|
1492
1503
|
` sessions: ${ctx.store.size} bound`,
|
|
@@ -1801,7 +1812,7 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
1801
1812
|
return;
|
|
1802
1813
|
}
|
|
1803
1814
|
if (sub === "bridge") {
|
|
1804
|
-
if (val === "all" || val === "mcp" || val === "none") {
|
|
1815
|
+
if (val === "all" || val === "mcp" || val === "none" || val === "codemode") {
|
|
1805
1816
|
const next = saveConfig({ bridgeTools: val });
|
|
1806
1817
|
ui?.notify(
|
|
1807
1818
|
ctx.getMcpPort() === null
|
|
@@ -1809,8 +1820,14 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
1809
1820
|
: `bridge ${next.bridgeTools}. The active catalog and call guard update now; ACP may keep cached tool schemas until a session reloads or an agy process restarts (/reload applies it).`,
|
|
1810
1821
|
"info",
|
|
1811
1822
|
);
|
|
1823
|
+
if (val === "codemode" && !pi.getActiveTools().includes("codemode")) {
|
|
1824
|
+
ui?.notify(
|
|
1825
|
+
"pi's codemode tool is inactive, so the engine sees an all-mode catalog and no codemode note. Activate it first: --tools codemode, the defaultTools setting, or /tools.",
|
|
1826
|
+
"warning",
|
|
1827
|
+
);
|
|
1828
|
+
}
|
|
1812
1829
|
} else {
|
|
1813
|
-
ui?.notify(`bridge: ${loadConfig().bridgeTools}\nusage: /agy bridge all|mcp|none\n all: active non-builtin pi tools. mcp: active pi-mcp-adapter tools + skills. none: bridge off.`, "info");
|
|
1830
|
+
ui?.notify(`bridge: ${loadConfig().bridgeTools}\nusage: /agy bridge all|mcp|codemode|none\n all: active non-builtin pi tools. mcp: active pi-mcp-adapter tools + skills. codemode: the codemode tool + info/call pair only (pi's codemode tool must be active; without it this behaves like all). none: bridge off.`, "info");
|
|
1814
1831
|
}
|
|
1815
1832
|
return;
|
|
1816
1833
|
}
|
|
@@ -1899,11 +1916,11 @@ function registerAgyCommand(pi: ExtensionAPI, ctx: AgyCommandCtx): void {
|
|
|
1899
1916
|
}
|
|
1900
1917
|
|
|
1901
1918
|
if (sub === "thinking") {
|
|
1902
|
-
if (val === "low" || val === "medium" || val === "high") {
|
|
1919
|
+
if (val === "low" || val === "medium" || val === "high" || val === "xhigh") {
|
|
1903
1920
|
const next = saveConfig({ defaultThinking: val as ThinkingTier });
|
|
1904
1921
|
ui?.notify(`AskAntigravity default thinking set to ${next.defaultThinking}`, "info");
|
|
1905
1922
|
} else {
|
|
1906
|
-
ui?.notify(`AskAntigravity thinking: ${loadConfig().defaultThinking} (fallback; callers may override per call)\nusage: /agy thinking low|medium|high`, "info");
|
|
1923
|
+
ui?.notify(`AskAntigravity thinking: ${loadConfig().defaultThinking} (fallback; callers may override per call)\nusage: /agy thinking low|medium|high|xhigh|xhigh`, "info");
|
|
1907
1924
|
}
|
|
1908
1925
|
return;
|
|
1909
1926
|
}
|
|
@@ -1993,15 +2010,15 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
1993
2010
|
description:
|
|
1994
2011
|
"AskAntigravity one-shot delegation tool: thinking tier used when the call names none. Callers may override per call; this is only the fallback. Pro has no Medium; it falls back to nearest.",
|
|
1995
2012
|
currentValue: config.defaultThinking,
|
|
1996
|
-
values: ["low", "medium", "high"],
|
|
2013
|
+
values: ["low", "medium", "high", "xhigh"],
|
|
1997
2014
|
},
|
|
1998
2015
|
{
|
|
1999
2016
|
id: "bridge",
|
|
2000
2017
|
label: "Bridge tools",
|
|
2001
2018
|
description:
|
|
2002
|
-
"Which pi tools the MCP bridge exposes to agy. all: every non-builtin tool (default). mcp: pi-mcp-adapter tools + skills. none: bridge off.",
|
|
2019
|
+
"Which pi tools the MCP bridge exposes to agy. all: every non-builtin tool (default). mcp: pi-mcp-adapter tools + skills. codemode: the codemode tool + info/call pair only (pi's codemode tool must be active, e.g. --tools codemode). none: bridge off.",
|
|
2003
2020
|
currentValue: config.bridgeTools,
|
|
2004
|
-
values: ["all", "mcp", "none"],
|
|
2021
|
+
values: ["all", "mcp", "codemode", "none"],
|
|
2005
2022
|
},
|
|
2006
2023
|
{
|
|
2007
2024
|
id: "turn-cap",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estebanforge/pi-antigravity-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.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",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@estebanforge/pi-ask-shared": "^0.1.
|
|
57
|
+
"@estebanforge/pi-ask-shared": "^0.1.7",
|
|
58
58
|
"@estebanforge/pi-tui-dialogs": "^0.1.3",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.31.0"
|
|
60
60
|
}
|
package/src/acp/driver.ts
CHANGED
|
@@ -335,6 +335,16 @@ export class AcpDriver implements TurnDriver {
|
|
|
335
335
|
sessionId: request.conversationId,
|
|
336
336
|
message: err instanceof Error ? err.message : String(err),
|
|
337
337
|
});
|
|
338
|
+
// Sync hook BEFORE the fresh creation: the provider invalidates
|
|
339
|
+
// and re-prepares without an orphaned session (a hook failure
|
|
340
|
+
// after newSession would strand the created conversation).
|
|
341
|
+
let rebuild: { prompt: string; contextBlock?: { uri: string; text: string }; images?: Array<{ data: string; mimeType: string }> } | undefined;
|
|
342
|
+
try {
|
|
343
|
+
rebuild = request.onSessionLoadFailed?.({ sessionId: request.conversationId, error: err }) || undefined;
|
|
344
|
+
} catch (hookErr) {
|
|
345
|
+
this.#failTurn(turn, `ACP session-load hook failed: ${describe(hookErr)}`);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
338
348
|
try {
|
|
339
349
|
const created = await conn.newSession(request.cwd);
|
|
340
350
|
turn.sessionId = created.sessionId;
|
|
@@ -343,11 +353,23 @@ export class AcpDriver implements TurnDriver {
|
|
|
343
353
|
this.#failTurn(turn, `ACP session failed: ${describe(err2)}`);
|
|
344
354
|
return;
|
|
345
355
|
}
|
|
346
|
-
if (
|
|
347
|
-
// The recreated conversation holds nothing: swap in the
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
this.#log("session-load-fallback-applied", { sessionId: request.conversationId });
|
|
356
|
+
if (rebuild) {
|
|
357
|
+
// The recreated conversation holds nothing: swap in the sync
|
|
358
|
+
// rebuild input — a fresh conversation needs the full history
|
|
359
|
+
// block and the complete image set.
|
|
360
|
+
this.#log("session-load-fallback-applied", { sessionId: request.conversationId, source: "sync-rebuild" });
|
|
361
|
+
request = {
|
|
362
|
+
...request,
|
|
363
|
+
prompt: rebuild.prompt,
|
|
364
|
+
contextBlock: rebuild.contextBlock,
|
|
365
|
+
...(rebuild.images ? { images: rebuild.images } : {}),
|
|
366
|
+
};
|
|
367
|
+
turn.request = request;
|
|
368
|
+
} else if (request.fallback) {
|
|
369
|
+
// Digest mode: swap in the as-if-fresh variant the provider
|
|
370
|
+
// prebuilt (system prompt + full bound:false digest) instead
|
|
371
|
+
// of shipping the bound-mode prompt blind.
|
|
372
|
+
this.#log("session-load-fallback-applied", { sessionId: request.conversationId, source: "digest-fallback" });
|
|
351
373
|
request = { ...request, prompt: request.fallback.prompt, contextBlock: request.fallback.contextBlock };
|
|
352
374
|
turn.request = request;
|
|
353
375
|
}
|
|
@@ -358,6 +380,18 @@ export class AcpDriver implements TurnDriver {
|
|
|
358
380
|
}
|
|
359
381
|
if (turn.closed) return;
|
|
360
382
|
|
|
383
|
+
// Binding hook before config apply: the provider persists the binding
|
|
384
|
+
// before model config/prompt, so a later failure cannot leave state
|
|
385
|
+
// that claims a session the transport never confirmed. fresh compares
|
|
386
|
+
// ids, not request.conversationId: a load-failure fresh session must
|
|
387
|
+
// report fresh despite the stale request id.
|
|
388
|
+
try {
|
|
389
|
+
await request.onSessionBound?.({ sessionId: turn.sessionId, reused, fresh: turn.sessionId !== request.conversationId });
|
|
390
|
+
} catch (err) {
|
|
391
|
+
this.#failTurn(turn, `ACP session-bound hook failed: ${describe(err)}`);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
|
|
361
395
|
// Config: model + mode. Model failure fails the turn (wrong-model turns
|
|
362
396
|
// are a parity break); mode failure is best-effort (auto policy makes
|
|
363
397
|
// the modes converge anyway).
|
|
@@ -379,6 +413,14 @@ export class AcpDriver implements TurnDriver {
|
|
|
379
413
|
// Prompt. Updates stream through the connection's onUpdate callback.
|
|
380
414
|
try {
|
|
381
415
|
// Nothing to cancel before the prompt RPC exists; see promptStarted.
|
|
416
|
+
// attempted stamps only after the write-ahead hook passed: a hook
|
|
417
|
+
// failure means the prompt never went out (unconfirmed, not unknown).
|
|
418
|
+
try {
|
|
419
|
+
await request.onBeforePrompt?.({ sessionId: turn.sessionId });
|
|
420
|
+
} catch (err) {
|
|
421
|
+
this.#failTurn(turn, `ACP before-prompt hook failed: ${describe(err)}`);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
382
424
|
turn.promptStarted = true;
|
|
383
425
|
const result = await this.#sessionStep(
|
|
384
426
|
conn,
|
|
@@ -855,6 +897,11 @@ export class AcpDriver implements TurnDriver {
|
|
|
855
897
|
|
|
856
898
|
#settle(turn: ActiveTurn, outcome: TurnOutcome): void {
|
|
857
899
|
if (turn.closed) return;
|
|
900
|
+
// Provenance for the sync settle contract, populated once here so the
|
|
901
|
+
// failTurn, connection-exit and abort paths all carry it (??= keeps any
|
|
902
|
+
// explicitly set value).
|
|
903
|
+
outcome.promptAttempted ??= turn.promptStarted;
|
|
904
|
+
outcome.promptTerminal ??= turn.sawResult;
|
|
858
905
|
const flushed = turn.response.flush();
|
|
859
906
|
if (flushed) {
|
|
860
907
|
turn.textDeltas += 1;
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Per-turn orchestrator for history-sync handoff turns (handoff = "sync").
|
|
2
|
+
//
|
|
3
|
+
// Wraps the pure plan/coordinator modules around one provider turn: prepare
|
|
4
|
+
// the plan from the pi transcript plus the session record, assemble the
|
|
5
|
+
// driver input (framed history resource block + deduped images), and settle
|
|
6
|
+
// the turn with the documented outcome ordering. Store writes stay with the
|
|
7
|
+
// provider (rotation guards live there); record() only builds the zeroed
|
|
8
|
+
// persist contract shape.
|
|
9
|
+
// Run: npm test
|
|
10
|
+
|
|
11
|
+
import { projectHistory, type HistoryProjection } from "../history-projection.js";
|
|
12
|
+
import { SessionSyncCoordinator, type HistorySyncPlan, type SessionSyncState, type SyncOptions } from "../history-sync.js";
|
|
13
|
+
import type { AgySession } from "../sessions.js";
|
|
14
|
+
import type { Message } from "@earendil-works/pi-ai";
|
|
15
|
+
|
|
16
|
+
/** Thrown by inputFor when the framed turn would exceed the outbound budget;
|
|
17
|
+
* the provider uses it to report a budget refusal without string matching. */
|
|
18
|
+
export class OutboundFrameBudgetError extends Error {}
|
|
19
|
+
|
|
20
|
+
export interface AcpHistorySyncOptions extends SyncOptions {}
|
|
21
|
+
|
|
22
|
+
export interface SyncTurnOutcome {
|
|
23
|
+
ok: boolean;
|
|
24
|
+
conversationId?: string | null;
|
|
25
|
+
/** The driver invoked the transport prompt call (weaker than delivery). */
|
|
26
|
+
promptAttempted?: boolean;
|
|
27
|
+
/** The transport reported a terminal result for the prompt. */
|
|
28
|
+
promptTerminal?: boolean;
|
|
29
|
+
aborted?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface SyncInput {
|
|
33
|
+
prompt: string;
|
|
34
|
+
images?: Array<{ data: string; mimeType: string }>;
|
|
35
|
+
contextBlock?: { uri: string; text: string };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type SyncFinishResult = { settled: "terminal" } | { settled: "invalidated"; reason: string };
|
|
39
|
+
|
|
40
|
+
const HISTORY_URI = "urn:pi-bridge:history:v1";
|
|
41
|
+
const FRAME_MARGIN_BYTES = 2048;
|
|
42
|
+
// The engine ACCEPTS outbound frames past ~3.8MiB but silently truncates
|
|
43
|
+
// the resource there (probe-acp-frame 2026-11-24: "truncated at 4002908
|
|
44
|
+
// bytes" on a 4MiB block), so the lossless budget sits safely below the
|
|
45
|
+
// truncation point - well under frame-guard's 32MiB inbound cap.
|
|
46
|
+
const OUTBOUND_FRAME_BUDGET_BYTES = 3 * 1024 * 1024;
|
|
47
|
+
|
|
48
|
+
export class AcpHistorySync {
|
|
49
|
+
#coordinator: SessionSyncCoordinator;
|
|
50
|
+
#messages: Message[];
|
|
51
|
+
#conversationId: string | null;
|
|
52
|
+
#options: AcpHistorySyncOptions;
|
|
53
|
+
#plan: HistorySyncPlan;
|
|
54
|
+
|
|
55
|
+
constructor(messages: readonly Message[], existing?: AgySession | null, options: AcpHistorySyncOptions = {}) {
|
|
56
|
+
this.#messages = [...messages];
|
|
57
|
+
this.#options = options;
|
|
58
|
+
this.#coordinator = new SessionSyncCoordinator(existing?.sync);
|
|
59
|
+
this.#plan = this.#coordinator.prepare(this.#projection(), options);
|
|
60
|
+
// A rebuild deliberately starts a fresh conversation: the tracked id
|
|
61
|
+
// must be null so the outcome id is adopted instead of classified as a
|
|
62
|
+
// binding change, and a mid-turn crash cannot resurrect the stale id.
|
|
63
|
+
this.#conversationId = this.#plan.kind === "rebuild" ? null : (existing?.conversationId ?? null);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#projection(): HistoryProjection {
|
|
67
|
+
return projectHistory(this.#messages);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get plan(): HistorySyncPlan {
|
|
71
|
+
return this.#plan;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** A rebuild always starts a fresh conversation, even over an old binding. */
|
|
75
|
+
get freshConversation(): boolean {
|
|
76
|
+
return this.#plan.kind === "rebuild";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Null while an unbound rebuild is pending; warm sessions keep theirs. */
|
|
80
|
+
get boundConversationId(): string | null {
|
|
81
|
+
return this.#plan.kind === "rebuild" ? null : this.#conversationId;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get snapshot(): SessionSyncState {
|
|
85
|
+
return this.#coordinator.snapshot;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Re-plan from idle (multi-turn reuse); the constructor already planned. */
|
|
89
|
+
prepare(): HistorySyncPlan {
|
|
90
|
+
this.#plan = this.#coordinator.prepare(this.#projection(), this.#options);
|
|
91
|
+
return this.#plan;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
bound(turnId: string): void {
|
|
95
|
+
this.#coordinator.bound(turnId);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Write-ahead adoption from the driver's onSessionBound hook: the fresh
|
|
99
|
+
* conversation id is known before the prompt, so a mid-turn crash still
|
|
100
|
+
* persists the right binding. No-op once tracked. */
|
|
101
|
+
adoptBinding(sessionId: string): void {
|
|
102
|
+
if (!this.#conversationId) this.#conversationId = sessionId;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Session/load failed: invalidate, re-plan as a rebuild over the same
|
|
106
|
+
* transcript, unbind, and return the complete fresh-conversation input
|
|
107
|
+
* (system-prompt-bearing prompt plus full history block and images).
|
|
108
|
+
* The recreated conversation is adopted by the next finish, not treated
|
|
109
|
+
* as a binding change. */
|
|
110
|
+
loadFailed(request: { prompt: string; images?: Array<{ data: string; mimeType: string }> }): SyncInput {
|
|
111
|
+
this.#coordinator.invalidate("session-load-failed");
|
|
112
|
+
this.#conversationId = null;
|
|
113
|
+
this.#plan = this.#coordinator.prepare(this.#projection(), { ...this.#options, continuation: false });
|
|
114
|
+
return this.inputFor(request);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dispatching(): void {
|
|
118
|
+
this.#coordinator.dispatching();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
park(messages: readonly Message[], assistant: Message): void {
|
|
122
|
+
this.#coordinator.park(projectHistory(messages), assistant);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
terminal(messages: readonly Message[], assistant: Message, conversationId?: string | null): void {
|
|
126
|
+
this.#coordinator.terminal(projectHistory(messages), assistant);
|
|
127
|
+
if (conversationId) this.#conversationId = conversationId;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
invalidate(reason: string): void {
|
|
131
|
+
this.#coordinator.invalidate(reason);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Churn-gate latch: the session goes back to the digest flow after this
|
|
135
|
+
* turn's record persists. */
|
|
136
|
+
markDigestFallback(): void {
|
|
137
|
+
this.#coordinator.markDigestFallback();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Assemble the driver turn input: prompt, request + deduped history
|
|
141
|
+
* images, and the framed history resource block when history is owed.
|
|
142
|
+
* Hard-fails over the frame budget — history is never truncated. */
|
|
143
|
+
inputFor(request: { prompt: string; images?: Array<{ data: string; mimeType: string }> }): SyncInput {
|
|
144
|
+
const images = [...(request.images ?? [])];
|
|
145
|
+
const seen = new Set(images.map((image) => image.mimeType + ":" + image.data));
|
|
146
|
+
for (const image of this.#plan.historyImages) {
|
|
147
|
+
const key = image.mimeType + ":" + image.data;
|
|
148
|
+
if (seen.has(key)) continue;
|
|
149
|
+
seen.add(key);
|
|
150
|
+
images.push({ data: image.data, mimeType: image.mimeType });
|
|
151
|
+
}
|
|
152
|
+
const input: SyncInput = { prompt: request.prompt, ...(images.length ? { images } : {}) };
|
|
153
|
+
if (this.#plan.history.length > 0 && this.#plan.embeddedContext) {
|
|
154
|
+
input.contextBlock = { uri: HISTORY_URI, text: this.#plan.embeddedContext };
|
|
155
|
+
}
|
|
156
|
+
const bytes = Buffer.byteLength(JSON.stringify(input)) + FRAME_MARGIN_BYTES;
|
|
157
|
+
if (bytes > OUTBOUND_FRAME_BUDGET_BYTES) {
|
|
158
|
+
throw new OutboundFrameBudgetError(
|
|
159
|
+
`history-sync input exceeds the outbound frame budget (${bytes} bytes); compact the session to shrink history, or shorten the prompt, then retry`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
return input;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Settle the turn per the documented ordering: binding mismatch first,
|
|
166
|
+
* then adopt, then abort-before-terminal, then OK/terminal, then the
|
|
167
|
+
* delivery-unknown and unconfirmed-turn invalidations. */
|
|
168
|
+
finish(
|
|
169
|
+
outcome: SyncTurnOutcome,
|
|
170
|
+
assistant: Message,
|
|
171
|
+
messages: readonly Message[],
|
|
172
|
+
priorConversationId?: string | null,
|
|
173
|
+
): SyncFinishResult {
|
|
174
|
+
const id = outcome.conversationId ?? null;
|
|
175
|
+
// A rebuild EXPECTS a new conversation: only compare against a prior
|
|
176
|
+
// binding when the plan continued a warm session.
|
|
177
|
+
const known = this.freshConversation ? null : (priorConversationId ?? this.#conversationId);
|
|
178
|
+
if (id && known && id !== known) {
|
|
179
|
+
this.#coordinator.invalidate("unexpected-session-change");
|
|
180
|
+
return { settled: "invalidated", reason: "unexpected-session-change" };
|
|
181
|
+
}
|
|
182
|
+
if (id && this.#conversationId !== id) this.#conversationId = id;
|
|
183
|
+
if (outcome.aborted) {
|
|
184
|
+
this.#coordinator.invalidate("interrupted");
|
|
185
|
+
return { settled: "invalidated", reason: "interrupted" };
|
|
186
|
+
}
|
|
187
|
+
if (outcome.ok && outcome.promptTerminal && this.#coordinator.settleable) {
|
|
188
|
+
this.#coordinator.terminal(this.#projectionOf(messages), assistant);
|
|
189
|
+
return { settled: "terminal" };
|
|
190
|
+
}
|
|
191
|
+
if (outcome.ok && outcome.promptTerminal) {
|
|
192
|
+
// Driver-confirmed delivery, but the turn was never bound (provider
|
|
193
|
+
// contract violation or an unwired hook): the checkpoint cannot
|
|
194
|
+
// absorb, so force the named rebuild instead of crashing terminal().
|
|
195
|
+
this.#coordinator.invalidate("unsettled-terminal");
|
|
196
|
+
return { settled: "invalidated", reason: "unsettled-terminal" };
|
|
197
|
+
}
|
|
198
|
+
// A terminal-but-failed outcome (refusal, engine error with a result
|
|
199
|
+
// frame) IS confirmed delivery - only an attempted prompt that never
|
|
200
|
+
// went terminal stays delivery-unknown; everything else never left.
|
|
201
|
+
const reason = outcome.promptAttempted && !outcome.promptTerminal ? "delivery-unknown" : "unconfirmed-turn";
|
|
202
|
+
this.#coordinator.invalidate(reason);
|
|
203
|
+
return { settled: "invalidated", reason };
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
#projectionOf(messages: readonly Message[]): HistoryProjection {
|
|
207
|
+
return projectHistory(messages);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Zeroed persist-contract record: digest watermark fields zeroed so a
|
|
211
|
+
* later digest flip re-offers the backlog once, safely. Null
|
|
212
|
+
* conversationId means the caller skips persisting. */
|
|
213
|
+
record(): Omit<AgySession, 'conversationId'> & { conversationId: string | null } {
|
|
214
|
+
return {
|
|
215
|
+
conversationId: this.#conversationId,
|
|
216
|
+
lastStepIdx: -1,
|
|
217
|
+
lastMessageCount: 0,
|
|
218
|
+
sync: this.#coordinator.snapshot,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
package/src/ask-tool.ts
CHANGED
|
@@ -675,7 +675,7 @@ export async function registerAskAntigravityTool(
|
|
|
675
675
|
thinking: Type.Optional(
|
|
676
676
|
Type.String({
|
|
677
677
|
description:
|
|
678
|
-
"Thinking level (= agy effort tier). pi vocabulary: minimal|low|medium|high|xhigh|max
|
|
678
|
+
"Thinking level (= agy effort tier). pi vocabulary: minimal|low|medium|high|xhigh|max; passes through when the target model lists the tier (the Gemini 4 line ships xhigh) and clamps to the nearest tier below otherwise. Overrides a tier embedded in `model`. Omit for the configured default.",
|
|
679
679
|
}),
|
|
680
680
|
),
|
|
681
681
|
effort: Type.Optional(
|
package/src/bridge-catalog.ts
CHANGED
|
@@ -53,9 +53,14 @@ export function bridgedPiTools(
|
|
|
53
53
|
// Never bridge the bridge's own tools. agy has native web tools, so
|
|
54
54
|
// our quota-burning one-shot wrappers must not tempt it through MCP.
|
|
55
55
|
!BRIDGE_INTERNAL_TOOLS.has(tool.name) &&
|
|
56
|
-
(mode === "
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
(mode === "codemode"
|
|
57
|
+
// Codemode mode: pi's builtin codemode tool is the one builtin that
|
|
58
|
+
// bridges (scripts reach the rest pi-side); the info/call pair covers
|
|
59
|
+
// tools the engine should not call directly.
|
|
60
|
+
? tool.name === "codemode" || tool.sourceInfo?.source !== "builtin"
|
|
61
|
+
: mode === "mcp"
|
|
62
|
+
? /pi-mcp-adapter/.test(tool.sourceInfo?.source ?? "")
|
|
63
|
+
: tool.sourceInfo?.source !== "builtin"),
|
|
59
64
|
);
|
|
60
65
|
}
|
|
61
66
|
|
|
@@ -70,6 +75,21 @@ export function partitionBridgeTools<T extends BridgeToolInfo>(tools: readonly T
|
|
|
70
75
|
return { direct, proxied };
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
/** Codemode-only catalog projection: pi's codemode tool is the one direct
|
|
79
|
+
* tool (its own description teaches the script grammar and pi executes the
|
|
80
|
+
* scripts with pi's tools injected), every other authorized tool rides the
|
|
81
|
+
* info/call pair so the engine never sees a wide direct catalog. */
|
|
82
|
+
export function codemodeCatalog<T extends BridgeToolInfo>(
|
|
83
|
+
authorized: readonly T[],
|
|
84
|
+
): { direct: Array<{ name: string; description: string; inputSchema: object }>; proxied: T[] } {
|
|
85
|
+
const cm = authorized.find((t) => t.name === "codemode");
|
|
86
|
+
const proxied = authorized.filter((t) => t.name !== "codemode");
|
|
87
|
+
const direct = cm
|
|
88
|
+
? [{ name: cm.name, description: cm.description ?? cm.name, inputSchema: serializeToolSchema(cm.parameters) }]
|
|
89
|
+
: [];
|
|
90
|
+
return { direct, proxied };
|
|
91
|
+
}
|
|
92
|
+
|
|
73
93
|
/** Build the bridge_tool_info MCP tool definition listing proxied extension tool names. */
|
|
74
94
|
export function bridgeToolInfoDef(proxied: readonly BridgeToolInfo[]): {
|
|
75
95
|
name: string;
|
package/src/config.ts
CHANGED
|
@@ -49,8 +49,8 @@ export type Engine = "stream-json" | "acp";
|
|
|
49
49
|
* fall back here. Startup checks that the required agy CLI is available. */
|
|
50
50
|
export const DEFAULT_ENGINE: Engine = "acp";
|
|
51
51
|
export type AgyMode = "accept-edits" | "plan";
|
|
52
|
-
export type ThinkingTier = "low" | "medium" | "high";
|
|
53
|
-
export type BridgeTools = "none" | "mcp" | "all";
|
|
52
|
+
export type ThinkingTier = "low" | "medium" | "high" | "xhigh";
|
|
53
|
+
export type BridgeTools = "none" | "mcp" | "all" | "codemode";
|
|
54
54
|
|
|
55
55
|
/** How ACP turns report token usage while Gate B stands (agy sends none).
|
|
56
56
|
* "estimate" (default): word-boundary regex over prompt/response/thought
|
|
@@ -104,6 +104,10 @@ export interface AgyConfig {
|
|
|
104
104
|
/** Official-server ACP engine options (used when engine = "acp"). */
|
|
105
105
|
acp: AcpConfig;
|
|
106
106
|
mode: AgyMode;
|
|
107
|
+
/** Fresh-conversation handoff style. "digest" (default) ships the bounded
|
|
108
|
+
* context digest; "sync" ships canonical history checkpoints (ACP only —
|
|
109
|
+
* stream-json keeps the digest path regardless). AGY_HANDOFF=sync opts in. */
|
|
110
|
+
handoff: "digest" | "sync";
|
|
107
111
|
/** Fail-closed kill switch for provider turns. ON = every provider turn
|
|
108
112
|
* is refused visibly: the agy CLI has no review-only enforcement on any
|
|
109
113
|
* path (probed 2026-10-07, upstream #1181: plan mode stages a plan and
|
|
@@ -220,6 +224,7 @@ export interface AgyConfig {
|
|
|
220
224
|
const DEFAULTS: AgyConfig = {
|
|
221
225
|
engine: DEFAULT_ENGINE,
|
|
222
226
|
mode: "accept-edits",
|
|
227
|
+
handoff: "digest",
|
|
223
228
|
readOnly: false,
|
|
224
229
|
skipPermissions: true,
|
|
225
230
|
defaultModel: "gemini-4-hydrogen",
|
|
@@ -398,6 +403,12 @@ export function loadConfig(configFile: string = configPath()): AgyConfig {
|
|
|
398
403
|
? "plan"
|
|
399
404
|
: "accept-edits";
|
|
400
405
|
|
|
406
|
+
const handoffRaw = (process.env.AGY_HANDOFF ?? file.handoff ?? DEFAULTS.handoff).toString().toLowerCase();
|
|
407
|
+
const handoff: "digest" | "sync" = handoffRaw === "sync" ? "sync" : handoffRaw === "digest" ? "digest" : (() => {
|
|
408
|
+
parseWarnings.push(`handoff: ${String(handoffRaw)} is not digest|sync; using ${DEFAULTS.handoff}`);
|
|
409
|
+
return DEFAULTS.handoff;
|
|
410
|
+
})();
|
|
411
|
+
|
|
401
412
|
const envPerm = process.env.AGY_SKIP_PERMISSIONS;
|
|
402
413
|
const skipPermissions =
|
|
403
414
|
envPerm !== undefined
|
|
@@ -423,7 +434,7 @@ export function loadConfig(configFile: string = configPath()): AgyConfig {
|
|
|
423
434
|
const envThink = process.env.AGY_DEFAULT_THINKING;
|
|
424
435
|
const thinkRaw = String(envThink ?? file.defaultThinking ?? DEFAULTS.defaultThinking).toLowerCase();
|
|
425
436
|
const defaultThinking: ThinkingTier =
|
|
426
|
-
thinkRaw === "low" || thinkRaw === "high" ? thinkRaw : "medium";
|
|
437
|
+
thinkRaw === "low" || thinkRaw === "high" || thinkRaw === "xhigh" ? thinkRaw : "medium";
|
|
427
438
|
|
|
428
439
|
const askTool = process.env.AGY_ASK_TOOL !== undefined
|
|
429
440
|
? ["1", "true", "on"].includes(process.env.AGY_ASK_TOOL.toLowerCase())
|
|
@@ -435,9 +446,12 @@ export function loadConfig(configFile: string = configPath()): AgyConfig {
|
|
|
435
446
|
|
|
436
447
|
const bridgeRaw = String(process.env.AGY_BRIDGE_TOOLS ?? file.bridgeTools ?? DEFAULTS.bridgeTools).toLowerCase();
|
|
437
448
|
const bridgeTools: BridgeTools =
|
|
438
|
-
bridgeRaw === "none" || bridgeRaw === "all" || bridgeRaw === "mcp"
|
|
449
|
+
bridgeRaw === "none" || bridgeRaw === "all" || bridgeRaw === "mcp" || bridgeRaw === "codemode"
|
|
439
450
|
? bridgeRaw
|
|
440
|
-
:
|
|
451
|
+
: (() => {
|
|
452
|
+
parseWarnings.push(`bridgeTools: ${bridgeRaw} is not all|mcp|codemode|none; using ${DEFAULTS.bridgeTools}`);
|
|
453
|
+
return DEFAULTS.bridgeTools;
|
|
454
|
+
})();
|
|
441
455
|
|
|
442
456
|
// Extra long-window tool names for the bridge escalation (issue #6).
|
|
443
457
|
// Comma-separated in the env; junk entries and junk shapes are dropped,
|
|
@@ -513,6 +527,7 @@ export function loadConfig(configFile: string = configPath()): AgyConfig {
|
|
|
513
527
|
engine,
|
|
514
528
|
acp,
|
|
515
529
|
mode,
|
|
530
|
+
handoff,
|
|
516
531
|
readOnly,
|
|
517
532
|
skipPermissions,
|
|
518
533
|
defaultModel,
|