@codexhost/cli-darwin-x64 0.13.1 → 0.13.3

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.
@@ -1138,10 +1138,10 @@ function mergeDefs(...defs) {
1138
1138
  function cloneDef(schema) {
1139
1139
  return mergeDefs(schema._zod.def);
1140
1140
  }
1141
- function getElementAtPath(obj, path8) {
1142
- if (!path8)
1141
+ function getElementAtPath(obj, path9) {
1142
+ if (!path9)
1143
1143
  return obj;
1144
- return path8.reduce((acc, key) => acc?.[key], obj);
1144
+ return path9.reduce((acc, key) => acc?.[key], obj);
1145
1145
  }
1146
1146
  function promiseAllObject(promisesObj) {
1147
1147
  const keys = Object.keys(promisesObj);
@@ -1550,11 +1550,11 @@ function explicitlyAborted(x, startIndex = 0) {
1550
1550
  }
1551
1551
  return false;
1552
1552
  }
1553
- function prefixIssues(path8, issues) {
1553
+ function prefixIssues(path9, issues) {
1554
1554
  return issues.map((iss) => {
1555
1555
  var _a3;
1556
1556
  (_a3 = iss).path ?? (_a3.path = []);
1557
- iss.path.unshift(path8);
1557
+ iss.path.unshift(path9);
1558
1558
  return iss;
1559
1559
  });
1560
1560
  }
@@ -1701,16 +1701,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1701
1701
  }
1702
1702
  function formatError(error51, mapper = (issue2) => issue2.message) {
1703
1703
  const fieldErrors = { _errors: [] };
1704
- const processError = (error52, path8 = []) => {
1704
+ const processError = (error52, path9 = []) => {
1705
1705
  for (const issue2 of error52.issues) {
1706
1706
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1707
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1707
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1708
1708
  } else if (issue2.code === "invalid_key") {
1709
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1709
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1710
1710
  } else if (issue2.code === "invalid_element") {
1711
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1711
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1712
1712
  } else {
1713
- const fullpath = [...path8, ...issue2.path];
1713
+ const fullpath = [...path9, ...issue2.path];
1714
1714
  if (fullpath.length === 0) {
1715
1715
  fieldErrors._errors.push(mapper(issue2));
1716
1716
  } else {
@@ -1737,17 +1737,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1737
1737
  }
1738
1738
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1739
1739
  const result = { errors: [] };
1740
- const processError = (error52, path8 = []) => {
1740
+ const processError = (error52, path9 = []) => {
1741
1741
  var _a3, _b;
1742
1742
  for (const issue2 of error52.issues) {
1743
1743
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1744
- issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
1744
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
1745
1745
  } else if (issue2.code === "invalid_key") {
1746
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1746
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1747
1747
  } else if (issue2.code === "invalid_element") {
1748
- processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
1748
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
1749
1749
  } else {
1750
- const fullpath = [...path8, ...issue2.path];
1750
+ const fullpath = [...path9, ...issue2.path];
1751
1751
  if (fullpath.length === 0) {
1752
1752
  result.errors.push(mapper(issue2));
1753
1753
  continue;
@@ -1779,8 +1779,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1779
1779
  }
1780
1780
  function toDotPath(_path) {
1781
1781
  const segs = [];
1782
- const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1783
- for (const seg of path8) {
1782
+ const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1783
+ for (const seg of path9) {
1784
1784
  if (typeof seg === "number")
1785
1785
  segs.push(`[${seg}]`);
1786
1786
  else if (typeof seg === "symbol")
@@ -14472,13 +14472,13 @@ function resolveRef(ref, ctx) {
14472
14472
  if (!ref.startsWith("#")) {
14473
14473
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14474
14474
  }
14475
- const path8 = ref.slice(1).split("/").filter(Boolean);
14476
- if (path8.length === 0) {
14475
+ const path9 = ref.slice(1).split("/").filter(Boolean);
14476
+ if (path9.length === 0) {
14477
14477
  return ctx.rootSchema;
14478
14478
  }
14479
14479
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14480
- if (path8[0] === defsKey) {
14481
- const key = path8[1];
14480
+ if (path9[0] === defsKey) {
14481
+ const key = path9[1];
14482
14482
  if (!key || !ctx.defs[key]) {
14483
14483
  throw new Error(`Reference not found: ${ref}`);
14484
14484
  }
@@ -14965,6 +14965,15 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14965
14965
  initializeOnly: external_exports.boolean().optional()
14966
14966
  });
14967
14967
 
14968
+ // ../../shared-contracts/dist/harness-presentation.js
14969
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
14970
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
14971
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
14972
+ label: displayText(256).optional(),
14973
+ description: displayText(1024).optional()
14974
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14975
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14976
+
14968
14977
  // ../../shared-contracts/dist/model-price-overrides.js
14969
14978
  var usdPerMillionTokens = external_exports.number().finite().nonnegative();
14970
14979
  var modelPriceOverrideSchema = external_exports.strictObject({
@@ -15301,8 +15310,24 @@ var threadUsageSnapshotSchema = external_exports.object({
15301
15310
  }
15302
15311
  });
15303
15312
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
15313
+ var accountCreditsPeriodSchema = external_exports.enum([
15314
+ "weekly",
15315
+ "monthly",
15316
+ "five_hour",
15317
+ "seven_day",
15318
+ "unknown"
15319
+ ]);
15320
+ var accountCreditsScopeSchema = external_exports.object({
15321
+ id: external_exports.string().min(1).max(256),
15322
+ label: external_exports.string().min(1).max(256),
15323
+ localizations: harnessLocalizationsSchema.optional()
15324
+ }).strict();
15304
15325
  var accountCreditsProductUsageSchema = external_exports.object({
15305
15326
  product: external_exports.string().min(1),
15327
+ /** Native period and scope, never inferred from the display name. */
15328
+ periodType: accountCreditsPeriodSchema.optional(),
15329
+ scope: accountCreditsScopeSchema.optional(),
15330
+ localizations: harnessLocalizationsSchema.optional(),
15306
15331
  used: external_exports.number().finite().nonnegative().optional(),
15307
15332
  // Zero is a real empty cap, not an absent field.
15308
15333
  limit: external_exports.number().finite().nonnegative().optional(),
@@ -15322,9 +15347,11 @@ var accountCreditsSnapshotSchema = external_exports.object({
15322
15347
  unit: external_exports.string().min(1).max(32).optional(),
15323
15348
  /** Native label when the primary limit is scoped to a model or product group. */
15324
15349
  label: external_exports.string().min(1).optional(),
15350
+ scope: accountCreditsScopeSchema.optional(),
15351
+ localizations: harnessLocalizationsSchema.optional(),
15325
15352
  usedPercent: usagePercentSchema,
15326
15353
  resetsAt: external_exports.string().min(1).optional(),
15327
- periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
15354
+ periodType: accountCreditsPeriodSchema,
15328
15355
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
15329
15356
  resetCredits: accountResetCreditsSchema.optional()
15330
15357
  }).strict();
@@ -15335,7 +15362,9 @@ var threadUsageInspectionParamsSchema = external_exports.object({
15335
15362
  var threadUsageInspectionSchema = external_exports.object({
15336
15363
  threadId: hostThreadIdSchema,
15337
15364
  usage: threadUsageSnapshotSchema.nullable(),
15338
- accountCredits: accountCreditsSnapshotSchema.optional()
15365
+ accountCredits: accountCreditsSnapshotSchema.optional(),
15366
+ /** Whether this source can provide cached account quota independently of usage. */
15367
+ accountCreditsSupported: external_exports.boolean().optional()
15339
15368
  }).strict();
15340
15369
 
15341
15370
  // ../../shared-contracts/dist/harness-accounts.js
@@ -15462,7 +15491,8 @@ var harnessPermissionModeSchema = external_exports.object({
15462
15491
  id: harnessPermissionModeIdSchema,
15463
15492
  label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15464
15493
  description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15465
- dangerous: external_exports.boolean().optional()
15494
+ dangerous: external_exports.boolean().optional(),
15495
+ localizations: harnessLocalizationsSchema.optional()
15466
15496
  }).strict();
15467
15497
  var harnessPermissionModeCatalogSchema = external_exports.object({
15468
15498
  modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
@@ -15849,6 +15879,8 @@ var harnessInstallationStateSchema = external_exports.object({
15849
15879
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15850
15880
  message: external_exports.string().max(2048).optional(),
15851
15881
  messageCode: external_exports.string().min(1).max(128).optional(),
15882
+ /** Safe plugin-owned explanation, distinct from raw diagnostic message. */
15883
+ notice: harnessLocalizedTextSchema.optional(),
15852
15884
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15853
15885
  }).strict();
15854
15886
 
@@ -15975,6 +16007,7 @@ var harnessCommandDescriptorSchema = external_exports.object({
15975
16007
  invocation: commandInvocationSchema,
15976
16008
  label: commandLabelSchema,
15977
16009
  description: commandDescriptionSchema.optional(),
16010
+ localizations: harnessLocalizationsSchema.optional(),
15978
16011
  argumentMode: external_exports.enum(["none", "text"]),
15979
16012
  /**
15980
16013
  * Native distinction reported by the Harness. Omitted when the Harness does
@@ -18010,14 +18043,14 @@ function gatewayDiff(text2) {
18010
18043
  if (!text2 || text2.length > 1024 * 1024)
18011
18044
  return [];
18012
18045
  const result = [];
18013
- let path8 = "";
18046
+ let path9 = "";
18014
18047
  let inHunk = false;
18015
18048
  let oldLines = [], newLines = [];
18016
18049
  const flush = () => {
18017
- if (path8)
18050
+ if (path9)
18018
18051
  result.push({
18019
18052
  type: "diff",
18020
- path: path8,
18053
+ path: path9,
18021
18054
  oldText: oldLines.join("\n"),
18022
18055
  newText: newLines.join("\n")
18023
18056
  });
@@ -18030,24 +18063,24 @@ function gatewayDiff(text2) {
18030
18063
  if (header) {
18031
18064
  flush();
18032
18065
  inHunk = false;
18033
- path8 = (header[2] === "/dev/null" ? header[1] ?? "" : header[2] ?? "").replace(/^[ab]\//u, "");
18066
+ path9 = (header[2] === "/dev/null" ? header[1] ?? "" : header[2] ?? "").replace(/^[ab]\//u, "");
18034
18067
  continue;
18035
18068
  }
18036
18069
  if (line.startsWith("--- ") && !inHunk) {
18037
18070
  flush();
18038
- path8 = line.slice(4).replace(/^a\//u, "");
18071
+ path9 = line.slice(4).replace(/^a\//u, "");
18039
18072
  } else if (line.startsWith("+++ ") && !inHunk) {
18040
18073
  const next = line.slice(4);
18041
18074
  if (next !== "/dev/null")
18042
- path8 = next.replace(/^b\//u, "");
18075
+ path9 = next.replace(/^b\//u, "");
18043
18076
  } else if (line.startsWith("@@")) {
18044
18077
  inHunk = true;
18045
18078
  continue;
18046
- } else if (path8 && line.startsWith("-"))
18079
+ } else if (path9 && line.startsWith("-"))
18047
18080
  oldLines.push(line.slice(1));
18048
- else if (path8 && line.startsWith("+"))
18081
+ else if (path9 && line.startsWith("+"))
18049
18082
  newLines.push(line.slice(1));
18050
- else if (path8 && line.startsWith(" ")) {
18083
+ else if (path9 && line.startsWith(" ")) {
18051
18084
  oldLines.push(line.slice(1));
18052
18085
  newLines.push(line.slice(1));
18053
18086
  }
@@ -18471,8 +18504,150 @@ var HermesGatewaySessionTransport = class {
18471
18504
  }
18472
18505
  };
18473
18506
 
18474
- // dist/gateway-open.js
18507
+ // dist/usage-statistics.js
18508
+ import os3 from "node:os";
18475
18509
  import path7 from "node:path";
18510
+ import { lstat } from "node:fs/promises";
18511
+
18512
+ // ../../harness-adapter/dist/usage-statistics.js
18513
+ var MAX_SESSION_ID_LENGTH = 512;
18514
+ var MAX_CWD_LENGTH = 4096;
18515
+ var MAX_SESSION_TITLE_LENGTH = 200;
18516
+ function usageSessionTitle(value) {
18517
+ if (typeof value !== "string")
18518
+ return void 0;
18519
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
18520
+ if (!normalized)
18521
+ return void 0;
18522
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
18523
+ return normalized;
18524
+ const characters = [...normalized];
18525
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
18526
+ return normalized;
18527
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
18528
+ }
18529
+ function sessionIdOk(value) {
18530
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
18531
+ }
18532
+ function cwdOk(value) {
18533
+ 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("\\\\"));
18534
+ }
18535
+ function withUsageSession(entry, session) {
18536
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
18537
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
18538
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
18539
+ if (sessionId === void 0 && cwd === void 0)
18540
+ return entry;
18541
+ return {
18542
+ ...entry,
18543
+ ...sessionId !== void 0 ? { sessionId } : {},
18544
+ ...cwd !== void 0 ? { cwd } : {},
18545
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
18546
+ };
18547
+ }
18548
+ function usageEntryFromRequest(request, occurredAtMs) {
18549
+ if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
18550
+ return null;
18551
+ return {
18552
+ id: request.requestId,
18553
+ occurredAtMs,
18554
+ ...request.model !== void 0 ? { model: request.model } : {},
18555
+ inputTokens: request.inputTokens,
18556
+ ...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
18557
+ ...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
18558
+ ...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
18559
+ outputTokens: request.outputTokens,
18560
+ ...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
18561
+ };
18562
+ }
18563
+
18564
+ // dist/usage-statistics.js
18565
+ function hermesStateDatabasePath(environment) {
18566
+ const home = environment.HOME || environment.USERPROFILE || os3.homedir();
18567
+ const configured = environment.HERMES_HOME;
18568
+ return path7.resolve(configured ? path7.join(configured, "state.db") : path7.join(home, ".hermes", "state.db"));
18569
+ }
18570
+ async function fingerprint(file2) {
18571
+ const info = await lstat(file2).catch(() => null);
18572
+ if (!info?.isFile())
18573
+ return null;
18574
+ const wal = await lstat(`${file2}-wal`).catch(() => null);
18575
+ return `${info.ino}:${info.size}:${info.mtimeMs}:${wal ? `${wal.size}:${wal.mtimeMs}` : "-"}`;
18576
+ }
18577
+ function tokenCount(value) {
18578
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
18579
+ }
18580
+ function hermesUsageEntry(row) {
18581
+ const apiCalls = tokenCount(row.api_call_count) ? row.api_call_count : 0;
18582
+ const input = tokenCount(row.input_tokens) ? row.input_tokens : 0;
18583
+ const output = tokenCount(row.output_tokens) ? row.output_tokens : 0;
18584
+ const cacheRead = tokenCount(row.cache_read_tokens) ? row.cache_read_tokens : 0;
18585
+ const cacheWrite = tokenCount(row.cache_write_tokens) ? row.cache_write_tokens : 0;
18586
+ const reasoning = tokenCount(row.reasoning_tokens) ? row.reasoning_tokens : 0;
18587
+ if (apiCalls === 0 && input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
18588
+ return null;
18589
+ }
18590
+ const id = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
18591
+ const epochSeconds = (value) => {
18592
+ if (typeof value !== "number" || !Number.isFinite(value))
18593
+ return null;
18594
+ const ms = Math.floor(value * 1e3);
18595
+ return Number.isSafeInteger(ms) && !Number.isNaN(new Date(ms).getTime()) ? ms : null;
18596
+ };
18597
+ const at = epochSeconds(row.last_activity_at) ?? epochSeconds(row.started_at);
18598
+ if (id === null || at === null)
18599
+ return null;
18600
+ const request = {
18601
+ requestId: id,
18602
+ ...typeof row.model === "string" && row.model.length > 0 ? { model: row.model } : {},
18603
+ inputTokens: input + cacheRead + cacheWrite,
18604
+ outputTokens: output,
18605
+ ...reasoning > 0 ? { reasoningOutputTokens: reasoning } : {},
18606
+ // Both buckets exist whenever either does: the writer records them as a pair.
18607
+ ...cacheRead > 0 || cacheWrite > 0 ? { cachedInputTokens: cacheRead, cacheWriteInputTokens: cacheWrite } : {}
18608
+ };
18609
+ const entry = usageEntryFromRequest(request, at);
18610
+ if (!entry)
18611
+ return null;
18612
+ return withUsageSession(entry, {
18613
+ sessionId: id,
18614
+ cwd: typeof row.cwd === "string" ? row.cwd : void 0,
18615
+ title: usageSessionTitle(row.title ?? row.display_name)
18616
+ });
18617
+ }
18618
+ var SESSIONS_QUERY = `
18619
+ SELECT id, model, cwd, title, display_name, started_at, last_activity_at,
18620
+ api_call_count, input_tokens, output_tokens, cache_read_tokens,
18621
+ cache_write_tokens, reasoning_tokens
18622
+ FROM sessions`;
18623
+ async function readHermesUsage(file2) {
18624
+ const { DatabaseSync } = await import("node:sqlite");
18625
+ const database = new DatabaseSync(file2, { readOnly: true });
18626
+ try {
18627
+ const entries = [];
18628
+ for (const row of database.prepare(SESSIONS_QUERY).iterate()) {
18629
+ const entry = hermesUsageEntry(row);
18630
+ if (entry)
18631
+ entries.push(entry);
18632
+ }
18633
+ return entries;
18634
+ } finally {
18635
+ database.close();
18636
+ }
18637
+ }
18638
+ function createHermesUsageStatistics(environment) {
18639
+ return Object.freeze({
18640
+ async listSources() {
18641
+ const file2 = hermesStateDatabasePath(environment);
18642
+ const stamp = await fingerprint(file2);
18643
+ return stamp ? [{ id: file2, fingerprint: stamp }] : [];
18644
+ },
18645
+ readSource: (id) => readHermesUsage(id)
18646
+ });
18647
+ }
18648
+
18649
+ // dist/gateway-open.js
18650
+ import path8 from "node:path";
18476
18651
  import { realpath } from "node:fs/promises";
18477
18652
 
18478
18653
  // dist/hermes-session.js
@@ -18682,16 +18857,16 @@ var Diff = class {
18682
18857
  }
18683
18858
  }
18684
18859
  }
18685
- addToPath(path8, added, removed, oldPosInc, options) {
18686
- const last = path8.lastComponent;
18860
+ addToPath(path9, added, removed, oldPosInc, options) {
18861
+ const last = path9.lastComponent;
18687
18862
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
18688
18863
  return {
18689
- oldPos: path8.oldPos + oldPosInc,
18864
+ oldPos: path9.oldPos + oldPosInc,
18690
18865
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
18691
18866
  };
18692
18867
  } else {
18693
18868
  return {
18694
- oldPos: path8.oldPos + oldPosInc,
18869
+ oldPos: path9.oldPos + oldPosInc,
18695
18870
  lastComponent: { count: 1, added, removed, previousComponent: last }
18696
18871
  };
18697
18872
  }
@@ -19006,8 +19181,8 @@ function hermesFileChanges(update) {
19006
19181
  for (const block of update.content ?? []) {
19007
19182
  if (block.type !== "diff")
19008
19183
  continue;
19009
- const { path: path8, oldText, newText } = block;
19010
- if (!path8.trim() || /[\0\r\n]/u.test(path8) || typeof newText !== "string")
19184
+ const { path: path9, oldText, newText } = block;
19185
+ if (!path9.trim() || /[\0\r\n]/u.test(path9) || typeof newText !== "string")
19011
19186
  continue;
19012
19187
  if (oldText === newText)
19013
19188
  continue;
@@ -19015,10 +19190,10 @@ function hermesFileChanges(update) {
19015
19190
  if (bytes > MAX_DIFF_BYTES || changes.length === MAX_DIFFS)
19016
19191
  return [];
19017
19192
  changes.push({
19018
- path: path8,
19193
+ path: path9,
19019
19194
  kind: "update",
19020
19195
  diffScope: "fragment",
19021
- unifiedDiff: createTwoFilesPatch(path8, path8, oldText ?? "", newText, "", "", {
19196
+ unifiedDiff: createTwoFilesPatch(path9, path9, oldText ?? "", newText, "", "", {
19022
19197
  context: 3
19023
19198
  })
19024
19199
  });
@@ -19821,7 +19996,7 @@ ${reason}` }
19821
19996
 
19822
19997
  // dist/gateway-open.js
19823
19998
  async function sameDirectory(left, right) {
19824
- return await realpath(left).catch(() => path7.resolve(left)) === await realpath(right).catch(() => path7.resolve(right));
19999
+ return await realpath(left).catch(() => path8.resolve(left)) === await realpath(right).catch(() => path8.resolve(right));
19825
20000
  }
19826
20001
  var gatewayCapabilities = {
19827
20002
  configuration: {
@@ -19838,11 +20013,23 @@ function gatewayPermissionModes() {
19838
20013
  {
19839
20014
  id: "default",
19840
20015
  label: "原生审批策略",
20016
+ localizations: {
20017
+ en: {
20018
+ label: "Native approval policy",
20019
+ description: "Follow the Hermes global approval policy; disable YOLO for this Session."
20020
+ }
20021
+ },
19841
20022
  description: "遵循 Hermes 全局审批策略,关闭本会话 YOLO。"
19842
20023
  },
19843
20024
  {
19844
20025
  id: "dont_ask",
19845
20026
  label: "会话 YOLO",
20027
+ localizations: {
20028
+ en: {
20029
+ label: "Session YOLO",
20030
+ description: "Automatically approve Hermes tool actions in this Session."
20031
+ }
20032
+ },
19846
20033
  description: "本会话自动批准 Hermes 工具操作。",
19847
20034
  dangerous: true
19848
20035
  }
@@ -19963,8 +20150,10 @@ var HermesAdapter = class {
19963
20150
  #gatewayTransports = /* @__PURE__ */ new Set();
19964
20151
  #gatewayProbes = /* @__PURE__ */ new Map();
19965
20152
  #openingNativeIds = /* @__PURE__ */ new Set();
20153
+ usageStatistics;
19966
20154
  constructor(options = {}) {
19967
20155
  this.#options = options;
20156
+ this.usageStatistics = createHermesUsageStatistics(options.environment ?? process.env);
19968
20157
  }
19969
20158
  async inspect(input = {}) {
19970
20159
  const cwd = input.cwd ?? process.cwd();
@@ -20243,6 +20432,10 @@ function createHermesInstallation(environment, command) {
20243
20432
  updateAvailable: false,
20244
20433
  canUpdate: false,
20245
20434
  messageCode: "hermes-update-plan-unavailable",
20435
+ notice: {
20436
+ en: "This Hermes release does not expose a safe update plan. Use the original installer.",
20437
+ "zh-CN": "此 Hermes 版本不提供安全的更新计划,请使用原安装方式更新。"
20438
+ },
20246
20439
  message: "This Hermes release does not expose a safe update plan. Use the original installer."
20247
20440
  };
20248
20441
  const plan = await run(["update", "--plan"]);
@@ -20255,6 +20448,10 @@ function createHermesInstallation(environment, command) {
20255
20448
  updateAvailable: false,
20256
20449
  canUpdate: false,
20257
20450
  messageCode: "hermes-externally-managed",
20451
+ notice: {
20452
+ en: "This Hermes installation is managed externally. Update it through its desktop app, container, or original package manager.",
20453
+ "zh-CN": "此 Hermes 安装由外部工具管理,请通过其桌面应用、容器或原包管理器更新。"
20454
+ },
20258
20455
  message: "This Hermes installation is managed externally. Update it through its desktop app, container, or original package manager."
20259
20456
  };
20260
20457
  const output = await run(["update", "--check"]);
@@ -20273,6 +20470,13 @@ function createHermesInstallation(environment, command) {
20273
20470
  canUpdate,
20274
20471
  ...updateAvailable && !release ? { latestVersionKind: "tracking-branch" } : {},
20275
20472
  messageCode: canUpdate ? "hermes-update-channel" : "hermes-manual-update",
20473
+ notice: canUpdate ? {
20474
+ en: "Uses Hermes's configured update channel. Gateway restarts are deferred; existing processes keep their running code.",
20475
+ "zh-CN": "使用 Hermes 配置的更新渠道,暂不重启 Gateway;现有进程继续运行原有代码。"
20476
+ } : {
20477
+ en: "Use the native updater manually. Safe non-interactive updates require a clean source checkout, commit identity, and Gateway restart deferral.",
20478
+ "zh-CN": "请手动使用原生更新器。安全的非交互更新要求源码目录无未提交修改、可识别当前提交,并支持推迟 Gateway 重启。"
20479
+ },
20276
20480
  message: canUpdate ? "Uses Hermes's configured update channel. Gateway restarts are deferred; existing processes keep their running code." : "Use the native updater manually. Safe non-interactive updates require a clean source checkout, commit identity, and Gateway restart deferral."
20277
20481
  };
20278
20482
  },