@liberseek/boft-cli-linux-x64 0.8.3 → 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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +117 -13
  4. package/app/console-web.js +713 -129
  5. package/app/desktop-controller.mjs +713 -42
  6. package/app/host-runtime.mjs +2535 -855
  7. package/app/plugins/antigravity/plugin.mjs +437 -67
  8. package/app/plugins/claude-code/plugin.mjs +758 -248
  9. package/app/plugins/codebuddy/plugin.mjs +348 -156
  10. package/app/plugins/codex-usage/plugin.mjs +258 -106
  11. package/app/plugins/copilot/assets/icon.png +0 -0
  12. package/app/plugins/copilot/manifest.json +26 -0
  13. package/app/plugins/copilot/plugin.mjs +34651 -0
  14. package/app/plugins/cursor-cli/plugin.mjs +20905 -44961
  15. package/app/plugins/deepseek-harness/plugin.mjs +195 -53
  16. package/app/plugins/enabled.json +1 -0
  17. package/app/plugins/grok/plugin.mjs +584 -138
  18. package/app/plugins/hermes/plugin.mjs +134 -13
  19. package/app/plugins/kimi-code/plugin.mjs +145 -26
  20. package/app/plugins/kiro-cli/plugin.mjs +145 -26
  21. package/app/plugins/muse/plugin.mjs +132 -14
  22. package/app/plugins/omp/plugin.mjs +2245 -2040
  23. package/app/plugins/opencode/plugin.mjs +196 -72
  24. package/app/plugins/pi/plugin.mjs +2643 -2309
  25. package/app/plugins/qoder/plugin.mjs +162 -40
  26. package/app/plugins/qoder-cn/plugin.mjs +162 -40
  27. package/app/plugins/workbuddy/plugin.mjs +609 -180
  28. package/app/plugins/zcode/plugin.mjs +192 -44
  29. package/app/renderer-extension.js +3405 -429
  30. package/bin/boft +0 -0
  31. package/libexec/boft-shim +0 -0
  32. package/libexec/boft-updater +0 -0
  33. package/package.json +1 -1
@@ -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
  }
@@ -15068,10 +15068,19 @@ var model = external_exports.string().min(1).max(512);
15068
15068
  var project = external_exports.string().min(1).max(4096);
15069
15069
  var usageStatisticsParamsSchema = external_exports.strictObject({
15070
15070
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15071
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
15072
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
15073
+ try {
15074
+ new Intl.DateTimeFormat("en", { timeZone: value });
15075
+ return true;
15076
+ } catch {
15077
+ return false;
15078
+ }
15079
+ }, "Unsupported usage statistics timezone").optional(),
15071
15080
  harness: harness.optional(),
15072
15081
  model: model.nullable().optional(),
15073
15082
  project: project.nullable().optional(),
15074
- /** One local date inside the range. */
15083
+ /** One date in the query timezone inside the range. */
15075
15084
  date: localDate.optional()
15076
15085
  });
15077
15086
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -15080,6 +15089,8 @@ var usageStatisticsTotalsSchema = external_exports.strictObject({
15080
15089
  cachedInputTokens: count,
15081
15090
  cacheWriteInputTokens: count,
15082
15091
  cacheKnownInputTokens: count,
15092
+ cacheHitCachedInputTokens: count,
15093
+ cacheHitInputTokens: count,
15083
15094
  outputTokens: count,
15084
15095
  reasoningOutputTokens: count,
15085
15096
  /** USD at the public price, summed over the priced requests only. */
@@ -15107,7 +15118,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15107
15118
  });
