diff --git a/packages/agy-cli/README.en.md b/packages/agy-cli/README.en.md index 2795258..603e7e9 100644 --- a/packages/agy-cli/README.en.md +++ b/packages/agy-cli/README.en.md @@ -255,6 +255,7 @@ usage reads wait 10 minutes before the next try, doubling up to 6 hours. | `AGY_BRIDGE_THINKING` | on | Set to `0` to stop forwarding thought summaries | | `AGY_BRIDGE_EFFORT` | unset | Force a thinking level: `minimal`, `low`, `medium`, `high`, `xhigh` or `max` | | `AGY_BRIDGE_MINIMAL_AGENT` | off | Set to `1` to drop agy's own prompt components; see "Minimal agent" below | +| `AGY_BRIDGE_TELEMETRY` | off (agy reports nothing) | The bridge starts agy with `--disable-telemetry` when agy's `acp --help` lists it; set to `1` to keep agy's own reporting | | `AGY_BRIDGE_SYSTEM_APPEND` | off | Set to `1` to append the client's system prompt to agy's own instead of putting it in the first prompt; see below | | `AGY_BRIDGE_IDLE_MS` | 600000 | How long a process may sit idle before it is reclaimed; the session can still resume | | `AGY_BRIDGE_SPARE` | on | Keeps one spare agy per account, started but with no session and no request sent, so a new conversation skips agy's start; set to `0` to turn it off | diff --git a/packages/agy-cli/README.md b/packages/agy-cli/README.md index 56aea51..1b2f463 100644 --- a/packages/agy-cli/README.md +++ b/packages/agy-cli/README.md @@ -184,6 +184,7 @@ agy 的拒绝原因,不显示数字。 | `AGY_BRIDGE_THINKING` | 开启 | 设为 `0` 关闭思考摘要 | | `AGY_BRIDGE_EFFORT` | 未设置 | 强制思考等级:`minimal` / `low` / `medium` / `high` / `xhigh` / `max` | | `AGY_BRIDGE_MINIMAL_AGENT` | 关闭 | 设为 `1` 去掉 agy 自带的提示组件,见下文「精简 agent」 | +| `AGY_BRIDGE_TELEMETRY` | 关闭(agy 不上报) | 插件启动 agy 时带上 `--disable-telemetry`(agy 的 `acp --help` 没这个开关就带不上);设成 `1` 保留 agy 自己的上报 | | `AGY_BRIDGE_SYSTEM_APPEND` | 关闭 | 设为 `1` 把客户端的系统提示词附加到 agy 自己的系统提示词后面,而不是放进第一条提示词,见下文 | | `AGY_BRIDGE_IDLE_MS` | 600000 | 进程空闲多久后回收(会话仍可续接) | | `AGY_BRIDGE_SPARE` | 开启 | 每个账号预先启动一个备用 agy(只启动、不建会话,不发任何请求),新对话直接用它,省掉 agy 的启动时间;设为 `0` 关闭 | diff --git a/packages/agy-cli/index.mjs b/packages/agy-cli/index.mjs index 01facab..8ff8860 100644 --- a/packages/agy-cli/index.mjs +++ b/packages/agy-cli/index.mjs @@ -312,6 +312,17 @@ export function noDefaultCustomizationsArgs(agyPath) { return acpHelp(agyPath).then((help) => (/--include-default-customizations\b/.test(help) ? ["--include-default-customizations=false"] : [])) } +// agy reports the run to its vendor unless it is told not to. The bridge turns +// that off by default, as a privacy setting rather than a workaround: what the +// user types here is the client's business and agy's vendor's logs are not the +// place it lands. Passed only when `agy acp --help` lists the flag, since an +// agy without it refuses to start on it; AGY_BRIDGE_TELEMETRY=1 keeps agy's +// own default for anyone who wants the vendor's diagnostics. +export function telemetryArgs(agyPath, env = process.env) { + if (/^(?:1|true|on|yes|enabled)$/i.test(env.AGY_BRIDGE_TELEMETRY || "")) return Promise.resolve([]) + return acpHelp(agyPath).then((help) => (/--disable[-_]telemetry\b/.test(help) ? ["--disable-telemetry"] : [])) +} + // The bridge's own agy folder, kept across restarts so agy finds a // conversation again on session/resume. AGY_BRIDGE_GEMINI_DIR names another; // "default" (or 0, off, …) leaves agy on its own ~/.gemini, skills and all. @@ -1996,6 +2007,7 @@ class Proc { ] if (this.workDir) args.push("--add-dir", this.workDir) args.push(...await noDefaultCustomizationsArgs(this.agyPath)) + args.push(...await telemetryArgs(this.agyPath)) const own = await geminiDirArgs(this.agyPath) args.push(...own.args) // agy writes the conversation's steps under the folder it was given @@ -3271,7 +3283,7 @@ async function launchKey(agyPath, workDir) { try { mtime = (await fs.promises.stat(agyPath)).mtimeMs } catch {} const own = await geminiDirArgs(agyPath) return digest(JSON.stringify([currentHome(), agyPath, mtime, workDir || "", - await noDefaultCustomizationsArgs(agyPath), own.args, childEnv(process.env)])) + await noDefaultCustomizationsArgs(agyPath), await telemetryArgs(agyPath), own.args, childEnv(process.env)])) } function dropSpare(spare) { diff --git a/packages/agy-cli/package.json b/packages/agy-cli/package.json index 29034a2..e8f47e1 100644 --- a/packages/agy-cli/package.json +++ b/packages/agy-cli/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-agy-cli-auth", - "version": "0.1.85", + "version": "0.1.86", "description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI", "type": "module", "main": "./opencode.mjs", diff --git a/packages/agy-cli/test/repeat-batch.mjs b/packages/agy-cli/test/repeat-batch.mjs index 6aa3fe1..6d9fcb0 100644 --- a/packages/agy-cli/test/repeat-batch.mjs +++ b/packages/agy-cli/test/repeat-batch.mjs @@ -904,6 +904,33 @@ test("A16: under a tight budget, a mid-loop user steer beats an opening meta com }) }) +// #896: agy reports the run to its vendor unless it is told not to; the flag +// is passed only to an agy whose own acp --help lists it. +const TELEMETRY_HELP = "Usage of acp:\n --disable-telemetry\n \tdisable telemetry (default false)\n" + +test("#896: an agy whose acp --help lists --disable-telemetry starts with telemetry off", async () => { + await withKit({ acpHelp: TELEMETRY_HELP }, async (kit) => { + scriptedAgent(kit) + const reply = await readSse(await kit.request(baseBody({ metadata: { user_id: "telemetry-listed" }, + messages: [{ role: "user", content: "hello" }] }))) + assert.equal(reply.stopReason, "end_turn") + assert.equal(kit.acpSpawns.length, 1) + assert.ok(kit.acpSpawns[0].args.includes("--disable-telemetry"), kit.acpSpawns[0].args.join(" ")) + }) +}) + +test("#896: an agy without the flag is never given it, and AGY_BRIDGE_TELEMETRY=1 keeps agy's own default", async () => { + for (const options of [{}, { acpHelp: TELEMETRY_HELP, env: { AGY_BRIDGE_TELEMETRY: "1" } }]) { + await withKit(options, async (kit) => { + scriptedAgent(kit) + const reply = await readSse(await kit.request(baseBody({ metadata: { user_id: "telemetry-unlisted" }, + messages: [{ role: "user", content: "hello" }] }))) + assert.equal(reply.stopReason, "end_turn") + assert.ok(!kit.acpSpawns[0].args.includes("--disable-telemetry"), kit.acpSpawns[0].args.join(" ")) + }) + } +}) + // ----------------------------------------------- agy's error marker (#1052) function markerAgent(kit, chunks) { diff --git a/packages/agy-cli/test/smoke.mjs b/packages/agy-cli/test/smoke.mjs index f104b6d..5c8ef73 100644 --- a/packages/agy-cli/test/smoke.mjs +++ b/packages/agy-cli/test/smoke.mjs @@ -110,7 +110,7 @@ if (argv.includes("models")) { } if (argv[0] === "acp" && argv.includes("--help")) { log({ type: "acpHelp" }) - process.stderr.write("Usage of acp:\n --agent string\n --include-default-customizations\n \tload the default customizations (default true)\n") + process.stderr.write("Usage of acp:\n --agent string\n --include-default-customizations\n \tload the default customizations (default true)\n --disable-telemetry\n \tdisable telemetry (default false)\n") process.exit(0) } if (argv[0] !== "acp") { @@ -3084,6 +3084,8 @@ for (const location of ["inline", "system", "developer", "user"]) { const sessions = inits().filter(event => event.args.includes("--agent")) const without = sessions.filter(event => !event.args.includes("--include-default-customizations=false")) check("an agy whose acp --help lists it starts without the machine's own customizations (#1166)", sessions.length > 0 && without.length === 0, JSON.stringify(without.map(event => event.args))) + const talkative = sessions.filter(event => !event.args.includes("--disable-telemetry")) + check("an agy whose acp --help lists it starts with telemetry off (#896)", sessions.length > 0 && talkative.length === 0, JSON.stringify(talkative.map(event => event.args))) } check("all ACP children disable auto update when the user set nothing", inits().length > 0 && inits().every(event => event.update === "true")) check("child launches never mutate the parent's update setting", process.env.AGY_CLI_DISABLE_AUTO_UPDATE === undefined)