@liberseek/boft-cli-linux-x64 0.8.4 → 0.8.5

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.
@@ -413,8 +413,8 @@ import { spawn } from "node:child_process";
413
413
  import { randomUUID as randomUUID6 } from "node:crypto";
414
414
  import { readFile as readFile2, unlink } from "node:fs/promises";
415
415
  import https3 from "node:https";
416
- import os5 from "node:os";
417
- import path10 from "node:path";
416
+ import os6 from "node:os";
417
+ import path11 from "node:path";
418
418
  import readline from "node:readline";
419
419
 
420
420
  // ../../../node_modules/zod/v4/classic/external.js
@@ -1183,10 +1183,10 @@ function mergeDefs(...defs) {
1183
1183
  function cloneDef(schema) {
1184
1184
  return mergeDefs(schema._zod.def);
1185
1185
  }
1186
- function getElementAtPath(obj, path11) {
1187
- if (!path11)
1186
+ function getElementAtPath(obj, path12) {
1187
+ if (!path12)
1188
1188
  return obj;
1189
- return path11.reduce((acc, key) => acc?.[key], obj);
1189
+ return path12.reduce((acc, key) => acc?.[key], obj);
1190
1190
  }
1191
1191
  function promiseAllObject(promisesObj) {
1192
1192
  const keys = Object.keys(promisesObj);
@@ -1595,11 +1595,11 @@ function explicitlyAborted(x, startIndex = 0) {
1595
1595
  }
1596
1596
  return false;
1597
1597
  }
1598
- function prefixIssues(path11, issues) {
1598
+ function prefixIssues(path12, issues) {
1599
1599
  return issues.map((iss) => {
1600
1600
  var _a3;
1601
1601
  (_a3 = iss).path ?? (_a3.path = []);
1602
- iss.path.unshift(path11);
1602
+ iss.path.unshift(path12);
1603
1603
  return iss;
1604
1604
  });
1605
1605
  }
@@ -1746,16 +1746,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1746
1746
  }
1747
1747
  function formatError(error51, mapper = (issue2) => issue2.message) {
1748
1748
  const fieldErrors = { _errors: [] };
1749
- const processError = (error52, path11 = []) => {
1749
+ const processError = (error52, path12 = []) => {
1750
1750
  for (const issue2 of error52.issues) {
1751
1751
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1752
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1752
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1753
1753
  } else if (issue2.code === "invalid_key") {
1754
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1754
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1755
1755
  } else if (issue2.code === "invalid_element") {
1756
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1756
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1757
1757
  } else {
1758
- const fullpath = [...path11, ...issue2.path];
1758
+ const fullpath = [...path12, ...issue2.path];
1759
1759
  if (fullpath.length === 0) {
1760
1760
  fieldErrors._errors.push(mapper(issue2));
1761
1761
  } else {
@@ -1782,17 +1782,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1782
1782
  }
1783
1783
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1784
1784
  const result = { errors: [] };
1785
- const processError = (error52, path11 = []) => {
1785
+ const processError = (error52, path12 = []) => {
1786
1786
  var _a3, _b;
1787
1787
  for (const issue2 of error52.issues) {
1788
1788
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1789
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1789
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1790
1790
  } else if (issue2.code === "invalid_key") {
1791
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1791
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1792
1792
  } else if (issue2.code === "invalid_element") {
1793
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1793
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1794
1794
  } else {
1795
- const fullpath = [...path11, ...issue2.path];
1795
+ const fullpath = [...path12, ...issue2.path];
1796
1796
  if (fullpath.length === 0) {
1797
1797
  result.errors.push(mapper(issue2));
1798
1798
  continue;
@@ -1824,8 +1824,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1824
1824
  }
1825
1825
  function toDotPath(_path) {
1826
1826
  const segs = [];
1827
- const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1828
- for (const seg of path11) {
1827
+ const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1828
+ for (const seg of path12) {
1829
1829
  if (typeof seg === "number")
1830
1830
  segs.push(`[${seg}]`);
1831
1831
  else if (typeof seg === "symbol")
@@ -3446,10 +3446,10 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
3446
3446
  const shape = def.shape;
3447
3447
  const propValues = {};
3448
3448
  for (const key in shape) {
3449
- const field = shape[key]._zod;
3450
- if (field.values) {
3449
+ const field2 = shape[key]._zod;
3450
+ if (field2.values) {
3451
3451
  propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
3452
- for (const v of field.values)
3452
+ for (const v of field2.values)
3453
3453
  propValues[key].add(v);
3454
3454
  }
3455
3455
  }
@@ -5053,8 +5053,8 @@ function az_default() {
5053
5053
  }
5054
5054
 
5055
5055
  // ../../../node_modules/zod/v4/locales/be.js
5056
- function getBelarusianPlural(count2, one, few, many) {
5057
- const absCount = Math.abs(count2);
5056
+ function getBelarusianPlural(count3, one, few, many) {
5057
+ const absCount = Math.abs(count3);
5058
5058
  const lastDigit = absCount % 10;
5059
5059
  const lastTwoDigits = absCount % 100;
5060
5060
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -7132,8 +7132,8 @@ function hu_default() {
7132
7132
  }
7133
7133
 
7134
7134
  // ../../../node_modules/zod/v4/locales/hy.js
7135
- function getArmenianPlural(count2, one, many) {
7136
- return Math.abs(count2) === 1 ? one : many;
7135
+ function getArmenianPlural(count3, one, many) {
7136
+ return Math.abs(count3) === 1 ? one : many;
7137
7137
  }
7138
7138
  function withDefiniteArticle(word) {
7139
7139
  if (!word)
@@ -9261,8 +9261,8 @@ function ro_default() {
9261
9261
  }
9262
9262
 
9263
9263
  // ../../../node_modules/zod/v4/locales/ru.js
9264
- function getRussianPlural(count2, one, few, many) {
9265
- const absCount = Math.abs(count2);
9264
+ function getRussianPlural(count3, one, few, many) {
9265
+ const absCount = Math.abs(count3);
9266
9266
  const lastDigit = absCount % 10;
9267
9267
  const lastTwoDigits = absCount % 100;
9268
9268
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -14517,13 +14517,13 @@ function resolveRef(ref, ctx) {
14517
14517
  if (!ref.startsWith("#")) {
14518
14518
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14519
14519
  }
14520
- const path11 = ref.slice(1).split("/").filter(Boolean);
14521
- if (path11.length === 0) {
14520
+ const path12 = ref.slice(1).split("/").filter(Boolean);
14521
+ if (path12.length === 0) {
14522
14522
  return ctx.rootSchema;
14523
14523
  }
14524
14524
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14525
- if (path11[0] === defsKey) {
14526
- const key = path11[1];
14525
+ if (path12[0] === defsKey) {
14526
+ const key = path12[1];
14527
14527
  if (!key || !ctx.defs[key]) {
14528
14528
  throw new Error(`Reference not found: ${ref}`);
14529
14529
  }
@@ -15089,6 +15089,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15089
15089
  cachedInputTokens: count,
15090
15090
  cacheWriteInputTokens: count,
15091
15091
  cacheKnownInputTokens: count,
15092
+ cacheHitCachedInputTokens: count,
15093
+ cacheHitInputTokens: count,
15092
15094
  outputTokens: count,
15093
15095
  reasoningOutputTokens: count,
15094
15096
  /** USD at the public price, summed over the priced requests only. */
@@ -15196,6 +15198,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
15196
15198
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15197
15199
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15198
15200
 
15201
+ // ../../shared-contracts/dist/thread-questions.js
15202
+ var field = external_exports.discriminatedUnion("type", [
15203
+ external_exports.object({
15204
+ id: external_exports.string().min(1),
15205
+ type: external_exports.literal("choice"),
15206
+ prompt: external_exports.string(),
15207
+ options: external_exports.array(external_exports.object({
15208
+ value: external_exports.string().min(1),
15209
+ label: external_exports.string(),
15210
+ description: external_exports.string().optional()
15211
+ })).min(1),
15212
+ multiple: external_exports.boolean(),
15213
+ allowOther: external_exports.boolean(),
15214
+ optional: external_exports.boolean()
15215
+ }),
15216
+ external_exports.object({
15217
+ id: external_exports.string().min(1),
15218
+ type: external_exports.literal("text"),
15219
+ prompt: external_exports.string(),
15220
+ multiline: external_exports.boolean(),
15221
+ secret: external_exports.literal(false),
15222
+ optional: external_exports.boolean(),
15223
+ placeholder: external_exports.string().optional(),
15224
+ prefill: external_exports.string().optional()
15225
+ })
15226
+ ]);
15227
+ var threadQuestionSchema = external_exports.object({
15228
+ interactionId: external_exports.string().min(1),
15229
+ turnId: external_exports.string().min(1),
15230
+ title: external_exports.string().optional(),
15231
+ questions: external_exports.array(field).min(1)
15232
+ }).refine(({ questions }) => questions.some((q) => q.type === "choice" && q.multiple), {
15233
+ message: "Shared cards require at least one multi-select question"
15234
+ });
15235
+ var threadQuestionsListParamsSchema = external_exports.strictObject({ threadId: external_exports.string().min(1) });
15236
+ var threadQuestionsResultSchema = external_exports.object({ questions: external_exports.array(threadQuestionSchema) });
15237
+ var threadQuestionRespondParamsSchema = external_exports.strictObject({
15238
+ threadId: external_exports.string().min(1),
15239
+ turnId: external_exports.string().min(1),
15240
+ interactionId: external_exports.string().min(1),
15241
+ answers: external_exports.record(external_exports.string(), external_exports.array(external_exports.string())),
15242
+ cancelled: external_exports.boolean().default(false)
15243
+ });
15244
+ var threadQuestionRespondResultSchema = external_exports.object({ accepted: external_exports.literal(true) });
15245
+
15199
15246
  // ../../shared-contracts/dist/harness-plugins.js
15200
15247
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15201
15248
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -15965,7 +16012,10 @@ var harnessPluginRouteSchema = external_exports.object({
15965
16012
  harnessId: harnessPluginIdSchema,
15966
16013
  model: harnessModelRefSchema.optional(),
15967
16014
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15968
- permissionModeId: harnessPermissionModeIdSchema.optional()
16015
+ permissionModeId: harnessPermissionModeIdSchema.optional(),
16016
+ /** A draft prewarm create: stays unsubmitted until the user's first Turn.
16017
+ * Desktop forwards only the Model of a main-process prewarm to thread/start. */
16018
+ prewarm: external_exports.literal(true).optional()
15969
16019
  }).strict();
15970
16020
 
15971
16021
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -16712,6 +16762,12 @@ function historyPath(environment) {
16712
16762
  const threadId = safeThreadId(environment);
16713
16763
  return threadId ? path5.join(historyRoot(environment), `${threadId}.json`) : null;
16714
16764
  }
16765
+ function antigravityHookDirectory(environment) {
16766
+ const threadId = safeThreadId(environment);
16767
+ if (!threadId || threadId === "." || threadId === "..")
16768
+ return null;
16769
+ return path5.join(historyRoot(environment), "hooks", threadId);
16770
+ }
16715
16771
  function jsonTurn(turn) {
16716
16772
  return JSON.parse(JSON.stringify(turn));
16717
16773
  }
@@ -16900,8 +16956,11 @@ var AntigravityHistory = class _AntigravityHistory {
16900
16956
  function nativeConversationDbPath(nativeSessionId, homedir2 = os3.homedir()) {
16901
16957
  return path6.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
16902
16958
  }
16959
+ function nativeBrainRoot(homedir2 = os3.homedir()) {
16960
+ return path6.join(homedir2, ".gemini", "antigravity-cli", "brain");
16961
+ }
16903
16962
  function nativeBrainDirPath(nativeSessionId, homedir2 = os3.homedir()) {
16904
- return path6.join(homedir2, ".gemini", "antigravity-cli", "brain", nativeSessionId);
16963
+ return path6.join(nativeBrainRoot(homedir2), nativeSessionId);
16905
16964
  }
16906
16965
  async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, retainedTurnsCountOrHomedir, homedirOption = os3.homedir()) {
16907
16966
  let retainedTurnsCount;
@@ -18154,7 +18213,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18154
18213
  this.#server.on("request", (request, response) => this.#receive(request, response));
18155
18214
  }
18156
18215
  static async create(options) {
18157
- const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
18216
+ const directory = options.directory ?? await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
18158
18217
  const bridge = new _AntigravityQuestionBridge(directory, options);
18159
18218
  try {
18160
18219
  await new Promise((resolve, reject) => {
@@ -18170,7 +18229,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18170
18229
  throw new Error("Question bridge did not bind");
18171
18230
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
18172
18231
  const client = path8.join(directory, "question-hook.cjs");
18173
- await mkdir3(path8.join(directory, ".agents"));
18232
+ await mkdir3(path8.join(directory, ".agents"), { recursive: true, mode: 448 });
18174
18233
  await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
18175
18234
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
18176
18235
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
@@ -18399,7 +18458,9 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18399
18458
  this.#server.close(() => resolve());
18400
18459
  this.#server.closeAllConnections();
18401
18460
  });
18402
- await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
18461
+ if (this.#options.directory === void 0) {
18462
+ await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
18463
+ }
18403
18464
  })();
18404
18465
  return this.#disposal;
18405
18466
  }
@@ -18893,12 +18954,195 @@ var AntigravitySubagents = class {
18893
18954
  }
18894
18955
  };
18895
18956
 
18957
+ // dist/usage-statistics.js
18958
+ import { lstat, opendir } from "node:fs/promises";
18959
+ import os5 from "node:os";
18960
+ import path10 from "node:path";
18961
+
18962
+ // ../../harness-adapter/dist/usage-statistics.js
18963
+ import { createReadStream } from "node:fs";
18964
+ import { createInterface } from "node:readline";
18965
+ var HarnessUsageSourceChangedError = class extends Error {
18966
+ code = "HARNESS_USAGE_SOURCE_CHANGED";
18967
+ /** Plugins may bundle their own copy of this contract, so instanceof is insufficient. */
18968
+ static is(error51) {
18969
+ return typeof error51 === "object" && error51 !== null && "code" in error51 && error51.code === "HARNESS_USAGE_SOURCE_CHANGED";
18970
+ }
18971
+ };
18972
+ var MAX_SESSION_ID_LENGTH = 512;
18973
+ var MAX_CWD_LENGTH = 4096;
18974
+ var MAX_SESSION_TITLE_LENGTH = 200;
18975
+ function usageSessionTitle(value) {
18976
+ if (typeof value !== "string")
18977
+ return void 0;
18978
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
18979
+ if (!normalized)
18980
+ return void 0;
18981
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
18982
+ return normalized;
18983
+ let title = "";
18984
+ for (const character of normalized) {
18985
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
18986
+ break;
18987
+ title += character;
18988
+ }
18989
+ return `${title.trimEnd()}…`;
18990
+ }
18991
+ function sessionIdOk(value) {
18992
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
18993
+ }
18994
+ function cwdOk(value) {
18995
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_CWD_LENGTH && !value.includes("\0") && (value.startsWith("/") || /^[A-Za-z]:[\\/]/u.test(value) || value.startsWith("\\\\"));
18996
+ }
18997
+ function withUsageSession(entry, session) {
18998
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
18999
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
19000
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
19001
+ if (sessionId === void 0 && cwd === void 0)
19002
+ return entry;
19003
+ return {
19004
+ ...entry,
19005
+ ...sessionId !== void 0 ? { sessionId } : {},
19006
+ ...cwd !== void 0 ? { cwd } : {},
19007
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
19008
+ };
19009
+ }
19010
+ async function* jsonlRecords(file2, marker, signal) {
19011
+ const lines = createInterface({
19012
+ input: createReadStream(file2, { encoding: "utf8", signal }),
19013
+ crlfDelay: Infinity
19014
+ });
19015
+ for await (const line of lines) {
19016
+ if (!line.includes(marker))
19017
+ continue;
19018
+ let value;
19019
+ try {
19020
+ value = JSON.parse(line);
19021
+ } catch {
19022
+ continue;
19023
+ }
19024
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
19025
+ yield value;
19026
+ }
19027
+ }
19028
+ }
19029
+ function nativeTimeMs(value) {
19030
+ const time3 = typeof value === "number" ? value : typeof value === "string" ? Date.parse(value) : Number.NaN;
19031
+ return Number.isFinite(time3) && time3 > 0 ? Math.floor(time3) : null;
19032
+ }
19033
+
19034
+ // dist/usage-statistics.js
19035
+ function count2(value) {
19036
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
19037
+ }
19038
+ function antigravityHome(environment) {
19039
+ return (process.platform === "win32" ? environment.USERPROFILE : environment.HOME) || os5.homedir();
19040
+ }
19041
+ function transcriptPath(brainRoot, conversationId) {
19042
+ return path10.join(brainRoot, conversationId, ".system_generated", "logs", "transcript.jsonl");
19043
+ }
19044
+ function isMissing(error51) {
19045
+ const code = error51?.code;
19046
+ return code === "ENOENT" || code === "ENOTDIR";
19047
+ }
19048
+ async function lstatIfPresent(target) {
19049
+ try {
19050
+ return await lstat(target);
19051
+ } catch (error51) {
19052
+ if (isMissing(error51))
19053
+ return null;
19054
+ throw error51;
19055
+ }
19056
+ }
19057
+ async function transcriptFingerprint(file2) {
19058
+ const logs = path10.dirname(file2);
19059
+ for (const directory of [path10.dirname(logs), logs]) {
19060
+ if (!(await lstatIfPresent(directory))?.isDirectory())
19061
+ return null;
19062
+ }
19063
+ const info = await lstatIfPresent(file2);
19064
+ return info?.isFile() && info.size > 0 ? `${info.ino}:${info.size}:${info.mtimeMs}` : null;
19065
+ }
19066
+ async function listTranscripts(brainRoot, signal) {
19067
+ signal.throwIfAborted();
19068
+ const conversations = await opendir(brainRoot).catch((error51) => {
19069
+ if (error51.code === "ENOENT")
19070
+ return null;
19071
+ throw error51;
19072
+ });
19073
+ if (!conversations)
19074
+ return [];
19075
+ const sources = [];
19076
+ for await (const entry of conversations) {
19077
+ signal.throwIfAborted();
19078
+ if (!entry.isDirectory())
19079
+ continue;
19080
+ const file2 = transcriptPath(brainRoot, entry.name);
19081
+ const fingerprint = await transcriptFingerprint(file2);
19082
+ if (fingerprint)
19083
+ sources.push({ id: file2, fingerprint });
19084
+ }
19085
+ return sources;
19086
+ }
19087
+ async function readAntigravityUsage(file2, signal) {
19088
+ const sessionId = path10.basename(path10.resolve(file2, "..", "..", ".."));
19089
+ const requests = /* @__PURE__ */ new Map();
19090
+ for await (const record2 of jsonlRecords(file2, '"input_tokens"', signal)) {
19091
+ if (record2.type !== "PLANNER_RESPONSE")
19092
+ continue;
19093
+ const step = count2(record2.step_index);
19094
+ const input = count2(record2.input_tokens);
19095
+ const output = count2(record2.output_tokens);
19096
+ const cached2 = count2(record2.cache_read_tokens);
19097
+ const at = nativeTimeMs(record2.created_at);
19098
+ if (step === null || input === null || output === null || at === null)
19099
+ continue;
19100
+ requests.set(step, withUsageSession({
19101
+ id: `${String(record2.created_at)}:${step}:${input}:${cached2 ?? "-"}:${output}`,
19102
+ occurredAtMs: at,
19103
+ inputTokens: input + (cached2 ?? 0),
19104
+ ...cached2 !== null ? { cachedInputTokens: cached2 } : {},
19105
+ outputTokens: output
19106
+ }, { sessionId }));
19107
+ }
19108
+ return [...requests.values()];
19109
+ }
19110
+ function createAntigravityUsageStatistics(environment) {
19111
+ const brainRoot = nativeBrainRoot(antigravityHome(environment));
19112
+ let listed = /* @__PURE__ */ new Map();
19113
+ return Object.freeze({
19114
+ async listSources(signal) {
19115
+ const sources = await listTranscripts(brainRoot, signal);
19116
+ listed = new Map(sources.map(({ id, fingerprint }) => [id, fingerprint]));
19117
+ return sources;
19118
+ },
19119
+ async readSource(id, signal) {
19120
+ const expected = listed.get(id);
19121
+ let entries;
19122
+ try {
19123
+ entries = await readAntigravityUsage(id, signal);
19124
+ } catch (error51) {
19125
+ if (expected !== void 0 && isMissing(error51)) {
19126
+ throw new HarnessUsageSourceChangedError("Antigravity transcript disappeared before reading; refresh to retry");
19127
+ }
19128
+ throw error51;
19129
+ }
19130
+ if (expected !== void 0 && await transcriptFingerprint(id) !== expected) {
19131
+ throw new HarnessUsageSourceChangedError("Antigravity transcript changed while reading; refresh to retry");
19132
+ }
19133
+ return entries;
19134
+ }
19135
+ });
19136
+ }
19137
+
18896
19138
  // dist/antigravity-adapter.js
18897
19139
  var antigravityHarnessId = harnessIdSchema.parse("antigravity");
18898
19140
  var DEFAULT_INSPECT_TIMEOUT_MS = 2e4;
18899
19141
  var DEFAULT_PRINT_TIMEOUT = "30m";
18900
19142
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
18901
19143
  var DEFAULT_SUBAGENT_OBSERVATION_TIMEOUT_MS = 3e4;
19144
+ var NATIVE_EXIT_GRACE_MS = 2e3;
19145
+ var DEFAULT_TURN_CLEANUP_WAIT_MS = 5e3;
18902
19146
  var CONTEXT_USAGE_TIMEOUT_MS = 8e3;
18903
19147
  var CONTEXT_USAGE_RETRY_MS = 100;
18904
19148
  var TRAJECTORY_TIMEOUT_MS = 2e3;
@@ -18927,8 +19171,8 @@ function mergePendingStep(pending, step) {
18927
19171
  };
18928
19172
  }
18929
19173
  function sameFile(left, right) {
18930
- const a = path10.resolve(left);
18931
- const b = path10.resolve(right);
19174
+ const a = path11.resolve(left);
19175
+ const b = path11.resolve(right);
18932
19176
  return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
18933
19177
  }
18934
19178
  function resolveAntigravityContextWindow(modelId, reportedWindow) {
@@ -18956,12 +19200,28 @@ function errorMessage(error51) {
18956
19200
  function invalidState(message) {
18957
19201
  return { code: "invalidState", message, retryable: false };
18958
19202
  }
19203
+ function settledWithin(promise2, timeoutMs) {
19204
+ return new Promise((resolve) => {
19205
+ const timer = setTimeout(resolve, timeoutMs);
19206
+ const settle = () => {
19207
+ clearTimeout(timer);
19208
+ resolve();
19209
+ };
19210
+ void promise2.then(settle, settle);
19211
+ });
19212
+ }
18959
19213
  var ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION = "[System Instruction: When creating new files in the workspace, you MUST use the write_to_file tool. When modifying existing files, use the replace_file_content tool. CRITICAL: NEVER include ArtifactMetadata when calling write_to_file for workspace files (ArtifactMetadata is strictly reserved for artifacts in the brain directory, and providing it for workspace files causes a path validation rejection). Do NOT use terminal commands (such as Set-Content, Out-File, echo, or cat) to create or write code files. For clarification, ask_question is connected to the codexhost Desktop through a Hook. Use single-choice or text questions. The Hook returns the actual user response in its reason while blocking the native auto-skip behavior; do not retry merely because the native tool reports it was blocked.]\n\n";
18960
- function formatAntigravityTurnPrompt(text) {
19214
+ function antigravityWorkingDirectoryInstruction(cwd) {
19215
+ return `[System Instruction: The project working directory is ${JSON.stringify(cwd)}. Run terminal commands and resolve relative file paths in this directory unless the task requires another one.]
19216
+
19217
+ `;
19218
+ }
19219
+ function formatAntigravityTurnPrompt(text, cwd) {
18961
19220
  if (text.startsWith("/") || text.includes("ArtifactMetadata")) {
18962
19221
  return text;
18963
19222
  }
18964
- return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${text}`;
19223
+ const workingDirectory = cwd ? antigravityWorkingDirectoryInstruction(cwd) : "";
19224
+ return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${workingDirectory}${text}`;
18965
19225
  }
18966
19226
  function permissionDeniedTurnError(nativeMode, denial) {
18967
19227
  const mode = nativeMode ? ` '${nativeMode}'` : "";
@@ -19063,14 +19323,15 @@ async function pollAntigravityContextUsage(logPath, conversationId, modelId, isD
19063
19323
  }
19064
19324
  return null;
19065
19325
  }
19066
- function hostUsage(value, modelId) {
19326
+ function hostUsage(value, modelId, scope) {
19067
19327
  if (!value)
19068
19328
  return null;
19069
19329
  const inputTokens = safeToken(value.input_tokens);
19070
19330
  const outputTokens = safeToken(value.output_tokens);
19071
19331
  const reasoningOutputTokens = safeToken(value.thinking_tokens);
19072
19332
  const totalTokens = safeToken(value.total_tokens);
19073
- const contextUsedTokens = safeToken(value.context_used_tokens ?? value.estimated_tokens_used ?? value.input_tokens);
19333
+ const requestPromptTokens = scope === "request" && inputTokens !== void 0 ? inputTokens + (safeToken(value.cache_read_tokens) ?? 0) : void 0;
19334
+ const contextUsedTokens = safeToken(value.context_used_tokens ?? value.estimated_tokens_used) ?? requestPromptTokens;
19074
19335
  const rawWindow = safeToken(value.context_window_tokens ?? value.max_context_tokens);
19075
19336
  const contextWindowTokens = contextUsedTokens !== void 0 || rawWindow !== void 0 ? resolveAntigravityContextWindow(modelId, rawWindow) : void 0;
19076
19337
  const usage = {
@@ -19147,6 +19408,7 @@ var AntigravitySession = class {
19147
19408
  #printTimeout;
19148
19409
  #toolOutputLimit;
19149
19410
  #subagentObservationTimeoutMs;
19411
+ #turnCleanupWaitMs;
19150
19412
  #history;
19151
19413
  #subagentObservers = /* @__PURE__ */ new Set();
19152
19414
  #active = null;
@@ -19173,6 +19435,7 @@ var AntigravitySession = class {
19173
19435
  this.#thinkingOptionId = input.thinkingOptionId ?? input.history.thinkingOptionId;
19174
19436
  this.#toolOutputLimit = input.toolOutputLimit;
19175
19437
  this.#subagentObservationTimeoutMs = input.subagentObservationTimeoutMs;
19438
+ this.#turnCleanupWaitMs = input.turnCleanupWaitMs;
19176
19439
  this.#onClosed = input.onClosed;
19177
19440
  this.initialState = this.#state();
19178
19441
  this.outputs = this.#channel.outputs;
@@ -19250,7 +19513,10 @@ var AntigravitySession = class {
19250
19513
  };
19251
19514
  }
19252
19515
  let questions;
19253
- this.#preparingQuestions = AntigravityQuestionBridge.create({
19516
+ const hookDirectory = antigravityHookDirectory(this.#environment);
19517
+ const previousTurn = hookDirectory ? this.#questionCleanup : Promise.resolve();
19518
+ this.#preparingQuestions = previousTurn.then(() => AntigravityQuestionBridge.create({
19519
+ ...hookDirectory ? { directory: hookDirectory } : {},
19254
19520
  turnId: command.turnId,
19255
19521
  nativeSessionId: () => this.#active?.command === command && !this.#active.cancellationRequested ? this.#nativeRef?.nativeSessionId : void 0,
19256
19522
  schedule: (action) => {
@@ -19273,7 +19539,7 @@ var AntigravitySession = class {
19273
19539
  }
19274
19540
  this.#channel.emit(output);
19275
19541
  }
19276
- });
19542
+ }));
19277
19543
  try {
19278
19544
  questions = await this.#preparingQuestions;
19279
19545
  } catch (error51) {
@@ -19293,7 +19559,7 @@ var AntigravitySession = class {
19293
19559
  return { ok: false, error: invalidState("Antigravity Session is closed") };
19294
19560
  }
19295
19561
  const environment = { ...this.#environment, ...questions.environment };
19296
- const logPath = path10.join(os5.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
19562
+ const logPath = path11.join(os6.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
19297
19563
  const arguments_ = [
19298
19564
  "--input-format",
19299
19565
  "stream-json",
@@ -19414,7 +19680,7 @@ ${line}`).slice(-8e3);
19414
19680
  });
19415
19681
  });
19416
19682
  try {
19417
- const turnPrompt = formatAntigravityTurnPrompt(text);
19683
+ const turnPrompt = formatAntigravityTurnPrompt(text, this.#cwd);
19418
19684
  if (child.stdin.writable) {
19419
19685
  child.stdin.write(`${JSON.stringify({ event: "user", message: { content: turnPrompt } })}
19420
19686
  `, () => void 0);
@@ -19498,7 +19764,7 @@ ${line}`).slice(-8e3);
19498
19764
  if (event.step_update.conversation_id !== this.#nativeRef?.nativeSessionId)
19499
19765
  return;
19500
19766
  await this.#handleStep(active, event.step_update);
19501
- const usage = hostUsage(event.step_update.usage, active.model?.id);
19767
+ const usage = hostUsage(event.step_update.usage, active.model?.id, "request");
19502
19768
  if (usage)
19503
19769
  this.#publishUsage(active, usage);
19504
19770
  this.#ensureContextUsage(active, event.step_update.conversation_id);
@@ -19524,7 +19790,7 @@ ${line}`).slice(-8e3);
19524
19790
  });
19525
19791
  return;
19526
19792
  }
19527
- const usage = hostUsage(event.result.usage, active.model?.id);
19793
+ const usage = hostUsage(event.result.usage, active.model?.id, "conversation");
19528
19794
  if (usage)
19529
19795
  this.#publishUsage(active, usage);
19530
19796
  this.#ensureContextUsage(active, event.result.conversation_id);
@@ -19761,8 +20027,9 @@ ${line}`).slice(-8e3);
19761
20027
  await active.subagents.settled;
19762
20028
  if (active.process.stdin.writable)
19763
20029
  active.process.stdin.end();
19764
- const timer = setTimeout(() => active.process.kill(), 2e3);
19765
- await active.exited.finally(() => clearTimeout(timer));
20030
+ const timer = setTimeout(() => active.process.kill(), NATIVE_EXIT_GRACE_MS);
20031
+ await settledWithin(active.exited, NATIVE_EXIT_GRACE_MS + this.#turnCleanupWaitMs);
20032
+ clearTimeout(timer);
19766
20033
  await active.questions.dispose();
19767
20034
  this.#subagentObservers.delete(active.subagents);
19768
20035
  }).catch(() => void 0);
@@ -19939,6 +20206,7 @@ function historySubagentState(history, id) {
19939
20206
  var AntigravityAdapter = class {
19940
20207
  commandCatalog = ANTIGRAVITY_COMMAND_CATALOG;
19941
20208
  harnessId = antigravityHarnessId;
20209
+ usageStatistics;
19942
20210
  subagents = {
19943
20211
  readSnapshot: async (input) => {
19944
20212
  if (this.#closed || input.parent.harnessId !== this.harnessId || !nativeSubagentIdSchema.safeParse(input.nativeSubagentId).success) {
@@ -19971,6 +20239,7 @@ var AntigravityAdapter = class {
19971
20239
  #sessions = /* @__PURE__ */ new Set();
19972
20240
  #toolOutputLimit;
19973
20241
  #subagentObservationTimeoutMs;
20242
+ #turnCleanupWaitMs;
19974
20243
  #closed = false;
19975
20244
  #quota = null;
19976
20245
  #quotaCwd = null;
@@ -19979,6 +20248,7 @@ var AntigravityAdapter = class {
19979
20248
  constructor(options = {}) {
19980
20249
  this.#command = options.command;
19981
20250
  this.#environment = options.environment ?? process.env;
20251
+ this.usageStatistics = createAntigravityUsageStatistics(this.#environment);
19982
20252
  this.#inspectTimeoutMs = options.inspectTimeoutMs ?? DEFAULT_INSPECT_TIMEOUT_MS;
19983
20253
  this.#printTimeout = options.printTimeout ?? DEFAULT_PRINT_TIMEOUT;
19984
20254
  this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_TOOL_OUTPUT_LIMIT;
@@ -19987,12 +20257,17 @@ var AntigravityAdapter = class {
19987
20257
  throw new RangeError("subagentObservationTimeoutMs must be a finite positive number");
19988
20258
  }
19989
20259
  this.#subagentObservationTimeoutMs = subagentObservationTimeoutMs;
20260
+ const turnCleanupWaitMs = options.turnCleanupWaitMs ?? DEFAULT_TURN_CLEANUP_WAIT_MS;
20261
+ if (!Number.isFinite(turnCleanupWaitMs) || turnCleanupWaitMs < 0) {
20262
+ throw new RangeError("turnCleanupWaitMs must be a finite non-negative number");
20263
+ }
20264
+ this.#turnCleanupWaitMs = turnCleanupWaitMs;
19990
20265
  }
19991
20266
  async inspect(input = {}) {
19992
20267
  if (this.#closed) {
19993
20268
  return { status: "unavailable", error: invalidState("Antigravity Adapter is closed") };
19994
20269
  }
19995
- const cwd = path10.resolve(input.cwd ?? process.cwd());
20270
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
19996
20271
  const inFlight = this.#inspectionInFlight.get(cwd);
19997
20272
  if (inFlight)
19998
20273
  return inFlight;
@@ -20135,7 +20410,7 @@ var AntigravityAdapter = class {
20135
20410
  }
20136
20411
  };
20137
20412
  }
20138
- const cwd = path10.resolve(input.cwd);
20413
+ const cwd = path11.resolve(input.cwd);
20139
20414
  let catalog = this.#inspectionCache.get(cwd)?.catalog;
20140
20415
  if (!catalog) {
20141
20416
  const inspection = await this.inspect({ cwd: input.cwd });
@@ -20171,6 +20446,7 @@ var AntigravityAdapter = class {
20171
20446
  ...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
20172
20447
  toolOutputLimit: this.#toolOutputLimit,
20173
20448
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20449
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20174
20450
  onClosed: () => this.#sessions.delete(session2)
20175
20451
  });
20176
20452
  this.#sessions.add(session2);
@@ -20207,6 +20483,7 @@ var AntigravityAdapter = class {
20207
20483
  ...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
20208
20484
  toolOutputLimit: this.#toolOutputLimit,
20209
20485
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20486
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20210
20487
  onClosed: () => this.#sessions.delete(session2)
20211
20488
  });
20212
20489
  this.#sessions.add(session2);
@@ -20264,6 +20541,7 @@ var AntigravityAdapter = class {
20264
20541
  ...thinkingOptionId ? { thinkingOptionId } : {},
20265
20542
  toolOutputLimit: this.#toolOutputLimit,
20266
20543
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20544
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20267
20545
  onClosed: () => this.#sessions.delete(session)
20268
20546
  });
20269
20547
  this.#sessions.add(session);
@@ -20323,11 +20601,23 @@ function createAntigravityInstallation(environment, command, dependencies = {})
20323
20601
 
20324
20602
  // dist/plugin.js
20325
20603
  var ANTIGRAVITY_COMMAND_ENV = "CODEXHOST_ANTIGRAVITY_COMMAND";
20604
+ var ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV = "AGY_CLI_DISABLE_AUTO_UPDATE";
20605
+ function antigravityProcessEnvironment(environment, platform) {
20606
+ if (platform !== "win32" && platform !== "darwin")
20607
+ return environment;
20608
+ const isWindows = platform === "win32";
20609
+ const matchesSwitch = (name) => isWindows ? name.toUpperCase() === ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV : name === ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV;
20610
+ const entries = Object.entries(environment);
20611
+ const configured = entries.some(([name, value]) => matchesSwitch(name) && value !== void 0);
20612
+ const hasUndefinedSwitch = entries.some(([name, value]) => matchesSwitch(name) && value === void 0);
20613
+ const cleanEnvironment = hasUndefinedSwitch ? Object.fromEntries(entries.filter(([name, value]) => !matchesSwitch(name) || value !== void 0)) : environment;
20614
+ return configured ? cleanEnvironment : { ...cleanEnvironment, [ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV]: "true" };
20615
+ }
20326
20616
  function createHarnessAdapter(context) {
20327
20617
  const environment = { ...context.environment };
20328
20618
  return Object.assign(new AntigravityAdapter({
20329
20619
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
20330
- environment
20620
+ environment: antigravityProcessEnvironment(environment, context.platform)
20331
20621
  }), {
20332
20622
  install: createHarnessInstaller(environment, {
20333
20623
  posix: "https://antigravity.google/cli/install.sh",
@@ -20344,6 +20634,8 @@ async function warmup(adapter) {
20344
20634
  }
20345
20635
  export {
20346
20636
  ANTIGRAVITY_COMMAND_ENV,
20637
+ ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV,
20638
+ antigravityProcessEnvironment,
20347
20639
  createHarnessAdapter,
20348
20640
  warmup
20349
20641
  };