@liberseek/boft-cli-win32-arm64 0.7.9 → 0.8.1

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 (57) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +9 -1
  3. package/app/codexhost-distribution.json +1 -1
  4. package/app/console-server.mjs +322 -67
  5. package/app/console-web.js +9202 -5218
  6. package/app/desktop-controller.mjs +259 -42
  7. package/app/host-runtime.mjs +6250 -1689
  8. package/app/plugins/antigravity/manifest.json +18 -1
  9. package/app/plugins/antigravity/plugin.mjs +283 -42
  10. package/app/plugins/claude-code/manifest.json +28 -0
  11. package/app/plugins/claude-code/plugin.mjs +35676 -24151
  12. package/app/plugins/codebuddy/manifest.json +17 -0
  13. package/app/plugins/codebuddy/plugin.mjs +5972 -5356
  14. package/app/plugins/codex-usage/manifest.json +9 -0
  15. package/app/plugins/codex-usage/plugin.mjs +17386 -0
  16. package/app/plugins/cursor-cli/manifest.json +18 -1
  17. package/app/plugins/cursor-cli/plugin.mjs +358 -77
  18. package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
  19. package/app/plugins/deepseek-harness/manifest.json +35 -2
  20. package/app/plugins/deepseek-harness/plugin.mjs +823 -242
  21. package/app/plugins/enabled.json +2 -1
  22. package/app/plugins/grok/manifest.json +21 -1
  23. package/app/plugins/grok/plugin.mjs +933 -268
  24. package/app/plugins/hermes/assets/icon.png +0 -0
  25. package/app/plugins/hermes/manifest.json +30 -2
  26. package/app/plugins/hermes/plugin.mjs +469 -73
  27. package/app/plugins/kimi-code/assets/icon.svg +5 -0
  28. package/app/plugins/kimi-code/manifest.json +25 -2
  29. package/app/plugins/kimi-code/plugin.mjs +562 -36
  30. package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
  31. package/app/plugins/kiro-cli/manifest.json +18 -1
  32. package/app/plugins/kiro-cli/plugin.mjs +291 -22
  33. package/app/plugins/muse/manifest.json +18 -1
  34. package/app/plugins/muse/plugin.mjs +258 -17
  35. package/app/plugins/omp/manifest.json +21 -1
  36. package/app/plugins/omp/plugin.mjs +2763 -1958
  37. package/app/plugins/opencode/manifest.json +18 -1
  38. package/app/plugins/opencode/plugin.mjs +724 -147
  39. package/app/plugins/pi/manifest.json +32 -0
  40. package/app/plugins/pi/plugin.mjs +2908 -2312
  41. package/app/plugins/qoder/manifest.json +18 -1
  42. package/app/plugins/qoder/plugin.mjs +635 -81
  43. package/app/plugins/qoder-cn/manifest.json +18 -1
  44. package/app/plugins/qoder-cn/plugin.mjs +635 -81
  45. package/app/plugins/workbuddy/manifest.json +18 -0
  46. package/app/plugins/workbuddy/plugin.mjs +6362 -5748
  47. package/app/plugins/zcode/manifest.json +19 -1
  48. package/app/plugins/zcode/plugin.mjs +1117 -278
  49. package/app/renderer-extension.js +14675 -10087
  50. package/bin/boft.exe +0 -0
  51. package/libexec/boft-node-repl.exe +0 -0
  52. package/libexec/boft-shim.exe +0 -0
  53. package/libexec/boft-updater.exe +0 -0
  54. package/licenses/Cordis-LICENSE.txt +21 -0
  55. package/licenses/Cosmokit-LICENSE.txt +21 -0
  56. package/package.json +4 -4
  57. package/app/plugins/kiro-cli/assets/icon.svg +0 -5
@@ -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")
@@ -5008,8 +5008,8 @@ function az_default() {
5008
5008
  }
5009
5009
 
5010
5010
  // ../../../node_modules/zod/v4/locales/be.js