15108
15119
  var usageStatisticsResultSchema = external_exports.strictObject({
15109
15120
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15110
- /** First local date of the range; null for all time. */
15121
+ /** First date in the query timezone (Host local when omitted); null for all time. */
15111
15122
  from: localDate.nullable(),
15112
15123
  to: localDate,
15113
15124
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -15147,7 +15158,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15147
15158
  totals: usageStatisticsTotalsSchema,
15148
15159
  /** Each date and Harness of the range: every filter except the day. */
15149
15160
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
15150
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
15161
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
15151
15162
  hourly: external_exports.array(external_exports.strictObject({
15152
15163
  weekday: external_exports.number().int().min(0).max(6),
15153
15164
  hour: external_exports.number().int().min(0).max(23),
@@ -15187,6 +15198,51 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
15187
15198
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15188
15199
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15189
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
+
15190
15246
  // ../../shared-contracts/dist/harness-plugins.js
15191
15247
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15192
15248
  var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
@@ -15289,6 +15345,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15289
15345
  "codexhost/harness/display-settings/set",
15290
15346
  "codexhost/harness/inspect",
15291
15347
  "codexhost/harness/installation",
15348
+ "codexhost/harness/installation/start",
15349
+ "codexhost/harness/installation/status",
15292
15350
  "codexhost/harness/launch-settings/get",
15293
15351
  "codexhost/harness/launch-settings/set",
15294
15352
  HARNESS_LONG_CONTEXT_GET_METHOD,
@@ -15366,7 +15424,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
15366
15424
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15367
15425
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15368
15426
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15427
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
15428
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15429
+ kind: external_exports.literal("countdown"),
15430
+ id: external_exports.string().min(1).max(64),
15431
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
15432
+ label: indicatorTextSchema(256).optional(),
15433
+ tooltip: indicatorTextSchema(1024).optional()
15434
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15435
+ message: "Composer indicator IDs must be unique"
15436
+ });
15369
15437
  var threadUsageSnapshotSchema = external_exports.object({
15438
+ composerIndicators: composerIndicatorsSchema.optional(),
15370
15439
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
15371
15440
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
15372
15441
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15792,7 +15861,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15792
15861
  }).strict().optional(),
15793
15862
  input: external_exports.object({
15794
15863
  image: external_exports.boolean()
15795
- }).strict().optional()
15864
+ }).strict().optional(),
15865
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15866
+ steer: external_exports.boolean().optional()
15796
15867
  }).strict();
