toc-ocra 0.3.20 → 0.3.22

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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/cli.mjs +667 -195
  3. package/dist/service/agent.mjs +642 -170
  4. package/dist/src/acp/acp-dialects/acp-dialect.d.ts +5 -1
  5. package/dist/src/acp/acp-dialects/acp-dialect.js.map +1 -1
  6. package/dist/src/acp/acp-dialects/antigravity-dialect.d.ts +20 -0
  7. package/dist/src/acp/acp-dialects/antigravity-dialect.js +126 -0
  8. package/dist/src/acp/acp-dialects/antigravity-dialect.js.map +1 -0
  9. package/dist/src/acp/acp-dialects/gemini-dialect.d.ts +1 -1
  10. package/dist/src/acp/acp-dialects/gemini-dialect.js +6 -2
  11. package/dist/src/acp/acp-dialects/gemini-dialect.js.map +1 -1
  12. package/dist/src/acp/acp-launch-specs.d.ts +2 -0
  13. package/dist/src/acp/acp-launch-specs.js +24 -2
  14. package/dist/src/acp/acp-launch-specs.js.map +1 -1
  15. package/dist/src/acp/acp-options.js +6 -3
  16. package/dist/src/acp/acp-options.js.map +1 -1
  17. package/dist/src/acp/chat-agents.js +3 -1
  18. package/dist/src/acp/chat-agents.js.map +1 -1
  19. package/dist/src/acp/chat-session.js +10 -2
  20. package/dist/src/acp/chat-session.js.map +1 -1
  21. package/dist/src/providers/acp/acp-driver.js +9 -3
  22. package/dist/src/providers/acp/acp-driver.js.map +1 -1
  23. package/dist/src/providers/antigravity-quota.d.ts +17 -0
  24. package/dist/src/providers/antigravity-quota.js +253 -0
  25. package/dist/src/providers/antigravity-quota.js.map +1 -0
  26. package/dist/src/providers/cli-specs.js +1 -0
  27. package/dist/src/providers/cli-specs.js.map +1 -1
  28. package/dist/src/providers/model-catalog.d.ts +9 -0
  29. package/dist/src/providers/model-catalog.js +126 -0
  30. package/dist/src/providers/model-catalog.js.map +1 -1
  31. package/dist/src/providers/registry.js +2 -0
  32. package/dist/src/providers/registry.js.map +1 -1
  33. package/package.json +1 -1
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
 
8
8
  // src/plugin-service.ts
9
9
  import { existsSync as existsSync8 } from "node:fs";
10
- import { delimiter as delimiter5, join as join24 } from "node:path";
10
+ import { delimiter as delimiter5, join as join25 } from "node:path";
11
11
 
12
12
  // src/config.ts
13
13
  import { randomUUID } from "node:crypto";
@@ -851,14 +851,14 @@ function promiseAllObject(promisesObj) {
851
851
  }
852
852
  function randomString(length = 10) {
853
853
  const chars = "abcdefghijklmnopqrstuvwxyz";
854
- let str2 = "";
854
+ let str3 = "";
855
855
  for (let i = 0; i < length; i++) {
856
- str2 += chars[Math.floor(Math.random() * chars.length)];
856
+ str3 += chars[Math.floor(Math.random() * chars.length)];
857
857
  }
858
- return str2;
858
+ return str3;
859
859
  }