5011
- function getBelarusianPlural(count, one, few, many) {
5012
- const absCount = Math.abs(count);
5011
+ function getBelarusianPlural(count2, one, few, many) {
5012
+ const absCount = Math.abs(count2);
5013
5013
  const lastDigit = absCount % 10;
5014
5014
  const lastTwoDigits = absCount % 100;
5015
5015
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -7087,8 +7087,8 @@ function hu_default() {
7087
7087
  }
7088
7088
 
7089
7089
  // ../../../node_modules/zod/v4/locales/hy.js
7090
- function getArmenianPlural(count, one, many) {
7091
- return Math.abs(count) === 1 ? one : many;
7090
+ function getArmenianPlural(count2, one, many) {
7091
+ return Math.abs(count2) === 1 ? one : many;
7092
7092
  }
7093
7093
  function withDefiniteArticle(word) {
7094
7094
  if (!word)
@@ -9216,8 +9216,8 @@ function ro_default() {
9216
9216
  }
9217
9217
 
9218
9218
  // ../../../node_modules/zod/v4/locales/ru.js
9219
- function getRussianPlural(count, one, few, many) {
9220
- const absCount = Math.abs(count);
9219
+ function getRussianPlural(count2, one, few, many) {
9220
+ const absCount = Math.abs(count2);
9221
9221
  const lastDigit = absCount % 10;
9222
9222
  const lastTwoDigits = absCount % 100;
9223
9223
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -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
  }
@@ -14886,6 +14886,15 @@ function date4(params) {
14886
14886
  // ../../../node_modules/zod/v4/classic/external.js
14887
14887
  config(en_default());
14888
14888
 
14889
+ // ../../shared-contracts/dist/delegation-read.js
14890
+ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
14891
+ var delegationReadParamsSchema = external_exports.strictObject({
14892
+ threadId: external_exports.string().min(1).max(1024),
14893
+ view: external_exports.enum(["result", "messages"]),
14894
+ cursor: external_exports.string().min(1).max(8192).optional(),
14895
+ limit: external_exports.number().int().min(1).max(100).optional()
14896
+ });
14897
+
14889
14898
  // ../../shared-contracts/dist/credential-imports.js
14890
14899
  var credentialSourceSchema = external_exports.object({
14891
14900
  id: external_exports.string().min(1).max(256),
@@ -14956,6 +14965,160 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14956
14965
  initializeOnly: external_exports.boolean().optional()
14957
14966
  });
14958
14967
 
14968
+ // ../../shared-contracts/dist/model-price-overrides.js
14969
+ var usdPerMillionTokens = external_exports.number().finite().nonnegative();
14970
+ var modelPriceOverrideSchema = external_exports.strictObject({
14971
+ input: usdPerMillionTokens,
14972
+ output: usdPerMillionTokens,
14973
+ cacheRead: usdPerMillionTokens.optional(),
14974
+ cacheWrite: usdPerMillionTokens.optional(),
14975
+ cacheWrite1h: usdPerMillionTokens.optional()
14976
+ });
14977
+ var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
14978
+ var modelPriceOverridesSchema = external_exports.strictObject({
14979
+ /** Absolute path of the Host's `pricing.json`. */
14980
+ path: external_exports.string(),
14981
+ entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
14982
+ /** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
14983
+ error: external_exports.string().nullable()
14984
+ });
14985
+ var modelPriceOverridesGetSchema = external_exports.strictObject({});
14986
+ var modelPriceOverridesSetSchema = external_exports.strictObject({
14987
+ key: modelPriceKeySchema,
14988
+ price: modelPriceOverrideSchema.nullable(),
14989
+ previousKey: modelPriceKeySchema.optional()
14990
+ });
14991
+ var modelPriceDefaultParamsSchema = external_exports.strictObject({
14992
+ model: modelPriceKeySchema
14993
+ });
14994
+ var modelPriceSuggestionSchema = external_exports.strictObject({
14995
+ /** Verified from catalog canonical links, not inferred from names or equal prices. */
14996
+ official: external_exports.boolean().optional(),
14997
+ canonicalModelId: external_exports.string().min(1).optional(),
14998
+ provider: external_exports.string().min(1).max(512),
14999
+ model: external_exports.string().min(1).max(512),
15000
+ price: modelPriceOverrideSchema
15001
+ });
15002
+ var modelPriceDefaultResultSchema = external_exports.strictObject({
15003
+ price: modelPriceOverrideSchema.nullable(),
15004
+ /** Local catalog suggestions only; never used automatically for pricing. */
15005
+ suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
15006
+ });
15007
+
15008
+ // ../../shared-contracts/dist/usage-statistics.js
15009
+ var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
15010
+ var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
15011
+ var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
15012
+ var harness = external_exports.string().min(1).max(128);
15013
+ var model = external_exports.string().min(1).max(512);
15014
+ var project = external_exports.string().min(1).max(4096);
15015
+ var usageStatisticsParamsSchema = external_exports.strictObject({
15016
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
15017
+ harness: harness.optional(),
15018
+ model: model.nullable().optional(),
15019
+ project: project.nullable().optional(),
15020
+ /** One local date inside the range. */
15021
+ date: localDate.optional()
15022
+ });
15023
+ var usageStatisticsTotalsSchema = external_exports.strictObject({
15024
+ requests: count,
15025
+ inputTokens: count,
15026
+ cachedInputTokens: count,
15027
+ cacheWriteInputTokens: count,
15028
+ cacheKnownInputTokens: count,
15029
+ outputTokens: count,
15030
+ reasoningOutputTokens: count,
15031
+ /** USD at the public price, summed over the priced requests only. */
15032
+ costUsd: external_exports.number().finite().min(0),
15033
+ /** Requests without a price (or the cache data the price needs); not in `costUsd`. */
15034
+ unpricedRequests: count,
15035
+ /**
15036
+ * Requests whose storage gave no token counts: counted as requests, with neither tokens nor
15037
+ * cost, and not as unpriced.
15038
+ */
15039
+ unmeteredRequests: count
15040
+ });
15041
+ var totals = usageStatisticsTotalsSchema.shape;
15042
+ var usageStatisticsSessionSchema = external_exports.strictObject({
15043
+ harness,
15044
+ sessionId: external_exports.string().min(1).max(512),
15045
+ project: project.nullable(),
15046
+ /** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
15047
+ title: external_exports.string().min(1).max(200).optional(),
15048
+ /** Models the session used, most requests first. */
15049
+ models: external_exports.array(model).max(16),
15050
+ firstAtMs: count,
15051
+ lastAtMs: count,
15052
+ ...totals
15053
+ });
15054
+ var usageStatisticsResultSchema = external_exports.strictObject({
15055
+ range: external_exports.enum(USAGE_STATISTICS_RANGES),
15056
+ /** First local date of the range; null for all time. */
15057
+ from: localDate.nullable(),
15058
+ to: localDate,
15059
+ /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
15060
+ filters: external_exports.strictObject({
15061
+ harness: harness.nullable(),
15062
+ model: model.nullable(),
15063
+ unknownModel: external_exports.boolean(),
15064
+ project: project.nullable(),
15065
+ unknownProject: external_exports.boolean(),
15066
+ date: localDate.nullable()
15067
+ }),
15068
+ /** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
15069
+ reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
15070
+ /** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
15071
+ failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
15072
+ /** Every value seen in the range, ignoring the filters, to choose filters from. */
15073
+ options: external_exports.strictObject({
15074
+ harnesses: external_exports.array(harness).max(256),
15075
+ models: external_exports.array(model.nullable()).max(4096),
15076
+ projects: external_exports.array(project.nullable()).max(4096)
15077
+ }),
15078
+ /** Current display metadata, scoped by Harness. Never a pricing or filter identity.
15079
+ * Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
15080
+ */
15081
+ modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
15082
+ /** Native credits, all filters applied, never combined across Harnesses or treated as USD.
15083
+ * Only groups with at least one reported value appear; reportedRequests exposes partial data.
15084
+ */
15085
+ credits: external_exports.array(external_exports.strictObject({
15086
+ harness,
15087
+ model: model.nullable(),
15088
+ credits: external_exports.number().finite().min(0),
15089
+ reportedRequests: count,
15090
+ requests: count
15091
+ })).max(4096).optional(),
15092
+ /** All filters applied. */
15093
+ totals: usageStatisticsTotalsSchema,
15094
+ /** Each date and Harness of the range: every filter except the day. */
15095
+ daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
15096
+ /** Local weekday (0 = Sunday) and hour, all filters applied. */
15097
+ hourly: external_exports.array(external_exports.strictObject({
15098
+ weekday: external_exports.number().int().min(0).max(6),
15099
+ hour: external_exports.number().int().min(0).max(23),
15100
+ ...totals
15101
+ })).max(168),
15102
+ byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
15103
+ byModel: external_exports.array(external_exports.strictObject({
15104
+ model: model.nullable(),
15105
+ ...totals,
15106
+ /** Requests priced by what the Harness recorded they cost, not by a price list. */
15107
+ harnessPricedRequests: count
15108
+ })).max(4096),
15109
+ byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
15110
+ /**
15111
+ * The sessions that spent the most, by cost and by tokens without cache, all filters applied;
15112
+ * requests without a native session are not listed here but count everywhere else.
15113
+ */
15114
+ sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
15115
+ /**
15116
+ * The sessions last active in the range, newest first, all filters applied. Optional for older
15117
+ * Hosts; missing is treated as no list rather than no sessions.
15118
+ */
15119
+ recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
15120
+ });
15121
+
14959
15122
  // ../../shared-contracts/dist/ids.js
14960
15123
  var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14961
15124
  message: "Identifier must not be empty or whitespace"
@@ -14977,13 +15140,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
14977
15140
  var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
14978
15141
  var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
14979
15142
  var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15143
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15144
+ var harnessInstallationGuideSchema = external_exports.object({
15145
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15146
+ before: localizedTextSchema.optional(),
15147
+ after: localizedTextSchema.optional(),
15148
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15149
+ }).strict();
14980
15150
  var pluginPresentationShape = {
14981
15151
  id: harnessPluginIdSchema,
14982
15152
  name: external_exports.string().trim().min(1).max(128),
14983
15153
  version: external_exports.string().min(1).max(128),
15154
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15155
+ kind: external_exports.literal("usage").optional(),
15156
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15157
+ iconStyle: external_exports.object({
15158
+ vector: external_exports.object({
15159
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15160
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15161
+ paths: external_exports.array(external_exports.object({
15162
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15163
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15164
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15165
+ }).strict()).min(1).max(32)
15166
+ }).strict().optional(),
15167
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15168
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15169
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15170
+ }).strict().optional(),
15171
+ installation: harnessInstallationGuideSchema.optional(),
15172
+ notice: localizedTextSchema.optional(),
14984
15173
  /** The factory accepts a persisted local entrypoint through its construction context. */
14985
15174
  launchCommand: external_exports.literal(true).optional(),
14986
15175
  links: external_exports.object({
15176
+ website: documentationUrlSchema.optional(),
14987
15177
  documentation: documentationUrlSchema.optional(),
14988
15178
  installation: documentationUrlSchema.optional()
14989
15179
  }).strict().optional()
@@ -15060,6 +15250,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15060
15250
  "codexhost/account/list",
15061
15251
  "codexhost/account/refresh",
15062
15252
  "codexhost/account/usage/inspect",
15253
+ "codexhost/usage/model-prices/get",
15254
+ "codexhost/usage/model-prices/set",
15255
+ "codexhost/usage/model-prices/default",
15256
+ "codexhost/usage/statistics/get",
15063
15257
  "codexhost/update/check",
15064
15258
  "codexhost/update/start",
15065
15259
  "codexhost/update/status"
@@ -15124,6 +15318,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15124
15318
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
15125
15319
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
15126
15320
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15321
+ apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15127
15322
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
15128
15323
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
15129
15324
  totalCostUsd: finiteNonNegativeNumberSchema.optional(),
@@ -15135,7 +15330,11 @@ var threadUsageSnapshotSchema = external_exports.object({
15135
15330
  planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
15136
15331
  planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15137
15332
  planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
15138
- planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
15333
+ planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15334
+ sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15335
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15336
+ costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15337
+ unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15139
15338
  }).strict().superRefine((usage, context) => {
15140
15339
  if (Object.keys(usage).length === 0) {
15141
15340
  context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
@@ -15156,6 +15355,20 @@ var threadUsageSnapshotSchema = external_exports.object({
15156
15355
  path: ["contextWindowTokens"]
15157
15356
  });
15158
15357
  }
15358
+ if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
15359
+ context.addIssue({
15360
+ code: "custom",
15361
+ message: "Thread Usage costSource must be provided with totalCostUsd",
15362
+ path: ["costSource"]
15363
+ });
15364
+ }
15365
+ if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
15366
+ context.addIssue({
15367
+ code: "custom",
15368
+ message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
15369
+ path: ["unpricedModels"]
15370
+ });
15371
+ }
15159
15372
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
15160
15373
  context.addIssue({
15161
15374
  code: "custom",
@@ -15425,27 +15638,27 @@ var harnessModelCatalogSchema = external_exports.object({
15425
15638
  }).strict().superRefine((catalog, context) => {
15426
15639
  const refs = /* @__PURE__ */ new Set();
15427
15640
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15428
- for (const [index, model] of catalog.models.entries()) {
15429
- if (refs.has(model.ref.id)) {
15641
+ for (const [index, model2] of catalog.models.entries()) {
15642
+ if (refs.has(model2.ref.id)) {
15430
15643
  context.addIssue({
15431
15644
  code: "custom",
15432
15645
  message: "Model Catalog refs must be unique",
15433
15646
  path: ["models", index, "ref", "id"]
15434
15647
  });
15435
15648
  }
15436
- refs.add(model.ref.id);
15437
- if (model.fastModel) {
15438
- if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15649
+ refs.add(model2.ref.id);
15650
+ if (model2.fastModel) {
15651
+ if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15439
15652
  context.addIssue({
15440
15653
  code: "custom",
15441
15654
  message: "Fast Model refs must be distinct and unique",
15442
15655
  path: ["models", index, "fastModel"]
15443
15656
  });
15444
15657
  }
15445
- refs.add(model.fastModel.id);
15658
+ refs.add(model2.fastModel.id);
15446
15659
  }
15447
15660
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15448
- for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
15661
+ for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
15449
15662
  if (supportedThinkingIds.has(optionId)) {
15450
15663
  context.addIssue({
15451
15664
  code: "custom",
@@ -16039,6 +16252,11 @@ var codexSshDraftSchema = external_exports.strictObject({
16039
16252
  });
16040
16253
  var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
16041
16254
  external_exports.strictObject({ action: external_exports.literal("list") }),
16255
+ external_exports.strictObject({
16256
+ action: external_exports.literal("read-thread"),
16257
+ hostId: hostId.refine((id) => id !== "local"),
16258
+ input: delegationReadParamsSchema
16259
+ }),
16042
16260
  external_exports.strictObject({
16043
16261
  action: external_exports.literal("save"),
16044
16262
  draft: codexSshDraftSchema,
@@ -16170,7 +16388,6 @@ var tokenFields = [
16170
16388
  "cachedInputTokens",
16171
16389
  "cacheWriteInputTokens",
16172
16390
  "outputTokens",
16173
- "outputTokensPerSecond",
16174
16391
  "reasoningOutputTokens",
16175
16392
  "totalTokens",
16176
16393
  "contextWindowTokens",
@@ -16178,10 +16395,12 @@ var tokenFields = [
16178
16395
  ];
16179
16396
  var safeIntegerFields = [
16180
16397
  "planFiveHourResetsAtUnix",
16181
- "planSevenDayResetsAtUnix"
16398
+ "planSevenDayResetsAtUnix",
16399
+ "timeToFirstOutputMs"
16182
16400
  ];
16183
16401
  var percentFields = [
16184
16402
  "cacheHitRatePercent",
16403
+ "sessionCacheHitRatePercent",
16185
16404
  "planFiveHourUsedPercent",
16186
16405
  "planSevenDayUsedPercent"
16187
16406
  ];
@@ -16189,9 +16408,31 @@ var usageFields = /* @__PURE__ */ new Set([
16189
16408
  ...tokenFields,
16190
16409
  ...safeIntegerFields,
16191
16410
  ...percentFields,
16411
+ "sessionCacheUsage",
16192
16412
  "totalCostUsd",
16193
16413
  "totalCredits",
16194
- "contextUsagePercent"
16414
+ "contextUsagePercent",
16415
+ "outputTokensPerSecond",
16416
+ "apiOutputTokensPerSecond",
16417
+ "costSource",
16418
+ "unpricedModels"
16419
+ ]);
16420
+ var requestTokenFields = [
16421
+ "inputTokens",
16422
+ "cachedInputTokens",
16423
+ "cacheWriteInputTokens",
16424
+ "cacheWrite1hInputTokens",
16425
+ "outputTokens",
16426
+ "reasoningOutputTokens",
16427
+ "startedAtMs",
16428
+ "completedAtMs"
16429
+ ];
16430
+ var requestFields = /* @__PURE__ */ new Set([
16431
+ ...requestTokenFields,
16432
+ "requestId",
16433
+ "historical",
16434
+ "model",
16435
+ "provider"
16195
16436
  ]);
16196
16437
 
16197
16438
  // ../../harness-adapter/dist/live-command-catalog.js
@@ -16572,7 +16813,7 @@ function runProbe(pythonExecutable, timeoutMs, environment, arguments_ = ["-I",
16572
16813
  try {
16573
16814
  const payload = stdout.split(/\r?\n/).find((line) => line.startsWith("codexhost_inventory="));
16574
16815
  const parsed2 = JSON.parse(payload ? payload.slice("codexhost_inventory=".length) : stdout.trim());
16575
- const models = (parsed2.models ?? []).filter((model) => typeof model?.modelId === "string" && model.modelId.length > 0);
16816
+ const models = (parsed2.models ?? []).filter((model2) => typeof model2?.modelId === "string" && model2.modelId.length > 0);
16576
16817
  resolve({
16577
16818
  models,
16578
16819
  ...typeof parsed2.configured === "boolean" ? { configured: parsed2.configured } : {},
@@ -16611,14 +16852,14 @@ function catalogModelsFromInventory(inventory) {
16611
16852
  const models = [];
16612
16853
  let defaultModel = null;
16613
16854
  const seen = /* @__PURE__ */ new Set();
16614
- for (const model of inventory.models) {
16615
- if (model.available === false)
16855
+ for (const model2 of inventory.models) {
16856
+ if (model2.available === false)
16616
16857
  continue;
16617
- const nativeModelId = model.modelId;
16858
+ const nativeModelId = model2.modelId;
16618
16859
  const ref = encodeHermesModelRef(nativeModelId);
16619
16860
  if (!ref)
16620
16861
  continue;
16621
- if (inventory.currentModelId && (model.modelId === inventory.currentModelId || nativeModelId === inventory.currentModelId || model.modelIdAliases?.includes(inventory.currentModelId))) {
16862
+ if (inventory.currentModelId && (model2.modelId === inventory.currentModelId || nativeModelId === inventory.currentModelId || model2.modelIdAliases?.includes(inventory.currentModelId))) {
16622
16863
  if (defaultModel && defaultModel.id !== ref.id) {
16623
16864
  throw new HermesInventoryError("Hermes configured Model matches multiple Provider routes");
16624
16865
  }
@@ -16629,8 +16870,8 @@ function catalogModelsFromInventory(inventory) {
16629
16870
  seen.add(ref.id);
16630
16871
  models.push({
16631
16872
  ref,
16632
- label: `${model.provider} / ${model.label}`,
16633
- description: `Provider: ${model.provider}`
16873
+ label: `${model2.provider} / ${model2.label}`,
16874
+ description: `Provider: ${model2.provider}`
16634
16875
  });
16635
16876
  }
16636
16877
  if (inventory.currentModelId && models.length > 0 && !defaultModel) {
@@ -16672,7 +16913,18 @@ ${HERMES_DELEGATION_GUIDANCE}
16672
16913
  },
16673
16914
  // Reserve RPC stdout before native plugin imports. The registration is
16674
16915
  // process-local; no plugin is installed and no user config is changed.
16675
- bootstrap: `from tui_gateway import server
16916
+ //
16917
+ // ``hermes_bootstrap`` must run before ``tui_gateway.server`` is imported:
16918
+ // the gateway spawn uses ``python -I``, so PYTHONPATH and the launcher's
16919
+ // activation are stripped. Hermes's own entry point (``tui_gateway/entry.py``)
16920
+ // imports this module first to put the selected dependency environment on
16921
+ // ``sys.path``; skipping it makes bare third-party imports (e.g.
16922
+ // ``hermes_yaml`` -> ``ruamel``) fail on interpreters whose site-packages
16923
+ // do not already carry Hermes's dependencies. ``hermes_bootstrap`` is
16924
+ // import-safe here for the same reason entry.py relies on it: stdlib-only
16925
+ // at import time, so nothing can shadow it from the launch directory.
16926
+ bootstrap: `import hermes_bootstrap
16927
+ from tui_gateway import server
16676
16928
  from pathlib import Path
16677
16929
  from hermes_cli.plugins import PluginContext, PluginManifest, get_plugin_manager
16678
16930
  PluginContext(PluginManifest(name="codexhost-runtime"), get_plugin_manager()).register_skill(
@@ -17805,14 +18057,14 @@ function gatewayDiff(text2) {
17805
18057
  if (!text2 || text2.length > 1024 * 1024)
17806
18058
  return [];
17807
18059
  const result = [];
17808
- let path8 = "";
18060
+ let path9 = "";
17809
18061
  let inHunk = false;
17810
18062
  let oldLines = [], newLines = [];
17811
18063
  const flush = () => {
17812
- if (path8)
18064
+ if (path9)
17813
18065
  result.push({
17814
18066
  type: "diff",
17815
- path: path8,
18067
+ path: path9,
17816
18068
  oldText: oldLines.join("\n"),
17817
18069
  newText: newLines.join("\n")
17818
18070
  });
@@ -17825,24 +18077,24 @@ function gatewayDiff(text2) {
17825
18077
  if (header) {
17826
18078
  flush();
17827
18079
  inHunk = false;
17828
- path8 = (header[2] === "/dev/null" ? header[1] ?? "" : header[2] ?? "").replace(/^[ab]\//u, "");
18080
+ path9 = (header[2] === "/dev/null" ? header[1] ?? "" : header[2] ?? "").replace(/^[ab]\//u, "");
17829
18081
  continue;
17830
18082
  }
17831
18083
  if (line.startsWith("--- ") && !inHunk) {
17832
18084
  flush();
17833
- path8 = line.slice(4).replace(/^a\//u, "");
18085
+ path9 = line.slice(4).replace(/^a\//u, "");
17834
18086
  } else if (line.startsWith("+++ ") && !inHunk) {
17835
18087
  const next = line.slice(4);
17836
18088
  if (next !== "/dev/null")
17837
- path8 = next.replace(/^b\//u, "");
18089
+ path9 = next.replace(/^b\//u, "");
17838
18090
  } else if (line.startsWith("@@")) {
17839
18091
  inHunk = true;
17840
18092
  continue;
17841
- } else if (path8 && line.startsWith("-"))
18093
+ } else if (path9 && line.startsWith("-"))
17842
18094
  oldLines.push(line.slice(1));
17843
- else if (path8 && line.startsWith("+"))
18095
+ else if (path9 && line.startsWith("+"))
17844
18096
  newLines.push(line.slice(1));
17845
- else if (path8 && line.startsWith(" ")) {
18097
+ else if (path9 && line.startsWith(" ")) {
17846
18098
  oldLines.push(line.slice(1));
17847
18099
  newLines.push(line.slice(1));
17848
18100
  }
@@ -17916,9 +18168,9 @@ var HermesGatewaySessionTransport = class {
17916
18168
  session_id: this.sessionId
17917
18169
  });
17918
18170
  const currentThinkingOptionId = gatewayString(reasoning.value);
17919
- const model = gatewayString(this.#info.model);
18171
+ const model2 = gatewayString(this.#info.model);
17920
18172
  const provider = gatewayString(this.#info.provider);
17921
- const currentModelId = provider ? `${provider}:${model}` : model;
18173
+ const currentModelId = provider ? `${provider}:${model2}` : model2;
17922
18174
  return {
17923
18175
  sessionId: this.nativeSessionId,
17924
18176
  session: {
@@ -17926,7 +18178,7 @@ var HermesGatewaySessionTransport = class {
17926
18178
  models: currentModelId ? {
17927
18179
  currentModelId,
17928
18180
  availableModels: [
17929
- { modelId: currentModelId, name: provider ? `${provider} / ${model}` : model }
18181
+ { modelId: currentModelId, name: provider ? `${provider} / ${model2}` : model2 }
17930
18182
  ]
17931
18183
  } : null,
17932
18184
  modes: {
@@ -18266,8 +18518,150 @@ var HermesGatewaySessionTransport = class {
18266
18518
  }
18267
18519
  };
18268
18520
 
18269
- // dist/gateway-open.js
18521
+ // dist/usage-statistics.js
18522
+ import os3 from "node:os";
18270
18523
  import path7 from "node:path";
18524
+ import { lstat } from "node:fs/promises";
18525
+
18526
+ // ../../harness-adapter/dist/usage-statistics.js
18527
+ var MAX_SESSION_ID_LENGTH = 512;
18528
+ var MAX_CWD_LENGTH = 4096;
18529
+ var MAX_SESSION_TITLE_LENGTH = 200;
18530
+ function usageSessionTitle(value) {
18531
+ if (typeof value !== "string")
18532
+ return void 0;
18533
+ const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
18534
+ if (!normalized)
18535
+ return void 0;
18536
+ if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
18537
+ return normalized;
18538
+ const characters = [...normalized];
18539
+ if (characters.length <= MAX_SESSION_TITLE_LENGTH)
18540
+ return normalized;
18541
+ return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
18542
+ }
18543
+ function sessionIdOk(value) {
18544
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
18545
+ }
18546
+ function cwdOk(value) {
18547
+ 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("\\\\"));
18548
+ }
18549
+ function withUsageSession(entry, session) {
18550
+ const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
18551
+ const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
18552
+ const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
18553
+ if (sessionId === void 0 && cwd === void 0)
18554
+ return entry;
18555
+ return {
18556
+ ...entry,
18557
+ ...sessionId !== void 0 ? { sessionId } : {},
18558
+ ...cwd !== void 0 ? { cwd } : {},
18559
+ ...sessionTitle !== void 0 ? { sessionTitle } : {}
18560
+ };
18561
+ }
18562
+ function usageEntryFromRequest(request, occurredAtMs) {
18563
+ if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
18564
+ return null;
18565
+ return {
18566
+ id: request.requestId,
18567
+ occurredAtMs,
18568
+ ...request.model !== void 0 ? { model: request.model } : {},
18569
+ inputTokens: request.inputTokens,
18570
+ ...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
18571
+ ...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
18572
+ ...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
18573
+ outputTokens: request.outputTokens,
18574
+ ...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
18575
+ };
18576
+ }
18577
+
18578
+ // dist/usage-statistics.js
18579
+ function hermesStateDatabasePath(environment) {
18580
+ const home = environment.HOME || environment.USERPROFILE || os3.homedir();
18581
+ const configured = environment.HERMES_HOME;
18582
+ return path7.resolve(configured ? path7.join(configured, "state.db") : path7.join(home, ".hermes", "state.db"));
18583
+ }
18584
+ async function fingerprint(file2) {
18585
+ const info = await lstat(file2).catch(() => null);
18586
+ if (!info?.isFile())
18587
+ return null;
18588
+ const wal = await lstat(`${file2}-wal`).catch(() => null);
18589
+ return `${info.ino}:${info.size}:${info.mtimeMs}:${wal ? `${wal.size}:${wal.mtimeMs}` : "-"}`;
18590
+ }
18591
+ function tokenCount(value) {
18592
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
18593
+ }
18594
+ function hermesUsageEntry(row) {
18595
+ const apiCalls = tokenCount(row.api_call_count) ? row.api_call_count : 0;
18596
+ const input = tokenCount(row.input_tokens) ? row.input_tokens : 0;
18597
+ const output = tokenCount(row.output_tokens) ? row.output_tokens : 0;
18598
+ const cacheRead = tokenCount(row.cache_read_tokens) ? row.cache_read_tokens : 0;
18599
+ const cacheWrite = tokenCount(row.cache_write_tokens) ? row.cache_write_tokens : 0;
18600
+ const reasoning = tokenCount(row.reasoning_tokens) ? row.reasoning_tokens : 0;
18601
+ if (apiCalls === 0 && input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
18602
+ return null;
18603
+ }
18604
+ const id = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
18605
+ const epochSeconds = (value) => {
18606
+ if (typeof value !== "number" || !Number.isFinite(value))
18607
+ return null;
18608
+ const ms = Math.floor(value * 1e3);
18609
+ return Number.isSafeInteger(ms) && !Number.isNaN(new Date(ms).getTime()) ? ms : null;
18610
+ };
18611
+ const at = epochSeconds(row.last_activity_at) ?? epochSeconds(row.started_at);
18612
+ if (id === null || at === null)
18613
+ return null;
18614
+ const request = {
18615
+ requestId: id,
18616
+ ...typeof row.model === "string" && row.model.length > 0 ? { model: row.model } : {},
18617
+ inputTokens: input + cacheRead + cacheWrite,
18618
+ outputTokens: output,
18619
+ ...reasoning > 0 ? { reasoningOutputTokens: reasoning } : {},
18620
+ // Both buckets exist whenever either does: the writer records them as a pair.
18621
+ ...cacheRead > 0 || cacheWrite > 0 ? { cachedInputTokens: cacheRead, cacheWriteInputTokens: cacheWrite } : {}
18622
+ };
18623
+ const entry = usageEntryFromRequest(request, at);
18624
+ if (!entry)
18625
+ return null;
18626
+ return withUsageSession(entry, {
18627
+ sessionId: id,
18628
+ cwd: typeof row.cwd === "string" ? row.cwd : void 0,
18629
+ title: usageSessionTitle(row.title ?? row.display_name)
18630
+ });
18631
+ }
18632
+ var SESSIONS_QUERY = `
18633
+ SELECT id, model, cwd, title, display_name, started_at, last_activity_at,
18634
+ api_call_count, input_tokens, output_tokens, cache_read_tokens,
18635
+ cache_write_tokens, reasoning_tokens
18636
+ FROM sessions`;
18637
+ async function readHermesUsage(file2) {
18638
+ const { DatabaseSync } = await import("node:sqlite");
18639
+ const database = new DatabaseSync(file2, { readOnly: true });
18640
+ try {
18641
+ const entries = [];
18642
+ for (const row of database.prepare(SESSIONS_QUERY).iterate()) {
18643
+ const entry = hermesUsageEntry(row);
18644
+ if (entry)
18645
+ entries.push(entry);
18646
+ }
18647
+ return entries;
18648
+ } finally {
18649
+ database.close();
18650
+ }
18651
+ }
18652
+ function createHermesUsageStatistics(environment) {
18653
+ return Object.freeze({
18654
+ async listSources() {
18655
+ const file2 = hermesStateDatabasePath(environment);
18656
+ const stamp = await fingerprint(file2);
18657
+ return stamp ? [{ id: file2, fingerprint: stamp }] : [];
18658
+ },
18659
+ readSource: (id) => readHermesUsage(id)
18660
+ });
18661
+ }
18662
+
18663
+ // dist/gateway-open.js
18664
+ import path8 from "node:path";
18271
18665
  import { realpath } from "node:fs/promises";
18272
18666
 
18273
18667
  // dist/hermes-session.js
@@ -18477,16 +18871,16 @@ var Diff = class {
18477
18871
  }
18478
18872
  }
18479
18873
  }
18480
- addToPath(path8, added, removed, oldPosInc, options) {
18481
- const last = path8.lastComponent;
18874
+ addToPath(path9, added, removed, oldPosInc, options) {
18875
+ const last = path9.lastComponent;
18482
18876
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
18483
18877
  return {
18484
- oldPos: path8.oldPos + oldPosInc,
18878
+ oldPos: path9.oldPos + oldPosInc,
18485
18879
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
18486
18880
  };
18487
18881
  } else {
18488
18882
  return {
18489
- oldPos: path8.oldPos + oldPosInc,
18883
+ oldPos: path9.oldPos + oldPosInc,
18490
18884
  lastComponent: { count: 1, added, removed, previousComponent: last }
18491
18885
  };
18492
18886
  }
@@ -18801,8 +19195,8 @@ function hermesFileChanges(update) {
18801
19195
  for (const block of update.content ?? []) {
18802
19196
  if (block.type !== "diff")
18803
19197
  continue;
18804
- const { path: path8, oldText, newText } = block;
18805
- if (!path8.trim() || /[\0\r\n]/u.test(path8) || typeof newText !== "string")
19198
+ const { path: path9, oldText, newText } = block;
19199
+ if (!path9.trim() || /[\0\r\n]/u.test(path9) || typeof newText !== "string")
18806
19200
  continue;
18807
19201
  if (oldText === newText)
18808
19202
  continue;
@@ -18810,10 +19204,10 @@ function hermesFileChanges(update) {
18810
19204
  if (bytes > MAX_DIFF_BYTES || changes.length === MAX_DIFFS)
18811
19205
  return [];
18812
19206
  changes.push({
18813
- path: path8,
19207
+ path: path9,
18814
19208
  kind: "update",
18815
19209
  diffScope: "fragment",
18816
- unifiedDiff: createTwoFilesPatch(path8, path8, oldText ?? "", newText, "", "", {
19210
+ unifiedDiff: createTwoFilesPatch(path9, path9, oldText ?? "", newText, "", "", {
18817
19211
  context: 3
18818
19212
  })
18819
19213
  });
@@ -19616,7 +20010,7 @@ ${reason}` }
19616
20010
 
19617
20011
  // dist/gateway-open.js
19618
20012
  async function sameDirectory(left, right) {
19619
- return await realpath(left).catch(() => path7.resolve(left)) === await realpath(right).catch(() => path7.resolve(right));
20013
+ return await realpath(left).catch(() => path8.resolve(left)) === await realpath(right).catch(() => path8.resolve(right));
19620
20014
  }
19621
20015
  var gatewayCapabilities = {
19622
20016
  configuration: {
@@ -19658,8 +20052,8 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
19658
20052
  throw new HermesGatewayHistoryError("unsupported", "Hermes gateway supports only native approval policy and session YOLO");
19659
20053
  if (input.kind === "create" && input.executionPolicy === "unattended-full-access" && mode && mode !== "dont_ask")
19660
20054
  throw new HermesGatewayHistoryError("invalidRequest", "unattended-full-access requires dont_ask");
19661
- const model = input.kind !== "fork" && input.model ? decodeHermesModelRefId(input.model.id) : null;
19662
- if (input.kind !== "fork" && input.model && !model)
20055
+ const model2 = input.kind !== "fork" && input.model ? decodeHermesModelRefId(input.model.id) : null;
20056
+ if (input.kind !== "fork" && input.model && !model2)
19663
20057
  throw new HermesGatewayHistoryError("invalidRequest", "Model Ref does not belong to Hermes");
19664
20058
  if (source && gatewayRecord(source.locator).cwd && !await sameDirectory(String(gatewayRecord(source?.locator).cwd), input.cwd))
19665
20059
  throw new HermesGatewayHistoryError("unsupported", "Hermes gateway preserves the native Session working directory");
@@ -19677,7 +20071,7 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
19677
20071
  });
19678
20072
  nativeRef = await sourceHistory.derive(input.kind === "fork" ? { checkpoint: input.checkpoint } : { rollbackLastTurn: true });
19679
20073
  }
19680
- const choice = model ? await resolveGatewayModel(transport, model) : null;
20074
+ const choice = model2 ? await resolveGatewayModel(transport, model2) : null;
19681
20075
  const response = await transport.request(nativeRef ? "session.resume" : "session.create", nativeRef ? { session_id: nativeRef.nativeSessionId, eager_build: true, omit_messages: true } : {
19682
20076
  cwd: input.cwd,
19683
20077
  close_on_disconnect: true,
@@ -19705,8 +20099,8 @@ async function openGatewaySession(input, transport, onSettle, inheritedPermissio
19705
20099
  const physicalId = await bridge.history.resolvePhysicalSessionId();
19706
20100
  if (gatewayString(info.stored_session_id) !== physicalId)
19707
20101
  throw new Error("Hermes live Session and persisted history identities differ");
19708
- if (model)
19709
- await bridge.setModel(model);
20102
+ if (model2)
20103
+ await bridge.setModel(model2);
19710
20104
  if (input.kind !== "fork" && input.thinkingOptionId)
19711
20105
  await bridge.setThinking(input.thinkingOptionId);
19712
20106
  const desiredMode = input.kind === "create" && input.executionPolicy === "unattended-full-access" ? "dont_ask" : mode;
@@ -19758,8 +20152,10 @@ var HermesAdapter = class {
19758
20152
  #gatewayTransports = /* @__PURE__ */ new Set();
19759
20153
  #gatewayProbes = /* @__PURE__ */ new Map();
19760
20154
  #openingNativeIds = /* @__PURE__ */ new Set();
20155
+ usageStatistics;
19761
20156
  constructor(options = {}) {
19762
20157
  this.#options = options;
20158
+ this.usageStatistics = createHermesUsageStatistics(options.environment ?? process.env);
19763
20159
  }
19764
20160
  async inspect(input = {}) {
19765
20161
  const cwd = input.cwd ?? process.cwd();