15797
15868
  var harnessConfigurationStateSchema = external_exports.object({
15798
15869
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15839,7 +15910,9 @@ var harnessInspectionSchema = external_exports.union([
15839
15910
  var harnessInspectParamsSchema = external_exports.object({
15840
15911
  harnessId: harnessIdSchema,
15841
15912
  cwd: nonBlankTextSchema2.max(16384).optional(),
15842
- refresh: external_exports.boolean().optional()
15913
+ refresh: external_exports.boolean().optional(),
15914
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15915
+ purpose: external_exports.literal("availability").optional()
15843
15916
  }).strict();
15844
15917
  var harnessWebUiOpenParamsSchema = external_exports.object({
15845
15918
  harnessId: harnessIdSchema
@@ -15924,13 +15997,25 @@ var threadOwnershipListResultSchema = external_exports.object({
15924
15997
  seen.add(thread.threadId);
15925
15998
  }
15926
15999
  });
16000
+ var threadSteeringInspectParamsSchema = external_exports.object({
16001
+ threadId: hostThreadIdSchema,
16002
+ /** The text about to be steered; a Harness command always stops and restarts. */
16003
+ text: external_exports.string().optional()
16004
+ }).strict();
16005
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
16006
+ var threadSteeringInspectResultSchema = external_exports.object({
16007
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
16008
+ }).strict();
15927
16009
 
15928
16010
  // ../../shared-contracts/dist/harness-route.js
15929
16011
  var harnessPluginRouteSchema = external_exports.object({
15930
16012
  harnessId: harnessPluginIdSchema,
15931
16013
  model: harnessModelRefSchema.optional(),
15932
16014
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15933
- 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()
15934
16019
  }).strict();
15935
16020
 
15936
16021
  // ../../shared-contracts/dist/harness-launch-settings.js
@@ -15956,6 +16041,10 @@ var harnessInstallationStateSchema = external_exports.object({
15956
16041
  latestVersion: external_exports.string().min(1).max(128),
15957
16042
  updateAvailable: external_exports.boolean(),
15958
16043
  canUpdate: external_exports.boolean(),
16044
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
16045
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
16046
+ /** Official download opened by the user; does not imply an automatic installation. */
16047
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
15959
16048
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15960
16049
  message: external_exports.string().max(2048).optional(),
15961
16050
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -15963,6 +16052,20 @@ var harnessInstallationStateSchema = external_exports.object({
15963
16052
  notice: harnessLocalizedTextSchema.optional(),
15964
16053
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15965
16054
  }).strict();
16055
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
16056
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
16057
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
16058
+ external_exports.object({
16059
+ taskId: external_exports.string().uuid(),
16060
+ status: external_exports.literal("succeeded"),
16061
+ result: harnessInstallationStateSchema
16062
+ }).strict(),
16063
+ external_exports.object({
16064
+ taskId: external_exports.string().uuid(),
16065
+ status: external_exports.literal("failed"),
16066
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
16067
+ }).strict()
16068
+ ]);
15966
16069
 
15967
16070
  // ../../shared-contracts/dist/codex-accounts.js
15968
16071
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -16452,6 +16555,18 @@ function sanitizeDiagnosticTail(value) {
16452
16555
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16453
16556
  }
16454
16557
 
16558
+ // ../../harness-adapter/dist/steer.js
16559
+ function unsupportedSteer(harnessLabel) {
16560
+ return {
16561
+ ok: false,
16562
+ error: {
16563
+ code: "unsupported",
16564
+ message: `${harnessLabel} cannot steer an active Turn natively`,
16565
+ retryable: false
16566
+ }
16567
+ };
16568
+ }
16569
+
16455
16570
  // ../../harness-adapter/dist/usage.js
16456
16571
  var tokenFields = [
16457
16572
  "inputTokens",
@@ -16479,6 +16594,7 @@ var usageFields = /* @__PURE__ */ new Set([
16479
16594
  ...safeIntegerFields,
16480
16595
  ...percentFields,
16481
16596
  "sessionCacheUsage",
16597
+ "composerIndicators",
16482
16598
  "totalCostUsd",
16483
16599
  "totalCredits",
16484
16600
  "contextUsagePercent",
@@ -16646,6 +16762,12 @@ function historyPath(environment) {
16646
16762
  const threadId = safeThreadId(environment);
16647
16763
  return threadId ? path5.join(historyRoot(environment), `${threadId}.json`) : null;
16648
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
+ }
16649
16771
  function jsonTurn(turn) {
16650
16772
  return JSON.parse(JSON.stringify(turn));
16651
16773
  }
@@ -16834,8 +16956,11 @@ var AntigravityHistory = class _AntigravityHistory {
16834
16956
  function nativeConversationDbPath(nativeSessionId, homedir2 = os3.homedir()) {
16835
16957
  return path6.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
16836
16958
  }
16959
+ function nativeBrainRoot(homedir2 = os3.homedir()) {
16960
+ return path6.join(homedir2, ".gemini", "antigravity-cli", "brain");
16961
+ }
16837
16962
  function nativeBrainDirPath(nativeSessionId, homedir2 = os3.homedir()) {
16838
- return path6.join(homedir2, ".gemini", "antigravity-cli", "brain", nativeSessionId);
16963
+ return path6.join(nativeBrainRoot(homedir2), nativeSessionId);
16839
16964
  }
16840
16965
  async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, retainedTurnsCountOrHomedir, homedirOption = os3.homedir()) {
16841
16966
  let retainedTurnsCount;
@@ -18088,7 +18213,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18088
18213
  this.#server.on("request", (request, response) => this.#receive(request, response));
18089
18214
  }
18090
18215
  static async create(options) {
18091
- 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-"));
18092
18217
  const bridge = new _AntigravityQuestionBridge(directory, options);
18093
18218
  try {
18094
18219
  await new Promise((resolve, reject) => {
@@ -18104,7 +18229,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18104
18229
  throw new Error("Question bridge did not bind");
18105
18230
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
18106
18231
  const client = path8.join(directory, "question-hook.cjs");
18107
- await mkdir3(path8.join(directory, ".agents"));
18232
+ await mkdir3(path8.join(directory, ".agents"), { recursive: true, mode: 448 });
18108
18233
  await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
18109
18234
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
18110
18235
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
@@ -18333,7 +18458,9 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
18333
18458
  this.#server.close(() => resolve());
18334
18459
  this.#server.closeAllConnections();
18335
18460
  });
18336
- 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
+ }
18337
18464
  })();
18338
18465
  return this.#disposal;
18339
18466
  }
@@ -18827,12 +18954,195 @@ var AntigravitySubagents = class {
18827
18954
  }
18828
18955
  };
18829
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
+
18830
19138
  // dist/antigravity-adapter.js
18831
19139
  var antigravityHarnessId = harnessIdSchema.parse("antigravity");
18832
19140
  var DEFAULT_INSPECT_TIMEOUT_MS = 2e4;
18833
19141
  var DEFAULT_PRINT_TIMEOUT = "30m";
18834
19142
  var DEFAULT_TOOL_OUTPUT_LIMIT = 64e3;
18835
19143
  var DEFAULT_SUBAGENT_OBSERVATION_TIMEOUT_MS = 3e4;
19144
+ var NATIVE_EXIT_GRACE_MS = 2e3;
19145
+ var DEFAULT_TURN_CLEANUP_WAIT_MS = 5e3;
18836
19146
  var CONTEXT_USAGE_TIMEOUT_MS = 8e3;
18837
19147
  var CONTEXT_USAGE_RETRY_MS = 100;
18838
19148
  var TRAJECTORY_TIMEOUT_MS = 2e3;
@@ -18861,8 +19171,8 @@ function mergePendingStep(pending, step) {
18861
19171
  };
18862
19172
  }
18863
19173
  function sameFile(left, right) {
18864
- const a = path10.resolve(left);
18865
- const b = path10.resolve(right);
19174
+ const a = path11.resolve(left);
19175
+ const b = path11.resolve(right);
18866
19176
  return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
18867
19177
  }
18868
19178
  function resolveAntigravityContextWindow(modelId, reportedWindow) {
@@ -18890,12 +19200,28 @@ function errorMessage(error51) {
18890
19200
  function invalidState(message) {
18891
19201
  return { code: "invalidState", message, retryable: false };
18892
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
+ }
18893
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";
18894
- 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) {
18895
19220
  if (text.startsWith("/") || text.includes("ArtifactMetadata")) {
18896
19221
  return text;
18897
19222
  }
18898
- return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${text}`;
19223
+ const workingDirectory = cwd ? antigravityWorkingDirectoryInstruction(cwd) : "";
19224
+ return `${ANTIGRAVITY_WORKSPACE_FILE_INSTRUCTION}${workingDirectory}${text}`;
18899
19225
  }
18900
19226
  function permissionDeniedTurnError(nativeMode, denial) {
18901
19227
  const mode = nativeMode ? ` '${nativeMode}'` : "";
@@ -18997,14 +19323,15 @@ async function pollAntigravityContextUsage(logPath, conversationId, modelId, isD
18997
19323
  }
18998
19324
  return null;
18999
19325
  }
19000
- function hostUsage(value, modelId) {
19326
+ function hostUsage(value, modelId, scope) {
19001
19327
  if (!value)
19002
19328
  return null;
19003
19329
  const inputTokens = safeToken(value.input_tokens);
19004
19330
  const outputTokens = safeToken(value.output_tokens);
19005
19331
  const reasoningOutputTokens = safeToken(value.thinking_tokens);
19006
19332
  const totalTokens = safeToken(value.total_tokens);
19007
- 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;
19008
19335
  const rawWindow = safeToken(value.context_window_tokens ?? value.max_context_tokens);
19009
19336
  const contextWindowTokens = contextUsedTokens !== void 0 || rawWindow !== void 0 ? resolveAntigravityContextWindow(modelId, rawWindow) : void 0;
19010
19337
  const usage = {
@@ -19081,6 +19408,7 @@ var AntigravitySession = class {
19081
19408
  #printTimeout;
19082
19409
  #toolOutputLimit;
19083
19410
  #subagentObservationTimeoutMs;
19411
+ #turnCleanupWaitMs;
19084
19412
  #history;
19085
19413
  #subagentObservers = /* @__PURE__ */ new Set();
19086
19414
  #active = null;
@@ -19089,6 +19417,8 @@ var AntigravitySession = class {
19089
19417
  #closed = false;
19090
19418
  #model;
19091
19419
  #nativeRef;
19420
+ /** The last result's `response`: agy carries earlier Turns' replies in it. */
19421
+ #lastResultResponse = "";
19092
19422
  #permissionMode;
19093
19423
  #thinkingOptionId;
19094
19424
  #catalog;
@@ -19105,6 +19435,7 @@ var AntigravitySession = class {
19105
19435
  this.#thinkingOptionId = input.thinkingOptionId ?? input.history.thinkingOptionId;
19106
19436
  this.#toolOutputLimit = input.toolOutputLimit;
19107
19437
  this.#subagentObservationTimeoutMs = input.subagentObservationTimeoutMs;
19438
+ this.#turnCleanupWaitMs = input.turnCleanupWaitMs;
19108
19439
  this.#onClosed = input.onClosed;
19109
19440
  this.initialState = this.#state();
19110
19441
  this.outputs = this.#channel.outputs;
@@ -19150,6 +19481,8 @@ var AntigravitySession = class {
19150
19481
  return { ok: false, error: invalidState("Antigravity Session is closed") };
19151
19482
  if (command.type === "turn.cancel")
19152
19483
  return this.#cancel(command);
19484
+ if (command.type === "turn.steer")
19485
+ return unsupportedSteer("Antigravity");
19153
19486
  if (command.type === "model.select")
19154
19487
  return this.#selectModel(command);
19155
19488
  if (command.type === "permissionMode.select")
@@ -19180,7 +19513,10 @@ var AntigravitySession = class {
19180
19513
  };
19181
19514
  }
19182
19515
  let questions;
19183
- 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 } : {},
19184
19520
  turnId: command.turnId,
19185
19521
  nativeSessionId: () => this.#active?.command === command && !this.#active.cancellationRequested ? this.#nativeRef?.nativeSessionId : void 0,
19186
19522
  schedule: (action) => {
@@ -19203,7 +19539,7 @@ var AntigravitySession = class {
19203
19539
  }
19204
19540
  this.#channel.emit(output);
19205
19541
  }
19206
- });
19542
+ }));
19207
19543
  try {
19208
19544
  questions = await this.#preparingQuestions;
19209
19545
  } catch (error51) {
@@ -19223,7 +19559,7 @@ var AntigravitySession = class {
19223
19559
  return { ok: false, error: invalidState("Antigravity Session is closed") };
19224
19560
  }
19225
19561
  const environment = { ...this.#environment, ...questions.environment };
19226
- const logPath = path10.join(os5.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
19562
+ const logPath = path11.join(os6.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
19227
19563
  const arguments_ = [
19228
19564
  "--input-format",
19229
19565
  "stream-json",
@@ -19344,7 +19680,7 @@ ${line}`).slice(-8e3);
19344
19680
  });
19345
19681
  });
19346
19682
  try {
19347
- const turnPrompt = formatAntigravityTurnPrompt(text);
19683
+ const turnPrompt = formatAntigravityTurnPrompt(text, this.#cwd);
19348
19684
  if (child.stdin.writable) {
19349
19685
  child.stdin.write(`${JSON.stringify({ event: "user", message: { content: turnPrompt } })}
19350
19686
  `, () => void 0);
@@ -19428,7 +19764,7 @@ ${line}`).slice(-8e3);
19428
19764
  if (event.step_update.conversation_id !== this.#nativeRef?.nativeSessionId)
19429
19765
  return;
19430
19766
  await this.#handleStep(active, event.step_update);
19431
- const usage = hostUsage(event.step_update.usage, active.model?.id);
19767
+ const usage = hostUsage(event.step_update.usage, active.model?.id, "request");
19432
19768
  if (usage)
19433
19769
  this.#publishUsage(active, usage);
19434
19770
  this.#ensureContextUsage(active, event.step_update.conversation_id);
@@ -19454,7 +19790,7 @@ ${line}`).slice(-8e3);
19454
19790
  });
19455
19791
  return;
19456
19792
  }