860
- function esc(str2) {
861
- return JSON.stringify(str2);
860
+ function esc(str3) {
861
+ return JSON.stringify(str3);
862
862
  }
863
863
  function slugify(input2) {
864
864
  return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -972,8 +972,8 @@ var primitiveTypes = /* @__PURE__ */ new Set([
972
972
  "symbol",
973
973
  "undefined"
974
974
  ]);
975
- function escapeRegex(str2) {
976
- return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
975
+ function escapeRegex(str3) {
976
+ return str3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
977
977
  }
978
978
  function clone(inst, def, params) {
979
979
  const cl = new inst._zod.constr(def ?? inst._zod.def);
@@ -1239,13 +1239,13 @@ function getSizableOrigin(input2) {
1239
1239
  return "unknown";
1240
1240
  }
1241
1241
  var highSurrogate = /[\uD800-\uDBFF]/;
1242
- function codePointLength(str2) {
1243
- const units = str2.length;
1244
- if (!highSurrogate.test(str2))
1242
+ function codePointLength(str3) {
1243
+ const units = str3.length;
1244
+ if (!highSurrogate.test(str3))
1245
1245
  return units;
1246
1246
  let count2 = units;
1247
1247
  for (let i = 0; i < units - 1; i++) {
1248
- if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
1248
+ if ((str3.charCodeAt(i) & 64512) === 55296 && (str3.charCodeAt(i + 1) & 64512) === 56320) {
1249
1249
  count2--;
1250
1250
  i++;
1251
1251
  }
@@ -20331,7 +20331,7 @@ function createDiagnosticLogger(filePath, options = {}) {
20331
20331
  }
20332
20332
 
20333
20333
  // src/providers/detection.ts
20334
- import { spawn as spawn9 } from "node:child_process";
20334
+ import { spawn as spawn10 } from "node:child_process";
20335
20335
 
20336
20336
  // src/runtime/cli/hydrate-shell-path.ts
20337
20337
  import { delimiter as delimiter3 } from "node:path";
@@ -20781,6 +20781,7 @@ var SOURCES = [
20781
20781
  { id: "claude", label: "Claude Code", aliases: ["claude-code"], command: "claude", commandAliases: ["claude-code"], versionArguments: ["--version"], promptStdin: "omit", restrictedPermission: true, installHint: "npm i -g @anthropic-ai/claude-code" },
20782
20782
  { id: "grok", label: "Grok CLI", command: "grok", versionArguments: ["--version"] },
20783
20783
  { id: "gemini", label: "Gemini CLI", command: "gemini", versionArguments: ["--version"], restrictedPermission: true, installHint: "npm i -g @google/gemini-cli" },
20784
+ { id: "antigravity", label: "Antigravity", aliases: ["agy"], command: "agy", versionArguments: ["--version"], restrictedPermission: true, installHint: "https://antigravity.google/cli" },
20784
20785
  { id: "opencode", label: "OpenCode", command: "opencode", versionArguments: ["--version"], installHint: "npm i -g opencode-ai" },
20785
20786
  { id: "kiro", label: "Kiro CLI", aliases: ["kiro-cli"], command: "kiro-cli", commandAliases: ["kiro"], versionArguments: ["--version"], promptStdin: "omit", restrictedPermission: true },
20786
20787
  { id: "omp", label: "OMP", command: "omp", versionArguments: ["--version"] },
@@ -21011,7 +21012,7 @@ function textRows(prefix, text3, maxRows = 40) {
21011
21012
 
21012
21013
  // src/acp/acp-launch-specs.ts
21013
21014
  import { realpathSync as realpathSync2 } from "node:fs";
21014
- import { join as join13 } from "node:path";
21015
+ import { join as join14 } from "node:path";
21015
21016
 
21016
21017
  // src/providers/claude-sessions.ts
21017
21018
  import { existsSync as existsSync5, readdirSync as readdirSync3 } from "node:fs";
@@ -21173,8 +21174,8 @@ function codexCatalogArgs() {
21173
21174
  // src/providers/model-catalog.ts
21174
21175
  import { spawn as spawn5 } from "node:child_process";
21175
21176
  import { readdir, readFile as readFile4 } from "node:fs/promises";
21176
- import { homedir as homedir7 } from "node:os";
21177
- import { isAbsolute as isAbsolute2, join as join10, resolve as resolve3 } from "node:path";
21177
+ import { homedir as homedir8 } from "node:os";
21178
+ import { isAbsolute as isAbsolute2, join as join11, resolve as resolve3 } from "node:path";
21178
21179
 
21179
21180
  // src/providers/kiro-auth.ts
21180
21181
  import { execFile as execFile3 } from "node:child_process";
@@ -21294,6 +21295,116 @@ async function readKiroNativeModels(launch, cwd, options = {}) {
21294
21295
  }
21295
21296
  }
21296
21297
 
21298
+ // src/acp/acp-dialects/antigravity-dialect.ts
21299
+ import { readFileSync as readFileSync5 } from "node:fs";
21300
+ import { homedir as homedir7 } from "node:os";
21301
+ import { join as join10 } from "node:path";
21302
+
21303
+ // src/acp/acp-dialects/acp-dialect.ts
21304
+ var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
21305
+
21306
+ // src/acp/acp-dialects/antigravity-dialect.ts
21307
+ var str2 = (value) => typeof value === "string" && value ? value : void 0;
21308
+ var num = (value) => typeof value === "number" && Number.isSafeInteger(value) ? value : void 0;
21309
+ var ANTIGRAVITY_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
21310
+ var ANTIGRAVITY_LEVEL_SUFFIX = /^(.+)-(low|medium|high|xhigh|max)$/;
21311
+ var CLOUD_CODE_PREFIX = /^Cloud Code Assist API error \(\d{3}\):\s*/;
21312
+ var EXECUTOR_API_ERROR = /^(\u26a0 agent executor error: [^\n]*?Error (\d{3}), Message: ([^\n]*?)), Status: ([A-Z_]+)(?:, Details: ([^\n]*))?$/;
21313
+ var ANTIGRAVITY_FAILURE_RULES = [
21314
+ {
21315
+ kind: "notSignedIn",
21316
+ pattern: /not logged into antigravity|not logged in|not signed in|not authenticated|unauthenticated|authentication required|run agy login|please sign in|api key not valid/i
21317
+ },
21318
+ {
21319
+ kind: "rateLimited",
21320
+ pattern: /resource_exhausted|quota exceeded|rate limit|too many requests|429/i
21321
+ },
21322
+ {
21323
+ kind: "sessionMissing",
21324
+ pattern: /session not found|failed to rebuild agent:/i
21325
+ }
21326
+ ];
21327
+ function antigravityUsesApiKeyProvider(homePath = homedir7()) {
21328
+ try {
21329
+ const raw = readFileSync5(join10(homePath, ".gemini", "antigravity-cli", "settings.json"), "utf8");
21330
+ const parsed = JSON.parse(raw);
21331
+ return Boolean(record2(parsed).modelProvider);
21332
+ } catch {
21333
+ return false;
21334
+ }
21335
+ }
21336
+ function scrubAntigravityEnv(env, homePath = homedir7()) {
21337
+ const next = { ...env };
21338
+ if (!antigravityUsesApiKeyProvider(homePath)) {
21339
+ for (const key of Object.keys(next)) {
21340
+ const normalized = process.platform === "win32" ? key.toUpperCase() : key;
21341
+ if (normalized === "GEMINI_API_KEY" || normalized === "GOOGLE_API_KEY") {
21342
+ delete next[key];
21343
+ }
21344
+ }
21345
+ }
21346
+ if (process.platform === "win32") {
21347
+ for (const key of Object.keys(next)) {
21348
+ if (key.toUpperCase() === "AGY_CLI_DISABLE_AUTO_UPDATE" && key !== "AGY_CLI_DISABLE_AUTO_UPDATE") {
21349
+ delete next[key];
21350
+ }
21351
+ }
21352
+ }
21353
+ next.AGY_CLI_DISABLE_AUTO_UPDATE = "true";
21354
+ return next;
21355
+ }
21356
+ function errorText(error62) {
21357
+ if (typeof error62.data === "string" && error62.data.trim()) return error62.data.trim();
21358
+ const nested = record2(error62.data);
21359
+ const nestedMsg = str2(nested.message) ?? str2(nested.details) ?? str2(nested.error);
21360
+ return nestedMsg ?? error62.message ?? "";
21361
+ }
21362
+ function promptErrorDetail(error62) {
21363
+ const text3 = errorText(error62);
21364
+ if (!text3) return void 0;
21365
+ const prefix = CLOUD_CODE_PREFIX.exec(text3);
21366
+ if (prefix) {
21367
+ try {
21368
+ const parsed = record2(JSON.parse(text3.slice(prefix[0].length)));
21369
+ const msg = str2(record2(parsed.error).message)?.trim();
21370
+ if (msg) return msg;
21371
+ } catch {
21372
+ }
21373
+ }
21374
+ const execMatch = EXECUTOR_API_ERROR.exec(text3);
21375
+ if (execMatch) {
21376
+ const [, , code, rawMessage, status] = execMatch;
21377
+ const message = rawMessage?.trim();
21378
+ return message || `Google returned error ${code} (${status}).`;
21379
+ }
21380
+ return void 0;
21381
+ }
21382
+ function normalizeToolUpdate(update) {
21383
+ const input2 = record2(update.rawInput);
21384
+ const output2 = record2(update.rawOutput);
21385
+ const command = str2(input2.CommandLine) ?? str2(input2.command_line) ?? str2(input2.commandLine);
21386
+ const cwd = str2(input2.Cwd) ?? str2(input2.WorkingDirectory) ?? str2(input2.working_dir) ?? str2(input2.workingDir) ?? str2(input2.cwd);
21387
+ const stdout = str2(output2.combinedOutput) ?? str2(output2.combined_output);
21388
+ const exitCode = num(output2.exitCode) ?? num(output2.exit_code);
21389
+ return {
21390
+ ...update,
21391
+ ...command === void 0 ? {} : { rawInput: { command, ...cwd === void 0 ? {} : { cwd } } },
21392
+ ...stdout === void 0 && exitCode === void 0 ? {} : {
21393
+ rawOutput: {
21394
+ ...stdout === void 0 ? {} : { stdout },
21395
+ ...exitCode === void 0 ? {} : { exitCode }
21396
+ }
21397
+ }
21398
+ };
21399
+ }
21400
+ var ANTIGRAVITY_ACP_DIALECT = {
21401
+ failureRules: ANTIGRAVITY_FAILURE_RULES,
21402
+ failureKind: ({ code }) => code === 401 ? "notSignedIn" : code === 429 ? "rateLimited" : void 0,
21403
+ promptErrorDetail,
21404
+ normalizeToolUpdate,
21405
+ toolName: (update) => update.kind === "execute" ? "execute" : void 0
21406
+ };
21407
+
21297
21408
  // src/providers/model-catalog.ts
21298
21409
  function stringValue(value) {
21299
21410
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
@@ -21382,15 +21493,16 @@ function parseClaudeModelCatalog(settings, environment = process.env, fetchedAt
21382
21493
  models: [...models2.values()]
21383
21494
  };
21384
21495
  }
21385
- var claudeHome = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join10(homedir7(), ".claude");
21386
- var codexHome2 = () => process.env.CODEX_HOME?.trim() || join10(homedir7(), ".codex");
21387
- var geminiHome = () => process.env.GEMINI_CLI_HOME?.trim() || join10(homedir7(), ".gemini");
21388
- var grokHome = () => process.env.GROK_HOME?.trim() || join10(homedir7(), ".grok");
21389
- var opencodeHome = () => join10(process.env.XDG_CONFIG_HOME?.trim() || join10(homedir7(), ".config"), "opencode");
21390
- var kiroHome = () => join10(homedir7(), ".kiro");
21496
+ var claudeHome = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join11(homedir8(), ".claude");
21497
+ var codexHome2 = () => process.env.CODEX_HOME?.trim() || join11(homedir8(), ".codex");
21498
+ var geminiHome = () => process.env.GEMINI_CLI_HOME?.trim() || join11(homedir8(), ".gemini");
21499
+ var antigravityHome = () => join11(homedir8(), ".gemini", "antigravity-cli");
21500
+ var grokHome = () => process.env.GROK_HOME?.trim() || join11(homedir8(), ".grok");
21501
+ var opencodeHome = () => join11(process.env.XDG_CONFIG_HOME?.trim() || join11(homedir8(), ".config"), "opencode");
21502
+ var kiroHome = () => join11(homedir8(), ".kiro");
21391
21503
  async function readClaudeModelCatalog() {
21392
21504
  const home = claudeHome();
21393
- const content = await readFile4(join10(home, "settings.json"), "utf8").catch(() => "");
21505
+ const content = await readFile4(join11(home, "settings.json"), "utf8").catch(() => "");
21394
21506
  let settings = {};
21395
21507
  if (content) {
21396
21508
  try {
@@ -21402,13 +21514,13 @@ async function readClaudeModelCatalog() {
21402
21514
  return parseClaudeModelCatalog(settings, process.env, (/* @__PURE__ */ new Date()).toISOString(), await readClaudeCachedModels(home));
21403
21515
  }
21404
21516
  async function readClaudeCachedModels(home) {
21405
- const dir = join10(home, "cache", "model-catalog");
21517
+ const dir = join11(home, "cache", "model-catalog");
21406
21518
  const names = await readdir(dir).catch(() => []);
21407
21519
  let newest;
21408
21520
  for (const name of names) {
21409
21521
  if (!name.endsWith(".json")) continue;
21410
21522
  try {
21411
- const cache = JSON.parse(await readFile4(join10(dir, name), "utf8"));
21523
+ const cache = JSON.parse(await readFile4(join11(dir, name), "utf8"));
21412
21524
  const models2 = parseClaudeCachedModels(cache);
21413
21525
  const fetchedAt = Number(objectValue(cache).fetchedAt) || 0;
21414
21526
  if (models2.length && (!newest || fetchedAt > newest.fetchedAt)) newest = { fetchedAt, models: models2 };
@@ -21464,13 +21576,13 @@ async function readCodexModels(codexHome3, config2) {
21464
21576
  const configuredModels = parseCodexModels(await readFile4(catalogPath, "utf8").catch(() => ""));
21465
21577
  if (configuredModels?.length) return configuredModels;
21466
21578
  }
21467
- const cached3 = parseCodexModels(await readFile4(join10(codexHome3, "models_cache.json"), "utf8").catch(() => ""));
21579
+ const cached3 = parseCodexModels(await readFile4(join11(codexHome3, "models_cache.json"), "utf8").catch(() => ""));
21468
21580
  if (cached3?.length) return cached3;
21469
21581
  return codexModelsFrom(await codexBundledCatalog().catch(() => void 0), { listedOnly: true }) ?? [];
21470
21582
  }
21471
21583
  async function readCodexModelCatalog() {
21472
21584
  const home = codexHome2();
21473
- const config2 = await readFile4(join10(home, "config.toml"), "utf8").catch(() => "");
21585
+ const config2 = await readFile4(join11(home, "config.toml"), "utf8").catch(() => "");
21474
21586
  const models2 = await readCodexModels(home, config2);
21475
21587
  const defaultModel = configValue(config2, "model");
21476
21588
  const defaultReasoningEffort = configValue(config2, "model_reasoning_effort");
@@ -21584,7 +21696,7 @@ async function readKiroModelCatalog(options = {}) {
21584
21696
  if (current) return known.catalog;
21585
21697
  try {
21586
21698
  const launch = launchCli({ spec: kiro, args: ["acp", "--trust-tools="], env: environment });
21587
- const catalog = await readKiroNativeModels(launch, homedir7(), { catalog: base });
21699
+ const catalog = await readKiroNativeModels(launch, homedir8(), { catalog: base });
21588
21700
  kiroEfforts = { signature, readAt: Date.now(), catalog };
21589
21701
  return catalog;
21590
21702
  } catch {
@@ -21593,7 +21705,7 @@ async function readKiroModelCatalog(options = {}) {
21593
21705
  };
21594
21706
  const [payload, content] = await Promise.all([
21595
21707
  readEfforts(),
21596
- readFile4(join10(kiroHome(), "settings", "cli.json"), "utf8").catch(() => "{}")
21708
+ readFile4(join11(kiroHome(), "settings", "cli.json"), "utf8").catch(() => "{}")
21597
21709
  ]);
21598
21710
  let settings;
21599
21711
  try {
@@ -21650,7 +21762,7 @@ function geminiModelsUrl(baseUrl) {
21650
21762
  }
21651
21763
  async function readGeminiModelCatalog() {
21652
21764
  const fileEnvironment = parseEnvFile(
21653
- await readFile4(join10(geminiHome(), ".env"), "utf8").catch(() => "")
21765
+ await readFile4(join11(geminiHome(), ".env"), "utf8").catch(() => "")
21654
21766
  );
21655
21767
  const environment = { ...fileEnvironment, ...process.env };
21656
21768
  const baseUrl = environment.GOOGLE_GEMINI_BASE_URL?.trim();
@@ -21695,7 +21807,7 @@ function parseGrokModelCatalog(output2, config2 = "", fetchedAt = (/* @__PURE__
21695
21807
  return catalog;
21696
21808
  }
21697
21809
  async function readGrokModelCatalog() {
21698
- const config2 = await readFile4(join10(grokHome(), "config.toml"), "utf8").catch(() => "");
21810
+ const config2 = await readFile4(join11(grokHome(), "config.toml"), "utf8").catch(() => "");
21699
21811
  const output2 = await runModelListCommand(cliExecutable("grok"), ["models"], "grok");
21700
21812
  const catalog = parseGrokModelCatalog(output2, config2);
21701
21813
  if (catalog.models.length === 0) throw new Error("Grok \u672C\u673A\u672A\u8FD4\u56DE\u53EF\u7528\u6A21\u578B");
@@ -21714,30 +21826,139 @@ function parseOpencodeModelCatalog(output2, config2 = "", fetchedAt = (/* @__PUR
21714
21826
  return catalog;
21715
21827
  }
21716
21828
  async function readOpencodeModelCatalog() {
21717
- const config2 = await readFile4(join10(opencodeHome(), "opencode.json"), "utf8").catch(() => "") || await readFile4(join10(opencodeHome(), "opencode.jsonc"), "utf8").catch(() => "");
21829
+ const config2 = await readFile4(join11(opencodeHome(), "opencode.json"), "utf8").catch(() => "") || await readFile4(join11(opencodeHome(), "opencode.jsonc"), "utf8").catch(() => "");
21718
21830
  const output2 = await runModelListCommand(cliExecutable("opencode"), ["models"], "opencode");
21719
21831
  const catalog = parseOpencodeModelCatalog(output2, config2);
21720
21832
  if (catalog.models.length === 0) throw new Error("OpenCode \u672C\u673A\u672A\u8FD4\u56DE\u53EF\u7528\u6A21\u578B");
21721
21833
  return catalog;
21722
21834
  }
21835
+ function parseAntigravityModelCatalog(output2, settingsContent = "", fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
21836
+ const plain = output2.replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, "");
21837
+ const variants = [];
21838
+ const seenIds = /* @__PURE__ */ new Set();
21839
+ for (const line of plain.split(/\r?\n/)) {
21840
+ const parts = line.split(" ").map((field) => field.trim());
21841
+ const [modelId, name, ...extra] = parts;
21842
+ if (!modelId || !name || extra.length > 0 || seenIds.has(modelId)) continue;
21843
+ seenIds.add(modelId);
21844
+ variants.push({ modelId, name });
21845
+ }
21846
+ const familyLevels = /* @__PURE__ */ new Map();
21847
+ for (const variant of variants) {
21848
+ const match = ANTIGRAVITY_LEVEL_SUFFIX.exec(variant.modelId);
21849
+ const family = match?.[1];
21850
+ const level = match?.[2];
21851
+ if (!family || !level || seenIds.has(family)) continue;
21852
+ const list = familyLevels.get(family) ?? [];
21853
+ if (!list.includes(level)) list.push(level);
21854
+ familyLevels.set(family, list);
21855
+ }
21856
+ const models2 = [];
21857
+ const addedFamilies = /* @__PURE__ */ new Set();
21858
+ for (const variant of variants) {
21859
+ const match = ANTIGRAVITY_LEVEL_SUFFIX.exec(variant.modelId);
21860
+ const family = match?.[1];
21861
+ const levels = family ? familyLevels.get(family) : void 0;
21862
+ if (family && levels && levels.length > 1) {
21863
+ if (addedFamilies.has(family)) continue;
21864
+ addedFamilies.add(family);
21865
+ const ordered = ANTIGRAVITY_EFFORT_LEVELS.filter((level) => levels.includes(level));
21866
+ const firstLevel = levels[0];
21867
+ models2.push({
21868
+ id: family,
21869
+ name: variant.name.replace(/\s*\([^()]+\)$/, ""),
21870
+ supported_reasoning_efforts: [...ordered],
21871
+ ...firstLevel && ordered.includes(firstLevel) ? { default_reasoning_effort: firstLevel } : {}
21872
+ });
21873
+ } else {
21874
+ models2.push({
21875
+ id: variant.modelId,
21876
+ name: variant.name,
21877
+ supported_reasoning_efforts: []
21878
+ });
21879
+ }
21880
+ }
21881
+ let configuredModel;
21882
+ if (settingsContent.trim()) {
21883
+ try {
21884
+ configuredModel = stringValue(objectValue(JSON.parse(settingsContent)).model);
21885
+ } catch {
21886
+ }
21887
+ }
21888
+ let defaultModel;
21889
+ let defaultEffort;
21890
+ if (configuredModel) {
21891
+ const matchedVariant = variants.find(
21892
+ (variant) => variant.modelId === configuredModel || variant.name.toLowerCase() === configuredModel.toLowerCase()
21893
+ );
21894
+ if (matchedVariant) {
21895
+ const match = ANTIGRAVITY_LEVEL_SUFFIX.exec(matchedVariant.modelId);
21896
+ const family = match?.[1];
21897
+ const level = match?.[2];
21898
+ if (family && addedFamilies.has(family)) {
21899
+ defaultModel = family;
21900
+ defaultEffort = level;
21901
+ } else {
21902
+ defaultModel = matchedVariant.modelId;
21903
+ }
21904
+ } else {
21905
+ const matchedFamily = models2.find(
21906
+ (model) => model.id === configuredModel || model.name.toLowerCase() === configuredModel.toLowerCase()
21907
+ );
21908
+ if (matchedFamily) {
21909
+ defaultModel = matchedFamily.id;
21910
+ defaultEffort = matchedFamily.default_reasoning_effort;
21911
+ }
21912
+ }
21913
+ }
21914
+ if (!defaultModel && models2.length > 0) {
21915
+ defaultModel = models2[0].id;
21916
+ defaultEffort = models2[0].default_reasoning_effort;
21917
+ }
21918
+ return {
21919
+ agent_type: "antigravity",
21920
+ fetched_at: fetchedAt,
21921
+ ...defaultModel ? { default_model: defaultModel } : {},
21922
+ ...defaultEffort ? { default_reasoning_effort: defaultEffort } : {},
21923
+ models: models2
21924
+ };
21925
+ }
21926
+ async function readAntigravityModelCatalog() {
21927
+ const baseEnv = mergeShellProxyEnvironment(await hydrateShellPath(), providerEnvironment());
21928
+ const env = scrubAntigravityEnv(baseEnv);
21929
+ const spec = requireCliSpec("antigravity");
21930
+ const launch = launchCli({ spec, args: ["models"], env });
21931
+ const [output2, settings] = await Promise.all([
21932
+ runModelListCommand(launch.executable, launch.args, "agy", launch.env ?? env),
21933
+ readFile4(join11(antigravityHome(), "settings.json"), "utf8").catch(() => "")
21934
+ ]);
21935
+ const catalog = parseAntigravityModelCatalog(output2, settings);
21936
+ if (catalog.models.length === 0) throw new Error("Antigravity \u672C\u673A\u672A\u8FD4\u56DE\u53EF\u7528\u6A21\u578B\uFF0C\u8BF7\u786E\u8BA4\u5DF2\u767B\u5F55 agy");
21937
+ return catalog;
21938
+ }
21723
21939
  var TEN_MINUTES = 10 * 60 * 1e3;
21724
21940
  var MODEL_SOURCES = {
21725
- claude: { read: readClaudeModelCatalog, watchFiles: () => [join10(claudeHome(), "settings.json"), join10(claudeHome(), "cache", "model-catalog")] },
21941
+ antigravity: {
21942
+ read: readAntigravityModelCatalog,
21943
+ watchFiles: () => [join11(antigravityHome(), "settings.json")],
21944
+ refreshEveryMs: TEN_MINUTES
21945
+ },
21946
+ claude: { read: readClaudeModelCatalog, watchFiles: () => [join11(claudeHome(), "settings.json"), join11(claudeHome(), "cache", "model-catalog")] },
21726
21947
  codex: {
21727
21948
  read: readCodexModelCatalog,
21728
21949
  watchFiles: () => {
21729
21950
  const home = codexHome2();
21730
- return [join10(home, "config.toml"), join10(home, "models_cache.json")];
21951
+ return [join11(home, "config.toml"), join11(home, "models_cache.json")];
21731
21952
  },
21732
21953
  // model_catalog_json may point anywhere; a periodic re-read covers it.
21733
21954
  refreshEveryMs: TEN_MINUTES
21734
21955
  },
21735
- gemini: { read: readGeminiModelCatalog, watchFiles: () => [join10(geminiHome(), ".env")], refreshEveryMs: TEN_MINUTES },
21736
- grok: { read: readGrokModelCatalog, watchFiles: () => [join10(grokHome(), "config.toml")], refreshEveryMs: TEN_MINUTES },
21737
- kiro: { read: readKiroModelCatalog, watchFiles: () => [join10(kiroHome(), "settings", "cli.json")] },
21956
+ gemini: { read: readGeminiModelCatalog, watchFiles: () => [join11(geminiHome(), ".env")], refreshEveryMs: TEN_MINUTES },
21957
+ grok: { read: readGrokModelCatalog, watchFiles: () => [join11(grokHome(), "config.toml")], refreshEveryMs: TEN_MINUTES },
21958
+ kiro: { read: readKiroModelCatalog, watchFiles: () => [join11(kiroHome(), "settings", "cli.json")] },
21738
21959
  opencode: {
21739
21960
  read: readOpencodeModelCatalog,
21740
- watchFiles: () => [join10(opencodeHome(), "opencode.json"), join10(opencodeHome(), "opencode.jsonc")],
21961
+ watchFiles: () => [join11(opencodeHome(), "opencode.json"), join11(opencodeHome(), "opencode.jsonc")],
21741
21962
  refreshEveryMs: TEN_MINUTES
21742
21963
  }
21743
21964
  };
@@ -21747,10 +21968,11 @@ var GEMINI_FAILURE_RULES = [
21747
21968
  { kind: "sessionMissing", pattern: /session[^\n]{0,60}(?:not found|does not exist)|no session found|invalid session/i },
21748
21969
  { kind: "notSignedIn", pattern: /api key is missing|not configured|login required|please (?:log|sign) ?in/i }
21749
21970
  ];
21750
- var GEMINI_ACP_DIALECT = { failureRules: GEMINI_FAILURE_RULES };
21751
-
21752
- // src/acp/acp-dialects/acp-dialect.ts
21753
- var record2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
21971
+ var GEMINI_ACP_DIALECT = {
21972
+ failureRules: GEMINI_FAILURE_RULES,
21973
+ failureKind: ({ code }) => code === 401 ? "notSignedIn" : code === 429 ? "rateLimited" : void 0,
21974
+ linksFileMentions: true
21975
+ };
21754
21976
 
21755
21977
  // src/acp/acp-dialects/grok-dialect.ts
21756
21978
  function modelEfforts(model) {
@@ -21851,11 +22073,11 @@ function classifySpawnError(error62, context) {
21851
22073
 
21852
22074
  // src/providers/cli/kiro-session-log.ts
21853
22075
  import { open as open2, readdir as readdir2, readFile as readFile5, stat as stat2 } from "node:fs/promises";
21854
- import { homedir as homedir8 } from "node:os";
21855
- import { join as join11 } from "node:path";
22076
+ import { homedir as homedir9 } from "node:os";
22077
+ import { join as join12 } from "node:path";
21856
22078
  var SHELL_TOOLS = /* @__PURE__ */ new Set(["shell", "execute_bash", "bash"]);
21857
22079
  function kiroSessionsDirectory() {
21858
- return process.env.TOC_OCRA_KIRO_SESSIONS_DIR || join11(homedir8(), ".kiro", "sessions", "cli");
22080
+ return process.env.TOC_OCRA_KIRO_SESSIONS_DIR || join12(homedir9(), ".kiro", "sessions", "cli");
21859
22081
  }
21860
22082
  var KiroSessionLog = class {
21861
22083
  constructor(options) {
@@ -21874,7 +22096,7 @@ var KiroSessionLog = class {
21874
22096
  /** Called before the CLI starts: a resumed log is followed from its current end. */
21875
22097
  async begin() {
21876
22098
  if (!this.options.sessionId) return;
21877
- this.path = join11(this.directory, `${this.options.sessionId}.jsonl`);
22099
+ this.path = join12(this.directory, `${this.options.sessionId}.jsonl`);
21878
22100
  this.offset = await stat2(this.path).then((info) => info.size, () => 0);
21879
22101
  }
21880
22102
  /**
@@ -21887,11 +22109,11 @@ var KiroSessionLog = class {
21887
22109
  const found = [];
21888
22110
  for (const name of names) {
21889
22111
  if (!name.endsWith(".json")) continue;
21890
- const meta3 = await readFile5(join11(this.directory, name), "utf8").then((text3) => JSON.parse(text3), () => void 0);
22112
+ const meta3 = await readFile5(join12(this.directory, name), "utf8").then((text3) => JSON.parse(text3), () => void 0);
21891
22113
  const created = meta3?.created_at ? Date.parse(meta3.created_at) : NaN;
21892
22114
  if (meta3?.cwd && sameFolder(meta3.cwd, this.options.workdir) && created >= this.options.startedAt - 2e3) found.push(name.slice(0, -5));
21893
22115
  }
21894
- if (found.length === 1) this.path = join11(this.directory, `${found[0]}.jsonl`);
22116
+ if (found.length === 1) this.path = join12(this.directory, `${found[0]}.jsonl`);
21895
22117
  }
21896
22118
  /** Reads entries appended since the last call. */
21897
22119
  async refresh() {
@@ -22202,7 +22424,7 @@ var KIRO_ACP_DIALECT = {
22202
22424
  };
22203
22425
 
22204
22426
  // src/acp/acp-dialects/omp-dialect.ts
22205
- function normalizeToolUpdate(update) {
22427
+ function normalizeToolUpdate2(update) {
22206
22428
  const rawOutput = record2(update.rawOutput);
22207
22429
  if (!Array.isArray(rawOutput.content)) return update;
22208
22430
  if (["exitCode", "exit_code", "stdout", "stderr"].some((key) => rawOutput[key] !== void 0)) return update;
@@ -22218,7 +22440,7 @@ function normalizeToolUpdate(update) {
22218
22440
  };
22219
22441
  }
22220
22442
  var OMP_ACP_DIALECT = {
22221
- normalizeToolUpdate,
22443
+ normalizeToolUpdate: normalizeToolUpdate2,
22222
22444
  promptErrorDetail: (error62) => {
22223
22445
  const details = record2(error62.data).details;
22224
22446
  return typeof details === "string" && details ? details : void 0;
@@ -22230,7 +22452,7 @@ var OMP_ACP_DIALECT = {
22230
22452
  };
22231
22453
 
22232
22454
  // src/acp/acp-dialects/opencode-dialect.ts
22233
- function normalizeToolUpdate2(update) {
22455
+ function normalizeToolUpdate3(update) {
22234
22456
  const raw = update.rawOutput;
22235
22457
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return update;
22236
22458
  const rawOutput = raw;
@@ -22250,7 +22472,7 @@ function normalizeToolUpdate2(update) {
22250
22472
  };
22251
22473
  }
22252
22474
  var OPENCODE_ACP_DIALECT = {
22253
- normalizeToolUpdate: normalizeToolUpdate2,
22475
+ normalizeToolUpdate: normalizeToolUpdate3,
22254
22476
  failureRules: [
22255
22477
  { kind: "usageLimit", pattern: /"errorName"\s*:\s*"provider\.quota"/ },
22256
22478
  { kind: "rateLimited", pattern: /"errorName"\s*:\s*"provider\.rate-limit"/ }
@@ -22260,9 +22482,9 @@ var OPENCODE_ACP_DIALECT = {
22260
22482
  // src/acp/vendor.ts
22261
22483
  import { spawn as spawn6 } from "node:child_process";
22262
22484
  import { createHash } from "node:crypto";
22263
- import { existsSync as existsSync6, readFileSync as readFileSync5 } from "node:fs";
22485
+ import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
22264
22486
  import { copyFile, mkdir as mkdir4, rename as rename4, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
22265
- import { dirname as dirname7, join as join12, resolve as resolve4 } from "node:path";
22487
+ import { dirname as dirname7, join as join13, resolve as resolve4 } from "node:path";
22266
22488
  import { fileURLToPath } from "node:url";
22267
22489
  var AcpRuntimeUnavailable = class extends Error {
22268
22490
  constructor(message) {
@@ -22277,7 +22499,7 @@ function packageRoot() {
22277
22499
  const path = resolve4(directory, "package.json");
22278
22500
  if (existsSync6(path)) {
22279
22501
  try {
22280
- if (JSON.parse(readFileSync5(path, "utf8")).name === "toc-ocra") return directory;
22502
+ if (JSON.parse(readFileSync6(path, "utf8")).name === "toc-ocra") return directory;
22281
22503
  } catch {
22282
22504
  }
22283
22505
  }
@@ -22295,29 +22517,29 @@ function agentPackageVersion() {
22295
22517
  const directory = agentRoot();
22296
22518
  if (!directory) return "0";
22297
22519
  try {
22298
- return JSON.parse(readFileSync5(join12(directory, "package.json"), "utf8")).version ?? "0";
22520
+ return JSON.parse(readFileSync6(join13(directory, "package.json"), "utf8")).version ?? "0";
22299
22521
  } catch {
22300
22522
  return "0";
22301
22523
  }
22302
22524
  }
22303
22525
  function vendoredAdapter(name) {
22304
22526
  const directory = agentRoot();
22305
- const entry = directory ? join12(directory, "assets", "acp", name, "index.mjs") : void 0;
22527
+ const entry = directory ? join13(directory, "assets", "acp", name, "index.mjs") : void 0;
22306
22528
  return entry && existsSync6(entry) ? entry : void 0;
22307
22529
  }
22308
22530
  var installs = /* @__PURE__ */ new Map();
22309
22531
  function ensureClaudeRuntime(dataDir2) {
22310
22532
  const entry = vendoredAdapter("claude");
22311
22533
  if (!entry) return Promise.reject(new AcpRuntimeUnavailable("\u8FD9\u4E2A\u7248\u672C\u7684\u8BBE\u5907\u4EE3\u7406\u6CA1\u6709\u9644\u5E26 Claude ACP \u9002\u914D\u5668"));
22312
- const manifestPath = join12(dirname7(entry), "runtime.json");
22534
+ const manifestPath = join13(dirname7(entry), "runtime.json");
22313
22535
  let manifest;
22314
22536
  try {
22315
- manifest = JSON.parse(readFileSync5(manifestPath, "utf8"));
22537
+ manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
22316
22538
  } catch {
22317
22539
  return Promise.reject(new AcpRuntimeUnavailable("Claude ACP \u9002\u914D\u5668\u7F3A\u5C11 runtime.json"));
22318
22540
  }
22319
- const hash2 = createHash("sha256").update(readFileSync5(entry)).digest("hex").slice(0, 12);
22320
- const directory = join12(dataDir2, "acp-runtimes", `claude-${manifest.adapterVersion}-sdk-${manifest.sdk.version}-${hash2}`);
22541
+ const hash2 = createHash("sha256").update(readFileSync6(entry)).digest("hex").slice(0, 12);
22542
+ const directory = join13(dataDir2, "acp-runtimes", `claude-${manifest.adapterVersion}-sdk-${manifest.sdk.version}-${hash2}`);
22321
22543
  const existing = installs.get(directory);
22322
22544
  if (existing) return existing;
22323
22545
  const install = installClaudeRuntime(directory, entry, manifest).catch((error62) => {
@@ -22328,19 +22550,19 @@ function ensureClaudeRuntime(dataDir2) {
22328
22550
  return install;
22329
22551
  }
22330
22552
  async function installClaudeRuntime(directory, entry, manifest) {
22331
- const sdkPackage = join12(directory, "node_modules", ...manifest.sdk.name.split("/"), "package.json");
22332
- if (existsSync6(sdkPackage) && existsSync6(join12(directory, "index.mjs"))) return directory;
22553
+ const sdkPackage = join13(directory, "node_modules", ...manifest.sdk.name.split("/"), "package.json");
22554
+ if (existsSync6(sdkPackage) && existsSync6(join13(directory, "index.mjs"))) return directory;
22333
22555
  const temporary = `${directory}.tmp-${process.pid}-${Date.now()}`;
22334
22556
  await mkdir4(temporary, { recursive: true, mode: 448 });
22335
22557
  try {
22336
- await writeFile4(join12(temporary, "package.json"), JSON.stringify({
22558
+ await writeFile4(join13(temporary, "package.json"), JSON.stringify({
22337
22559
  name: "toc-ocra-claude-acp-runtime",
22338
22560
  private: true,
22339
22561
  type: "module",
22340
22562
  dependencies: { [manifest.sdk.name]: manifest.sdk.version }
22341
22563
  }, null, 2));
22342
22564
  await runNpm(["install", "--omit=optional", "--no-audit", "--no-fund", "--no-package-lock", "--loglevel=error"], temporary);
22343
- await copyFile(entry, join12(temporary, "index.mjs"));
22565
+ await copyFile(entry, join13(temporary, "index.mjs"));
22344
22566
  await rm2(directory, { recursive: true, force: true });
22345
22567
  await rename4(temporary, directory);
22346
22568
  } catch (error62) {
@@ -22405,12 +22627,31 @@ var KIMI_LAUNCH_SPEC = {
22405
22627
  var GEMINI_LAUNCH_SPEC = {
22406
22628
  agent: "gemini",
22407
22629
  headless: "acp",
22408
- // Below full access Gemini asks before editing or running anything.
22409
- args: ({ access, model }) => ["--acp", ...access === "bypassPermissions" ? ["--yolo"] : ["--approval-mode", "default"], ...model ? ["--model", model] : []],
22630
+ // The shared ACP driver enforces each turn's permission level.
22631
+ args: ({ model }) => ["--acp", "--approval-mode", "default", ...model ? ["--model", model] : []],
22632
+ env: { NO_BROWSER: "true" },
22633
+ // Earlier releases can replay session history after `session/load` has answered.
22634
+ minimumVersions: ["0.68.0"],
22410
22635
  launchApplies: { model: true },
22411
22636
  dialect: GEMINI_ACP_DIALECT,
22412
22637
  modelDiscovery: { kind: "reader", source: MODEL_SOURCES.gemini }
22413
22638
  };
22639
+ var ANTIGRAVITY_LAUNCH_SPEC = {
22640
+ agent: "antigravity",
22641
+ headless: "acp",
22642
+ // agy has no full-access mode in session/set_mode; its launch flag grants it while plan approvals still reach the chat.
22643
+ args: ({ access }) => ["acp", ...access === "bypassPermissions" ? ["--dangerously-skip-permissions"] : []],
22644
+ env: { AGY_CLI_DISABLE_AUTO_UPDATE: "true" },
22645
+ scrubEnv: (env) => scrubAntigravityEnv(env),
22646
+ minimumVersions: ["1.5.2"],
22647
+ permissionModeConfig: {
22648
+ values: { ask: "default", acceptEdits: "accept-edits", bypassPermissions: "default", plan: "plan" }
22649
+ },
22650
+ resumePreference: "resume",
22651
+ dialect: ANTIGRAVITY_ACP_DIALECT,
22652
+ modelDiscovery: { kind: "reader", source: MODEL_SOURCES.antigravity },
22653
+ runSettings: { permissionModes: ["read-only", "acceptEdits", "bypassPermissions"], plan: "native" }
22654
+ };
22414
22655
  var GROK_LAUNCH_SPEC = {
22415
22656
  agent: "grok",
22416
22657
  headless: "acp",
@@ -22463,7 +22704,7 @@ var CLAUDE_LAUNCH_SPEC = {
22463
22704
  const executable = installedCli(claude);
22464
22705
  const runtime = await ensureClaudeRuntime(dataDir2);
22465
22706
  return {
22466
- launch: { executable: process.execPath, args: [join13(runtime, "index.mjs")], env: { ...providerEnvironment(), CLAUDE_CODE_EXECUTABLE: executable }, cwd: workdir },
22707
+ launch: { executable: process.execPath, args: [join14(runtime, "index.mjs")], env: { ...providerEnvironment(), CLAUDE_CODE_EXECUTABLE: executable }, cwd: workdir },
22467
22708
  fingerprint: `claude:${runtime}:${executable}`
22468
22709
  };
22469
22710
  },
@@ -22511,6 +22752,7 @@ var ACP_LAUNCH_SPECS = [
22511
22752
  KIRO_LAUNCH_SPEC,
22512
22753
  KIMI_LAUNCH_SPEC,
22513
22754
  GEMINI_LAUNCH_SPEC,
22755
+ ANTIGRAVITY_LAUNCH_SPEC,
22514
22756
  GROK_LAUNCH_SPEC,
22515
22757
  OPENCODE_LAUNCH_SPEC,
22516
22758
  OMP_LAUNCH_SPEC,
@@ -22558,7 +22800,9 @@ function chatSpec(row) {
22558
22800
  async launch({ access, model, reasoningEffort, workdir, dataDir: dataDir2 }) {
22559
22801
  if (row.adapter) return row.adapter({ access, model, reasoningEffort, workdir, dataDir: dataDir2 });
22560
22802
  const args = row.args({ access, model, reasoningEffort });
22561
- const spec = launchCli({ spec: cli, args, env: { ...providerEnvironment(), ...row.env } });
22803
+ const baseEnv = { ...providerEnvironment(), ...row.env };
22804
+ const env = row.scrubEnv ? row.scrubEnv(baseEnv) : baseEnv;
22805
+ const spec = launchCli({ spec: cli, args, env });
22562
22806
  return { launch: { executable: spec.executable, args: spec.args, env: spec.env, cwd: workdir }, fingerprint: args.join(" ") };
22563
22807
  },
22564
22808
  ...row.permissionModeConfig ? { modeFor: (access, plan) => acpModeFor(row, access, plan) } : {},
@@ -22582,7 +22826,7 @@ var ACP_CHAT_IDS = [...ACP_CHAT.keys()];
22582
22826
  // src/acp/acp-model-catalog-probe.ts
22583
22827
  import { mkdtemp, rm as rm3 } from "node:fs/promises";
22584
22828
  import { tmpdir } from "node:os";
22585
- import { join as join14 } from "node:path";
22829
+ import { join as join15 } from "node:path";
22586
22830
 
22587
22831
  // src/acp/acp-options.ts
22588
22832
  var text = (value) => typeof value === "string" && value ? value : void 0;
@@ -22661,7 +22905,8 @@ function settingWrite(state, step, settings, cliLabel) {
22661
22905
  if (!model) return {};
22662
22906
  const option = findOption(state.configOptions, "model");
22663
22907
  if (option) {
22664
- const value = matchChoice(option, model);
22908
+ const stripped = /^(.+)-(?:low|medium|high|xhigh|max)$/i.exec(model)?.[1];
22909
+ const value = matchChoice(option, model) ?? (stripped ? matchChoice(option, stripped) : void 0);
22665
22910
  if (!value) return { note: `${cliLabel} \u6CA1\u6709\u6A21\u578B\u300C${model}\u300D\uFF0C\u672C\u8F6E\u4F7F\u7528\u5F53\u524D\u6A21\u578B` };
22666
22911
  return option.currentValue === value ? {} : config2(option, value);
22667
22912
  }
@@ -22669,9 +22914,11 @@ function settingWrite(state, step, settings, cliLabel) {
22669
22914
  return state.currentModelId === model ? {} : { write: { step, label: STEP_LABEL[step], method: "session/set_model", params: { modelId: model } } };
22670
22915
  }
22671
22916
  case "effort": {
22672
- if (!settings.reasoningEffort) return {};
22917
+ const inferred = settings.model ? /^.+-(low|medium|high|xhigh|max)$/i.exec(settings.model)?.[1] : void 0;
22918
+ const wantedEffort = settings.reasoningEffort || inferred;
22919
+ if (!wantedEffort) return {};
22673
22920
  const option = findOption(state.configOptions, "thought_level");
22674
- const value = option ? matchChoice(option, settings.reasoningEffort) : void 0;
22921
+ const value = option ? matchChoice(option, wantedEffort) : void 0;
22675
22922
  return option && value && option.currentValue !== value ? config2(option, value) : {};
22676
22923
  }
22677
22924
  case "fast": {
@@ -23215,9 +23462,9 @@ async function readSessionModels(row, clientVersion = "1") {
23215
23462
  const discovery = row.modelDiscovery;
23216
23463
  if (discovery.kind !== "session") throw new Error(`${row.agent} does not list its models in a session`);
23217
23464
  const cli = requireCliSpec(row.agent);
23218
- const folder = await mkdtemp(join14(tmpdir(), `toc-ocra-acp-models-${row.agent}-`));
23465
+ const folder = await mkdtemp(join15(tmpdir(), `toc-ocra-acp-models-${row.agent}-`));
23219
23466
  try {
23220
- const folderArgs = discovery.sessionFolderArgs?.(join14(folder, "sessions")) ?? [];
23467
+ const folderArgs = discovery.sessionFolderArgs?.(join15(folder, "sessions")) ?? [];
23221
23468
  const args = [...row.args({ access: "read-only", model: "", reasoningEffort: "" }), ...folderArgs];
23222
23469
  const launch = launchCli({ spec: cli, args, env: { ...providerEnvironment(), ...row.env } });
23223
23470
  const connection = await AcpConnection.open({ executable: launch.executable, args: launch.args, env: launch.env, cwd: folder }, {
@@ -23846,14 +24093,14 @@ function isWriterConflict(message) {
23846
24093
  }
23847
24094
 
23848
24095
  // src/providers/cli/claude.ts
23849
- import { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
23850
- import { homedir as homedir9 } from "node:os";
23851
- import { join as join15 } from "node:path";
24096
+ import { readdirSync as readdirSync4, readFileSync as readFileSync7 } from "node:fs";
24097
+ import { homedir as homedir10 } from "node:os";
24098
+ import { join as join16 } from "node:path";
23852
24099
  var CLAUDE = requireCliSpec("claude");
23853
24100
  function claudeProjectRoots() {
23854
24101
  const configured = process.env.CLAUDE_CONFIG_DIR;
23855
- const dirs = configured ? configured.split(process.platform === "win32" ? ";" : ":").map((entry) => entry.trim()).filter(Boolean) : [join15(homedir9(), ".claude")];
23856
- return dirs.map((dir) => join15(dir, "projects"));
24102
+ const dirs = configured ? configured.split(process.platform === "win32" ? ";" : ":").map((entry) => entry.trim()).filter(Boolean) : [join16(homedir10(), ".claude")];
24103
+ return dirs.map((dir) => join16(dir, "projects"));
23857
24104
  }
23858
24105
  function claudeTranscriptExists(sessionId) {
23859
24106
  return claudeTranscriptPath(sessionId) !== void 0;
@@ -23869,7 +24116,7 @@ function claudeTranscriptPath(sessionId) {
23869
24116
  }
23870
24117
  for (const project of projects) {
23871
24118
  try {
23872
- if (readdirSync4(join15(root2, project)).includes(file2)) return join15(root2, project, file2);
24119
+ if (readdirSync4(join16(root2, project)).includes(file2)) return join16(root2, project, file2);
23873
24120
  } catch {
23874
24121
  }
23875
24122
  }
@@ -23913,7 +24160,7 @@ var claudeProvider = {
23913
24160
  settings.disableAllHooks = true;
23914
24161
  args.push("--restricted", "--permission-mode", "plan", "--tools", "Read,Glob,Grep", "--strict-mcp-config", "--mcp-config", '{"mcpServers":{}}', "--disallowedTools", "mcp__*");
23915
24162
  try {
23916
- const userSettings = JSON.parse(readFileSync6(join15(homedir9(), ".claude", "settings.json"), "utf8"));
24163
+ const userSettings = JSON.parse(readFileSync7(join16(homedir10(), ".claude", "settings.json"), "utf8"));
23917
24164
  for (const [key, value] of Object.entries(userSettings.env ?? {})) {
23918
24165
  if (/^ANTHROPIC_[A-Z0-9_]+$/.test(key) && typeof value === "string" && env[key] === void 0) env[key] = value;
23919
24166
  }
@@ -23929,7 +24176,7 @@ var claudeProvider = {
23929
24176
  if (source && request.fork.keepTurns > 0) {
23930
24177
  let text3 = "";
23931
24178
  try {
23932
- text3 = readFileSync6(source, "utf8");
24179
+ text3 = readFileSync7(source, "utf8");
23933
24180
  } catch {
23934
24181
  }
23935
24182
  const at = claudeForkBoundary(text3, request.fork.keepTurns);
@@ -24494,7 +24741,8 @@ function createAcpProvider(row) {
24494
24741
  return { display: [runLog.event(`\u539F\u4F1A\u8BDD ${missing} \u5DF2\u4E0D\u5B58\u5728\uFF0C\u672C\u8F6E\u6539\u4E3A\u5F00\u59CB\u65B0\u4F1A\u8BDD`)] };
24495
24742
  }
24496
24743
  }
24497
- return fail(text3, code === AUTH_REQUIRED ? "notSignedIn" : void 0);
24744
+ const failureKind = code === AUTH_REQUIRED ? "notSignedIn" : message.error ? dialect.failureKind?.(message.error) : void 0;
24745
+ return fail(text3, failureKind);
24498
24746
  };
24499
24747
  const onResponse = (message) => {
24500
24748
  const phase = typeof message.id === "number" ? phases.get(message.id) : void 0;
@@ -24520,7 +24768,7 @@ function createAcpProvider(row) {
24520
24768
  return { display: [runLog.event(`\u65E0\u6CD5\u8BBE\u7F6E${label}\uFF1A${text3.slice(0, 200)}`), ...nextSetting()] };
24521
24769
  }
24522
24770
  default:
24523
- return fail(text3, message.error.code === AUTH_REQUIRED ? "notSignedIn" : void 0);
24771
+ return fail(text3, message.error.code === AUTH_REQUIRED ? "notSignedIn" : dialect.failureKind?.(message.error));
24524
24772
  }
24525
24773
  }
24526
24774
  switch (phase) {
@@ -24646,7 +24894,8 @@ function createAcpProvider(row) {
24646
24894
  ...turn.reasoningEffort && !row.launchApplies?.reasoningEffort ? { reasoningEffort: turn.reasoningEffort } : {},
24647
24895
  ...row.runSettings?.fast && turn.fast !== void 0 ? { fast: turn.fast } : {}
24648
24896
  };
24649
- const env = { ...providerEnvironment(), ...row.env };
24897
+ const baseEnv = { ...providerEnvironment(), ...row.env };
24898
+ const env = row.scrubEnv ? row.scrubEnv(baseEnv) : baseEnv;
24650
24899
  launchEnv = env;
24651
24900
  return launchCli({ spec: cli, args: row.args({ access, model: turn.model, reasoningEffort: turn.reasoningEffort }), env });
24652
24901
  },
@@ -24723,11 +24972,229 @@ var opencodeProvider = {
24723
24972
  }
24724
24973
  };
24725
24974
 
24975
+ // src/providers/antigravity-quota.ts
24976
+ import { spawn as spawn8 } from "node:child_process";
24977
+ var ANTIGRAVITY_MIN_USAGE_VERSION = "1.1.11";
24978
+ var ANTIGRAVITY_USAGE_ARGS = ["-p", "/usage", "--output-format", "json", "--print-timeout", "20s"];
24979
+ var VERSION_TIMEOUT_MS = 5e3;
24980
+ var USAGE_TIMEOUT_MS = 3e4;
24981
+ var MAX_OUTPUT_BYTES = 512 * 1024;
24982
+ var AGY_ERROR_PREFIX = "AGY_ERROR:";
24983
+ var WEEKLY_WINDOW_SECONDS = 7 * 86400;
24984
+ var SESSION_WINDOW_SECONDS = 5 * 3600;
24985
+ var SIGNED_OUT_PHRASES = [
24986
+ "not logged into antigravity",
24987
+ "not logged in",
24988
+ "not signed in",
24989
+ "not authenticated",
24990
+ "not-authenticated",
24991
+ "unauthenticated",
24992
+ "run agy login",
24993
+ "please sign in",
24994
+ "please log in",
24995
+ "sign in to antigravity",
24996
+ "no credentials",
24997
+ "authentication required"
24998
+ ];
24999
+ var unsupportedUsageLatched = false;
25000
+ function isRecord(value) {
25001
+ return typeof value === "object" && value !== null && !Array.isArray(value);
25002
+ }
25003
+ function readString(value) {
25004
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : null;
25005
+ }
25006
+ function parseResetSeconds(value) {
25007
+ const text3 = readString(value);
25008
+ if (!text3) return 0;
25009
+ const ms = Date.parse(text3);
25010
+ return Number.isFinite(ms) ? Math.floor(ms / 1e3) : 0;
25011
+ }
25012
+ function windowSecondsFor(window) {
25013
+ if (window === "weekly") return WEEKLY_WINDOW_SECONDS;
25014
+ if (window === "5h") return SESSION_WINDOW_SECONDS;
25015
+ return void 0;
25016
+ }
25017
+ function shortGroupLabel(groupName) {
25018
+ const lower = groupName.toLowerCase();
25019
+ if (lower === "gemini models" || lower === "gemini") return "Gemini";
25020
+ if (lower === "claude and gpt models" || lower === "claude & gpt models") return "Claude / GPT";
25021
+ return groupName.replace(/\s+models$/i, "").trim() || groupName;
25022
+ }
25023
+ function shortWindowLabel(window, rawName) {
25024
+ if (window === "weekly") return "\u6BCF\u5468\u989D\u5EA6";
25025
+ if (window === "5h") return "5 \u5C0F\u65F6\u989D\u5EA6";
25026
+ if (!rawName) return "\u989D\u5EA6";
25027
+ return rawName.replace(/\s+(?:remaining|used|left)$/i, "").trim() || rawName;
25028
+ }
25029
+ function formatBucketLabel(groupName, window, rawName, siblings) {
25030
+ const group = shortGroupLabel(groupName);
25031
+ const win = shortWindowLabel(window, rawName);
25032
+ return siblings <= 1 && !window && !rawName ? group : `${group} \xB7 ${win}`;
25033
+ }
25034
+ function findEnvelope(stdout, parse4) {
25035
+ for (const line of stdout.split(/\r?\n/)) {
25036
+ const trimmed = line.trim();
25037
+ if (!trimmed.startsWith("{")) continue;
25038
+ try {
25039
+ const found = parse4(JSON.parse(trimmed));
25040
+ if (found !== null) return found;
25041
+ } catch {
25042
+ continue;
25043
+ }
25044
+ }
25045
+ return null;
25046
+ }
25047
+ function antigravityStdoutShowsModelTurn(stdout) {
25048
+ return findEnvelope(stdout, (value) => {
25049
+ if (!isRecord(value)) return null;
25050
+ if (typeof value.num_turns === "number" && value.num_turns > 0) return true;
25051
+ return readString(value.conversation_id) !== null ? true : null;
25052
+ }) !== null;
25053
+ }
25054
+ function parseAntigravityUsageEnvelope(value) {
25055
+ if (!isRecord(value) || readString(value.status) !== "SUCCESS") return null;
25056
+ const command = value.command;
25057
+ if (!isRecord(command) || readString(command.name) !== "usage") return null;
25058
+ const data = command.data;
25059
+ if (!isRecord(data) || !Array.isArray(data.groups)) return null;
25060
+ const windows = [];
25061
+ for (const rawGroup of data.groups) {
25062
+ if (!isRecord(rawGroup)) continue;
25063
+ const groupName = readString(rawGroup.name);
25064
+ const rawBuckets = Array.isArray(rawGroup.buckets) ? rawGroup.buckets : [];
25065
+ if (!groupName) continue;
25066
+ const enabled = rawBuckets.filter((item) => isRecord(item) && item.disabled !== true);
25067
+ for (const bucket of enabled) {
25068
+ const id = readString(bucket.id);
25069
+ const fraction = bucket.remaining_fraction;
25070
+ if (!id || typeof fraction !== "number" || !Number.isFinite(fraction)) continue;
25071
+ const windowKind = readString(bucket.window);
25072
+ const windowSeconds = windowSecondsFor(windowKind);
25073
+ const usedPercent = Math.min(100, Math.max(0, Math.round((1 - fraction) * 1e4) / 100));
25074
+ windows.push({
25075
+ key: `antigravity:${id}`,
25076
+ label: formatBucketLabel(groupName, windowKind, readString(bucket.name), enabled.length),
25077
+ used_percent: usedPercent,
25078
+ resets_at: parseResetSeconds(bucket.reset_time),
25079
+ ...windowSeconds ? { window_seconds: windowSeconds } : {}
25080
+ });
25081
+ }
25082
+ }
25083
+ if (data.groups.length > 0 && windows.length === 0) return null;
25084
+ return windows;
25085
+ }
25086
+ function parseAntigravityUsageStdout(stdout) {
25087
+ return findEnvelope(stdout, parseAntigravityUsageEnvelope);
25088
+ }
25089
+ function readAgyErrorEnvelope(stdout) {
25090
+ return findEnvelope(
25091
+ stdout,
25092
+ (value) => isRecord(value) && readString(value.status) === "ERROR" ? readString(value.error) : null
25093
+ );
25094
+ }
25095
+ function classifyFailure(output2, stderr) {
25096
+ if (stderr.includes("Authentication required. Please visit the URL")) {
25097
+ return "Antigravity \u672A\u767B\u5F55\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C agy \u5B8C\u6210\u540E\u518D\u540C\u6B65\u989D\u5EA6";
25098
+ }
25099
+ for (const line of output2.split(/\r?\n/)) {
25100
+ const idx = line.indexOf(AGY_ERROR_PREFIX);
25101
+ if (idx === -1) continue;
25102
+ const payload = line.slice(idx + AGY_ERROR_PREFIX.length).trim();
25103
+ if (!payload.startsWith("{")) continue;
25104
+ try {
25105
+ const parsed = JSON.parse(payload);
25106
+ const status = typeof parsed.status === "string" ? parsed.status.toUpperCase() : "";
25107
+ const code = typeof parsed.error_code === "number" ? parsed.error_code : null;
25108
+ if (status === "UNAUTHENTICATED" || code === 401) return "Antigravity \u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C agy \u91CD\u65B0\u767B\u5F55";
25109
+ if (status === "PERMISSION_DENIED" || code === 403) return "\u5F53\u524D Antigravity \u8D26\u53F7\u6CA1\u6709\u53EF\u7528\u7684\u8BA2\u9605\u989D\u5EA6\u6743\u9650";
25110
+ if (status === "RESOURCE_EXHAUSTED" || code === 429) return "Antigravity \u989D\u5EA6\u63A5\u53E3\u6682\u65F6\u9650\u6D41\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5";
25111
+ if (code !== null && code >= 500 && code < 600) return `Antigravity \u670D\u52A1\u7AEF\u8FD4\u56DE\u9519\u8BEF (${code})`;
25112
+ } catch {
25113
+ continue;
25114
+ }
25115
+ }
25116
+ const lowered = output2.toLowerCase();
25117
+ if (SIGNED_OUT_PHRASES.some((phrase) => lowered.includes(phrase))) {
25118
+ return "Antigravity \u672A\u767B\u5F55\uFF0C\u8BF7\u5728\u672C\u673A\u8FD0\u884C agy \u5B8C\u6210\u540E\u518D\u540C\u6B65\u989D\u5EA6";
25119
+ }
25120
+ return null;
25121
+ }
25122
+ function runCommand(executable, args, env, timeoutMs) {
25123
+ return new Promise((resolve9, reject) => {
25124
+ const child = spawn8(executable, [...args], { env, stdio: ["ignore", "pipe", "pipe"], shell: false, windowsHide: true });
25125
+ let stdout = "";
25126
+ let stderr = "";
25127
+ let timedOut = false;
25128
+ const append = (current, chunk) => {
25129
+ if (current.length >= MAX_OUTPUT_BYTES) return current;
25130
+ return current + chunk.toString("utf8", 0, Math.max(0, MAX_OUTPUT_BYTES - current.length));
25131
+ };
25132
+ const timer = setTimeout(() => {
25133
+ timedOut = true;
25134
+ child.kill("SIGKILL");
25135
+ }, timeoutMs);
25136
+ child.stdout.on("data", (chunk) => {
25137
+ stdout = append(stdout, chunk);
25138
+ });
25139
+ child.stderr.on("data", (chunk) => {
25140
+ stderr = append(stderr, chunk);
25141
+ });
25142
+ child.on("error", (error62) => {
25143
+ clearTimeout(timer);
25144
+ reject(error62);
25145
+ });
25146
+ child.on("close", (code) => {
25147
+ clearTimeout(timer);
25148
+ resolve9({ code, stdout, stderr, timedOut });
25149
+ });
25150
+ });
25151
+ }
25152
+ async function readAntigravityQuotaWindows() {
25153
+ if (unsupportedUsageLatched) {
25154
+ throw new Error("\u5F53\u524D\u7248\u672C\u7684 Antigravity CLI \u4E0D\u652F\u6301 /usage \u547D\u4EE4\uFF0C\u8BF7\u5347\u7EA7 agy \u540E\u91CD\u542F\u8BBE\u5907\u4EE3\u7406");
25155
+ }
25156
+ const spec = requireCliSpec("antigravity");
25157
+ const baseEnv = mergeShellProxyEnvironment(await hydrateShellPath(), providerEnvironment());
25158
+ const env = scrubAntigravityEnv(baseEnv);
25159
+ const versionLaunch = launchCli({ spec, args: ["--version"], env });
25160
+ const versionRun = await runCommand(versionLaunch.executable, versionLaunch.args, versionLaunch.env ?? env, VERSION_TIMEOUT_MS).catch((error62) => {
25161
+ const message = error62 instanceof Error ? error62.message : String(error62);
25162
+ if (/ENOENT/i.test(message)) throw new Error("\u672C\u673A\u672A\u5B89\u88C5 Antigravity CLI\uFF08agy\uFF09");
25163
+ throw new Error(`\u65E0\u6CD5\u542F\u52A8 Antigravity CLI\uFF1A${message}`);
25164
+ });
25165
+ const detected = versionRun.code === 0 && !versionRun.timedOut ? versionNumber(versionRun.stdout.trim() || versionRun.stderr.trim()) : void 0;
25166
+ if (!detected || compareVersions(detected, ANTIGRAVITY_MIN_USAGE_VERSION) < 0) {
25167
+ throw new Error(
25168
+ detected ? `Antigravity \u989D\u5EA6\u8BFB\u53D6\u9700\u8981 agy ${ANTIGRAVITY_MIN_USAGE_VERSION} \u6216\u66F4\u65B0\u7248\u672C\uFF08\u5F53\u524D ${detected}\uFF09` : "\u65E0\u6CD5\u8BFB\u53D6 Antigravity CLI \u7248\u672C\uFF0C\u8BF7\u786E\u8BA4 agy \u5DF2\u6B63\u786E\u5B89\u88C5"
25169
+ );
25170
+ }
25171
+ const usageLaunch = launchCli({ spec, args: [...ANTIGRAVITY_USAGE_ARGS], env });
25172
+ const result = await runCommand(usageLaunch.executable, usageLaunch.args, usageLaunch.env ?? env, USAGE_TIMEOUT_MS);
25173
+ const windows = parseAntigravityUsageStdout(result.stdout);
25174
+ if (!windows) {
25175
+ const classified = classifyFailure(`${result.stdout}
25176
+ ${result.stderr}`, result.stderr);
25177
+ if (classified) throw new Error(classified);
25178
+ if (result.timedOut) throw new Error("\u8BFB\u53D6 Antigravity \u989D\u5EA6\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");
25179
+ if (antigravityStdoutShowsModelTurn(result.stdout)) {
25180
+ unsupportedUsageLatched = true;
25181
+ throw new Error("\u5F53\u524D\u7248\u672C\u7684 Antigravity CLI \u5C06 /usage \u5F53\u4F5C\u5BF9\u8BDD\u6267\u884C\uFF0C\u5DF2\u505C\u6B62\u8BFB\u53D6\u4EE5\u514D\u6D88\u8017\u989D\u5EA6\uFF0C\u8BF7\u5347\u7EA7 agy");
25182
+ }
25183
+ const envelopeError = readAgyErrorEnvelope(result.stdout);
25184
+ if (envelopeError) throw new Error(`Antigravity \u989D\u5EA6\u8BFB\u53D6\u5931\u8D25\uFF1A${envelopeError}`);
25185
+ throw new Error(`Antigravity \u672A\u8FD4\u56DE\u6709\u6548\u989D\u5EA6\u6570\u636E${result.code ? ` (exit ${result.code})` : ""}`);
25186
+ }
25187
+ if (windows.length === 0) {
25188
+ throw new Error("Antigravity \u5F53\u524D\u8D26\u53F7\u6CA1\u6709\u8FD4\u56DE\u6709\u6548\u7684\u989D\u5EA6\u7A97\u53E3");
25189
+ }
25190
+ return windows;
25191
+ }
25192
+
24726
25193
  // src/providers/claude-quota.ts
24727
25194
  import { execFile as execFile5 } from "node:child_process";
24728
25195
  import { readFile as readFile6 } from "node:fs/promises";
24729
- import { homedir as homedir10 } from "node:os";
24730
- import { join as join16 } from "node:path";
25196
+ import { homedir as homedir11 } from "node:os";
25197
+ import { join as join17 } from "node:path";
24731
25198
  import { promisify as promisify3 } from "node:util";
24732
25199
  var execFileAsync3 = promisify3(execFile5);
24733
25200
  var CLAUDE_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
@@ -24766,7 +25233,7 @@ function parseClaudeQuota(body) {
24766
25233
  }
24767
25234
  return windows;
24768
25235
  }
24769
- var claudeHome2 = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join16(homedir10(), ".claude");
25236
+ var claudeHome2 = () => process.env.CLAUDE_CONFIG_DIR?.trim() || join17(homedir11(), ".claude");
24770
25237
  function tokenFrom(content) {
24771
25238
  try {
24772
25239
  const token = objectValue2(objectValue2(JSON.parse(content)).claudeAiOauth).accessToken;
@@ -24778,7 +25245,7 @@ function tokenFrom(content) {
24778
25245
  async function readClaudeAccessToken() {
24779
25246
  const fromEnv = process.env.CLAUDE_CODE_OAUTH_TOKEN?.trim();
24780
25247
  if (fromEnv) return fromEnv;
24781
- const fromFile = tokenFrom(await readFile6(join16(claudeHome2(), ".credentials.json"), "utf8").catch(() => ""));
25248
+ const fromFile = tokenFrom(await readFile6(join17(claudeHome2(), ".credentials.json"), "utf8").catch(() => ""));
24782
25249
  if (fromFile) return fromFile;
24783
25250
  if (process.platform !== "darwin") return void 0;
24784
25251
  const { stdout } = await execFileAsync3("security", ["find-generic-password", "-s", "Claude Code-credentials", "-w"], { timeout: 1e4 }).catch(() => ({ stdout: "" }));
@@ -24800,11 +25267,11 @@ async function readClaudeQuotaWindows() {
24800
25267
  }
24801
25268
 
24802
25269
  // src/providers/codex-quota.ts
24803
- import { spawn as spawn8 } from "node:child_process";
25270
+ import { spawn as spawn9 } from "node:child_process";
24804
25271
  import { createInterface as createInterface3 } from "node:readline";
24805
25272
  async function readCodexQuotaWindows() {
24806
25273
  const launch = launchCli({ spec: requireCliSpec("codex"), args: ["app-server", "--stdio"] });
24807
- const child = spawn8(launch.executable, launch.args, { env: launch.env, stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
25274
+ const child = spawn9(launch.executable, launch.args, { env: launch.env, stdio: ["pipe", "pipe", "ignore"], windowsHide: true });
24808
25275
  let nextId = 0;
24809
25276
  const pending = /* @__PURE__ */ new Map();
24810
25277
  const lines = createInterface3({ input: child.stdout });
@@ -24976,6 +25443,7 @@ var NATIVE = {
24976
25443
  claude: { headless: claudeProvider, chat: (_request, attachments) => claudeChatProvider(attachments), models: MODEL_SOURCES.claude, quota: readClaudeQuotaWindows, runSettings: { permissionModes: ALL_LEVELS, plan: "native", fast: true } }
24977
25444
  };
24978
25445
  var ACP_EXTRAS = {
25446
+ antigravity: { quota: readAntigravityQuotaWindows },
24979
25447
  kiro: { quota: readKiroQuotaWindows, legacy: { headless: kiroProvider, restrictedPermission: true, runSettings: { permissionModes: ["read-only", "bypassPermissions"], plan: "prompt" } } },
24980
25448
  gemini: { legacy: { headless: geminiProvider, restrictedPermission: false } },
24981
25449
  grok: { legacy: { headless: grokProvider, restrictedPermission: false } },
@@ -25075,7 +25543,7 @@ function probeVersion(path, args) {
25075
25543
  if (args.length === 0) return Promise.resolve({});
25076
25544
  return new Promise((resolve9) => {
25077
25545
  const launch = directLaunch2(path, args, process.env.TOC_OCRA_NODE_PATH || process.execPath);
25078
- const child = spawn9(launch.executable, launch.args, { stdio: ["ignore", "pipe", "pipe"], shell: false, windowsHide: true });
25546
+ const child = spawn10(launch.executable, launch.args, { stdio: ["ignore", "pipe", "pipe"], shell: false, windowsHide: true });
25079
25547
  let stdout = "";
25080
25548
  let stderr = "";
25081
25549
  let settled = false;
@@ -25159,10 +25627,10 @@ var cliDetection = new CliDetectionService();
25159
25627
 
25160
25628
  // src/runtime/agent-runtime.ts
25161
25629
  import { randomUUID as randomUUID4 } from "node:crypto";
25162
- import { join as join23 } from "node:path";
25630
+ import { join as join24 } from "node:path";
25163
25631
 
25164
25632
  // src/exec/script-runner.ts
25165
- import { spawn as spawn10 } from "node:child_process";
25633
+ import { spawn as spawn11 } from "node:child_process";
25166
25634
  var MAX_SCRIPT_OUTPUT_BYTES = 112 * 1024;
25167
25635
  function executeScript(command, workdir, timeoutSeconds) {
25168
25636
  return new Promise((resolveExecution) => {
@@ -25193,7 +25661,7 @@ function executeScript(command, workdir, timeoutSeconds) {
25193
25661
  };
25194
25662
  let child;
25195
25663
  try {
25196
- child = spawn10(executable, args, {
25664
+ child = spawn11(executable, args, {
25197
25665
  cwd: workdir,
25198
25666
  env: process.env,
25199
25667
  detached: ownGroup,
@@ -25287,12 +25755,12 @@ var MemoryBindingSchema = external_exports.object({
25287
25755
  memory_id: external_exports.string().trim().min(1).max(200)
25288
25756
  });
25289
25757
  var COMMAND_TIMEOUT_MS = 15e3;
25290
- var MAX_OUTPUT_BYTES = 1024 * 1024;
25758
+ var MAX_OUTPUT_BYTES2 = 1024 * 1024;
25291
25759
  var runNmem = (args) => {
25292
25760
  const env = providerEnvironment();
25293
25761
  const launch = resolveExecutable("nmem", args, env, process.env.TOC_OCRA_NMEM_PATH);
25294
25762
  return new Promise((resolve9) => {
25295
- execFile7(launch.executable, launch.args, { env: launch.env, timeout: COMMAND_TIMEOUT_MS, maxBuffer: MAX_OUTPUT_BYTES, windowsHide: true }, (error62, stdout) => {
25763
+ execFile7(launch.executable, launch.args, { env: launch.env, timeout: COMMAND_TIMEOUT_MS, maxBuffer: MAX_OUTPUT_BYTES2, windowsHide: true }, (error62, stdout) => {
25296
25764
  if (!error62) {
25297
25765
  resolve9({ stdout: String(stdout) });
25298
25766
  return;
@@ -25448,15 +25916,15 @@ async function readCLIQuotaReport(agentType) {
25448
25916
 
25449
25917
  // src/providers/tb-switch-control.ts
25450
25918
  import { readFile as readFile7 } from "node:fs/promises";
25451
- import { homedir as homedir11 } from "node:os";
25452
- import { join as join17 } from "node:path";
25919
+ import { homedir as homedir12 } from "node:os";
25920
+ import { join as join18 } from "node:path";
25453
25921
  function dataDir() {
25454
- return process.env.TB_SWITCH_HOME?.trim() || join17(homedir11(), ".tb-switch");
25922
+ return process.env.TB_SWITCH_HOME?.trim() || join18(homedir12(), ".tb-switch");
25455
25923
  }
25456
25924
  async function readLocalService() {
25457
25925
  let discovery;
25458
25926
  try {
25459
- discovery = JSON.parse(await readFile7(join17(dataDir(), "api.json"), "utf8"));
25927
+ discovery = JSON.parse(await readFile7(join18(dataDir(), "api.json"), "utf8"));
25460
25928
  } catch {
25461
25929
  throw new Error("\u8FD9\u53F0\u8BBE\u5907\u4E0A\u7684 TB Switch \u670D\u52A1\u672A\u8FD0\u884C\uFF0C\u8BF7\u6253\u5F00\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
25462
25930
  }
@@ -25472,7 +25940,7 @@ async function readLocalService() {
25472
25940
  }
25473
25941
  let token = process.env.TB_SWITCH_API_TOKEN?.trim() ?? "";
25474
25942
  try {
25475
- token = (await readFile7(join17(dataDir(), "api-token"), "utf8")).trim();
25943
+ token = (await readFile7(join18(dataDir(), "api-token"), "utf8")).trim();
25476
25944
  } catch {
25477
25945
  }
25478
25946
  if (!token) throw new Error("\u65E0\u6CD5\u8BFB\u53D6 TB Switch \u672C\u673A\u670D\u52A1\u51ED\u636E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u63D2\u4EF6\u540E\u91CD\u8BD5\u3002");
@@ -25615,9 +26083,9 @@ function commandOf(pid) {
25615
26083
  }
25616
26084
 
25617
26085
  // src/runs/run-supervisor.ts
25618
- import { spawn as spawn12 } from "node:child_process";
26086
+ import { spawn as spawn13 } from "node:child_process";
25619
26087
  import { mkdir as mkdir8, realpath as realpath2, stat as stat6, writeFile as writeFile8 } from "node:fs/promises";
25620
- import { basename as basename3, isAbsolute as isAbsolute4, join as join21, relative as relative2, resolve as resolve5 } from "node:path";
26088
+ import { basename as basename3, isAbsolute as isAbsolute4, join as join22, relative as relative2, resolve as resolve5 } from "node:path";
25621
26089
  import { createInterface as createInterface5 } from "node:readline";
25622
26090
 
25623
26091
  // src/session/terminal-tail-buffer.ts
@@ -25899,12 +26367,12 @@ function codexGoalProvider(request, goal) {
25899
26367
  }
25900
26368
 
25901
26369
  // src/providers/cli/codex-fork.ts
25902
- import { spawn as spawn11 } from "node:child_process";
26370
+ import { spawn as spawn12 } from "node:child_process";
25903
26371
  import { createInterface as createInterface4 } from "node:readline";
25904
26372
  var FORK_TIMEOUT_MS = 9e4;
25905
26373
  async function forkCodexThread(options) {
25906
26374
  const launch = launchCli({ spec: requireCliSpec("codex"), args: ["app-server", "--listen", "stdio://"] });
25907
- const child = spawn11(launch.executable, launch.args, {
26375
+ const child = spawn12(launch.executable, launch.args, {
25908
26376
  cwd: options.workdir,
25909
26377
  env: launch.env,
25910
26378
  shell: false,
@@ -25979,19 +26447,19 @@ async function forkCodexThread(options) {
25979
26447
 
25980
26448
  // src/runs/run-recorder.ts
25981
26449
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3 } from "node:fs";
25982
- import { homedir as homedir12 } from "node:os";
25983
- import { join as join18 } from "node:path";
26450
+ import { homedir as homedir13 } from "node:os";
26451
+ import { join as join19 } from "node:path";
25984
26452
  var RunRecorder = class _RunRecorder {
25985
26453
  constructor(path) {
25986
26454
  this.path = path;
25987
26455
  }
25988
26456
  path;
25989
- home = homedir12();
26457
+ home = homedir13();
25990
26458
  static fromEnvironment(runId, meta3) {
25991
26459
  const directory = process.env.TOC_OCRA_RECORD_DIR?.trim();
25992
26460
  if (!directory) return void 0;
25993
26461
  mkdirSync3(directory, { recursive: true });
25994
- const recorder = new _RunRecorder(join18(directory, `${String(meta3.agent ?? "cli")}-${runId}.jsonl`));
26462
+ const recorder = new _RunRecorder(join19(directory, `${String(meta3.agent ?? "cli")}-${runId}.jsonl`));
25995
26463
  recorder.write({ meta: meta3 });
25996
26464
  return recorder;
25997
26465
  }
@@ -26007,7 +26475,7 @@ var RunRecorder = class _RunRecorder {
26007
26475
 
26008
26476
  // src/runs/run-transcript.ts
26009
26477
  import { chmod as chmod4, mkdir as mkdir6, readdir as readdir3, readFile as readFile9, rename as rename6, stat as stat4, unlink, writeFile as writeFile6 } from "node:fs/promises";
26010
- import { join as join19 } from "node:path";
26478
+ import { join as join20 } from "node:path";
26011
26479
  var MAX_TRANSCRIPT_ITEMS = 5e3;
26012
26480
  var MAX_TRANSCRIPT_TEXT = 2e5;
26013
26481
  var MAX_TRANSCRIPT_LINES = 2e4;
@@ -26272,7 +26740,7 @@ function transcriptFileName(runId) {
26272
26740
  var TranscriptStore = class {
26273
26741
  constructor(dataDir2, logger, env = process.env) {
26274
26742
  this.logger = logger;
26275
- this.directory = dataDir2 ? join19(dataDir2, "transcripts") : "";
26743
+ this.directory = dataDir2 ? join20(dataDir2, "transcripts") : "";
26276
26744
  this.enabled = Boolean(dataDir2) && transcriptsOnDisk(env);
26277
26745
  }
26278
26746
  logger;
@@ -26327,7 +26795,7 @@ var TranscriptStore = class {
26327
26795
  await this.writes.get(runId);
26328
26796
  let text3;
26329
26797
  try {
26330
- text3 = await readFile9(join19(this.directory, name), "utf8");
26798
+ text3 = await readFile9(join20(this.directory, name), "utf8");
26331
26799
  } catch (error62) {
26332
26800
  if (errorCode(error62) !== "ENOENT") this.logger.warn("run-transcript-read-failed", { runId, error: errorMessage(error62) });
26333
26801
  return void 0;
@@ -26392,7 +26860,7 @@ var TranscriptStore = class {
26392
26860
  transcript.dirty = false;
26393
26861
  const body = JSON.stringify(transcript.toFile());
26394
26862
  await this.ensureDirectory();
26395
- const file2 = join19(this.directory, name);
26863
+ const file2 = join20(this.directory, name);
26396
26864
  const temporary = `${file2}.${process.pid}.tmp`;
26397
26865
  await writeFile6(temporary, body, { mode: 384 });
26398
26866
  await rename6(temporary, file2);
@@ -26429,7 +26897,7 @@ var TranscriptStore = class {
26429
26897
  const now = Date.now();
26430
26898
  const files = [];
26431
26899
  for (const name of names) {
26432
- const path = join19(this.directory, name);
26900
+ const path = join20(this.directory, name);
26433
26901
  if (name.endsWith(".tmp")) {
26434
26902
  const info2 = await stat4(path).catch(() => void 0);
26435
26903
  if (info2?.isFile() && now - info2.mtimeMs > STALE_TEMPORARY_MS) await unlink(path).catch(() => void 0);
@@ -26479,7 +26947,7 @@ function errorMessage(error62) {
26479
26947
  import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
26480
26948
  import { constants as constants2 } from "node:fs";
26481
26949
  import { lstat, mkdir as mkdir7, open as open3, realpath, rename as rename7, rm as rm4, writeFile as writeFile7 } from "node:fs/promises";
26482
- import { basename as basename2, isAbsolute as isAbsolute3, join as join20, relative } from "node:path";
26950
+ import { basename as basename2, isAbsolute as isAbsolute3, join as join21, relative } from "node:path";
26483
26951
  function within(root2, path) {
26484
26952
  const segment = relative(root2, path);
26485
26953
  return segment === "" || !segment.startsWith("..") && !isAbsolute3(segment);
@@ -26487,7 +26955,7 @@ function within(root2, path) {
26487
26955
  async function attachmentDirectory(workdir, messageId) {
26488
26956
  let directory = workdir;
26489
26957
  for (const segment of [".echo", "attachments", `message-${encodeURIComponent(messageId).slice(0, 180)}`]) {
26490
- directory = join20(directory, segment);
26958
+ directory = join21(directory, segment);
26491
26959
  await mkdir7(directory, { mode: 448 }).catch((error62) => {
26492
26960
  if (error62.code !== "EEXIST") throw error62;
26493
26961
  });
@@ -26495,7 +26963,7 @@ async function attachmentDirectory(workdir, messageId) {
26495
26963
  if (metadata.isSymbolicLink() || !metadata.isDirectory() || !within(workdir, await realpath(directory))) {
26496
26964
  throw new Error("\u9644\u4EF6\u76EE\u5F55\u5FC5\u987B\u4F4D\u4E8E CLI \u5DE5\u4F5C\u76EE\u5F55\u5185\uFF0C\u4E14\u4E0D\u80FD\u662F\u7B26\u53F7\u94FE\u63A5");
26497
26965
  }
26498
- if (segment === ".echo") await writeFile7(join20(directory, ".gitignore"), "*\n", { flag: "wx", mode: 384 }).catch((error62) => {
26966
+ if (segment === ".echo") await writeFile7(join21(directory, ".gitignore"), "*\n", { flag: "wx", mode: 384 }).catch((error62) => {
26499
26967
  if (error62.code !== "EEXIST") throw error62;
26500
26968
  });
26501
26969
  }
@@ -26532,9 +27000,9 @@ async function prepareTaskAttachments(payload, workdir, download, signal2) {
26532
27000
  const characters = Array.from(basename2(file2.name.replace(/\\/g, "/")).replace(/[^\p{L}\p{N}._-]/gu, "_").replace(/\.+$/u, ""));
26533
27001
  while (Buffer.byteLength(characters.join("")) > 160) characters.shift();
26534
27002
  const name = characters.join("") || "attachment";
26535
- const path = join20(directory, `${file2.file_id}-${name}`);
27003
+ const path = join21(directory, `${file2.file_id}-${name}`);
26536
27004
  if (!await matches(path, file2.size, file2.sha256, signal2)) {
26537
- const temporary = join20(directory, `.download-${file2.file_id}-${randomUUID2()}.part`);
27005
+ const temporary = join21(directory, `.download-${file2.file_id}-${randomUUID2()}.part`);
26538
27006
  try {
26539
27007
  await download(payload.run_id, file2.file_id, temporary, file2.size, file2.sha256, signal2);
26540
27008
  signal2.throwIfAborted();
@@ -26654,29 +27122,29 @@ import { extname } from "node:path";
26654
27122
  import { pathToFileURL } from "node:url";
26655
27123
 
26656
27124
  // src/acp/ask-user-question.ts
26657
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
27125
+ var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
26658
27126
  var getLodyMeta = (meta3) => {
26659
- if (!isRecord(meta3)) return null;
26660
- return isRecord(meta3.lody) ? meta3.lody : null;
27127
+ if (!isRecord2(meta3)) return null;
27128
+ return isRecord2(meta3.lody) ? meta3.lody : null;
26661
27129
  };
26662
27130
  var getClaudeCodeMeta = (meta3) => {
26663
- if (!isRecord(meta3)) return null;
26664
- return isRecord(meta3.claudeCode) ? meta3.claudeCode : null;
27131
+ if (!isRecord2(meta3)) return null;
27132
+ return isRecord2(meta3.claudeCode) ? meta3.claudeCode : null;
26665
27133
  };
26666
27134
  var getCodexMeta = (meta3) => {
26667
- if (!isRecord(meta3)) return null;
26668
- return isRecord(meta3.codex) ? meta3.codex : null;
27135
+ if (!isRecord2(meta3)) return null;
27136
+ return isRecord2(meta3.codex) ? meta3.codex : null;
26669
27137
  };
26670
27138
  var getLodyElicitationMeta = (meta3) => {
26671
27139
  const elicitation = getLodyMeta(meta3)?.elicitation;
26672
- return isRecord(elicitation) && elicitation.version === 1 ? elicitation : null;
27140
+ return isRecord2(elicitation) && elicitation.version === 1 ? elicitation : null;
26673
27141
  };
26674
27142
  function isAskUserQuestionPermission(params) {
26675
27143
  const meta3 = params._meta;
26676
27144
  const lody = getLodyElicitationMeta(meta3);
26677
27145
  if (lody && Array.isArray(lody.questions)) return true;
26678
- if (isRecord(getClaudeCodeMeta(meta3)?.askUserQuestion)) return true;
26679
- return isRecord(getCodexMeta(meta3)?.requestUserInput);
27146
+ if (isRecord2(getClaudeCodeMeta(meta3)?.askUserQuestion)) return true;
27147
+ return isRecord2(getCodexMeta(meta3)?.requestUserInput);
26680
27148
  }
26681
27149
  function hasValidNoteKeys(questions) {
26682
27150
  if (!questions.some((question) => question.note)) return true;
@@ -26700,18 +27168,18 @@ function getAskUserQuestionAnswerKey(questions, index) {
26700
27168
  }
26701
27169
  var getLodyOutcomeAnswers = (outcomeMeta) => {
26702
27170
  const elicitation = getLodyMeta(outcomeMeta)?.elicitation;
26703
- return isRecord(elicitation) && isRecord(elicitation.answers) ? elicitation.answers : null;
27171
+ return isRecord2(elicitation) && isRecord2(elicitation.answers) ? elicitation.answers : null;
26704
27172
  };
26705
27173
  var getCodexOutcomeAnswers = (outcomeMeta) => {
26706
27174
  const requestUserInput = getCodexMeta(outcomeMeta)?.requestUserInput;
26707
- return isRecord(requestUserInput) && isRecord(requestUserInput.answers) ? requestUserInput.answers : null;
27175
+ return isRecord2(requestUserInput) && isRecord2(requestUserInput.answers) ? requestUserInput.answers : null;
26708
27176
  };
26709
27177
  var getClaudeOutcomeAnswers = (outcomeMeta) => {
26710
27178
  const askUserQuestion = getClaudeCodeMeta(outcomeMeta)?.askUserQuestion;
26711
- return isRecord(askUserQuestion) && isRecord(askUserQuestion.answers) ? askUserQuestion.answers : null;
27179
+ return isRecord2(askUserQuestion) && isRecord2(askUserQuestion.answers) ? askUserQuestion.answers : null;
26712
27180
  };
26713
27181
  function extractAskUserQuestionAnswersFromOutcome(meta3, outcome) {
26714
- if (!outcome || !isRecord(outcome._meta) || !hasValidNoteKeys(meta3.questions)) return null;
27182
+ if (!outcome || !isRecord2(outcome._meta) || !hasValidNoteKeys(meta3.questions)) return null;
26715
27183
  const answerSources = [
26716
27184
  { source: "lody", answers: getLodyOutcomeAnswers(outcome._meta) },
26717
27185
  { source: "codex", answers: getCodexOutcomeAnswers(outcome._meta) },
@@ -26730,7 +27198,7 @@ function extractAskUserQuestionAnswersFromOutcome(meta3, outcome) {
26730
27198
  const raw = answerSource.answers[sourceKey];
26731
27199
  if (raw === void 0) continue;
26732
27200
  if (answerSource.source === "codex") {
26733
- if (!isRecord(raw) || !Array.isArray(raw.answers)) continue;
27201
+ if (!isRecord2(raw) || !Array.isArray(raw.answers)) continue;
26734
27202
  const values = raw.answers.filter((value) => typeof value === "string");
26735
27203
  if (values.length === 0) continue;
26736
27204
  result[key] = question.multiSelect ? values : values[0] ?? "";
@@ -26744,20 +27212,20 @@ function extractAskUserQuestionAnswersFromOutcome(meta3, outcome) {
26744
27212
  }
26745
27213
  return Object.keys(result).length > 0 ? result : null;
26746
27214
  }
26747
- var isEnumOption = (value) => isRecord(value) && typeof value.const === "string";
27215
+ var isEnumOption = (value) => isRecord2(value) && typeof value.const === "string";
26748
27216
  var getEnumOptionSource = (prop) => {
26749
27217
  if (Array.isArray(prop.oneOf)) return prop.oneOf;
26750
27218
  if (Array.isArray(prop.enum)) return prop.enum;
26751
27219
  const items = prop.items;
26752
- if (isRecord(items)) {
27220
+ if (isRecord2(items)) {
26753
27221
  if (Array.isArray(items.anyOf)) return items.anyOf;
26754
27222
  if (Array.isArray(items.enum)) return items.enum;
26755
27223
  }
26756
27224
  return null;
26757
27225
  };
26758
- var isQuestionProperty = (prop) => isRecord(prop) && getEnumOptionSource(prop) !== null;
26759
- var isFreeTextProperty = (prop) => isRecord(prop) && prop.type === "string" && !Array.isArray(prop.oneOf) && !Array.isArray(prop.enum);
26760
- var isMultiSelectProperty = (prop) => prop.type === "array" || isRecord(prop.items);
27226
+ var isQuestionProperty = (prop) => isRecord2(prop) && getEnumOptionSource(prop) !== null;
27227
+ var isFreeTextProperty = (prop) => isRecord2(prop) && prop.type === "string" && !Array.isArray(prop.oneOf) && !Array.isArray(prop.enum);
27228
+ var isMultiSelectProperty = (prop) => prop.type === "array" || isRecord2(prop.items);
26761
27229
  var parseElicitationOptions = (source) => {
26762
27230
  const options = [];
26763
27231
  for (const entry of source) {
@@ -26776,9 +27244,9 @@ var parseElicitationOptions = (source) => {
26776
27244
  return options;
26777
27245
  };
26778
27246
  function parseAskUserQuestionElicitationRequest(request) {
26779
- if (!isRecord(request) || request.mode !== "form") return null;
27247
+ if (!isRecord2(request) || request.mode !== "form") return null;
26780
27248
  const schema = request.requestedSchema;
26781
- if (!isRecord(schema) || !isRecord(schema.properties)) return null;
27249
+ if (!isRecord2(schema) || !isRecord2(schema.properties)) return null;
26782
27250
  const properties = schema.properties;
26783
27251
  const entries = Object.entries(properties);
26784
27252
  const requestMeta = getLodyElicitationMeta(request._meta);
@@ -26786,9 +27254,9 @@ function parseAskUserQuestionElicitationRequest(request) {
26786
27254
  const noteFieldKeyByQuestionId = /* @__PURE__ */ new Map();
26787
27255
  const associatedFields = /* @__PURE__ */ new Set();
26788
27256
  for (const [key, prop] of entries) {
26789
- if (!isRecord(prop)) continue;
27257
+ if (!isRecord2(prop)) continue;
26790
27258
  const rawMeta = getLodyMeta(prop._meta)?.elicitation;
26791
- if (isRecord(rawMeta) && rawMeta.noteFor !== void 0 && rawMeta.version !== 1) return null;
27259
+ if (isRecord2(rawMeta) && rawMeta.noteFor !== void 0 && rawMeta.version !== 1) return null;
26792
27260
  const meta3 = getLodyElicitationMeta(prop._meta);
26793
27261
  if (!meta3 || meta3.noteFor === void 0 && meta3.customAnswerFor === void 0) continue;
26794
27262
  if (meta3.noteFor !== void 0 && meta3.customAnswerFor !== void 0) return null;
@@ -26801,7 +27269,7 @@ function parseAskUserQuestionElicitationRequest(request) {
26801
27269
  }
26802
27270
  const isLodyForm = requestMeta !== null || associatedFields.size > 0;
26803
27271
  const questionEntries = entries.filter(([key, prop]) => {
26804
- if (!isRecord(prop) || associatedFields.has(key)) return false;
27272
+ if (!isRecord2(prop) || associatedFields.has(key)) return false;
26805
27273
  return isQuestionProperty(prop) || isLodyForm && isFreeTextProperty(prop);
26806
27274
  });
26807
27275
  if (questionEntries.length === 0) return null;
@@ -26811,13 +27279,13 @@ function parseAskUserQuestionElicitationRequest(request) {
26811
27279
  }
26812
27280
  if (associatedFields.size > 0 && questionEntries.some(([key]) => !key.trim())) return null;
26813
27281
  const singleQuestion = questionEntries.length === 1;
26814
- const allowCustomAnswer = isLodyForm ? questionEntries.some(([key, prop]) => isRecord(prop) && (getEnumOptionSource(prop) === null || customFieldKeyByQuestionId.has(key))) : entries.some(([, prop]) => isFreeTextProperty(prop));
27282
+ const allowCustomAnswer = isLodyForm ? questionEntries.some(([key, prop]) => isRecord2(prop) && (getEnumOptionSource(prop) === null || customFieldKeyByQuestionId.has(key))) : entries.some(([, prop]) => isFreeTextProperty(prop));
26815
27283
  const message = typeof request.message === "string" ? request.message : "";
26816
27284
  const questions = [];
26817
27285
  const fieldKeys = [];
26818
27286
  const customFieldKeys = [];
26819
27287
  for (const [key, prop] of questionEntries) {
26820
- if (!isRecord(prop)) continue;
27288
+ if (!isRecord2(prop)) continue;
26821
27289
  const source = getEnumOptionSource(prop);
26822
27290
  const header = typeof prop.title === "string" ? prop.title : "";
26823
27291
  const description = typeof prop.description === "string" ? prop.description : "";
@@ -26832,7 +27300,7 @@ function parseAskUserQuestionElicitationRequest(request) {
26832
27300
  multiSelect: isMultiSelectProperty(prop),
26833
27301
  ...isLodyForm ? { allowCustomAnswer: source === null || customFieldKeyByQuestionId.has(key) } : {},
26834
27302
  ...isLodyForm && getLodyElicitationMeta(prop._meta)?.secret === true ? { isSecret: true } : {},
26835
- ...noteFieldId !== void 0 && isRecord(noteProp) ? {
27303
+ ...noteFieldId !== void 0 && isRecord2(noteProp) ? {
26836
27304
  note: {
26837
27305
  fieldId: noteFieldId,
26838
27306
  ...typeof noteProp.title === "string" ? { title: noteProp.title } : {},
@@ -26855,7 +27323,7 @@ function parseAskUserQuestionElicitationRequest(request) {
26855
27323
  }
26856
27324
  function buildAskUserQuestionElicitationResponse(elicitation, outcome) {
26857
27325
  if (!outcome || outcome.outcome !== "selected" || outcome.optionId === "cancel") return { action: "cancel" };
26858
- const answers = extractAskUserQuestionAnswersFromOutcome(elicitation.meta, { _meta: isRecord(outcome._meta) ? outcome._meta : null });
27326
+ const answers = extractAskUserQuestionAnswersFromOutcome(elicitation.meta, { _meta: isRecord2(outcome._meta) ? outcome._meta : null });
26859
27327
  if (!answers) return { action: "accept", content: {} };
26860
27328
  const content = /* @__PURE__ */ Object.create(null);
26861
27329
  elicitation.meta.questions.forEach((question, index) => {
@@ -26882,8 +27350,8 @@ function redactSecretAnswers(elicitation, outcome) {
26882
27350
  if (question.note?.isSecret) secret.add(question.note.fieldId);
26883
27351
  });
26884
27352
  const lody = getLodyMeta(outcome._meta);
26885
- const elicitationMeta = lody && isRecord(lody.elicitation) ? lody.elicitation : null;
26886
- if (!secret.size || !elicitationMeta || !isRecord(elicitationMeta.answers)) return outcome;
27353
+ const elicitationMeta = lody && isRecord2(lody.elicitation) ? lody.elicitation : null;
27354
+ if (!secret.size || !elicitationMeta || !isRecord2(elicitationMeta.answers)) return outcome;
26887
27355
  const answers = Object.fromEntries(Object.entries(elicitationMeta.answers).map(([key, value]) => [key, secret.has(key) ? "[redacted]" : value]));
26888
27356
  return { ...outcome, _meta: { ...outcome._meta, lody: { ...lody, elicitation: { ...elicitationMeta, answers } } } };
26889
27357
  }
@@ -27262,7 +27730,7 @@ var AcpChatSession = class {
27262
27730
  }
27263
27731
  }
27264
27732
  blocks.push({ type: "resource_link", uri: pathToFileURL(file2.path).href, name: file2.name });
27265
- notes.push(`\u9644\u4EF6\u6587\u4EF6\uFF1A${file2.name}
27733
+ notes.push(this.spec.dialect?.linksFileMentions ? `@${file2.path}` : `\u9644\u4EF6\u6587\u4EF6\uFF1A${file2.name}
27266
27734
  \u672C\u673A\u8DEF\u5F84\uFF1A${file2.path}`);
27267
27735
  }
27268
27736
  const text3 = [request.prompt, ...notes].filter(Boolean).join("\n\n");
@@ -27309,8 +27777,10 @@ var AcpChatSession = class {
27309
27777
  */
27310
27778
  forwardsPermission(params, prompts) {
27311
27779
  if (isAskUserQuestionPermission(params)) return true;
27780
+ const call = record4(params.toolCall);
27781
+ if (typeof call.toolCallId === "string" && call.toolCallId.startsWith("interaction_")) return true;
27312
27782
  if (prompts.permissions === "none") return false;
27313
- const title = record4(params.toolCall).title;
27783
+ const title = call.title;
27314
27784
  if (ECHO_CALLBACK.test(typeof title === "string" ? title : "")) return false;
27315
27785
  if (prompts.permissions === "all") return true;
27316
27786
  return !permissionAllowed(params, { permissionMode: "full", access: "acceptEdits" });
@@ -27426,6 +27896,8 @@ var AcpChatSession = class {
27426
27896
  const text3 = detail ?? rpcErrorText(error62);
27427
27897
  const context = { label: this.spec.cli.label, ...this.spec.cli.installHint ? { installHint: this.spec.cli.installHint } : {} };
27428
27898
  if (/ACP 进程无法启动/.test(text3)) return classifySpawnError(text3, context);
27899
+ const statusFailure = error62 instanceof JsonRpcError ? this.spec.dialect?.failureKind?.({ code: error62.code, message: error62.message, data: error62.data }) : void 0;
27900
+ if (statusFailure) return cliFailure(statusFailure, { ...context, detail: text3 });
27429
27901
  if (error62 instanceof JsonRpcError && error62.code === -32e3) return cliFailure("notSignedIn", { ...context, detail: text3 });
27430
27902
  const stderr = this.connection?.process.stderrTail() ?? [];
27431
27903
  const known = classifyCliOutput([text3, ...stderr], this.spec.dialect?.failureRules, context);
@@ -27950,7 +28422,7 @@ ${PLAN_MODE_PREFIX}` : payload.prompt;
27950
28422
  if (!fitsCommandLine(launch)) return refuse(cliFailure("promptTooLong", { label: cli.label }));
27951
28423
  let child;
27952
28424
  try {
27953
- child = spawn12(launch.executable, launch.args, {
28425
+ child = spawn13(launch.executable, launch.args, {
27954
28426
  cwd: workdir,
27955
28427
  env: Object.keys(memoryEnv).length ? { ...launch.env, ...memoryEnv } : launch.env,
27956
28428
  detached: currentPlatform.runsInOwnProcessGroup,
@@ -28489,12 +28961,12 @@ ${PLAN_MODE_PREFIX}` : payload.prompt;
28489
28961
  async prepareChatAttachments(payload) {
28490
28962
  if (!payload.attachments?.length) return [];
28491
28963
  if (!this.reporter.chatMedia) throw new Error("\u9644\u4EF6\u8F6C\u53D1\u672A\u914D\u7F6E");
28492
- const directory = join21(this.config.dataDir, "chat-media", encodeURIComponent(payload.chat_session_id ?? payload.run_id));
28964
+ const directory = join22(this.config.dataDir, "chat-media", encodeURIComponent(payload.chat_session_id ?? payload.run_id));
28493
28965
  await mkdir8(directory, { recursive: true, mode: 448 });
28494
28966
  const files = [];
28495
28967
  for (const attachment of payload.attachments) {
28496
28968
  const name = basename3(attachment.name).replace(/[^\p{L}\p{N}._-]/gu, "_").slice(-120) || "attachment";
28497
- const path = join21(directory, `${encodeURIComponent(attachment.media_id)}-${name}`);
28969
+ const path = join22(directory, `${encodeURIComponent(attachment.media_id)}-${name}`);
28498
28970
  const existing = await stat6(path).catch(() => void 0);
28499
28971
  if (!existing?.isFile()) {
28500
28972
  const data = await this.reporter.chatMedia(payload.run_id, attachment.media_id);
@@ -28808,11 +29280,11 @@ var GatewayClient = class {
28808
29280
 
28809
29281
  // src/workspace/directory-browser.ts
28810
29282
  import { mkdir as mkdir9, readdir as readdir4, realpath as realpath3, stat as stat7 } from "node:fs/promises";
28811
- import { homedir as homedir13 } from "node:os";
29283
+ import { homedir as homedir14 } from "node:os";
28812
29284
  import { dirname as dirname9, isAbsolute as isAbsolute5, parse as parse3, resolve as resolve6 } from "node:path";
28813
29285
  var MAX_ENTRIES = 1e3;
28814
29286
  async function listDirectory(requested, allowedRoots) {
28815
- const raw = requested.trim().replace(/^~(?=$|[\\/])/, homedir13()) || homedir13();
29287
+ const raw = requested.trim().replace(/^~(?=$|[\\/])/, homedir14()) || homedir14();
28816
29288
  const directory = await realpath3(resolve6(raw)).catch(() => {
28817
29289
  throw new Error(`\u76EE\u5F55\u4E0D\u5B58\u5728\uFF1A${requested}`);
28818
29290
  });
@@ -28830,8 +29302,8 @@ async function listDirectory(requested, allowedRoots) {
28830
29302
  else if (entry.isFile()) files.push(item);
28831
29303
  }
28832
29304
  const parent = dirname9(directory);
28833
- const places = [{ label: "\u4E3B\u76EE\u5F55", path: homedir13() }];
28834
- for (const root2 of allowedRoots) if (root2 !== homedir13()) places.push({ label: "\u5141\u8BB8\u7684\u76EE\u5F55", path: root2 });
29305
+ const places = [{ label: "\u4E3B\u76EE\u5F55", path: homedir14() }];
29306
+ for (const root2 of allowedRoots) if (root2 !== homedir14()) places.push({ label: "\u5141\u8BB8\u7684\u76EE\u5F55", path: root2 });
28835
29307
  places.push({ label: "\u6839\u76EE\u5F55", path: process.platform === "win32" ? parse3(directory).root : "/" });
28836
29308
  return {
28837
29309
  path: directory,
@@ -28867,9 +29339,9 @@ async function createDirectory(parentRequested, name) {
28867
29339
  }
28868
29340
 
28869
29341
  // src/workspace/workspace-manager.ts
28870
- import { spawn as spawn13 } from "node:child_process";
29342
+ import { spawn as spawn14 } from "node:child_process";
28871
29343
  import { opendir, realpath as realpath4, stat as stat8 } from "node:fs/promises";
28872
- import { homedir as homedir14 } from "node:os";
29344
+ import { homedir as homedir15 } from "node:os";
28873
29345
  import { isAbsolute as isAbsolute6, relative as relative3, resolve as resolve7 } from "node:path";
28874
29346
  var MAX_NODES = 2e3;
28875
29347
  var MAX_DIRECTORY_ENTRIES = 12e3;
@@ -28905,7 +29377,7 @@ var WorkspaceManager = class {
28905
29377
  return { root_path: rootPath, nodes, truncated: nodes.length >= MAX_NODES, duration_ms: Date.now() - startedAt };
28906
29378
  }
28907
29379
  validateRootPath(value) {
28908
- const raw = value.trim().replace(/^~(?=$|[\\/])/, homedir14());
29380
+ const raw = value.trim().replace(/^~(?=$|[\\/])/, homedir15());
28909
29381
  const root2 = resolve7(raw);
28910
29382
  if (!isAbsolute6(raw)) throw new Error("\u6839\u76EE\u5F55\u5FC5\u987B\u662F\u7EDD\u5BF9\u8DEF\u5F84");
28911
29383
  if (relative3(root2, resolve7(root2, "..")) === "") throw new Error("\u4E0D\u80FD\u628A\u6587\u4EF6\u7CFB\u7EDF\u6839\u76EE\u5F55\u4F5C\u4E3A\u76EE\u5F55\u6839");
@@ -29031,7 +29503,7 @@ var WorkspaceManager = class {
29031
29503
  }
29032
29504
  runGit(args, cwd, timeoutSeconds, allowFailure = false) {
29033
29505
  return new Promise((resolveCommand, rejectCommand) => {
29034
- const child = spawn13("git", args, {
29506
+ const child = spawn14("git", args, {
29035
29507
  cwd,
29036
29508
  env: process.env,
29037
29509
  shell: false,
@@ -29245,7 +29717,7 @@ var AgentRuntime = class {
29245
29717
  }
29246
29718
  };
29247
29719
  this.workspaces = new WorkspaceManager(config2, this.logger);
29248
- this.orphans = new OrphanRegistry(join23(config2.dataDir, "active-runs.json"));
29720
+ this.orphans = new OrphanRegistry(join24(config2.dataDir, "active-runs.json"));
29249
29721
  this.runs = new RunSupervisor(config2, this.logger, reporter, this.orphans);
29250
29722
  }
29251
29723
  config;
@@ -29950,7 +30422,7 @@ function errorMessage3(error62) {
29950
30422
  }
29951
30423
 
29952
30424
  // src/runtime/run-service.ts
29953
- import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
30425
+ import { existsSync as existsSync7, readFileSync as readFileSync8 } from "node:fs";
29954
30426
  import { dirname as dirname10, resolve as resolve8 } from "node:path";
29955
30427
  import { fileURLToPath as fileURLToPath2 } from "node:url";
29956
30428
  var PACKAGE_NAME = "toc-ocra";
@@ -29960,7 +30432,7 @@ function agentPackageRoot() {
29960
30432
  const packagePath = resolve8(directory, "package.json");
29961
30433
  if (existsSync7(packagePath)) {
29962
30434
  try {
29963
- const info = JSON.parse(readFileSync7(packagePath, "utf8"));
30435
+ const info = JSON.parse(readFileSync8(packagePath, "utf8"));
29964
30436
  if (info.name === PACKAGE_NAME && typeof info.version === "string") return directory;
29965
30437
  } catch {
29966
30438
  }
@@ -29972,7 +30444,7 @@ function agentPackageRoot() {
29972
30444
  }
29973
30445
  function agentVersion() {
29974
30446
  const root2 = agentPackageRoot();
29975
- return root2 ? JSON.parse(readFileSync7(resolve8(root2, "package.json"), "utf8")).version : "unknown";
30447
+ return root2 ? JSON.parse(readFileSync8(resolve8(root2, "package.json"), "utf8")).version : "unknown";
29976
30448
  }
29977
30449
  async function runService(options = {}) {
29978
30450
  const version2 = agentVersion();
@@ -30028,7 +30500,7 @@ function preferSystemNode() {
30028
30500
  const names = process.platform === "win32" ? ["node.exe"] : ["node"];
30029
30501
  for (const directory of (process.env.PATH ?? "").split(delimiter5)) {
30030
30502
  for (const name of names) {
30031
- const candidate = directory && join24(directory, name);
30503
+ const candidate = directory && join25(directory, name);
30032
30504
  if (candidate && existsSync8(candidate)) {
30033
30505
  process.env.TOC_OCRA_NODE_PATH = candidate;
30034
30506
  return;