@liberseek/boft-cli-linux-x64 0.8.0 → 0.8.2
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.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +127 -50
- package/app/console-web.js +3804 -4074
- package/app/desktop-controller.mjs +44 -4
- package/app/host-runtime.mjs +1009 -258
- package/app/plugins/antigravity/plugin.mjs +60 -8
- package/app/plugins/claude-code/plugin.mjs +34939 -23926
- package/app/plugins/codebuddy/plugin.mjs +157 -12
- package/app/plugins/codex-usage/plugin.mjs +699 -30
- package/app/plugins/cursor-cli/plugin.mjs +79 -11
- package/app/plugins/deepseek-harness/manifest.json +2 -2
- package/app/plugins/deepseek-harness/plugin.mjs +226 -29
- package/app/plugins/grok/plugin.mjs +107 -13
- package/app/plugins/hermes/plugin.mjs +255 -44
- package/app/plugins/kimi-code/plugin.mjs +72 -10
- package/app/plugins/kiro-cli/plugin.mjs +53 -4
- package/app/plugins/muse/plugin.mjs +44 -4
- package/app/plugins/omp/plugin.mjs +77 -10
- package/app/plugins/opencode/plugin.mjs +86 -9
- package/app/plugins/pi/plugin.mjs +121 -46
- package/app/plugins/qoder/plugin.mjs +104 -7
- package/app/plugins/qoder-cn/plugin.mjs +104 -7
- package/app/plugins/workbuddy/plugin.mjs +274 -16
- package/app/plugins/zcode/plugin.mjs +86 -7
- package/app/renderer-extension.js +12529 -8157
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +4 -4
|
@@ -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,
|
|
1142
|
-
if (!
|
|
1141
|
+
function getElementAtPath(obj, path9) {
|
|
1142
|
+
if (!path9)
|
|
1143
1143
|
return obj;
|
|
1144
|
-
return
|
|
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(
|
|
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(
|
|
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,
|
|
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 }, [...
|
|
1707
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
1708
1708
|
} else if (issue2.code === "invalid_key") {
|
|
1709
|
-
processError({ issues: issue2.issues }, [...
|
|
1709
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1710
1710
|
} else if (issue2.code === "invalid_element") {
|
|
1711
|
-
processError({ issues: issue2.issues }, [...
|
|
1711
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1712
1712
|
} else {
|
|
1713
|
-
const fullpath = [...
|
|
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,
|
|
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 }, [...
|
|
1744
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
1745
1745
|
} else if (issue2.code === "invalid_key") {
|
|
1746
|
-
processError({ issues: issue2.issues }, [...
|
|
1746
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1747
1747
|
} else if (issue2.code === "invalid_element") {
|
|
1748
|
-
processError({ issues: issue2.issues }, [...
|
|
1748
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
1749
1749
|
} else {
|
|
1750
|
-
const fullpath = [...
|
|
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
|
|
1783
|
-
for (const seg of
|
|
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
|
|
14476
|
-
if (
|
|
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 (
|
|
14481
|
-
const key =
|
|
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({
|
|
@@ -15043,6 +15052,8 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
|
15043
15052
|
harness,
|
|
15044
15053
|
sessionId: external_exports.string().min(1).max(512),
|
|
15045
15054
|
project: project.nullable(),
|
|
15055
|
+
/** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
|
|
15056
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
15046
15057
|
/** Models the session used, most requests first. */
|
|
15047
15058
|
models: external_exports.array(model).max(16),
|
|
15048
15059
|
firstAtMs: count,
|
|
@@ -15109,7 +15120,12 @@ var usageStatisticsResultSchema = external_exports.strictObject({
|
|
|
15109
15120
|
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
15110
15121
|
* requests without a native session are not listed here but count everywhere else.
|
|
15111
15122
|
*/
|
|
15112
|
-
sessions: external_exports.array(usageStatisticsSessionSchema).max(100)
|
|
15123
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
|
|
15124
|
+
/**
|
|
15125
|
+
* The sessions last active in the range, newest first, all filters applied. Optional for older
|
|
15126
|
+
* Hosts; missing is treated as no list rather than no sessions.
|
|
15127
|
+
*/
|
|
15128
|
+
recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
|
|
15113
15129
|
});
|
|
15114
15130
|
|
|
15115
15131
|
// ../../shared-contracts/dist/ids.js
|
|
@@ -15378,8 +15394,24 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
15378
15394
|
}
|
|
15379
15395
|
});
|
|
15380
15396
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
15397
|
+
var accountCreditsPeriodSchema = external_exports.enum([
|
|
15398
|
+
"weekly",
|
|
15399
|
+
"monthly",
|
|
15400
|
+
"five_hour",
|
|
15401
|
+
"seven_day",
|
|
15402
|
+
"unknown"
|
|
15403
|
+
]);
|
|
15404
|
+
var accountCreditsScopeSchema = external_exports.object({
|
|
15405
|
+
id: external_exports.string().min(1).max(256),
|
|
15406
|
+
label: external_exports.string().min(1).max(256),
|
|
15407
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
15408
|
+
}).strict();
|
|
15381
15409
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
15382
15410
|
product: external_exports.string().min(1),
|
|
15411
|
+
/** Native period and scope, never inferred from the display name. */
|
|
15412
|
+
periodType: accountCreditsPeriodSchema.optional(),
|
|
15413
|
+
scope: accountCreditsScopeSchema.optional(),
|
|
15414
|
+
localizations: harnessLocalizationsSchema.optional(),
|
|
15383
15415
|
used: external_exports.number().finite().nonnegative().optional(),
|
|
15384
15416
|
// Zero is a real empty cap, not an absent field.
|
|
15385
15417
|
limit: external_exports.number().finite().nonnegative().optional(),
|
|
@@ -15401,8 +15433,10 @@ var accountCreditsSnapshotSchema = external_exports.object({
|
|
|
15401
15433
|
label: external_exports.string().min(1).optional(),
|
|
15402
15434
|
usedPercent: usagePercentSchema.optional(),
|
|
15403
15435
|
remaining: external_exports.number().finite().optional(),
|
|
15436
|
+
scope: accountCreditsScopeSchema.optional(),
|
|
15437
|
+
localizations: harnessLocalizationsSchema.optional(),
|
|
15404
15438
|
resetsAt: external_exports.string().min(1).optional(),
|
|
15405
|
-
periodType:
|
|
15439
|
+
periodType: accountCreditsPeriodSchema,
|
|
15406
15440
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
15407
15441
|
resetCredits: accountResetCreditsSchema.optional()
|
|
15408
15442
|
}).strict().superRefine((credits, context) => {
|
|
@@ -15427,7 +15461,9 @@ var threadUsageInspectionParamsSchema = external_exports.object({
|
|
|
15427
15461
|
var threadUsageInspectionSchema = external_exports.object({
|
|
15428
15462
|
threadId: hostThreadIdSchema,
|
|
15429
15463
|
usage: threadUsageSnapshotSchema.nullable(),
|
|
15430
|
-
accountCredits: accountCreditsSnapshotSchema.optional()
|
|
15464
|
+
accountCredits: accountCreditsSnapshotSchema.optional(),
|
|
15465
|
+
/** Whether this source can provide cached account quota independently of usage. */
|
|
15466
|
+
accountCreditsSupported: external_exports.boolean().optional()
|
|
15431
15467
|
}).strict();
|
|
15432
15468
|
|
|
15433
15469
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
@@ -15554,7 +15590,8 @@ var harnessPermissionModeSchema = external_exports.object({
|
|
|
15554
15590
|
id: harnessPermissionModeIdSchema,
|
|
15555
15591
|
label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
|
|
15556
15592
|
description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
|
|
15557
|
-
dangerous: external_exports.boolean().optional()
|
|
15593
|
+
dangerous: external_exports.boolean().optional(),
|
|
15594
|
+
localizations: harnessLocalizationsSchema.optional()
|
|
15558
15595
|
}).strict();
|
|
15559
15596
|
var harnessPermissionModeCatalogSchema = external_exports.object({
|
|
15560
15597
|
modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
|
|
@@ -15877,6 +15914,8 @@ var harnessInstallationStateSchema = external_exports.object({
|
|
|
15877
15914
|
// Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
|
|
15878
15915
|
message: external_exports.string().max(2048).optional(),
|
|
15879
15916
|
messageCode: external_exports.string().min(1).max(128).optional(),
|
|
15917
|
+
/** Safe plugin-owned explanation, distinct from raw diagnostic message. */
|
|
15918
|
+
notice: harnessLocalizedTextSchema.optional(),
|
|
15880
15919
|
latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
|
|
15881
15920
|
}).strict();
|
|
15882
15921
|
|
|
@@ -16015,6 +16054,7 @@ var harnessCommandDescriptorSchema = external_exports.object({
|
|
|
16015
16054
|
invocation: commandInvocationSchema,
|
|
16016
16055
|
label: commandLabelSchema,
|
|
16017
16056
|
description: commandDescriptionSchema.optional(),
|
|
16057
|
+
localizations: harnessLocalizationsSchema.optional(),
|
|
16018
16058
|
argumentMode: external_exports.enum(["none", "text"]),
|
|
16019
16059
|
/**
|
|
16020
16060
|
* Native distinction reported by the Harness. Omitted when the Harness does
|
|
@@ -18050,14 +18090,14 @@ function gatewayDiff(text2) {
|
|
|
18050
18090
|
if (!text2 || text2.length > 1024 * 1024)
|
|
18051
18091
|
return [];
|
|
18052
18092
|
const result = [];
|
|
18053
|
-
let
|
|
18093
|
+
let path9 = "";
|
|
18054
18094
|
let inHunk = false;
|
|
18055
18095
|
let oldLines = [], newLines = [];
|
|
18056
18096
|
const flush = () => {
|
|
18057
|
-
if (
|
|
18097
|
+
if (path9)
|
|
18058
18098
|
result.push({
|
|
18059
18099
|
type: "diff",
|
|
18060
|
-
path:
|
|
18100
|
+
path: path9,
|
|
18061
18101
|
oldText: oldLines.join("\n"),
|
|
18062
18102
|
newText: newLines.join("\n")
|
|
18063
18103
|
});
|
|
@@ -18070,24 +18110,24 @@ function gatewayDiff(text2) {
|
|
|
18070
18110
|
if (header) {
|
|
18071
18111
|
flush();
|
|
18072
18112
|
inHunk = false;
|
|
18073
|
-
|
|
18113
|
+
path9 = (header[2] === "/dev/null" ? header[1] ?? "" : header[2] ?? "").replace(/^[ab]\//u, "");
|
|
18074
18114
|
continue;
|
|
18075
18115
|
}
|
|
18076
18116
|
if (line.startsWith("--- ") && !inHunk) {
|
|
18077
18117
|
flush();
|
|
18078
|
-
|
|
18118
|
+
path9 = line.slice(4).replace(/^a\//u, "");
|
|
18079
18119
|
} else if (line.startsWith("+++ ") && !inHunk) {
|
|
18080
18120
|
const next = line.slice(4);
|
|
18081
18121
|
if (next !== "/dev/null")
|
|
18082
|
-
|
|
18122
|
+
path9 = next.replace(/^b\//u, "");
|
|
18083
18123
|
} else if (line.startsWith("@@")) {
|
|
18084
18124
|
inHunk = true;
|
|
18085
18125
|
continue;
|
|
18086
|
-
} else if (
|
|
18126
|
+
} else if (path9 && line.startsWith("-"))
|
|
18087
18127
|
oldLines.push(line.slice(1));
|
|
18088
|
-
else if (
|
|
18128
|
+
else if (path9 && line.startsWith("+"))
|
|
18089
18129
|
newLines.push(line.slice(1));
|
|
18090
|
-
else if (
|
|
18130
|
+
else if (path9 && line.startsWith(" ")) {
|
|
18091
18131
|
oldLines.push(line.slice(1));
|
|
18092
18132
|
newLines.push(line.slice(1));
|
|
18093
18133
|
}
|
|
@@ -18511,8 +18551,150 @@ var HermesGatewaySessionTransport = class {
|
|
|
18511
18551
|
}
|
|
18512
18552
|
};
|
|
18513
18553
|
|
|
18514
|
-
// dist/
|
|
18554
|
+
// dist/usage-statistics.js
|
|
18555
|
+
import os3 from "node:os";
|
|
18515
18556
|
import path7 from "node:path";
|
|
18557
|
+
import { lstat } from "node:fs/promises";
|
|
18558
|
+
|
|
18559
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
18560
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
18561
|
+
var MAX_CWD_LENGTH = 4096;
|
|
18562
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
18563
|
+
function usageSessionTitle(value) {
|
|
18564
|
+
if (typeof value !== "string")
|
|
18565
|
+
return void 0;
|
|
18566
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
18567
|
+
if (!normalized)
|
|
18568
|
+
return void 0;
|
|
18569
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
18570
|
+
return normalized;
|
|
18571
|
+
const characters = [...normalized];
|
|
18572
|
+
if (characters.length <= MAX_SESSION_TITLE_LENGTH)
|
|
18573
|
+
return normalized;
|
|
18574
|
+
return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
|
|
18575
|
+
}
|
|
18576
|
+
function sessionIdOk(value) {
|
|
18577
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
18578
|
+
}
|
|
18579
|
+
function cwdOk(value) {
|
|
18580
|
+
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("\\\\"));
|
|
18581
|
+
}
|
|
18582
|
+
function withUsageSession(entry, session) {
|
|
18583
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
18584
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
18585
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
18586
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
18587
|
+
return entry;
|
|
18588
|
+
return {
|
|
18589
|
+
...entry,
|
|
18590
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
18591
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
18592
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
18593
|
+
};
|
|
18594
|
+
}
|
|
18595
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
18596
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
18597
|
+
return null;
|
|
18598
|
+
return {
|
|
18599
|
+
id: request.requestId,
|
|
18600
|
+
occurredAtMs,
|
|
18601
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
18602
|
+
inputTokens: request.inputTokens,
|
|
18603
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
18604
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
18605
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
18606
|
+
outputTokens: request.outputTokens,
|
|
18607
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
18608
|
+
};
|
|
18609
|
+
}
|
|
18610
|
+
|
|
18611
|
+
// dist/usage-statistics.js
|
|
18612
|
+
function hermesStateDatabasePath(environment) {
|
|
18613
|
+
const home = environment.HOME || environment.USERPROFILE || os3.homedir();
|
|
18614
|
+
const configured = environment.HERMES_HOME;
|
|
18615
|
+
return path7.resolve(configured ? path7.join(configured, "state.db") : path7.join(home, ".hermes", "state.db"));
|
|
18616
|
+
}
|
|
18617
|
+
async function fingerprint(file2) {
|
|
18618
|
+
const info = await lstat(file2).catch(() => null);
|
|
18619
|
+
if (!info?.isFile())
|
|
18620
|
+
return null;
|
|
18621
|
+
const wal = await lstat(`${file2}-wal`).catch(() => null);
|
|
18622
|
+
return `${info.ino}:${info.size}:${info.mtimeMs}:${wal ? `${wal.size}:${wal.mtimeMs}` : "-"}`;
|
|
18623
|
+
}
|
|
18624
|
+
function tokenCount(value) {
|
|
18625
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
18626
|
+
}
|
|
18627
|
+
function hermesUsageEntry(row) {
|
|
18628
|
+
const apiCalls = tokenCount(row.api_call_count) ? row.api_call_count : 0;
|
|
18629
|
+
const input = tokenCount(row.input_tokens) ? row.input_tokens : 0;
|
|
18630
|
+
const output = tokenCount(row.output_tokens) ? row.output_tokens : 0;
|
|
18631
|
+
const cacheRead = tokenCount(row.cache_read_tokens) ? row.cache_read_tokens : 0;
|
|
18632
|
+
const cacheWrite = tokenCount(row.cache_write_tokens) ? row.cache_write_tokens : 0;
|
|
18633
|
+
const reasoning = tokenCount(row.reasoning_tokens) ? row.reasoning_tokens : 0;
|
|
18634
|
+
if (apiCalls === 0 && input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0) {
|
|
18635
|
+
return null;
|
|
18636
|
+
}
|
|
18637
|
+
const id = typeof row.id === "string" && row.id.length > 0 ? row.id : null;
|
|
18638
|
+
const epochSeconds = (value) => {
|
|
18639
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
18640
|
+
return null;
|
|
18641
|
+
const ms = Math.floor(value * 1e3);
|
|
18642
|
+
return Number.isSafeInteger(ms) && !Number.isNaN(new Date(ms).getTime()) ? ms : null;
|
|
18643
|
+
};
|
|
18644
|
+
const at = epochSeconds(row.last_activity_at) ?? epochSeconds(row.started_at);
|
|
18645
|
+
if (id === null || at === null)
|
|
18646
|
+
return null;
|
|
18647
|
+
const request = {
|
|
18648
|
+
requestId: id,
|
|
18649
|
+
...typeof row.model === "string" && row.model.length > 0 ? { model: row.model } : {},
|
|
18650
|
+
inputTokens: input + cacheRead + cacheWrite,
|
|
18651
|
+
outputTokens: output,
|
|
18652
|
+
...reasoning > 0 ? { reasoningOutputTokens: reasoning } : {},
|
|
18653
|
+
// Both buckets exist whenever either does: the writer records them as a pair.
|
|
18654
|
+
...cacheRead > 0 || cacheWrite > 0 ? { cachedInputTokens: cacheRead, cacheWriteInputTokens: cacheWrite } : {}
|
|
18655
|
+
};
|
|
18656
|
+
const entry = usageEntryFromRequest(request, at);
|
|
18657
|
+
if (!entry)
|
|
18658
|
+
return null;
|
|
18659
|
+
return withUsageSession(entry, {
|
|
18660
|
+
sessionId: id,
|
|
18661
|
+
cwd: typeof row.cwd === "string" ? row.cwd : void 0,
|
|
18662
|
+
title: usageSessionTitle(row.title ?? row.display_name)
|
|
18663
|
+
});
|
|
18664
|
+
}
|
|
18665
|
+
var SESSIONS_QUERY = `
|
|
18666
|
+
SELECT id, model, cwd, title, display_name, started_at, last_activity_at,
|
|
18667
|
+
api_call_count, input_tokens, output_tokens, cache_read_tokens,
|
|
18668
|
+
cache_write_tokens, reasoning_tokens
|
|
18669
|
+
FROM sessions`;
|
|
18670
|
+
async function readHermesUsage(file2) {
|
|
18671
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
18672
|
+
const database = new DatabaseSync(file2, { readOnly: true });
|
|
18673
|
+
try {
|
|
18674
|
+
const entries = [];
|
|
18675
|
+
for (const row of database.prepare(SESSIONS_QUERY).iterate()) {
|
|
18676
|
+
const entry = hermesUsageEntry(row);
|
|
18677
|
+
if (entry)
|
|
18678
|
+
entries.push(entry);
|
|
18679
|
+
}
|
|
18680
|
+
return entries;
|
|
18681
|
+
} finally {
|
|
18682
|
+
database.close();
|
|
18683
|
+
}
|
|
18684
|
+
}
|
|
18685
|
+
function createHermesUsageStatistics(environment) {
|
|
18686
|
+
return Object.freeze({
|
|
18687
|
+
async listSources() {
|
|
18688
|
+
const file2 = hermesStateDatabasePath(environment);
|
|
18689
|
+
const stamp = await fingerprint(file2);
|
|
18690
|
+
return stamp ? [{ id: file2, fingerprint: stamp }] : [];
|
|
18691
|
+
},
|
|
18692
|
+
readSource: (id) => readHermesUsage(id)
|
|
18693
|
+
});
|
|
18694
|
+
}
|
|
18695
|
+
|
|
18696
|
+
// dist/gateway-open.js
|
|
18697
|
+
import path8 from "node:path";
|
|
18516
18698
|
import { realpath } from "node:fs/promises";
|
|
18517
18699
|
|
|
18518
18700
|
// dist/hermes-session.js
|
|
@@ -18722,16 +18904,16 @@ var Diff = class {
|
|
|
18722
18904
|
}
|
|
18723
18905
|
}
|
|
18724
18906
|
}
|
|
18725
|
-
addToPath(
|
|
18726
|
-
const last =
|
|
18907
|
+
addToPath(path9, added, removed, oldPosInc, options) {
|
|
18908
|
+
const last = path9.lastComponent;
|
|
18727
18909
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
18728
18910
|
return {
|
|
18729
|
-
oldPos:
|
|
18911
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
18730
18912
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
18731
18913
|
};
|
|
18732
18914
|
} else {
|
|
18733
18915
|
return {
|
|
18734
|
-
oldPos:
|
|
18916
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
18735
18917
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
18736
18918
|
};
|
|
18737
18919
|
}
|
|
@@ -19046,8 +19228,8 @@ function hermesFileChanges(update) {
|
|
|
19046
19228
|
for (const block of update.content ?? []) {
|
|
19047
19229
|
if (block.type !== "diff")
|
|
19048
19230
|
continue;
|
|
19049
|
-
const { path:
|
|
19050
|
-
if (!
|
|
19231
|
+
const { path: path9, oldText, newText } = block;
|
|
19232
|
+
if (!path9.trim() || /[\0\r\n]/u.test(path9) || typeof newText !== "string")
|
|
19051
19233
|
continue;
|
|
19052
19234
|
if (oldText === newText)
|
|
19053
19235
|
continue;
|
|
@@ -19055,10 +19237,10 @@ function hermesFileChanges(update) {
|
|
|
19055
19237
|
if (bytes > MAX_DIFF_BYTES || changes.length === MAX_DIFFS)
|
|
19056
19238
|
return [];
|
|
19057
19239
|
changes.push({
|
|
19058
|
-
path:
|
|
19240
|
+
path: path9,
|
|
19059
19241
|
kind: "update",
|
|
19060
19242
|
diffScope: "fragment",
|
|
19061
|
-
unifiedDiff: createTwoFilesPatch(
|
|
19243
|
+
unifiedDiff: createTwoFilesPatch(path9, path9, oldText ?? "", newText, "", "", {
|
|
19062
19244
|
context: 3
|
|
19063
19245
|
})
|
|
19064
19246
|
});
|
|
@@ -19861,7 +20043,7 @@ ${reason}` }
|
|
|
19861
20043
|
|
|
19862
20044
|
// dist/gateway-open.js
|
|
19863
20045
|
async function sameDirectory(left, right) {
|
|
19864
|
-
return await realpath(left).catch(() =>
|
|
20046
|
+
return await realpath(left).catch(() => path8.resolve(left)) === await realpath(right).catch(() => path8.resolve(right));
|
|
19865
20047
|
}
|
|
19866
20048
|
var gatewayCapabilities = {
|
|
19867
20049
|
configuration: {
|
|
@@ -19878,11 +20060,23 @@ function gatewayPermissionModes() {
|
|
|
19878
20060
|
{
|
|
19879
20061
|
id: "default",
|
|
19880
20062
|
label: "原生审批策略",
|
|
20063
|
+
localizations: {
|
|
20064
|
+
en: {
|
|
20065
|
+
label: "Native approval policy",
|
|
20066
|
+
description: "Follow the Hermes global approval policy; disable YOLO for this Session."
|
|
20067
|
+
}
|
|
20068
|
+
},
|
|
19881
20069
|
description: "遵循 Hermes 全局审批策略,关闭本会话 YOLO。"
|
|
19882
20070
|
},
|
|
19883
20071
|
{
|
|
19884
20072
|
id: "dont_ask",
|
|
19885
20073
|
label: "会话 YOLO",
|
|
20074
|
+
localizations: {
|
|
20075
|
+
en: {
|
|
20076
|
+
label: "Session YOLO",
|
|
20077
|
+
description: "Automatically approve Hermes tool actions in this Session."
|
|
20078
|
+
}
|
|
20079
|
+
},
|
|
19886
20080
|
description: "本会话自动批准 Hermes 工具操作。",
|
|
19887
20081
|
dangerous: true
|
|
19888
20082
|
}
|
|
@@ -20003,8 +20197,10 @@ var HermesAdapter = class {
|
|
|
20003
20197
|
#gatewayTransports = /* @__PURE__ */ new Set();
|
|
20004
20198
|
#gatewayProbes = /* @__PURE__ */ new Map();
|
|
20005
20199
|
#openingNativeIds = /* @__PURE__ */ new Set();
|
|
20200
|
+
usageStatistics;
|
|
20006
20201
|
constructor(options = {}) {
|
|
20007
20202
|
this.#options = options;
|
|
20203
|
+
this.usageStatistics = createHermesUsageStatistics(options.environment ?? process.env);
|
|
20008
20204
|
}
|
|
20009
20205
|
async inspect(input = {}) {
|
|
20010
20206
|
const cwd = input.cwd ?? process.cwd();
|
|
@@ -20283,6 +20479,10 @@ function createHermesInstallation(environment, command) {
|
|
|
20283
20479
|
updateAvailable: false,
|
|
20284
20480
|
canUpdate: false,
|
|
20285
20481
|
messageCode: "hermes-update-plan-unavailable",
|
|
20482
|
+
notice: {
|
|
20483
|
+
en: "This Hermes release does not expose a safe update plan. Use the original installer.",
|
|
20484
|
+
"zh-CN": "此 Hermes 版本不提供安全的更新计划,请使用原安装方式更新。"
|
|
20485
|
+
},
|
|
20286
20486
|
message: "This Hermes release does not expose a safe update plan. Use the original installer."
|
|
20287
20487
|
};
|
|
20288
20488
|
const plan = await run(["update", "--plan"]);
|
|
@@ -20295,6 +20495,10 @@ function createHermesInstallation(environment, command) {
|
|
|
20295
20495
|
updateAvailable: false,
|
|
20296
20496
|
canUpdate: false,
|
|
20297
20497
|
messageCode: "hermes-externally-managed",
|
|
20498
|
+
notice: {
|
|
20499
|
+
en: "This Hermes installation is managed externally. Update it through its desktop app, container, or original package manager.",
|
|
20500
|
+
"zh-CN": "此 Hermes 安装由外部工具管理,请通过其桌面应用、容器或原包管理器更新。"
|
|
20501
|
+
},
|
|
20298
20502
|
message: "This Hermes installation is managed externally. Update it through its desktop app, container, or original package manager."
|
|
20299
20503
|
};
|
|
20300
20504
|
const output = await run(["update", "--check"]);
|
|
@@ -20313,6 +20517,13 @@ function createHermesInstallation(environment, command) {
|
|
|
20313
20517
|
canUpdate,
|
|
20314
20518
|
...updateAvailable && !release ? { latestVersionKind: "tracking-branch" } : {},
|
|
20315
20519
|
messageCode: canUpdate ? "hermes-update-channel" : "hermes-manual-update",
|
|
20520
|
+
notice: canUpdate ? {
|
|
20521
|
+
en: "Uses Hermes's configured update channel. Gateway restarts are deferred; existing processes keep their running code.",
|
|
20522
|
+
"zh-CN": "使用 Hermes 配置的更新渠道,暂不重启 Gateway;现有进程继续运行原有代码。"
|
|
20523
|
+
} : {
|
|
20524
|
+
en: "Use the native updater manually. Safe non-interactive updates require a clean source checkout, commit identity, and Gateway restart deferral.",
|
|
20525
|
+
"zh-CN": "请手动使用原生更新器。安全的非交互更新要求源码目录无未提交修改、可识别当前提交,并支持推迟 Gateway 重启。"
|
|
20526
|
+
},
|
|
20316
20527
|
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."
|
|
20317
20528
|
};
|
|
20318
20529
|
},
|