@liberseek/boft-cli-linux-x64 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.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +9 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +322 -67
- package/app/console-web.js +9202 -5218
- package/app/desktop-controller.mjs +259 -42
- package/app/host-runtime.mjs +6250 -1689
- package/app/plugins/antigravity/manifest.json +18 -1
- package/app/plugins/antigravity/plugin.mjs +283 -42
- package/app/plugins/claude-code/manifest.json +28 -0
- package/app/plugins/claude-code/plugin.mjs +35676 -24151
- package/app/plugins/codebuddy/manifest.json +17 -0
- package/app/plugins/codebuddy/plugin.mjs +5972 -5356
- package/app/plugins/codex-usage/manifest.json +9 -0
- package/app/plugins/codex-usage/plugin.mjs +17386 -0
- package/app/plugins/cursor-cli/manifest.json +18 -1
- package/app/plugins/cursor-cli/plugin.mjs +358 -77
- package/app/plugins/deepseek-harness/assets/icon.svg +1 -0
- package/app/plugins/deepseek-harness/manifest.json +35 -2
- package/app/plugins/deepseek-harness/plugin.mjs +823 -242
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/manifest.json +21 -1
- package/app/plugins/grok/plugin.mjs +933 -268
- package/app/plugins/hermes/assets/icon.png +0 -0
- package/app/plugins/hermes/manifest.json +30 -2
- package/app/plugins/hermes/plugin.mjs +469 -73
- package/app/plugins/kimi-code/assets/icon.svg +5 -0
- package/app/plugins/kimi-code/manifest.json +25 -2
- package/app/plugins/kimi-code/plugin.mjs +562 -36
- package/app/plugins/kiro-cli/assets/kiro-agent.svg +11 -0
- package/app/plugins/kiro-cli/manifest.json +18 -1
- package/app/plugins/kiro-cli/plugin.mjs +291 -22
- package/app/plugins/muse/manifest.json +18 -1
- package/app/plugins/muse/plugin.mjs +258 -17
- package/app/plugins/omp/manifest.json +21 -1
- package/app/plugins/omp/plugin.mjs +2763 -1958
- package/app/plugins/opencode/manifest.json +18 -1
- package/app/plugins/opencode/plugin.mjs +724 -147
- package/app/plugins/pi/manifest.json +32 -0
- package/app/plugins/pi/plugin.mjs +2908 -2312
- package/app/plugins/qoder/manifest.json +18 -1
- package/app/plugins/qoder/plugin.mjs +635 -81
- package/app/plugins/qoder-cn/manifest.json +18 -1
- package/app/plugins/qoder-cn/plugin.mjs +635 -81
- package/app/plugins/workbuddy/manifest.json +18 -0
- package/app/plugins/workbuddy/plugin.mjs +6362 -5748
- package/app/plugins/zcode/manifest.json +19 -1
- package/app/plugins/zcode/plugin.mjs +1117 -278
- package/app/renderer-extension.js +14675 -10087
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/licenses/Cordis-LICENSE.txt +21 -0
- package/licenses/Cosmokit-LICENSE.txt +21 -0
- package/package.json +4 -4
- package/app/plugins/kiro-cli/assets/icon.svg +0 -5
|
@@ -4100,7 +4100,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
4100
4100
|
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
4101
4101
|
let globalInstall = modules === globalRoot;
|
|
4102
4102
|
if (process.platform === "win32") {
|
|
4103
|
-
const
|
|
4103
|
+
const project2 = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
|
|
4104
4104
|
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
4105
4105
|
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
4106
4106
|
if (path4.basename(bin) !== bin || entry.includes(".."))
|
|
@@ -4111,7 +4111,7 @@ async function npmInstallation(command, packages, environment) {
|
|
|
4111
4111
|
const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
4112
4112
|
return referencesNpmBin(shim, name, entry);
|
|
4113
4113
|
}));
|
|
4114
|
-
globalInstall = globalInstall && !
|
|
4114
|
+
globalInstall = globalInstall && !project2 && launchers.some(Boolean);
|
|
4115
4115
|
}
|
|
4116
4116
|
const canUpdate = globalInstall && !!npm;
|
|
4117
4117
|
return {
|
|
@@ -4191,6 +4191,64 @@ function createHarnessInstaller(environment, source) {
|
|
|
4191
4191
|
};
|
|
4192
4192
|
}
|
|
4193
4193
|
|
|
4194
|
+
// dist/modern/usage-statistics.js
|
|
4195
|
+
import os2 from "node:os";
|
|
4196
|
+
import path5 from "node:path";
|
|
4197
|
+
import { lstat, readFile as readFile2, readdir } from "node:fs/promises";
|
|
4198
|
+
import { zstdDecompressSync } from "node:zlib";
|
|
4199
|
+
|
|
4200
|
+
// ../../harness-adapter/dist/usage-statistics.js
|
|
4201
|
+
var MAX_SESSION_ID_LENGTH = 512;
|
|
4202
|
+
var MAX_CWD_LENGTH = 4096;
|
|
4203
|
+
var MAX_SESSION_TITLE_LENGTH = 200;
|
|
4204
|
+
function usageSessionTitle(value) {
|
|
4205
|
+
if (typeof value !== "string")
|
|
4206
|
+
return void 0;
|
|
4207
|
+
const normalized = value.replaceAll("\0", "").replaceAll(/\s+/gu, " ").trim();
|
|
4208
|
+
if (!normalized)
|
|
4209
|
+
return void 0;
|
|
4210
|
+
if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
|
|
4211
|
+
return normalized;
|
|
4212
|
+
const characters = [...normalized];
|
|
4213
|
+
if (characters.length <= MAX_SESSION_TITLE_LENGTH)
|
|
4214
|
+
return normalized;
|
|
4215
|
+
return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
|
|
4216
|
+
}
|
|
4217
|
+
function sessionIdOk(value) {
|
|
4218
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
|
|
4219
|
+
}
|
|
4220
|
+
function cwdOk(value) {
|
|
4221
|
+
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("\\\\"));
|
|
4222
|
+
}
|
|
4223
|
+
function withUsageSession(entry, session) {
|
|
4224
|
+
const sessionId = sessionIdOk(session.sessionId) ? session.sessionId : void 0;
|
|
4225
|
+
const cwd = cwdOk(session.cwd) ? session.cwd : void 0;
|
|
4226
|
+
const sessionTitle = sessionId !== void 0 ? usageSessionTitle(session.title) : void 0;
|
|
4227
|
+
if (sessionId === void 0 && cwd === void 0)
|
|
4228
|
+
return entry;
|
|
4229
|
+
return {
|
|
4230
|
+
...entry,
|
|
4231
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
4232
|
+
...cwd !== void 0 ? { cwd } : {},
|
|
4233
|
+
...sessionTitle !== void 0 ? { sessionTitle } : {}
|
|
4234
|
+
};
|
|
4235
|
+
}
|
|
4236
|
+
function usageEntryFromRequest(request, occurredAtMs) {
|
|
4237
|
+
if (!Number.isSafeInteger(occurredAtMs) || occurredAtMs <= 0)
|
|
4238
|
+
return null;
|
|
4239
|
+
return {
|
|
4240
|
+
id: request.requestId,
|
|
4241
|
+
occurredAtMs,
|
|
4242
|
+
...request.model !== void 0 ? { model: request.model } : {},
|
|
4243
|
+
inputTokens: request.inputTokens,
|
|
4244
|
+
...request.cachedInputTokens !== void 0 ? { cachedInputTokens: request.cachedInputTokens } : {},
|
|
4245
|
+
...request.cacheWriteInputTokens !== void 0 ? { cacheWriteInputTokens: request.cacheWriteInputTokens } : {},
|
|
4246
|
+
...request.cacheWrite1hInputTokens !== void 0 ? { cacheWrite1hInputTokens: request.cacheWrite1hInputTokens } : {},
|
|
4247
|
+
outputTokens: request.outputTokens,
|
|
4248
|
+
...request.reasoningOutputTokens !== void 0 ? { reasoningOutputTokens: request.reasoningOutputTokens } : {}
|
|
4249
|
+
};
|
|
4250
|
+
}
|
|
4251
|
+
|
|
4194
4252
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
4195
4253
|
var external_exports = {};
|
|
4196
4254
|
__export(external_exports, {
|
|
@@ -4957,10 +5015,10 @@ function mergeDefs(...defs) {
|
|
|
4957
5015
|
function cloneDef(schema) {
|
|
4958
5016
|
return mergeDefs(schema._zod.def);
|
|
4959
5017
|
}
|
|
4960
|
-
function getElementAtPath(obj,
|
|
4961
|
-
if (!
|
|
5018
|
+
function getElementAtPath(obj, path9) {
|
|
5019
|
+
if (!path9)
|
|
4962
5020
|
return obj;
|
|
4963
|
-
return
|
|
5021
|
+
return path9.reduce((acc, key) => acc?.[key], obj);
|
|
4964
5022
|
}
|
|
4965
5023
|
function promiseAllObject(promisesObj) {
|
|
4966
5024
|
const keys = Object.keys(promisesObj);
|
|
@@ -5369,11 +5427,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
5369
5427
|
}
|
|
5370
5428
|
return false;
|
|
5371
5429
|
}
|
|
5372
|
-
function prefixIssues(
|
|
5430
|
+
function prefixIssues(path9, issues) {
|
|
5373
5431
|
return issues.map((iss) => {
|
|
5374
5432
|
var _a3;
|
|
5375
5433
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
5376
|
-
iss.path.unshift(
|
|
5434
|
+
iss.path.unshift(path9);
|
|
5377
5435
|
return iss;
|
|
5378
5436
|
});
|
|
5379
5437
|
}
|
|
@@ -5520,16 +5578,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5520
5578
|
}
|
|
5521
5579
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
5522
5580
|
const fieldErrors = { _errors: [] };
|
|
5523
|
-
const processError = (error52,
|
|
5581
|
+
const processError = (error52, path9 = []) => {
|
|
5524
5582
|
for (const issue2 of error52.issues) {
|
|
5525
5583
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
5526
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
5584
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
5527
5585
|
} else if (issue2.code === "invalid_key") {
|
|
5528
|
-
processError({ issues: issue2.issues }, [...
|
|
5586
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
5529
5587
|
} else if (issue2.code === "invalid_element") {
|
|
5530
|
-
processError({ issues: issue2.issues }, [...
|
|
5588
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
5531
5589
|
} else {
|
|
5532
|
-
const fullpath = [...
|
|
5590
|
+
const fullpath = [...path9, ...issue2.path];
|
|
5533
5591
|
if (fullpath.length === 0) {
|
|
5534
5592
|
fieldErrors._errors.push(mapper(issue2));
|
|
5535
5593
|
} else {
|
|
@@ -5556,17 +5614,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5556
5614
|
}
|
|
5557
5615
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
5558
5616
|
const result = { errors: [] };
|
|
5559
|
-
const processError = (error52,
|
|
5617
|
+
const processError = (error52, path9 = []) => {
|
|
5560
5618
|
var _a3, _b;
|
|
5561
5619
|
for (const issue2 of error52.issues) {
|
|
5562
5620
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
5563
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
5621
|
+
issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
|
|
5564
5622
|
} else if (issue2.code === "invalid_key") {
|
|
5565
|
-
processError({ issues: issue2.issues }, [...
|
|
5623
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
5566
5624
|
} else if (issue2.code === "invalid_element") {
|
|
5567
|
-
processError({ issues: issue2.issues }, [...
|
|
5625
|
+
processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
|
|
5568
5626
|
} else {
|
|
5569
|
-
const fullpath = [...
|
|
5627
|
+
const fullpath = [...path9, ...issue2.path];
|
|
5570
5628
|
if (fullpath.length === 0) {
|
|
5571
5629
|
result.errors.push(mapper(issue2));
|
|
5572
5630
|
continue;
|
|
@@ -5598,8 +5656,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5598
5656
|
}
|
|
5599
5657
|
function toDotPath(_path) {
|
|
5600
5658
|
const segs = [];
|
|
5601
|
-
const
|
|
5602
|
-
for (const seg of
|
|
5659
|
+
const path9 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
5660
|
+
for (const seg of path9) {
|
|
5603
5661
|
if (typeof seg === "number")
|
|
5604
5662
|
segs.push(`[${seg}]`);
|
|
5605
5663
|
else if (typeof seg === "symbol")
|
|
@@ -8827,8 +8885,8 @@ function az_default() {
|
|
|
8827
8885
|
}
|
|
8828
8886
|
|
|
8829
8887
|
// ../../../node_modules/zod/v4/locales/be.js
|
|
8830
|
-
function getBelarusianPlural(
|
|
8831
|
-
const absCount = Math.abs(
|
|
8888
|
+
function getBelarusianPlural(count3, one, few, many) {
|
|
8889
|
+
const absCount = Math.abs(count3);
|
|
8832
8890
|
const lastDigit = absCount % 10;
|
|
8833
8891
|
const lastTwoDigits = absCount % 100;
|
|
8834
8892
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -10906,8 +10964,8 @@ function hu_default() {
|
|
|
10906
10964
|
}
|
|
10907
10965
|
|
|
10908
10966
|
// ../../../node_modules/zod/v4/locales/hy.js
|
|
10909
|
-
function getArmenianPlural(
|
|
10910
|
-
return Math.abs(
|
|
10967
|
+
function getArmenianPlural(count3, one, many) {
|
|
10968
|
+
return Math.abs(count3) === 1 ? one : many;
|
|
10911
10969
|
}
|
|
10912
10970
|
function withDefiniteArticle(word) {
|
|
10913
10971
|
if (!word)
|
|
@@ -13035,8 +13093,8 @@ function ro_default() {
|
|
|
13035
13093
|
}
|
|
13036
13094
|
|
|
13037
13095
|
// ../../../node_modules/zod/v4/locales/ru.js
|
|
13038
|
-
function getRussianPlural(
|
|
13039
|
-
const absCount = Math.abs(
|
|
13096
|
+
function getRussianPlural(count3, one, few, many) {
|
|
13097
|
+
const absCount = Math.abs(count3);
|
|
13040
13098
|
const lastDigit = absCount % 10;
|
|
13041
13099
|
const lastTwoDigits = absCount % 100;
|
|
13042
13100
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -18291,13 +18349,13 @@ function resolveRef(ref, ctx) {
|
|
|
18291
18349
|
if (!ref.startsWith("#")) {
|
|
18292
18350
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
18293
18351
|
}
|
|
18294
|
-
const
|
|
18295
|
-
if (
|
|
18352
|
+
const path9 = ref.slice(1).split("/").filter(Boolean);
|
|
18353
|
+
if (path9.length === 0) {
|
|
18296
18354
|
return ctx.rootSchema;
|
|
18297
18355
|
}
|
|
18298
18356
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
18299
|
-
if (
|
|
18300
|
-
const key =
|
|
18357
|
+
if (path9[0] === defsKey) {
|
|
18358
|
+
const key = path9[1];
|
|
18301
18359
|
if (!key || !ctx.defs[key]) {
|
|
18302
18360
|
throw new Error(`Reference not found: ${ref}`);
|
|
18303
18361
|
}
|
|
@@ -18705,6 +18763,15 @@ function date4(params) {
|
|
|
18705
18763
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
18706
18764
|
config(en_default());
|
|
18707
18765
|
|
|
18766
|
+
// ../../shared-contracts/dist/delegation-read.js
|
|
18767
|
+
var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
18768
|
+
var delegationReadParamsSchema = external_exports.strictObject({
|
|
18769
|
+
threadId: external_exports.string().min(1).max(1024),
|
|
18770
|
+
view: external_exports.enum(["result", "messages"]),
|
|
18771
|
+
cursor: external_exports.string().min(1).max(8192).optional(),
|
|
18772
|
+
limit: external_exports.number().int().min(1).max(100).optional()
|
|
18773
|
+
});
|
|
18774
|
+
|
|
18708
18775
|
// ../../shared-contracts/dist/credential-imports.js
|
|
18709
18776
|
var credentialSourceSchema = external_exports.object({
|
|
18710
18777
|
id: external_exports.string().min(1).max(256),
|
|
@@ -18775,6 +18842,160 @@ var harnessDisplaySetSchema = external_exports.strictObject({
|
|
|
18775
18842
|
initializeOnly: external_exports.boolean().optional()
|
|
18776
18843
|
});
|
|
18777
18844
|
|
|
18845
|
+
// ../../shared-contracts/dist/model-price-overrides.js
|
|
18846
|
+
var usdPerMillionTokens = external_exports.number().finite().nonnegative();
|
|
18847
|
+
var modelPriceOverrideSchema = external_exports.strictObject({
|
|
18848
|
+
input: usdPerMillionTokens,
|
|
18849
|
+
output: usdPerMillionTokens,
|
|
18850
|
+
cacheRead: usdPerMillionTokens.optional(),
|
|
18851
|
+
cacheWrite: usdPerMillionTokens.optional(),
|
|
18852
|
+
cacheWrite1h: usdPerMillionTokens.optional()
|
|
18853
|
+
});
|
|
18854
|
+
var modelPriceKeySchema = external_exports.string().max(512).refine((key) => key.trim() === key && key.length > 0, "Model ID is required");
|
|
18855
|
+
var modelPriceOverridesSchema = external_exports.strictObject({
|
|
18856
|
+
/** Absolute path of the Host's `pricing.json`. */
|
|
18857
|
+
path: external_exports.string(),
|
|
18858
|
+
entries: external_exports.array(external_exports.strictObject({ key: external_exports.string(), price: modelPriceOverrideSchema })),
|
|
18859
|
+
/** Why the existing file is unusable; the Host then ignores it and refuses to overwrite it. */
|
|
18860
|
+
error: external_exports.string().nullable()
|
|
18861
|
+
});
|
|
18862
|
+
var modelPriceOverridesGetSchema = external_exports.strictObject({});
|
|
18863
|
+
var modelPriceOverridesSetSchema = external_exports.strictObject({
|
|
18864
|
+
key: modelPriceKeySchema,
|
|
18865
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
18866
|
+
previousKey: modelPriceKeySchema.optional()
|
|
18867
|
+
});
|
|
18868
|
+
var modelPriceDefaultParamsSchema = external_exports.strictObject({
|
|
18869
|
+
model: modelPriceKeySchema
|
|
18870
|
+
});
|
|
18871
|
+
var modelPriceSuggestionSchema = external_exports.strictObject({
|
|
18872
|
+
/** Verified from catalog canonical links, not inferred from names or equal prices. */
|
|
18873
|
+
official: external_exports.boolean().optional(),
|
|
18874
|
+
canonicalModelId: external_exports.string().min(1).optional(),
|
|
18875
|
+
provider: external_exports.string().min(1).max(512),
|
|
18876
|
+
model: external_exports.string().min(1).max(512),
|
|
18877
|
+
price: modelPriceOverrideSchema
|
|
18878
|
+
});
|
|
18879
|
+
var modelPriceDefaultResultSchema = external_exports.strictObject({
|
|
18880
|
+
price: modelPriceOverrideSchema.nullable(),
|
|
18881
|
+
/** Local catalog suggestions only; never used automatically for pricing. */
|
|
18882
|
+
suggestions: external_exports.array(modelPriceSuggestionSchema).max(6).optional()
|
|
18883
|
+
});
|
|
18884
|
+
|
|
18885
|
+
// ../../shared-contracts/dist/usage-statistics.js
|
|
18886
|
+
var USAGE_STATISTICS_RANGES = ["today", "7d", "30d", "90d", "all"];
|
|
18887
|
+
var count = external_exports.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
18888
|
+
var localDate = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/u);
|
|
18889
|
+
var harness = external_exports.string().min(1).max(128);
|
|
18890
|
+
var model = external_exports.string().min(1).max(512);
|
|
18891
|
+
var project = external_exports.string().min(1).max(4096);
|
|
18892
|
+
var usageStatisticsParamsSchema = external_exports.strictObject({
|
|
18893
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
18894
|
+
harness: harness.optional(),
|
|
18895
|
+
model: model.nullable().optional(),
|
|
18896
|
+
project: project.nullable().optional(),
|
|
18897
|
+
/** One local date inside the range. */
|
|
18898
|
+
date: localDate.optional()
|
|
18899
|
+
});
|
|
18900
|
+
var usageStatisticsTotalsSchema = external_exports.strictObject({
|
|
18901
|
+
requests: count,
|
|
18902
|
+
inputTokens: count,
|
|
18903
|
+
cachedInputTokens: count,
|
|
18904
|
+
cacheWriteInputTokens: count,
|
|
18905
|
+
cacheKnownInputTokens: count,
|
|
18906
|
+
outputTokens: count,
|
|
18907
|
+
reasoningOutputTokens: count,
|
|
18908
|
+
/** USD at the public price, summed over the priced requests only. */
|
|
18909
|
+
costUsd: external_exports.number().finite().min(0),
|
|
18910
|
+
/** Requests without a price (or the cache data the price needs); not in `costUsd`. */
|
|
18911
|
+
unpricedRequests: count,
|
|
18912
|
+
/**
|
|
18913
|
+
* Requests whose storage gave no token counts: counted as requests, with neither tokens nor
|
|
18914
|
+
* cost, and not as unpriced.
|
|
18915
|
+
*/
|
|
18916
|
+
unmeteredRequests: count
|
|
18917
|
+
});
|
|
18918
|
+
var totals = usageStatisticsTotalsSchema.shape;
|
|
18919
|
+
var usageStatisticsSessionSchema = external_exports.strictObject({
|
|
18920
|
+
harness,
|
|
18921
|
+
sessionId: external_exports.string().min(1).max(512),
|
|
18922
|
+
project: project.nullable(),
|
|
18923
|
+
/** Persisted Desktop title for a mapped Session, otherwise its native name; may be absent. */
|
|
18924
|
+
title: external_exports.string().min(1).max(200).optional(),
|
|
18925
|
+
/** Models the session used, most requests first. */
|
|
18926
|
+
models: external_exports.array(model).max(16),
|
|
18927
|
+
firstAtMs: count,
|
|
18928
|
+
lastAtMs: count,
|
|
18929
|
+
...totals
|
|
18930
|
+
});
|
|
18931
|
+
var usageStatisticsResultSchema = external_exports.strictObject({
|
|
18932
|
+
range: external_exports.enum(USAGE_STATISTICS_RANGES),
|
|
18933
|
+
/** First local date of the range; null for all time. */
|
|
18934
|
+
from: localDate.nullable(),
|
|
18935
|
+
to: localDate,
|
|
18936
|
+
/** The filters these figures apply, echoed so a late answer to older filters is recognised. */
|
|
18937
|
+
filters: external_exports.strictObject({
|
|
18938
|
+
harness: harness.nullable(),
|
|
18939
|
+
model: model.nullable(),
|
|
18940
|
+
unknownModel: external_exports.boolean(),
|
|
18941
|
+
project: project.nullable(),
|
|
18942
|
+
unknownProject: external_exports.boolean(),
|
|
18943
|
+
date: localDate.nullable()
|
|
18944
|
+
}),
|
|
18945
|
+
/** Reading of native storage: incomplete while the first read, or a refresh, is under way. */
|
|
18946
|
+
reading: external_exports.strictObject({ complete: external_exports.boolean(), sources: count, read: count }),
|
|
18947
|
+
/** Harnesses whose storage could not be read; their part is missing, the rest is complete. */
|
|
18948
|
+
failures: external_exports.array(external_exports.strictObject({ harness, message: external_exports.string().max(2048) })).max(256),
|
|
18949
|
+
/** Every value seen in the range, ignoring the filters, to choose filters from. */
|
|
18950
|
+
options: external_exports.strictObject({
|
|
18951
|
+
harnesses: external_exports.array(harness).max(256),
|
|
18952
|
+
models: external_exports.array(model.nullable()).max(4096),
|
|
18953
|
+
projects: external_exports.array(project.nullable()).max(4096)
|
|
18954
|
+
}),
|
|
18955
|
+
/** Current display metadata, scoped by Harness. Never a pricing or filter identity.
|
|
18956
|
+
* Optional for older Hosts; missing/conflicting labels fall back to the native model ID.
|
|
18957
|
+
*/
|
|
18958
|
+
modelLabels: external_exports.array(external_exports.strictObject({ harness, model, label: model })).max(4096).optional(),
|
|
18959
|
+
/** Native credits, all filters applied, never combined across Harnesses or treated as USD.
|
|
18960
|
+
* Only groups with at least one reported value appear; reportedRequests exposes partial data.
|
|
18961
|
+
*/
|
|
18962
|
+
credits: external_exports.array(external_exports.strictObject({
|
|
18963
|
+
harness,
|
|
18964
|
+
model: model.nullable(),
|
|
18965
|
+
credits: external_exports.number().finite().min(0),
|
|
18966
|
+
reportedRequests: count,
|
|
18967
|
+
requests: count
|
|
18968
|
+
})).max(4096).optional(),
|
|
18969
|
+
/** All filters applied. */
|
|
18970
|
+
totals: usageStatisticsTotalsSchema,
|
|
18971
|
+
/** Each date and Harness of the range: every filter except the day. */
|
|
18972
|
+
daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
|
|
18973
|
+
/** Local weekday (0 = Sunday) and hour, all filters applied. */
|
|
18974
|
+
hourly: external_exports.array(external_exports.strictObject({
|
|
18975
|
+
weekday: external_exports.number().int().min(0).max(6),
|
|
18976
|
+
hour: external_exports.number().int().min(0).max(23),
|
|
18977
|
+
...totals
|
|
18978
|
+
})).max(168),
|
|
18979
|
+
byHarness: external_exports.array(external_exports.strictObject({ harness, ...totals })).max(256),
|
|
18980
|
+
byModel: external_exports.array(external_exports.strictObject({
|
|
18981
|
+
model: model.nullable(),
|
|
18982
|
+
...totals,
|
|
18983
|
+
/** Requests priced by what the Harness recorded they cost, not by a price list. */
|
|
18984
|
+
harnessPricedRequests: count
|
|
18985
|
+
})).max(4096),
|
|
18986
|
+
byProject: external_exports.array(external_exports.strictObject({ project: project.nullable(), ...totals })).max(4096),
|
|
18987
|
+
/**
|
|
18988
|
+
* The sessions that spent the most, by cost and by tokens without cache, all filters applied;
|
|
18989
|
+
* requests without a native session are not listed here but count everywhere else.
|
|
18990
|
+
*/
|
|
18991
|
+
sessions: external_exports.array(usageStatisticsSessionSchema).max(100),
|
|
18992
|
+
/**
|
|
18993
|
+
* The sessions last active in the range, newest first, all filters applied. Optional for older
|
|
18994
|
+
* Hosts; missing is treated as no list rather than no sessions.
|
|
18995
|
+
*/
|
|
18996
|
+
recentSessions: external_exports.array(usageStatisticsSessionSchema).max(100).optional()
|
|
18997
|
+
});
|
|
18998
|
+
|
|
18778
18999
|
// ../../shared-contracts/dist/ids.js
|
|
18779
19000
|
var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
|
|
18780
19001
|
message: "Identifier must not be empty or whitespace"
|
|
@@ -18796,13 +19017,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
|
|
|
18796
19017
|
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);
|
|
18797
19018
|
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");
|
|
18798
19019
|
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
19020
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
19021
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
19022
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
19023
|
+
before: localizedTextSchema.optional(),
|
|
19024
|
+
after: localizedTextSchema.optional(),
|
|
19025
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
19026
|
+
}).strict();
|
|
18799
19027
|
var pluginPresentationShape = {
|
|
18800
19028
|
id: harnessPluginIdSchema,
|
|
18801
19029
|
name: external_exports.string().trim().min(1).max(128),
|
|
18802
19030
|
version: external_exports.string().min(1).max(128),
|
|
19031
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
19032
|
+
kind: external_exports.literal("usage").optional(),
|
|
19033
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
19034
|
+
iconStyle: external_exports.object({
|
|
19035
|
+
vector: external_exports.object({
|
|
19036
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
19037
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
19038
|
+
paths: external_exports.array(external_exports.object({
|
|
19039
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
19040
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
19041
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
19042
|
+
}).strict()).min(1).max(32)
|
|
19043
|
+
}).strict().optional(),
|
|
19044
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
19045
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
19046
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
19047
|
+
}).strict().optional(),
|
|
19048
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
19049
|
+
notice: localizedTextSchema.optional(),
|
|
18803
19050
|
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
18804
19051
|
launchCommand: external_exports.literal(true).optional(),
|
|
18805
19052
|
links: external_exports.object({
|
|
19053
|
+
website: documentationUrlSchema.optional(),
|
|
18806
19054
|
documentation: documentationUrlSchema.optional(),
|
|
18807
19055
|
installation: documentationUrlSchema.optional()
|
|
18808
19056
|
}).strict().optional()
|
|
@@ -18879,6 +19127,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
18879
19127
|
"codexhost/account/list",
|
|
18880
19128
|
"codexhost/account/refresh",
|
|
18881
19129
|
"codexhost/account/usage/inspect",
|
|
19130
|
+
"codexhost/usage/model-prices/get",
|
|
19131
|
+
"codexhost/usage/model-prices/set",
|
|
19132
|
+
"codexhost/usage/model-prices/default",
|
|
19133
|
+
"codexhost/usage/statistics/get",
|
|
18882
19134
|
"codexhost/update/check",
|
|
18883
19135
|
"codexhost/update/start",
|
|
18884
19136
|
"codexhost/update/status"
|
|
@@ -18943,6 +19195,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18943
19195
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18944
19196
|
outputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18945
19197
|
outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
19198
|
+
apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
18946
19199
|
reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18947
19200
|
totalTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18948
19201
|
totalCostUsd: finiteNonNegativeNumberSchema.optional(),
|
|
@@ -18954,7 +19207,11 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18954
19207
|
planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
18955
19208
|
planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
18956
19209
|
planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
18957
|
-
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
|
|
19210
|
+
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
19211
|
+
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
19212
|
+
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
19213
|
+
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
19214
|
+
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
18958
19215
|
}).strict().superRefine((usage, context) => {
|
|
18959
19216
|
if (Object.keys(usage).length === 0) {
|
|
18960
19217
|
context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
|
|
@@ -18975,6 +19232,20 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18975
19232
|
path: ["contextWindowTokens"]
|
|
18976
19233
|
});
|
|
18977
19234
|
}
|
|
19235
|
+
if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
|
|
19236
|
+
context.addIssue({
|
|
19237
|
+
code: "custom",
|
|
19238
|
+
message: "Thread Usage costSource must be provided with totalCostUsd",
|
|
19239
|
+
path: ["costSource"]
|
|
19240
|
+
});
|
|
19241
|
+
}
|
|
19242
|
+
if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
|
|
19243
|
+
context.addIssue({
|
|
19244
|
+
code: "custom",
|
|
19245
|
+
message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
|
|
19246
|
+
path: ["unpricedModels"]
|
|
19247
|
+
});
|
|
19248
|
+
}
|
|
18978
19249
|
if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
|
|
18979
19250
|
context.addIssue({
|
|
18980
19251
|
code: "custom",
|
|
@@ -19244,27 +19515,27 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
19244
19515
|
}).strict().superRefine((catalog, context) => {
|
|
19245
19516
|
const refs = /* @__PURE__ */ new Set();
|
|
19246
19517
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
|
|
19247
|
-
for (const [index,
|
|
19248
|
-
if (refs.has(
|
|
19518
|
+
for (const [index, model2] of catalog.models.entries()) {
|
|
19519
|
+
if (refs.has(model2.ref.id)) {
|
|
19249
19520
|
context.addIssue({
|
|
19250
19521
|
code: "custom",
|
|
19251
19522
|
message: "Model Catalog refs must be unique",
|
|
19252
19523
|
path: ["models", index, "ref", "id"]
|
|
19253
19524
|
});
|
|
19254
19525
|
}
|
|
19255
|
-
refs.add(
|
|
19256
|
-
if (
|
|
19257
|
-
if (refs.has(
|
|
19526
|
+
refs.add(model2.ref.id);
|
|
19527
|
+
if (model2.fastModel) {
|
|
19528
|
+
if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
|
|
19258
19529
|
context.addIssue({
|
|
19259
19530
|
code: "custom",
|
|
19260
19531
|
message: "Fast Model refs must be distinct and unique",
|
|
19261
19532
|
path: ["models", index, "fastModel"]
|
|
19262
19533
|
});
|
|
19263
19534
|
}
|
|
19264
|
-
refs.add(
|
|
19535
|
+
refs.add(model2.fastModel.id);
|
|
19265
19536
|
}
|
|
19266
19537
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
19267
|
-
for (const [optionIndex, optionId] of (
|
|
19538
|
+
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
19268
19539
|
if (supportedThinkingIds.has(optionId)) {
|
|
19269
19540
|
context.addIssue({
|
|
19270
19541
|
code: "custom",
|
|
@@ -19862,6 +20133,11 @@ var codexSshDraftSchema = external_exports.strictObject({
|
|
|
19862
20133
|
});
|
|
19863
20134
|
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
19864
20135
|
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
20136
|
+
external_exports.strictObject({
|
|
20137
|
+
action: external_exports.literal("read-thread"),
|
|
20138
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
20139
|
+
input: delegationReadParamsSchema
|
|
20140
|
+
}),
|
|
19865
20141
|
external_exports.strictObject({
|
|
19866
20142
|
action: external_exports.literal("save"),
|
|
19867
20143
|
draft: codexSshDraftSchema,
|
|
@@ -20015,7 +20291,6 @@ var tokenFields = [
|
|
|
20015
20291
|
"cachedInputTokens",
|
|
20016
20292
|
"cacheWriteInputTokens",
|
|
20017
20293
|
"outputTokens",
|
|
20018
|
-
"outputTokensPerSecond",
|
|
20019
20294
|
"reasoningOutputTokens",
|
|
20020
20295
|
"totalTokens",
|
|
20021
20296
|
"contextWindowTokens",
|
|
@@ -20023,10 +20298,12 @@ var tokenFields = [
|
|
|
20023
20298
|
];
|
|
20024
20299
|
var safeIntegerFields = [
|
|
20025
20300
|
"planFiveHourResetsAtUnix",
|
|
20026
|
-
"planSevenDayResetsAtUnix"
|
|
20301
|
+
"planSevenDayResetsAtUnix",
|
|
20302
|
+
"timeToFirstOutputMs"
|
|
20027
20303
|
];
|
|
20028
20304
|
var percentFields = [
|
|
20029
20305
|
"cacheHitRatePercent",
|
|
20306
|
+
"sessionCacheHitRatePercent",
|
|
20030
20307
|
"planFiveHourUsedPercent",
|
|
20031
20308
|
"planSevenDayUsedPercent"
|
|
20032
20309
|
];
|
|
@@ -20034,9 +20311,14 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
20034
20311
|
...tokenFields,
|
|
20035
20312
|
...safeIntegerFields,
|
|
20036
20313
|
...percentFields,
|
|
20314
|
+
"sessionCacheUsage",
|
|
20037
20315
|
"totalCostUsd",
|
|
20038
20316
|
"totalCredits",
|
|
20039
|
-
"contextUsagePercent"
|
|
20317
|
+
"contextUsagePercent",
|
|
20318
|
+
"outputTokensPerSecond",
|
|
20319
|
+
"apiOutputTokensPerSecond",
|
|
20320
|
+
"costSource",
|
|
20321
|
+
"unpricedModels"
|
|
20040
20322
|
]);
|
|
20041
20323
|
function isRecord(value) {
|
|
20042
20324
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -20052,7 +20334,11 @@ function parseHostUsage(value) {
|
|
|
20052
20334
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
20053
20335
|
}
|
|
20054
20336
|
}
|
|
20055
|
-
for (const field of [
|
|
20337
|
+
for (const field of [
|
|
20338
|
+
"totalCredits",
|
|
20339
|
+
"contextUsagePercent",
|
|
20340
|
+
"apiOutputTokensPerSecond"
|
|
20341
|
+
]) {
|
|
20056
20342
|
const candidate = value[field];
|
|
20057
20343
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
20058
20344
|
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
@@ -20088,6 +20374,12 @@ function parseHostUsage(value) {
|
|
|
20088
20374
|
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
20089
20375
|
}
|
|
20090
20376
|
}
|
|
20377
|
+
if (value.sessionCacheUsage !== void 0) {
|
|
20378
|
+
const totals2 = value.sessionCacheUsage;
|
|
20379
|
+
if (!isRecord(totals2) || Object.keys(totals2).some((key) => key !== "inputTokens" && key !== "cachedInputTokens") || typeof totals2.inputTokens !== "number" || !Number.isSafeInteger(totals2.inputTokens) || totals2.inputTokens < 0 || typeof totals2.cachedInputTokens !== "number" || !Number.isSafeInteger(totals2.cachedInputTokens) || totals2.cachedInputTokens < 0 || totals2.cachedInputTokens > totals2.inputTokens) {
|
|
20380
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
20381
|
+
}
|
|
20382
|
+
}
|
|
20091
20383
|
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
20092
20384
|
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
20093
20385
|
if (hasContextUsed !== hasContextWindow) {
|
|
@@ -20102,168 +20394,89 @@ function parseHostUsage(value) {
|
|
|
20102
20394
|
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
20103
20395
|
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
20104
20396
|
}
|
|
20397
|
+
if (value.costSource !== void 0) {
|
|
20398
|
+
if (value.costSource !== "publicPrice" && value.costSource !== "native") {
|
|
20399
|
+
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
20400
|
+
}
|
|
20401
|
+
if (value.totalCostUsd === void 0) {
|
|
20402
|
+
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
20403
|
+
}
|
|
20404
|
+
}
|
|
20405
|
+
if (value.unpricedModels !== void 0) {
|
|
20406
|
+
const models = value.unpricedModels;
|
|
20407
|
+
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
20408
|
+
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
20409
|
+
}
|
|
20410
|
+
if (value.costSource !== "publicPrice") {
|
|
20411
|
+
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
20412
|
+
}
|
|
20413
|
+
return { ...value, unpricedModels: [...models] };
|
|
20414
|
+
}
|
|
20105
20415
|
return { ...value };
|
|
20106
20416
|
}
|
|
20107
|
-
|
|
20108
|
-
|
|
20109
|
-
|
|
20110
|
-
|
|
20111
|
-
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
|
|
20115
|
-
|
|
20116
|
-
},
|
|
20117
|
-
{
|
|
20118
|
-
id: "dsh.goal",
|
|
20119
|
-
invocation: "/dsh-goal",
|
|
20120
|
-
label: "Goal",
|
|
20121
|
-
description: "Set or view the goal for a long-running task",
|
|
20122
|
-
argumentMode: "text"
|
|
20123
|
-
},
|
|
20124
|
-
{
|
|
20125
|
-
id: "dsh.plan",
|
|
20126
|
-
invocation: "/plan",
|
|
20127
|
-
label: "Plan mode",
|
|
20128
|
-
description: "Enter or leave plan mode",
|
|
20129
|
-
argumentMode: "text"
|
|
20130
|
-
}
|
|
20417
|
+
var requestTokenFields = [
|
|
20418
|
+
"inputTokens",
|
|
20419
|
+
"cachedInputTokens",
|
|
20420
|
+
"cacheWriteInputTokens",
|
|
20421
|
+
"cacheWrite1hInputTokens",
|
|
20422
|
+
"outputTokens",
|
|
20423
|
+
"reasoningOutputTokens",
|
|
20424
|
+
"startedAtMs",
|
|
20425
|
+
"completedAtMs"
|
|
20131
20426
|
];
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
return {
|
|
20147
|
-
ok: false,
|
|
20148
|
-
error: {
|
|
20149
|
-
code: "unsupported",
|
|
20150
|
-
message: `DeepSeek Harness does not expose command '${command.commandId}'`,
|
|
20151
|
-
retryable: false
|
|
20152
|
-
}
|
|
20153
|
-
};
|
|
20154
|
-
}
|
|
20155
|
-
const nativeInvocation = definition.id === "dsh.goal" ? "/goal" : definition.invocation;
|
|
20156
|
-
const arguments_ = command.arguments;
|
|
20157
|
-
if (definition.argumentMode === "none") {
|
|
20158
|
-
return arguments_ && Object.keys(arguments_).length > 0 ? invalidArguments(`DeepSeek Harness ${nativeInvocation} command does not accept arguments`) : { ok: true, value: { commandId: definition.id, line: nativeInvocation } };
|
|
20427
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
20428
|
+
...requestTokenFields,
|
|
20429
|
+
"requestId",
|
|
20430
|
+
"historical",
|
|
20431
|
+
"model",
|
|
20432
|
+
"provider"
|
|
20433
|
+
]);
|
|
20434
|
+
function parseHostUsageRequest(value) {
|
|
20435
|
+
if (!isRecord(value))
|
|
20436
|
+
throw new Error("Harness Usage request must be an object");
|
|
20437
|
+
for (const key of Object.keys(value)) {
|
|
20438
|
+
if (!requestFields.has(key)) {
|
|
20439
|
+
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
20440
|
+
}
|
|
20159
20441
|
}
|
|
20160
|
-
if (
|
|
20161
|
-
|
|
20442
|
+
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
20443
|
+
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
20162
20444
|
}
|
|
20163
|
-
|
|
20164
|
-
|
|
20445
|
+
for (const field of ["model", "provider"]) {
|
|
20446
|
+
const candidate = value[field];
|
|
20447
|
+
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
20448
|
+
throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
|
|
20449
|
+
}
|
|
20165
20450
|
}
|
|
20166
|
-
|
|
20167
|
-
|
|
20168
|
-
return invalidArguments("DeepSeek Harness /goal edit command requires a replacement objective");
|
|
20451
|
+
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
20452
|
+
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
20169
20453
|
}
|
|
20170
|
-
|
|
20171
|
-
|
|
20172
|
-
|
|
20173
|
-
|
|
20174
|
-
line: text.length > 0 ? `${nativeInvocation} ${text}` : nativeInvocation
|
|
20454
|
+
for (const field of requestTokenFields) {
|
|
20455
|
+
const candidate = value[field];
|
|
20456
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
20457
|
+
throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
|
|
20175
20458
|
}
|
|
20176
|
-
};
|
|
20177
|
-
}
|
|
20178
|
-
|
|
20179
|
-
// dist/generation-selector.js
|
|
20180
|
-
import { spawn } from "node:child_process";
|
|
20181
|
-
|
|
20182
|
-
// dist/executable.js
|
|
20183
|
-
import { spawnSync } from "node:child_process";
|
|
20184
|
-
import { accessSync, constants, statSync } from "node:fs";
|
|
20185
|
-
import path5 from "node:path";
|
|
20186
|
-
function environmentValue2(environment, name) {
|
|
20187
|
-
return Object.entries(environment).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
20188
|
-
}
|
|
20189
|
-
function executableCandidates(command, environment) {
|
|
20190
|
-
const targetPath2 = process.platform === "win32" ? path5.win32 : path5.posix;
|
|
20191
|
-
if (targetPath2.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
20192
|
-
return [command];
|
|
20193
20459
|
}
|
|
20194
|
-
|
|
20195
|
-
|
|
20196
|
-
}
|
|
20197
|
-
function resolveExecutable(command, environment) {
|
|
20198
|
-
const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
20199
|
-
for (const candidate of executableCandidates(command, environment)) {
|
|
20200
|
-
try {
|
|
20201
|
-
accessSync(candidate, accessMode);
|
|
20202
|
-
if (statSync(candidate).isFile())
|
|
20203
|
-
return candidate;
|
|
20204
|
-
} catch {
|
|
20205
|
-
}
|
|
20460
|
+
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
20461
|
+
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
20206
20462
|
}
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
|
|
20210
|
-
if (configured) {
|
|
20211
|
-
const command = resolveExecutable(configured, environment);
|
|
20212
|
-
return command ? { command, arguments: [], kind: "configured" } : null;
|
|
20463
|
+
const request = value;
|
|
20464
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
20465
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
20213
20466
|
}
|
|
20214
|
-
|
|
20215
|
-
|
|
20216
|
-
return { command: dsh, arguments: [], kind: "dsh" };
|
|
20217
|
-
const npx = resolveExecutable(process.platform === "win32" ? "npx.cmd" : "npx", environment);
|
|
20218
|
-
return npx ? {
|
|
20219
|
-
command: npx,
|
|
20220
|
-
arguments: ["--offline", "--no-install", "@deepseek-ai/dsh"],
|
|
20221
|
-
kind: "npx"
|
|
20222
|
-
} : null;
|
|
20223
|
-
}
|
|
20224
|
-
function deepSeekProcessInvocation(command, arguments_, environment, platform = process.platform) {
|
|
20225
|
-
const extension2 = path5.win32.extname(command).toLowerCase();
|
|
20226
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension2)) {
|
|
20227
|
-
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
20228
|
-
}
|
|
20229
|
-
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
20230
|
-
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
20231
|
-
return {
|
|
20232
|
-
command: environmentValue2(environment, "ComSpec") ?? "cmd.exe",
|
|
20233
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
20234
|
-
windowsVerbatimArguments: true
|
|
20235
|
-
};
|
|
20236
|
-
}
|
|
20237
|
-
function resolveWindowsTaskkillPath(environment) {
|
|
20238
|
-
const systemRoot = environmentValue2(environment, "SystemRoot") ?? environmentValue2(environment, "windir");
|
|
20239
|
-
if (!systemRoot || !/^[A-Za-z]:[\\/]/u.test(systemRoot)) {
|
|
20240
|
-
throw new Error("Windows SystemRoot is unavailable or invalid");
|
|
20467
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
20468
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
20241
20469
|
}
|
|
20242
|
-
|
|
20243
|
-
|
|
20244
|
-
function killDeepSeekProcessTree(child, platform, timeoutMs) {
|
|
20245
|
-
if (!child.pid) {
|
|
20246
|
-
if (child.exitCode === null && child.signalCode === null)
|
|
20247
|
-
child.kill("SIGKILL");
|
|
20248
|
-
return;
|
|
20470
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
20471
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
20249
20472
|
}
|
|
20250
|
-
if (
|
|
20251
|
-
|
|
20252
|
-
stdio: "ignore",
|
|
20253
|
-
windowsHide: true,
|
|
20254
|
-
timeout: timeoutMs
|
|
20255
|
-
});
|
|
20256
|
-
if (result.error)
|
|
20257
|
-
throw result.error;
|
|
20258
|
-
return;
|
|
20473
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
20474
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
20259
20475
|
}
|
|
20260
|
-
|
|
20261
|
-
|
|
20262
|
-
} catch (error51) {
|
|
20263
|
-
if (typeof error51 !== "object" || error51 === null || Reflect.get(error51, "code") !== "ESRCH") {
|
|
20264
|
-
throw error51;
|
|
20265
|
-
}
|
|
20476
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
20477
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
20266
20478
|
}
|
|
20479
|
+
return { ...request };
|
|
20267
20480
|
}
|
|
20268
20481
|
|
|
20269
20482
|
// dist/profiles/v4.js
|
|
@@ -20640,16 +20853,16 @@ var Diff = class {
|
|
|
20640
20853
|
}
|
|
20641
20854
|
}
|
|
20642
20855
|
}
|
|
20643
|
-
addToPath(
|
|
20644
|
-
const last =
|
|
20856
|
+
addToPath(path9, added, removed, oldPosInc, options) {
|
|
20857
|
+
const last = path9.lastComponent;
|
|
20645
20858
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
20646
20859
|
return {
|
|
20647
|
-
oldPos:
|
|
20860
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20648
20861
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
20649
20862
|
};
|
|
20650
20863
|
} else {
|
|
20651
20864
|
return {
|
|
20652
|
-
oldPos:
|
|
20865
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20653
20866
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
20654
20867
|
};
|
|
20655
20868
|
}
|
|
@@ -21846,6 +22059,351 @@ var DEEPSEEK_V4_PROFILE = Object.freeze({
|
|
|
21846
22059
|
settlementUsage
|
|
21847
22060
|
});
|
|
21848
22061
|
|
|
22062
|
+
// dist/modern/usage-metering.js
|
|
22063
|
+
function isRecord5(value) {
|
|
22064
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22065
|
+
}
|
|
22066
|
+
function count2(value) {
|
|
22067
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
22068
|
+
}
|
|
22069
|
+
function firstTokenTime(chunks) {
|
|
22070
|
+
for (const { time: time3, chunk } of chunks) {
|
|
22071
|
+
if ((chunk.type === "reasoning-delta" || chunk.type === "text-delta") && typeof chunk.text === "string" && chunk.text.length > 0 || chunk.type === "tool-call-delta" && typeof chunk.name === "string" && chunk.name.length > 0) {
|
|
22072
|
+
return time3;
|
|
22073
|
+
}
|
|
22074
|
+
}
|
|
22075
|
+
return null;
|
|
22076
|
+
}
|
|
22077
|
+
function deepSeekUsageRecord(event, historical) {
|
|
22078
|
+
if (event.type !== "assistant/message" || event.surfaceOp !== "append")
|
|
22079
|
+
return { kind: "none" };
|
|
22080
|
+
const data = isRecord5(event.data) ? event.data : null;
|
|
22081
|
+
const message = data && isRecord5(data.message) ? data.message : null;
|
|
22082
|
+
const source = message && isRecord5(message.source) ? message.source : null;
|
|
22083
|
+
if (!data || !message || source?.kind !== "model")
|
|
22084
|
+
return { kind: "none" };
|
|
22085
|
+
if (typeof message.id !== "string" || message.id.length === 0)
|
|
22086
|
+
return { kind: "missing" };
|
|
22087
|
+
if (typeof source.model !== "string" || source.model.length === 0)
|
|
22088
|
+
return { kind: "missing" };
|
|
22089
|
+
let chunks;
|
|
22090
|
+
try {
|
|
22091
|
+
chunks = expandAssistantStream(data.stream);
|
|
22092
|
+
} catch {
|
|
22093
|
+
return { kind: "missing" };
|
|
22094
|
+
}
|
|
22095
|
+
let usage = data.usage;
|
|
22096
|
+
for (const { chunk } of chunks)
|
|
22097
|
+
if (chunk.type === "usage")
|
|
22098
|
+
usage = chunk.usage;
|
|
22099
|
+
if (usage === void 0)
|
|
22100
|
+
return data.interrupted === true ? { kind: "none" } : { kind: "missing" };
|
|
22101
|
+
if (!isRecord5(usage))
|
|
22102
|
+
return { kind: "missing" };
|
|
22103
|
+
const input = count2(usage.inputTokens);
|
|
22104
|
+
const output = count2(usage.outputTokens);
|
|
22105
|
+
const cacheRead = count2(usage.cacheReadTokens ?? 0);
|
|
22106
|
+
const cacheWrite = count2(usage.cacheWriteTokens ?? 0);
|
|
22107
|
+
const reasoning2 = usage.reasoningTokens === void 0 ? null : count2(usage.reasoningTokens);
|
|
22108
|
+
if (input === null || output === null || cacheRead === null || cacheWrite === null) {
|
|
22109
|
+
return { kind: "missing" };
|
|
22110
|
+
}
|
|
22111
|
+
const startedAtMs = historical ? null : firstTokenTime(chunks);
|
|
22112
|
+
const completedAtMs = typeof event.time === "number" ? event.time : null;
|
|
22113
|
+
try {
|
|
22114
|
+
return {
|
|
22115
|
+
kind: "request",
|
|
22116
|
+
request: parseHostUsageRequest({
|
|
22117
|
+
requestId: message.id,
|
|
22118
|
+
...historical ? { historical: true } : {},
|
|
22119
|
+
model: source.model,
|
|
22120
|
+
inputTokens: input + cacheRead + cacheWrite,
|
|
22121
|
+
cachedInputTokens: cacheRead,
|
|
22122
|
+
cacheWriteInputTokens: cacheWrite,
|
|
22123
|
+
outputTokens: output,
|
|
22124
|
+
...reasoning2 !== null && reasoning2 <= output ? { reasoningOutputTokens: reasoning2 } : {},
|
|
22125
|
+
...startedAtMs !== null && completedAtMs !== null && completedAtMs >= startedAtMs ? { startedAtMs, completedAtMs } : {}
|
|
22126
|
+
})
|
|
22127
|
+
};
|
|
22128
|
+
} catch {
|
|
22129
|
+
return { kind: "missing" };
|
|
22130
|
+
}
|
|
22131
|
+
}
|
|
22132
|
+
function deepSeekUsageHistory(events) {
|
|
22133
|
+
const requests = /* @__PURE__ */ new Map();
|
|
22134
|
+
let complete = true;
|
|
22135
|
+
for (const event of events) {
|
|
22136
|
+
const record2 = deepSeekUsageRecord(event, true);
|
|
22137
|
+
if (record2.kind === "request")
|
|
22138
|
+
requests.set(record2.request.requestId, record2.request);
|
|
22139
|
+
else if (record2.kind === "missing")
|
|
22140
|
+
complete = false;
|
|
22141
|
+
}
|
|
22142
|
+
return { requests: [...requests.values()], complete };
|
|
22143
|
+
}
|
|
22144
|
+
|
|
22145
|
+
// dist/modern/usage-statistics.js
|
|
22146
|
+
var SESSION_FILE = /^session(?:\.v(\d+))?\.jsonl(\.zstd)?$/u;
|
|
22147
|
+
var ZSTD_MAGIC = 4247762216;
|
|
22148
|
+
function dshHome(environment) {
|
|
22149
|
+
return environment.DSH_HOME || path5.join(environment.HOME || os2.homedir(), ".dsh");
|
|
22150
|
+
}
|
|
22151
|
+
function zstdFrames(buffer) {
|
|
22152
|
+
const frames = [];
|
|
22153
|
+
let offset = 0;
|
|
22154
|
+
while (offset + 8 <= buffer.length) {
|
|
22155
|
+
const magic = buffer.readUInt32LE(offset);
|
|
22156
|
+
if ((magic & 4294967280) === 407710288) {
|
|
22157
|
+
offset += 8 + buffer.readUInt32LE(offset + 4);
|
|
22158
|
+
continue;
|
|
22159
|
+
}
|
|
22160
|
+
if (magic !== ZSTD_MAGIC)
|
|
22161
|
+
throw new Error("dsh session file is not zstd");
|
|
22162
|
+
const start = offset;
|
|
22163
|
+
const descriptor = buffer[offset + 4] ?? 0;
|
|
22164
|
+
const single = descriptor >> 5 & 1;
|
|
22165
|
+
offset += 5 + (single ? 0 : 1);
|
|
22166
|
+
offset += [0, 1, 2, 4][descriptor & 3] ?? 0;
|
|
22167
|
+
offset += [single, 2, 4, 8][descriptor >> 6] ?? 0;
|
|
22168
|
+
for (; ; ) {
|
|
22169
|
+
if (offset + 3 > buffer.length)
|
|
22170
|
+
return frames;
|
|
22171
|
+
const header = buffer.readUIntLE(offset, 3);
|
|
22172
|
+
const type = header >> 1 & 3;
|
|
22173
|
+
if (type === 3)
|
|
22174
|
+
throw new Error("dsh session file has a reserved zstd block");
|
|
22175
|
+
offset += 3 + (type === 1 ? 1 : header >>> 3);
|
|
22176
|
+
if (header & 1)
|
|
22177
|
+
break;
|
|
22178
|
+
}
|
|
22179
|
+
if (descriptor >> 2 & 1)
|
|
22180
|
+
offset += 4;
|
|
22181
|
+
if (offset > buffer.length)
|
|
22182
|
+
return frames;
|
|
22183
|
+
frames.push(buffer.subarray(start, offset));
|
|
22184
|
+
}
|
|
22185
|
+
return frames;
|
|
22186
|
+
}
|
|
22187
|
+
async function readDshUsage(file2) {
|
|
22188
|
+
const buffer = await readFile2(file2);
|
|
22189
|
+
const text = file2.endsWith(".zstd") ? zstdFrames(buffer).map((frame) => zstdDecompressSync(frame).toString("utf8")).join("") : buffer.toString("utf8");
|
|
22190
|
+
const entries = [];
|
|
22191
|
+
let session = {};
|
|
22192
|
+
for (const line of text.split("\n")) {
|
|
22193
|
+
if (entries.length === 0 && line.startsWith('{"type":"session"')) {
|
|
22194
|
+
try {
|
|
22195
|
+
const header = JSON.parse(line);
|
|
22196
|
+
const title = usageSessionTitle(header.title ?? header.name);
|
|
22197
|
+
session = {
|
|
22198
|
+
...typeof header.id === "string" ? { sessionId: header.id } : {},
|
|
22199
|
+
...typeof header.cwd === "string" ? { cwd: header.cwd } : {},
|
|
22200
|
+
...title ? { title } : {}
|
|
22201
|
+
};
|
|
22202
|
+
} catch {
|
|
22203
|
+
}
|
|
22204
|
+
continue;
|
|
22205
|
+
}
|
|
22206
|
+
if (!line.includes('"assistant/message"'))
|
|
22207
|
+
continue;
|
|
22208
|
+
let event;
|
|
22209
|
+
try {
|
|
22210
|
+
event = JSON.parse(line);
|
|
22211
|
+
} catch {
|
|
22212
|
+
continue;
|
|
22213
|
+
}
|
|
22214
|
+
const record2 = deepSeekUsageRecord(event, true);
|
|
22215
|
+
const entry = record2.kind === "request" && usageEntryFromRequest(record2.request, event.time);
|
|
22216
|
+
if (entry)
|
|
22217
|
+
entries.push(withUsageSession(entry, session));
|
|
22218
|
+
}
|
|
22219
|
+
return entries;
|
|
22220
|
+
}
|
|
22221
|
+
function createDshUsageStatistics(environment) {
|
|
22222
|
+
return Object.freeze({
|
|
22223
|
+
async listSources(signal) {
|
|
22224
|
+
const root = path5.join(dshHome(environment), "sessions");
|
|
22225
|
+
const sources = [];
|
|
22226
|
+
for (const project2 of await readdir(root).catch(() => [])) {
|
|
22227
|
+
for (const session of await readdir(path5.join(root, project2)).catch(() => [])) {
|
|
22228
|
+
signal.throwIfAborted();
|
|
22229
|
+
const directory = path5.join(root, project2, session);
|
|
22230
|
+
const latest = (await readdir(directory).catch(() => [])).map((name) => ({ name, version: Number(SESSION_FILE.exec(name)?.[1] ?? 1) })).filter(({ name }) => SESSION_FILE.test(name)).sort((left, right) => right.version - left.version)[0];
|
|
22231
|
+
if (!latest)
|
|
22232
|
+
continue;
|
|
22233
|
+
const file2 = path5.join(directory, latest.name);
|
|
22234
|
+
const info = await lstat(file2).catch(() => null);
|
|
22235
|
+
if (info?.isFile() && info.size > 0) {
|
|
22236
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
22237
|
+
}
|
|
22238
|
+
}
|
|
22239
|
+
}
|
|
22240
|
+
return sources;
|
|
22241
|
+
},
|
|
22242
|
+
readSource: (id) => readDshUsage(id)
|
|
22243
|
+
});
|
|
22244
|
+
}
|
|
22245
|
+
|
|
22246
|
+
// dist/harness-commands.js
|
|
22247
|
+
var commandDefinitions = [
|
|
22248
|
+
{
|
|
22249
|
+
id: "dsh.compact",
|
|
22250
|
+
invocation: "/compact",
|
|
22251
|
+
label: "Compact context",
|
|
22252
|
+
description: "Compact the current conversation context",
|
|
22253
|
+
argumentMode: "none"
|
|
22254
|
+
},
|
|
22255
|
+
{
|
|
22256
|
+
id: "dsh.goal",
|
|
22257
|
+
invocation: "/dsh-goal",
|
|
22258
|
+
label: "Goal",
|
|
22259
|
+
description: "Set or view the goal for a long-running task",
|
|
22260
|
+
argumentMode: "text"
|
|
22261
|
+
},
|
|
22262
|
+
{
|
|
22263
|
+
id: "dsh.plan",
|
|
22264
|
+
invocation: "/plan",
|
|
22265
|
+
label: "Plan mode",
|
|
22266
|
+
description: "Enter or leave plan mode",
|
|
22267
|
+
argumentMode: "text"
|
|
22268
|
+
}
|
|
22269
|
+
];
|
|
22270
|
+
function invalidArguments(message) {
|
|
22271
|
+
return {
|
|
22272
|
+
ok: false,
|
|
22273
|
+
error: { code: "invalidRequest", message, retryable: false }
|
|
22274
|
+
};
|
|
22275
|
+
}
|
|
22276
|
+
function deepSeekHarnessCommandCatalog() {
|
|
22277
|
+
return harnessCommandCatalogSchema.parse({
|
|
22278
|
+
commands: commandDefinitions
|
|
22279
|
+
});
|
|
22280
|
+
}
|
|
22281
|
+
function parseDeepSeekHarnessCommand(command) {
|
|
22282
|
+
const definition = commandDefinitions.find(({ id }) => id === command.commandId);
|
|
22283
|
+
if (!definition) {
|
|
22284
|
+
return {
|
|
22285
|
+
ok: false,
|
|
22286
|
+
error: {
|
|
22287
|
+
code: "unsupported",
|
|
22288
|
+
message: `DeepSeek Harness does not expose command '${command.commandId}'`,
|
|
22289
|
+
retryable: false
|
|
22290
|
+
}
|
|
22291
|
+
};
|
|
22292
|
+
}
|
|
22293
|
+
const nativeInvocation = definition.id === "dsh.goal" ? "/goal" : definition.invocation;
|
|
22294
|
+
const arguments_ = command.arguments;
|
|
22295
|
+
if (definition.argumentMode === "none") {
|
|
22296
|
+
return arguments_ && Object.keys(arguments_).length > 0 ? invalidArguments(`DeepSeek Harness ${nativeInvocation} command does not accept arguments`) : { ok: true, value: { commandId: definition.id, line: nativeInvocation } };
|
|
22297
|
+
}
|
|
22298
|
+
if (arguments_?.text !== void 0 && typeof arguments_.text !== "string") {
|
|
22299
|
+
return invalidArguments(`DeepSeek Harness ${nativeInvocation} command argument 'text' must be a string`);
|
|
22300
|
+
}
|
|
22301
|
+
if (arguments_ && Object.keys(arguments_).some((key) => key !== "text")) {
|
|
22302
|
+
return invalidArguments(`DeepSeek Harness ${nativeInvocation} command has an unknown argument`);
|
|
22303
|
+
}
|
|
22304
|
+
const text = arguments_?.text?.trim() ?? "";
|
|
22305
|
+
if (definition.id === "dsh.goal" && text.toLowerCase() === "edit") {
|
|
22306
|
+
return invalidArguments("DeepSeek Harness /goal edit command requires a replacement objective");
|
|
22307
|
+
}
|
|
22308
|
+
return {
|
|
22309
|
+
ok: true,
|
|
22310
|
+
value: {
|
|
22311
|
+
commandId: definition.id,
|
|
22312
|
+
line: text.length > 0 ? `${nativeInvocation} ${text}` : nativeInvocation
|
|
22313
|
+
}
|
|
22314
|
+
};
|
|
22315
|
+
}
|
|
22316
|
+
|
|
22317
|
+
// dist/generation-selector.js
|
|
22318
|
+
import { spawn } from "node:child_process";
|
|
22319
|
+
|
|
22320
|
+
// dist/executable.js
|
|
22321
|
+
import { spawnSync } from "node:child_process";
|
|
22322
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
22323
|
+
import path6 from "node:path";
|
|
22324
|
+
function environmentValue2(environment, name) {
|
|
22325
|
+
return Object.entries(environment).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
22326
|
+
}
|
|
22327
|
+
function executableCandidates(command, environment) {
|
|
22328
|
+
const targetPath2 = process.platform === "win32" ? path6.win32 : path6.posix;
|
|
22329
|
+
if (targetPath2.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
22330
|
+
return [command];
|
|
22331
|
+
}
|
|
22332
|
+
const extensions = process.platform === "win32" && targetPath2.extname(command) === "" ? (environmentValue2(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension2) => extension2.trim()).filter(Boolean) : [""];
|
|
22333
|
+
return (environmentValue2(environment, "PATH") ?? "").split(targetPath2.delimiter).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean).flatMap((directory) => extensions.map((extension2) => targetPath2.join(directory, command + extension2)));
|
|
22334
|
+
}
|
|
22335
|
+
function resolveExecutable(command, environment) {
|
|
22336
|
+
const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
22337
|
+
for (const candidate of executableCandidates(command, environment)) {
|
|
22338
|
+
try {
|
|
22339
|
+
accessSync(candidate, accessMode);
|
|
22340
|
+
if (statSync(candidate).isFile())
|
|
22341
|
+
return candidate;
|
|
22342
|
+
} catch {
|
|
22343
|
+
}
|
|
22344
|
+
}
|
|
22345
|
+
return null;
|
|
22346
|
+
}
|
|
22347
|
+
function resolveDeepSeekCommand(configured, environment) {
|
|
22348
|
+
if (configured) {
|
|
22349
|
+
const command = resolveExecutable(configured, environment);
|
|
22350
|
+
return command ? { command, arguments: [], kind: "configured" } : null;
|
|
22351
|
+
}
|
|
22352
|
+
const dsh = resolveExecutable("dsh", environment);
|
|
22353
|
+
if (dsh)
|
|
22354
|
+
return { command: dsh, arguments: [], kind: "dsh" };
|
|
22355
|
+
const npx = resolveExecutable(process.platform === "win32" ? "npx.cmd" : "npx", environment);
|
|
22356
|
+
return npx ? {
|
|
22357
|
+
command: npx,
|
|
22358
|
+
arguments: ["--offline", "--no-install", "@deepseek-ai/dsh"],
|
|
22359
|
+
kind: "npx"
|
|
22360
|
+
} : null;
|
|
22361
|
+
}
|
|
22362
|
+
function deepSeekProcessInvocation(command, arguments_, environment, platform = process.platform) {
|
|
22363
|
+
const extension2 = path6.win32.extname(command).toLowerCase();
|
|
22364
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension2)) {
|
|
22365
|
+
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
22366
|
+
}
|
|
22367
|
+
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
22368
|
+
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
22369
|
+
return {
|
|
22370
|
+
command: environmentValue2(environment, "ComSpec") ?? "cmd.exe",
|
|
22371
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
22372
|
+
windowsVerbatimArguments: true
|
|
22373
|
+
};
|
|
22374
|
+
}
|
|
22375
|
+
function resolveWindowsTaskkillPath(environment) {
|
|
22376
|
+
const systemRoot = environmentValue2(environment, "SystemRoot") ?? environmentValue2(environment, "windir");
|
|
22377
|
+
if (!systemRoot || !/^[A-Za-z]:[\\/]/u.test(systemRoot)) {
|
|
22378
|
+
throw new Error("Windows SystemRoot is unavailable or invalid");
|
|
22379
|
+
}
|
|
22380
|
+
return path6.win32.join(systemRoot, "System32", "taskkill.exe");
|
|
22381
|
+
}
|
|
22382
|
+
function killDeepSeekProcessTree(child, platform, timeoutMs) {
|
|
22383
|
+
if (!child.pid) {
|
|
22384
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
22385
|
+
child.kill("SIGKILL");
|
|
22386
|
+
return;
|
|
22387
|
+
}
|
|
22388
|
+
if (platform === "win32") {
|
|
22389
|
+
const result = spawnSync(resolveWindowsTaskkillPath(process.env), ["/pid", String(child.pid), "/t", "/f"], {
|
|
22390
|
+
stdio: "ignore",
|
|
22391
|
+
windowsHide: true,
|
|
22392
|
+
timeout: timeoutMs
|
|
22393
|
+
});
|
|
22394
|
+
if (result.error)
|
|
22395
|
+
throw result.error;
|
|
22396
|
+
return;
|
|
22397
|
+
}
|
|
22398
|
+
try {
|
|
22399
|
+
process.kill(-child.pid, "SIGKILL");
|
|
22400
|
+
} catch (error51) {
|
|
22401
|
+
if (typeof error51 !== "object" || error51 === null || Reflect.get(error51, "code") !== "ESRCH") {
|
|
22402
|
+
throw error51;
|
|
22403
|
+
}
|
|
22404
|
+
}
|
|
22405
|
+
}
|
|
22406
|
+
|
|
21849
22407
|
// dist/profiles/profile.js
|
|
21850
22408
|
var DEEPSEEK_MINIMUM_VERSION = DEEPSEEK_V4_FIRST_VERSION;
|
|
21851
22409
|
var MINIMUM = parseSemVer(DEEPSEEK_MINIMUM_VERSION);
|
|
@@ -22218,7 +22776,7 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
|
|
|
22218
22776
|
|
|
22219
22777
|
// dist/modern/deepseek-harness-adapter.js
|
|
22220
22778
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22221
|
-
import
|
|
22779
|
+
import path8 from "node:path";
|
|
22222
22780
|
|
|
22223
22781
|
// dist/modern/catalog.js
|
|
22224
22782
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
@@ -22226,9 +22784,9 @@ import { Buffer as Buffer3 } from "node:buffer";
|
|
|
22226
22784
|
// dist/model-catalog.js
|
|
22227
22785
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
22228
22786
|
var MODEL_REF_PREFIX = "deepseek-harness-model-v2.";
|
|
22229
|
-
function encodeDeepSeekHarnessModelRef(
|
|
22230
|
-
const provider =
|
|
22231
|
-
const modelId =
|
|
22787
|
+
function encodeDeepSeekHarnessModelRef(model2) {
|
|
22788
|
+
const provider = model2.provider.trim();
|
|
22789
|
+
const modelId = model2.model.trim();
|
|
22232
22790
|
if (!provider || !modelId)
|
|
22233
22791
|
throw new Error("DeepSeek Harness Model identity must not be empty");
|
|
22234
22792
|
const encoded = Buffer2.from(JSON.stringify([provider, modelId]), "utf8").toString("base64url");
|
|
@@ -22267,8 +22825,8 @@ function parseDeepSeekThinkingOptionId(value) {
|
|
|
22267
22825
|
}
|
|
22268
22826
|
function normalizeDeepSeekThinkingOptions(models) {
|
|
22269
22827
|
const group = models.groups.find((candidate) => candidate.id === models.current.provider);
|
|
22270
|
-
const
|
|
22271
|
-
return (
|
|
22828
|
+
const model2 = group?.models.find((candidate) => candidate.id === models.current.model);
|
|
22829
|
+
return (model2?.reasoning?.efforts ?? []).flatMap((effort) => {
|
|
22272
22830
|
const parsedId = harnessThinkingOptionIdSchema.safeParse(effort.id);
|
|
22273
22831
|
return parsedId.success ? [{ id: parsedId.data, label: effort.name }] : [];
|
|
22274
22832
|
});
|
|
@@ -22277,8 +22835,8 @@ function normalizeDeepSeekModelCatalog(groups2, selection2) {
|
|
|
22277
22835
|
const thinkingOptions = [];
|
|
22278
22836
|
const knownEffortIds = /* @__PURE__ */ new Set();
|
|
22279
22837
|
for (const group of groups2) {
|
|
22280
|
-
for (const
|
|
22281
|
-
for (const effort of
|
|
22838
|
+
for (const model2 of group.models) {
|
|
22839
|
+
for (const effort of model2.reasoning?.efforts ?? []) {
|
|
22282
22840
|
if (knownEffortIds.has(effort.id))
|
|
22283
22841
|
continue;
|
|
22284
22842
|
const parsedId = harnessThinkingOptionIdSchema.safeParse(effort.id);
|
|
@@ -22289,16 +22847,16 @@ function normalizeDeepSeekModelCatalog(groups2, selection2) {
|
|
|
22289
22847
|
}
|
|
22290
22848
|
}
|
|
22291
22849
|
}
|
|
22292
|
-
const models = groups2.flatMap((group) => group.models.map((
|
|
22293
|
-
ref: encodeDeepSeekHarnessModelRef({ provider: group.id, model:
|
|
22294
|
-
label: `${group.name} / ${
|
|
22295
|
-
...
|
|
22850
|
+
const models = groups2.flatMap((group) => group.models.map((model2) => ({
|
|
22851
|
+
ref: encodeDeepSeekHarnessModelRef({ provider: group.id, model: model2.id }),
|
|
22852
|
+
label: `${group.name} / ${model2.name}`,
|
|
22853
|
+
...model2.reasoning && model2.reasoning.efforts.length > 0 ? { supportedThinkingOptionIds: model2.reasoning.efforts.map((effort) => effort.id) } : {}
|
|
22296
22854
|
})));
|
|
22297
22855
|
const defaultModel = selection2 ? encodeDeepSeekHarnessModelRef(selection2) : void 0;
|
|
22298
|
-
if (selection2 && defaultModel && !models.some((
|
|
22856
|
+
if (selection2 && defaultModel && !models.some((model2) => model2.ref.id === defaultModel.id)) {
|
|
22299
22857
|
models.unshift({ ref: defaultModel, label: `${selection2.provider} / ${selection2.model}` });
|
|
22300
22858
|
}
|
|
22301
|
-
const defaultReasoning = selection2 ? groups2.find((group) => group.id === selection2.provider)?.models.find((
|
|
22859
|
+
const defaultReasoning = selection2 ? groups2.find((group) => group.id === selection2.provider)?.models.find((model2) => model2.id === selection2.model)?.reasoning : void 0;
|
|
22302
22860
|
const defaultThinkingOptionId = parseDeepSeekThinkingOptionId(selection2?.reasoningEffort ?? defaultReasoning?.defaultEffort);
|
|
22303
22861
|
return harnessModelCatalogSchema.parse({
|
|
22304
22862
|
models,
|
|
@@ -23483,32 +24041,32 @@ function groups(value, routable) {
|
|
|
23483
24041
|
throw catalogError("protocolError", "DeepSeek Harness returned a non-routable Model group");
|
|
23484
24042
|
}
|
|
23485
24043
|
const name = boundedString(candidate.name, MAX_NAME_LENGTH, "Model provider name");
|
|
23486
|
-
const models = array2(candidate.models, MAX_MODELS, "Model list").map((
|
|
24044
|
+
const models = array2(candidate.models, MAX_MODELS, "Model list").map((model2) => {
|
|
23487
24045
|
modelCount += 1;
|
|
23488
24046
|
if (modelCount > MAX_MODELS) {
|
|
23489
24047
|
throw catalogError("limitExceeded", "DeepSeek Harness Model list exceeded its item bound");
|
|
23490
24048
|
}
|
|
23491
|
-
if (!isPlainRecord(
|
|
24049
|
+
if (!isPlainRecord(model2) || !exactKeys2(model2, ["id", "name"], ["description", "reasoning"])) {
|
|
23492
24050
|
throw catalogError("protocolError", "DeepSeek Harness returned an invalid Model");
|
|
23493
24051
|
}
|
|
23494
|
-
const modelId = boundedString(
|
|
23495
|
-
const modelName = boundedString(
|
|
24052
|
+
const modelId = boundedString(model2.id, MAX_ID_LENGTH, "Model id");
|
|
24053
|
+
const modelName = boundedString(model2.name, MAX_NAME_LENGTH, "Model name");
|
|
23496
24054
|
if (`${name} / ${modelName}`.length > HARNESS_MODEL_LABEL_MAX_LENGTH) {
|
|
23497
24055
|
throw catalogError("protocolError", "DeepSeek Harness returned a Model label that is too long");
|
|
23498
24056
|
}
|
|
23499
24057
|
return {
|
|
23500
24058
|
id: modelId,
|
|
23501
24059
|
name: modelName,
|
|
23502
|
-
...
|
|
23503
|
-
description: boundedString(
|
|
24060
|
+
...model2.description === void 0 ? {} : {
|
|
24061
|
+
description: boundedString(model2.description, MAX_DESCRIPTION_LENGTH, "Model description", true)
|
|
23504
24062
|
},
|
|
23505
|
-
...
|
|
24063
|
+
...model2.reasoning === void 0 ? {} : { reasoning: reasoning(model2.reasoning) }
|
|
23506
24064
|
};
|
|
23507
24065
|
});
|
|
23508
24066
|
if (models.length === 0) {
|
|
23509
24067
|
throw catalogError("protocolError", "DeepSeek Harness returned an empty Model provider group");
|
|
23510
24068
|
}
|
|
23511
|
-
const modelIds = models.map((
|
|
24069
|
+
const modelIds = models.map((model2) => model2.id);
|
|
23512
24070
|
if (new Set(modelIds).size !== modelIds.length) {
|
|
23513
24071
|
throw catalogError("protocolError", "DeepSeek Harness returned duplicate Model ids");
|
|
23514
24072
|
}
|
|
@@ -23719,11 +24277,11 @@ function sanitizedError(error51, fallback) {
|
|
|
23719
24277
|
failure.name = redactModernCredential(error51 instanceof Error ? error51.name : "Error");
|
|
23720
24278
|
return failure;
|
|
23721
24279
|
}
|
|
23722
|
-
function
|
|
24280
|
+
function isRecord6(value) {
|
|
23723
24281
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23724
24282
|
}
|
|
23725
24283
|
function isPlainRecord3(value) {
|
|
23726
|
-
if (!
|
|
24284
|
+
if (!isRecord6(value))
|
|
23727
24285
|
return false;
|
|
23728
24286
|
const prototype = Object.getPrototypeOf(value);
|
|
23729
24287
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -23873,7 +24431,7 @@ function projectionRow(value, seq) {
|
|
|
23873
24431
|
return Object.freeze({ value: detachedJson(value), seq });
|
|
23874
24432
|
}
|
|
23875
24433
|
function parseProjectionBaseline(value, maxKeys) {
|
|
23876
|
-
if (!
|
|
24434
|
+
if (!isRecord6(value) || !hasExactKeys4(value, ["asOfSeq", "values"])) {
|
|
23877
24435
|
throw storeError("protocolError", "DeepSeek Harness control baseline has invalid projections");
|
|
23878
24436
|
}
|
|
23879
24437
|
if (!validCursor(value.asOfSeq) || !isPlainRecord3(value.values)) {
|
|
@@ -23899,7 +24457,7 @@ function parseProjectionBaseline(value, maxKeys) {
|
|
|
23899
24457
|
return { asOfSeq: value.asOfSeq, values, rowBytes };
|
|
23900
24458
|
}
|
|
23901
24459
|
function parseBaseline(value, maxSessions, maxKeys) {
|
|
23902
|
-
if (!
|
|
24460
|
+
if (!isRecord6(value) || !hasExactKeys4(value, ["projections"]) || !isPlainRecord3(value.projections)) {
|
|
23903
24461
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid baseline");
|
|
23904
24462
|
}
|
|
23905
24463
|
const sessions = /* @__PURE__ */ new Set();
|
|
@@ -23917,7 +24475,7 @@ function parseBaseline(value, maxSessions, maxKeys) {
|
|
|
23917
24475
|
return { projections };
|
|
23918
24476
|
}
|
|
23919
24477
|
function parseControlFrame(value, maxSessions, maxKeys) {
|
|
23920
|
-
if (!
|
|
24478
|
+
if (!isRecord6(value) || typeof value.type !== "string") {
|
|
23921
24479
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid frame");
|
|
23922
24480
|
}
|
|
23923
24481
|
if (value.type === "baseline" && hasExactKeys4(value, ["type", "value"])) {
|
|
@@ -24642,14 +25200,14 @@ function parseSelection(value, area) {
|
|
|
24642
25200
|
throw configurationError("protocolError", `DeepSeek Harness returned an invalid ${area}`);
|
|
24643
25201
|
}
|
|
24644
25202
|
const provider = boundedSelectionString(value.provider, `${area} provider`);
|
|
24645
|
-
const
|
|
25203
|
+
const model2 = boundedSelectionString(value.model, `${area} Model`);
|
|
24646
25204
|
if (value.reasoningEffort === void 0)
|
|
24647
|
-
return { provider, model };
|
|
25205
|
+
return { provider, model: model2 };
|
|
24648
25206
|
const effort = harnessThinkingOptionIdSchema.safeParse(value.reasoningEffort);
|
|
24649
25207
|
if (!effort.success) {
|
|
24650
25208
|
throw configurationError("protocolError", `DeepSeek Harness returned an invalid ${area} reasoning effort`);
|
|
24651
25209
|
}
|
|
24652
|
-
return { provider, model, reasoningEffort: effort.data };
|
|
25210
|
+
return { provider, model: model2, reasoningEffort: effort.data };
|
|
24653
25211
|
}
|
|
24654
25212
|
function parseOptionalSelection(value, area) {
|
|
24655
25213
|
return value === null ? null : parseSelection(value, area);
|
|
@@ -24712,22 +25270,22 @@ function readModernConfigurationSnapshot(input) {
|
|
|
24712
25270
|
if (!rows) {
|
|
24713
25271
|
throw configurationError("protocolError", "DeepSeek Harness control state is detached");
|
|
24714
25272
|
}
|
|
24715
|
-
const
|
|
25273
|
+
const model2 = readModernModelSelectionState(rows[MODERN_MODEL_SELECTION_PROJECTION_KEY], input.modelCatalog);
|
|
24716
25274
|
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes);
|
|
24717
25275
|
return {
|
|
24718
|
-
model,
|
|
24719
|
-
state: stateForSelection(input.nativeRef,
|
|
25276
|
+
model: model2,
|
|
25277
|
+
state: stateForSelection(input.nativeRef, model2.selection, input.modelCatalog, permission?.permissionModeId),
|
|
24720
25278
|
...permission ? { permissionProjectionSeq: permission.projectionSeq } : {}
|
|
24721
25279
|
};
|
|
24722
25280
|
}
|
|
24723
|
-
function modernSelectionForModel(catalog,
|
|
25281
|
+
function modernSelectionForModel(catalog, model2, thinkingOptionId) {
|
|
24724
25282
|
let native;
|
|
24725
25283
|
try {
|
|
24726
|
-
native = decodeDeepSeekHarnessModelRef(
|
|
25284
|
+
native = decodeDeepSeekHarnessModelRef(model2);
|
|
24727
25285
|
} catch (error51) {
|
|
24728
25286
|
throw configurationError("invalidRequest", error51 instanceof Error ? error51.message : "DeepSeek Harness Model is invalid");
|
|
24729
25287
|
}
|
|
24730
|
-
const catalogModel = catalog.catalog.models.find(({ ref }) => ref.id ===
|
|
25288
|
+
const catalogModel = catalog.catalog.models.find(({ ref }) => ref.id === model2.id);
|
|
24731
25289
|
if (!catalogModel) {
|
|
24732
25290
|
throw configurationError("invalidRequest", "DeepSeek Harness Model is unavailable");
|
|
24733
25291
|
}
|
|
@@ -25806,11 +26364,11 @@ function malformedOutcome(event) {
|
|
|
25806
26364
|
function isApprovalOutcome(value) {
|
|
25807
26365
|
return value === "allowed-once" || value === "rejected" || value === "cancelled" || value === "unavailable";
|
|
25808
26366
|
}
|
|
25809
|
-
function
|
|
26367
|
+
function isRecord7(value) {
|
|
25810
26368
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25811
26369
|
}
|
|
25812
26370
|
function isPlainRecord6(value) {
|
|
25813
|
-
if (!
|
|
26371
|
+
if (!isRecord7(value))
|
|
25814
26372
|
return false;
|
|
25815
26373
|
const prototype = Object.getPrototypeOf(value);
|
|
25816
26374
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -28087,6 +28645,10 @@ var ModernHarnessSession = class {
|
|
|
28087
28645
|
this.#fallbackThinkingOptionId = configuration.state.effectiveThinkingOptionId;
|
|
28088
28646
|
this.capabilities = modernSessionCapabilities(this.#permissionModes);
|
|
28089
28647
|
this.outputs = this.#channel.outputs;
|
|
28648
|
+
const usageHistory = deepSeekUsageHistory(this.#events);
|
|
28649
|
+
for (const request of usageHistory.requests)
|
|
28650
|
+
this.#emit({ type: "usage.request", request });
|
|
28651
|
+
this.#emit({ type: "usage.history", complete: usageHistory.complete });
|
|
28090
28652
|
this.commands = {
|
|
28091
28653
|
list: () => this.#listHarnessCommands(),
|
|
28092
28654
|
execute: (command) => this.#executeHarnessCommand(command)
|
|
@@ -29076,6 +29638,7 @@ ${question.detail}` : question.question;
|
|
|
29076
29638
|
this.#validator.accept(event);
|
|
29077
29639
|
this.#observeAssistantSettlement(event);
|
|
29078
29640
|
this.#events.push(event);
|
|
29641
|
+
this.#meterUsage(event);
|
|
29079
29642
|
this.#historyBytes += bytes;
|
|
29080
29643
|
this.#receive(event);
|
|
29081
29644
|
}
|
|
@@ -30151,6 +30714,14 @@ ${question.detail}` : question.question;
|
|
|
30151
30714
|
#emit(event) {
|
|
30152
30715
|
this.#channel.emit({ kind: "event", event });
|
|
30153
30716
|
}
|
|
30717
|
+
/** Publishes a live model request settled in the journal to Host usage metering. */
|
|
30718
|
+
#meterUsage(event) {
|
|
30719
|
+
const record2 = deepSeekUsageRecord(event, false);
|
|
30720
|
+
if (record2.kind === "request")
|
|
30721
|
+
this.#emit({ type: "usage.request", request: record2.request });
|
|
30722
|
+
else if (record2.kind === "missing")
|
|
30723
|
+
this.#emit({ type: "usage.history", complete: false });
|
|
30724
|
+
}
|
|
30154
30725
|
};
|
|
30155
30726
|
var OperationAborted = class extends Error {
|
|
30156
30727
|
constructor() {
|
|
@@ -30481,7 +31052,7 @@ function safeTimerDelay(value, name) {
|
|
|
30481
31052
|
|
|
30482
31053
|
// dist/modern/session-list.js
|
|
30483
31054
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
30484
|
-
import
|
|
31055
|
+
import path7 from "node:path";
|
|
30485
31056
|
var MAX_SESSION_LIST_BYTES = 32 * 1024 * 1024;
|
|
30486
31057
|
var MAX_SESSION_LIST_DEPTH = 64;
|
|
30487
31058
|
var MAX_SESSION_LIST_NODES = 2e5;
|
|
@@ -30600,7 +31171,7 @@ function parseSummary(value) {
|
|
|
30600
31171
|
};
|
|
30601
31172
|
}
|
|
30602
31173
|
function isCanonicalAbsoluteCwd(value) {
|
|
30603
|
-
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") &&
|
|
31174
|
+
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path7.isAbsolute(value) && path7.resolve(value) === value;
|
|
30604
31175
|
}
|
|
30605
31176
|
function parseModernSessionCandidates(value) {
|
|
30606
31177
|
assertBoundedJson4(value);
|
|
@@ -30798,7 +31369,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30798
31369
|
let session;
|
|
30799
31370
|
let forkExpectation;
|
|
30800
31371
|
try {
|
|
30801
|
-
const cwd =
|
|
31372
|
+
const cwd = path8.resolve(input.cwd);
|
|
30802
31373
|
let forkInput = input.kind === "fork" ? parseModernForkInput(input, this.#profile) : void 0;
|
|
30803
31374
|
const rollbackSourceSessionId = input.kind === "rollbackLastTurn" ? modernSessionId(input.sourceRef, "roll back") : void 0;
|
|
30804
31375
|
let rollbackPlan;
|
|
@@ -30959,6 +31530,14 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30959
31530
|
this.#sessions.add(openedSession);
|
|
30960
31531
|
await this.#startEvents();
|
|
30961
31532
|
this.#assertAccepting();
|
|
31533
|
+
if (input.kind === "resume" && input.permissionModeId) {
|
|
31534
|
+
const restored = await openedSession.execute({
|
|
31535
|
+
type: "permissionMode.select",
|
|
31536
|
+
permissionModeId: input.permissionModeId
|
|
31537
|
+
});
|
|
31538
|
+
if (!restored.ok)
|
|
31539
|
+
throw new AdapterOperationError(restored.error);
|
|
31540
|
+
}
|
|
30962
31541
|
return { ok: true, value: openedSession };
|
|
30963
31542
|
} catch (error51) {
|
|
30964
31543
|
await session?.close().catch(() => void 0);
|
|
@@ -31001,7 +31580,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
31001
31580
|
});
|
|
31002
31581
|
if (!result.ok)
|
|
31003
31582
|
throw new AdapterOperationError(remoteFailure2("session/create", result.error));
|
|
31004
|
-
if (!
|
|
31583
|
+
if (!isRecord8(result.value) || !hasExactOptionalKeys(result.value, ["sessionId"], ["agentPreset"]) || result.value.sessionId !== requestedSessionId || Object.hasOwn(result.value, "agentPreset") && typeof result.value.agentPreset !== "string" || agentPreset !== void 0 && result.value.agentPreset !== agentPreset) {
|
|
31005
31584
|
throw new AdapterOperationError({
|
|
31006
31585
|
code: "protocolError",
|
|
31007
31586
|
message: "DeepSeek Harness session/create returned an invalid Session identity",
|
|
@@ -31085,7 +31664,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
31085
31664
|
const result = await this.#connection.call("session/fork", { request: { sessionId: input.sourceSessionId, atSeq } }, this.#lifetime.signal);
|
|
31086
31665
|
if (!result.ok)
|
|
31087
31666
|
throw new AdapterOperationError(forkRemoteFailure(result.error));
|
|
31088
|
-
if (!
|
|
31667
|
+
if (!isRecord8(result.value) || !hasExactOptionalKeys(result.value, ["sessionId"], []) || typeof result.value.sessionId !== "string" || result.value.sessionId.trim() === "" || result.value.sessionId === input.sourceSessionId) {
|
|
31089
31668
|
throw forkProtocolError();
|
|
31090
31669
|
}
|
|
31091
31670
|
return {
|
|
@@ -31319,7 +31898,7 @@ function verifyCreateConfiguration(requested, observed) {
|
|
|
31319
31898
|
}
|
|
31320
31899
|
}
|
|
31321
31900
|
function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
31322
|
-
let
|
|
31901
|
+
let model2;
|
|
31323
31902
|
if (input.model || input.thinkingOptionId) {
|
|
31324
31903
|
const requestedModel = input.model ?? modelCatalog.catalog.defaultModel;
|
|
31325
31904
|
if (!requestedModel) {
|
|
@@ -31329,7 +31908,7 @@ function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
|
31329
31908
|
retryable: false
|
|
31330
31909
|
});
|
|
31331
31910
|
}
|
|
31332
|
-
|
|
31911
|
+
model2 = modernSelectionForModel(modelCatalog, requestedModel, input.thinkingOptionId);
|
|
31333
31912
|
}
|
|
31334
31913
|
const unattended = input.executionPolicy === "unattended-full-access";
|
|
31335
31914
|
const permissionModeId = input.permissionModeId ?? (unattended ? harnessPermissionModeIdSchema.parse(DELEGATION_PERMISSION_PRESET) : void 0);
|
|
@@ -31341,7 +31920,7 @@ function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
|
31341
31920
|
});
|
|
31342
31921
|
}
|
|
31343
31922
|
return {
|
|
31344
|
-
...
|
|
31923
|
+
...model2 ? { model: model2 } : {},
|
|
31345
31924
|
...permissionModeId ? { permissionModeId } : {},
|
|
31346
31925
|
unattended
|
|
31347
31926
|
};
|
|
@@ -31351,7 +31930,7 @@ function delegationPermissionIsApplied(events) {
|
|
|
31351
31930
|
let sandboxMode;
|
|
31352
31931
|
let approvalPolicy;
|
|
31353
31932
|
for (const event of events) {
|
|
31354
|
-
if (!
|
|
31933
|
+
if (!isRecord8(event.data))
|
|
31355
31934
|
continue;
|
|
31356
31935
|
if (event.type === "permission/preset" && typeof event.data.preset === "string") {
|
|
31357
31936
|
preset = event.data.preset;
|
|
@@ -31390,10 +31969,10 @@ function parseModernForkInput(input, profile) {
|
|
|
31390
31969
|
};
|
|
31391
31970
|
}
|
|
31392
31971
|
function sessionLocatorMatches(locator) {
|
|
31393
|
-
return locator === void 0 ||
|
|
31972
|
+
return locator === void 0 || isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && typeof locator.dshVersion === "string" && isDeepSeekSemVer(locator.dshVersion);
|
|
31394
31973
|
}
|
|
31395
31974
|
function checkpointLocatorMatches(locator, profile) {
|
|
31396
|
-
return
|
|
31975
|
+
return isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && locator.dshVersion === profile.version;
|
|
31397
31976
|
}
|
|
31398
31977
|
function forkCheckpointError() {
|
|
31399
31978
|
return new AdapterOperationError({
|
|
@@ -31555,7 +32134,7 @@ function sanitizedHarnessError2(error51) {
|
|
|
31555
32134
|
...error51.stderrTail ? { stderrTail: sanitizeDiagnosticTail(redactModernCredential(error51.stderrTail)) } : {}
|
|
31556
32135
|
};
|
|
31557
32136
|
}
|
|
31558
|
-
function
|
|
32137
|
+
function isRecord8(value) {
|
|
31559
32138
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31560
32139
|
}
|
|
31561
32140
|
function hasExactOptionalKeys(value, required2, optional2) {
|
|
@@ -31577,6 +32156,7 @@ var DelegateSelectionError = class extends Error {
|
|
|
31577
32156
|
var DeepSeekHarnessAdapter = class {
|
|
31578
32157
|
commandCatalog = deepSeekHarnessCommandCatalog();
|
|
31579
32158
|
harnessId = DEEPSEEK_HARNESS_ID4;
|
|
32159
|
+
usageStatistics;
|
|
31580
32160
|
sessionImport = Object.freeze({
|
|
31581
32161
|
listCandidates: () => this.#listSessionImportCandidates(),
|
|
31582
32162
|
resolveCandidate: async (nativeSessionId) => {
|
|
@@ -31623,6 +32203,7 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31623
32203
|
#terminalFailure;
|
|
31624
32204
|
constructor(options = {}, dependencies = {}) {
|
|
31625
32205
|
this.#options = options;
|
|
32206
|
+
this.usageStatistics = createDshUsageStatistics(options.environment ?? process.env);
|
|
31626
32207
|
this.#probeExecutable = dependencies.probeExecutable ?? ((input) => probeDeepSeekExecutableGeneration(input));
|
|
31627
32208
|
this.#createModernAdapter = dependencies.createModernAdapter ?? ((modernOptions2) => new ModernDeepSeekHarnessAdapter(modernOptions2));
|
|
31628
32209
|
}
|