19457
- const usage = hostUsage(event.result.usage, active.model?.id);
19793
+ const usage = hostUsage(event.result.usage, active.model?.id, "conversation");
19458
19794
  if (usage)
19459
19795
  this.#publishUsage(active, usage);
19460
19796
  this.#ensureContextUsage(active, event.result.conversation_id);
@@ -19476,9 +19812,13 @@ ${line}`).slice(-8e3);
19476
19812
  this.#history.bindNativeSession(convId);
19477
19813
  this.#event({ type: "session.state.changed", state: this.#state() });
19478
19814
  }
19479
- if (event.result.response) {
19480
- this.#appendOrSyncAgentText(active, event.result.response, false);
19481
- }
19815
+ const response = event.result.response ?? "";
19816
+ const turnReply = response.startsWith(this.#lastResultResponse) ? response.slice(this.#lastResultResponse.length) : response;
19817
+ const repliedThisTurn = Boolean(active.agentItem) || turnReply.trim() !== "";
19818
+ if (response)
19819
+ this.#lastResultResponse = response;
19820
+ if (turnReply.trim() !== "")
19821
+ this.#appendOrSyncAgentText(active, turnReply, false);
19482
19822
  const safeTurnId = event.result.num_turns !== void 0 && event.result.num_turns !== null ? `turn:${event.result.num_turns}` : `turn:${this.#history.snapshot().length + 1}`;
19483
19823
  const safeSessionId = convId || this.#nativeRef?.nativeSessionId || "unknown-session";
19484
19824
  const nativeTurnRef = nativeTurnRefSchema.parse({
@@ -19508,13 +19848,17 @@ ${line}`).slice(-8e3);
19508
19848
  } else {
19509
19849
  const nativeError = event.result.error?.trim();
19510
19850
  const errorDetail = nativeError || active.stderr;
19511
- this.#completeTurn(active, {
19512
- status: "failed",
19513
- error: normalizedProcessError(errorDetail, `Antigravity Turn ended with status ${event.result.status}`, nativeError !== void 0),
19514
- checkpoint
19515
- }, nativeTurnRef);
19851
+ const error51 = normalizedProcessError(errorDetail, `Antigravity Turn ended with status ${event.result.status}`, nativeError !== void 0);
19852
+ if (repliedThisTurn && nativeError && this.#reportedEarlier(error51)) {
19853
+ this.#completeTurn(active, { status: "succeeded", checkpoint }, nativeTurnRef);
19854
+ } else {
19855
+ this.#completeTurn(active, { status: "failed", error: error51, checkpoint }, nativeTurnRef);
19856
+ }
19516
19857
  }
19517
19858
  }
19859
+ #reportedEarlier(error51) {
19860
+ return this.#history.snapshot().some(({ outcome }) => outcome.status === "failed" && outcome.error.code === error51.code && outcome.error.message === error51.message);
19861
+ }
19518
19862
  #publishUsage(active, usage) {
19519
19863
  active.latestUsage = { ...active.latestUsage ?? {}, ...usage };
19520
19864
  this.#event({
@@ -19683,8 +20027,9 @@ ${line}`).slice(-8e3);
19683
20027
  await active.subagents.settled;
19684
20028
  if (active.process.stdin.writable)
19685
20029
  active.process.stdin.end();
19686
- const timer = setTimeout(() => active.process.kill(), 2e3);
19687
- 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);
19688
20033
  await active.questions.dispose();
19689
20034
  this.#subagentObservers.delete(active.subagents);
19690
20035
  }).catch(() => void 0);
@@ -19861,6 +20206,7 @@ function historySubagentState(history, id) {
19861
20206
  var AntigravityAdapter = class {
19862
20207
  commandCatalog = ANTIGRAVITY_COMMAND_CATALOG;
19863
20208
  harnessId = antigravityHarnessId;
20209
+ usageStatistics;
19864
20210
  subagents = {
19865
20211
  readSnapshot: async (input) => {
19866
20212
  if (this.#closed || input.parent.harnessId !== this.harnessId || !nativeSubagentIdSchema.safeParse(input.nativeSubagentId).success) {
@@ -19893,6 +20239,7 @@ var AntigravityAdapter = class {
19893
20239
  #sessions = /* @__PURE__ */ new Set();
19894
20240
  #toolOutputLimit;
19895
20241
  #subagentObservationTimeoutMs;
20242
+ #turnCleanupWaitMs;
19896
20243
  #closed = false;
19897
20244
  #quota = null;
19898
20245
  #quotaCwd = null;
@@ -19901,6 +20248,7 @@ var AntigravityAdapter = class {
19901
20248
  constructor(options = {}) {
19902
20249
  this.#command = options.command;
19903
20250
  this.#environment = options.environment ?? process.env;
20251
+ this.usageStatistics = createAntigravityUsageStatistics(this.#environment);
19904
20252
  this.#inspectTimeoutMs = options.inspectTimeoutMs ?? DEFAULT_INSPECT_TIMEOUT_MS;
19905
20253
  this.#printTimeout = options.printTimeout ?? DEFAULT_PRINT_TIMEOUT;
19906
20254
  this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_TOOL_OUTPUT_LIMIT;
@@ -19909,12 +20257,17 @@ var AntigravityAdapter = class {
19909
20257
  throw new RangeError("subagentObservationTimeoutMs must be a finite positive number");
19910
20258
  }
19911
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;
19912
20265
  }
19913
20266
  async inspect(input = {}) {
19914
20267
  if (this.#closed) {
19915
20268
  return { status: "unavailable", error: invalidState("Antigravity Adapter is closed") };
19916
20269
  }
19917
- const cwd = path10.resolve(input.cwd ?? process.cwd());
20270
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
19918
20271
  const inFlight = this.#inspectionInFlight.get(cwd);
19919
20272
  if (inFlight)
19920
20273
  return inFlight;
@@ -20057,7 +20410,7 @@ var AntigravityAdapter = class {
20057
20410
  }
20058
20411
  };
20059
20412
  }
20060
- const cwd = path10.resolve(input.cwd);
20413
+ const cwd = path11.resolve(input.cwd);
20061
20414
  let catalog = this.#inspectionCache.get(cwd)?.catalog;
20062
20415
  if (!catalog) {
20063
20416
  const inspection = await this.inspect({ cwd: input.cwd });
@@ -20093,6 +20446,7 @@ var AntigravityAdapter = class {
20093
20446
  ...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
20094
20447
  toolOutputLimit: this.#toolOutputLimit,
20095
20448
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20449
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20096
20450
  onClosed: () => this.#sessions.delete(session2)
20097
20451
  });
20098
20452
  this.#sessions.add(session2);
@@ -20129,6 +20483,7 @@ var AntigravityAdapter = class {
20129
20483
  ...params.thinkingOptionId ? { thinkingOptionId: params.thinkingOptionId } : {},
20130
20484
  toolOutputLimit: this.#toolOutputLimit,
20131
20485
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20486
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20132
20487
  onClosed: () => this.#sessions.delete(session2)
20133
20488
  });
20134
20489
  this.#sessions.add(session2);
@@ -20186,6 +20541,7 @@ var AntigravityAdapter = class {
20186
20541
  ...thinkingOptionId ? { thinkingOptionId } : {},
20187
20542
  toolOutputLimit: this.#toolOutputLimit,
20188
20543
  subagentObservationTimeoutMs: this.#subagentObservationTimeoutMs,
20544
+ turnCleanupWaitMs: this.#turnCleanupWaitMs,
20189
20545
  onClosed: () => this.#sessions.delete(session)
20190
20546
  });
20191
20547
  this.#sessions.add(session);
@@ -20245,11 +20601,23 @@ function createAntigravityInstallation(environment, command, dependencies = {})
20245
20601
 
20246
20602
  // dist/plugin.js
20247
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
+ }
20248
20616
  function createHarnessAdapter(context) {
20249
20617
  const environment = { ...context.environment };
20250
20618
  return Object.assign(new AntigravityAdapter({
20251
20619
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
20252
- environment
20620
+ environment: antigravityProcessEnvironment(environment, context.platform)
20253
20621
  }), {
20254
20622
  install: createHarnessInstaller(environment, {
20255
20623
  posix: "https://antigravity.google/cli/install.sh",
@@ -20266,6 +20634,8 @@ async function warmup(adapter) {
20266
20634
  }
20267
20635
  export {
20268
20636
  ANTIGRAVITY_COMMAND_ENV,
20637
+ ANTIGRAVITY_DISABLE_AUTO_UPDATE_ENV,
20638
+ antigravityProcessEnvironment,
20269
20639
  createHarnessAdapter,
20270
20640
  warmup
20271
20641
  };