@codexhost/cli-darwin-x64 0.12.2 → 0.13.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 +319 -64
- package/app/console-web.js +5089 -1367
- package/app/desktop-controller.mjs +259 -41
- package/app/host-runtime.mjs +5735 -1564
- package/app/plugins/antigravity/manifest.json +18 -1
- package/app/plugins/antigravity/plugin.mjs +282 -41
- package/app/plugins/claude-code/manifest.json +28 -0
- package/app/plugins/claude-code/plugin.mjs +35300 -23918
- package/app/plugins/codebuddy/manifest.json +17 -0
- package/app/plugins/codebuddy/plugin.mjs +5971 -5355
- package/app/plugins/codex-usage/manifest.json +9 -0
- package/app/plugins/codex-usage/plugin.mjs +17324 -0
- package/app/plugins/cursor-cli/manifest.json +17 -0
- package/app/plugins/cursor-cli/plugin.mjs +357 -76
- 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 +822 -241
- package/app/plugins/enabled.json +2 -1
- package/app/plugins/grok/manifest.json +21 -1
- package/app/plugins/grok/plugin.mjs +918 -258
- package/app/plugins/hermes/assets/icon.png +0 -0
- package/app/plugins/hermes/manifest.json +30 -2
- package/app/plugins/hermes/plugin.mjs +284 -32
- 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 +561 -35
- 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 +290 -21
- package/app/plugins/omp/manifest.json +21 -1
- package/app/plugins/omp/plugin.mjs +2765 -1960
- package/app/plugins/opencode/manifest.json +18 -1
- package/app/plugins/opencode/plugin.mjs +723 -146
- 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 +634 -80
- package/app/plugins/qoder-cn/manifest.json +18 -1
- package/app/plugins/qoder-cn/plugin.mjs +634 -80
- package/app/plugins/workbuddy/manifest.json +18 -0
- package/app/plugins/workbuddy/plugin.mjs +6361 -5747
- package/app/plugins/zcode/manifest.json +19 -1
- package/app/plugins/zcode/plugin.mjs +1098 -259
- package/app/renderer-extension.js +13080 -8884
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/licenses/Cordis-LICENSE.txt +21 -0
- package/licenses/Cosmokit-LICENSE.txt +21 -0
- package/package.json +1 -1
- 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"
|
|
@@ -18822,6 +19043,10 @@ var CONSOLE_HOST_METHODS = Object.freeze([
|
|
|
18822
19043
|
"codexhost/account/list",
|
|
18823
19044
|
"codexhost/account/refresh",
|
|
18824
19045
|
"codexhost/account/usage/inspect",
|
|
19046
|
+
"codexhost/usage/model-prices/get",
|
|
19047
|
+
"codexhost/usage/model-prices/set",
|
|
19048
|
+
"codexhost/usage/model-prices/default",
|
|
19049
|
+
"codexhost/usage/statistics/get",
|
|
18825
19050
|
"codexhost/update/check",
|
|
18826
19051
|
"codexhost/update/start",
|
|
18827
19052
|
"codexhost/update/status"
|
|
@@ -18886,6 +19111,7 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18886
19111
|
cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18887
19112
|
outputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18888
19113
|
outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
19114
|
+
apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
|
|
18889
19115
|
reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18890
19116
|
totalTokens: nonNegativeSafeIntegerSchema.optional(),
|
|
18891
19117
|
totalCostUsd: finiteNonNegativeNumberSchema.optional(),
|
|
@@ -18897,7 +19123,11 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18897
19123
|
planFiveHourUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
18898
19124
|
planFiveHourResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
18899
19125
|
planSevenDayUsedPercent: cacheHitRatePercentSchema.optional(),
|
|
18900
|
-
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional()
|
|
19126
|
+
planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
|
|
19127
|
+
sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
|
|
19128
|
+
timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
|
|
19129
|
+
costSource: external_exports.enum(["publicPrice", "native"]).optional(),
|
|
19130
|
+
unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
|
|
18901
19131
|
}).strict().superRefine((usage, context) => {
|
|
18902
19132
|
if (Object.keys(usage).length === 0) {
|
|
18903
19133
|
context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
|
|
@@ -18918,6 +19148,20 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18918
19148
|
path: ["contextWindowTokens"]
|
|
18919
19149
|
});
|
|
18920
19150
|
}
|
|
19151
|
+
if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
|
|
19152
|
+
context.addIssue({
|
|
19153
|
+
code: "custom",
|
|
19154
|
+
message: "Thread Usage costSource must be provided with totalCostUsd",
|
|
19155
|
+
path: ["costSource"]
|
|
19156
|
+
});
|
|
19157
|
+
}
|
|
19158
|
+
if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
|
|
19159
|
+
context.addIssue({
|
|
19160
|
+
code: "custom",
|
|
19161
|
+
message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
|
|
19162
|
+
path: ["unpricedModels"]
|
|
19163
|
+
});
|
|
19164
|
+
}
|
|
18921
19165
|
if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
|
|
18922
19166
|
context.addIssue({
|
|
18923
19167
|
code: "custom",
|
|
@@ -19172,27 +19416,27 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
19172
19416
|
}).strict().superRefine((catalog, context) => {
|
|
19173
19417
|
const refs = /* @__PURE__ */ new Set();
|
|
19174
19418
|
const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
|
|
19175
|
-
for (const [index,
|
|
19176
|
-
if (refs.has(
|
|
19419
|
+
for (const [index, model2] of catalog.models.entries()) {
|
|
19420
|
+
if (refs.has(model2.ref.id)) {
|
|
19177
19421
|
context.addIssue({
|
|
19178
19422
|
code: "custom",
|
|
19179
19423
|
message: "Model Catalog refs must be unique",
|
|
19180
19424
|
path: ["models", index, "ref", "id"]
|
|
19181
19425
|
});
|
|
19182
19426
|
}
|
|
19183
|
-
refs.add(
|
|
19184
|
-
if (
|
|
19185
|
-
if (refs.has(
|
|
19427
|
+
refs.add(model2.ref.id);
|
|
19428
|
+
if (model2.fastModel) {
|
|
19429
|
+
if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
|
|
19186
19430
|
context.addIssue({
|
|
19187
19431
|
code: "custom",
|
|
19188
19432
|
message: "Fast Model refs must be distinct and unique",
|
|
19189
19433
|
path: ["models", index, "fastModel"]
|
|
19190
19434
|
});
|
|
19191
19435
|
}
|
|
19192
|
-
refs.add(
|
|
19436
|
+
refs.add(model2.fastModel.id);
|
|
19193
19437
|
}
|
|
19194
19438
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
19195
|
-
for (const [optionIndex, optionId] of (
|
|
19439
|
+
for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
|
|
19196
19440
|
if (supportedThinkingIds.has(optionId)) {
|
|
19197
19441
|
context.addIssue({
|
|
19198
19442
|
code: "custom",
|
|
@@ -19386,13 +19630,40 @@ var HARNESS_PLUGIN_LIMIT = 128;
|
|
|
19386
19630
|
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);
|
|
19387
19631
|
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");
|
|
19388
19632
|
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
19633
|
+
var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
|
|
19634
|
+
var harnessInstallationGuideSchema = external_exports.object({
|
|
19635
|
+
commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
|
|
19636
|
+
before: localizedTextSchema.optional(),
|
|
19637
|
+
after: localizedTextSchema.optional(),
|
|
19638
|
+
downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
|
|
19639
|
+
}).strict();
|
|
19389
19640
|
var pluginPresentationShape = {
|
|
19390
19641
|
id: harnessPluginIdSchema,
|
|
19391
19642
|
name: external_exports.string().trim().min(1).max(128),
|
|
19392
19643
|
version: external_exports.string().min(1).max(128),
|
|
19644
|
+
/** Capability-only plugin; omitted for existing session-capable plugins. */
|
|
19645
|
+
kind: external_exports.literal("usage").optional(),
|
|
19646
|
+
/** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
|
|
19647
|
+
iconStyle: external_exports.object({
|
|
19648
|
+
vector: external_exports.object({
|
|
19649
|
+
viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
|
|
19650
|
+
color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
|
|
19651
|
+
paths: external_exports.array(external_exports.object({
|
|
19652
|
+
d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
|
|
19653
|
+
fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
|
|
19654
|
+
fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
|
|
19655
|
+
}).strict()).min(1).max(32)
|
|
19656
|
+
}).strict().optional(),
|
|
19657
|
+
background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
|
|
19658
|
+
borderRadius: external_exports.number().min(0).max(50).optional(),
|
|
19659
|
+
paddingRatio: external_exports.number().min(0).max(0.25).optional()
|
|
19660
|
+
}).strict().optional(),
|
|
19661
|
+
installation: harnessInstallationGuideSchema.optional(),
|
|
19662
|
+
notice: localizedTextSchema.optional(),
|
|
19393
19663
|
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
19394
19664
|
launchCommand: external_exports.literal(true).optional(),
|
|
19395
19665
|
links: external_exports.object({
|
|
19666
|
+
website: documentationUrlSchema.optional(),
|
|
19396
19667
|
documentation: documentationUrlSchema.optional(),
|
|
19397
19668
|
installation: documentationUrlSchema.optional()
|
|
19398
19669
|
}).strict().optional()
|
|
@@ -19815,6 +20086,11 @@ var codexSshDraftSchema = external_exports.strictObject({
|
|
|
19815
20086
|
});
|
|
19816
20087
|
var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action", [
|
|
19817
20088
|
external_exports.strictObject({ action: external_exports.literal("list") }),
|
|
20089
|
+
external_exports.strictObject({
|
|
20090
|
+
action: external_exports.literal("read-thread"),
|
|
20091
|
+
hostId: hostId.refine((id) => id !== "local"),
|
|
20092
|
+
input: delegationReadParamsSchema
|
|
20093
|
+
}),
|
|
19818
20094
|
external_exports.strictObject({
|
|
19819
20095
|
action: external_exports.literal("save"),
|
|
19820
20096
|
draft: codexSshDraftSchema,
|
|
@@ -19975,10 +20251,12 @@ var tokenFields = [
|
|
|
19975
20251
|
];
|
|
19976
20252
|
var safeIntegerFields = [
|
|
19977
20253
|
"planFiveHourResetsAtUnix",
|
|
19978
|
-
"planSevenDayResetsAtUnix"
|
|
20254
|
+
"planSevenDayResetsAtUnix",
|
|
20255
|
+
"timeToFirstOutputMs"
|
|
19979
20256
|
];
|
|
19980
20257
|
var percentFields = [
|
|
19981
20258
|
"cacheHitRatePercent",
|
|
20259
|
+
"sessionCacheHitRatePercent",
|
|
19982
20260
|
"planFiveHourUsedPercent",
|
|
19983
20261
|
"planSevenDayUsedPercent"
|
|
19984
20262
|
];
|
|
@@ -19986,10 +20264,14 @@ var usageFields = /* @__PURE__ */ new Set([
|
|
|
19986
20264
|
...tokenFields,
|
|
19987
20265
|
...safeIntegerFields,
|
|
19988
20266
|
...percentFields,
|
|
20267
|
+
"sessionCacheUsage",
|
|
19989
20268
|
"totalCostUsd",
|
|
19990
20269
|
"totalCredits",
|
|
19991
20270
|
"contextUsagePercent",
|
|
19992
|
-
"outputTokensPerSecond"
|
|
20271
|
+
"outputTokensPerSecond",
|
|
20272
|
+
"apiOutputTokensPerSecond",
|
|
20273
|
+
"costSource",
|
|
20274
|
+
"unpricedModels"
|
|
19993
20275
|
]);
|
|
19994
20276
|
function isRecord(value) {
|
|
19995
20277
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -20005,7 +20287,11 @@ function parseHostUsage(value) {
|
|
|
20005
20287
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
20006
20288
|
}
|
|
20007
20289
|
}
|
|
20008
|
-
for (const field of [
|
|
20290
|
+
for (const field of [
|
|
20291
|
+
"totalCredits",
|
|
20292
|
+
"contextUsagePercent",
|
|
20293
|
+
"apiOutputTokensPerSecond"
|
|
20294
|
+
]) {
|
|
20009
20295
|
const candidate = value[field];
|
|
20010
20296
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
20011
20297
|
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
@@ -20035,6 +20321,12 @@ function parseHostUsage(value) {
|
|
|
20035
20321
|
throw new Error(`Harness Usage '${field}' must be between 0 and 100`);
|
|
20036
20322
|
}
|
|
20037
20323
|
}
|
|
20324
|
+
if (value.sessionCacheUsage !== void 0) {
|
|
20325
|
+
const totals2 = value.sessionCacheUsage;
|
|
20326
|
+
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) {
|
|
20327
|
+
throw new Error("Harness Usage 'sessionCacheUsage' must contain complete bounded token totals");
|
|
20328
|
+
}
|
|
20329
|
+
}
|
|
20038
20330
|
const hasContextUsed = value.contextUsedTokens !== void 0;
|
|
20039
20331
|
const hasContextWindow = value.contextWindowTokens !== void 0;
|
|
20040
20332
|
if (hasContextUsed !== hasContextWindow) {
|
|
@@ -20049,168 +20341,89 @@ function parseHostUsage(value) {
|
|
|
20049
20341
|
if (value.planSevenDayResetsAtUnix !== void 0 && value.planSevenDayUsedPercent === void 0) {
|
|
20050
20342
|
throw new Error("Harness Usage 'planSevenDayResetsAtUnix' must be provided with 'planSevenDayUsedPercent'");
|
|
20051
20343
|
}
|
|
20344
|
+
if (value.costSource !== void 0) {
|
|
20345
|
+
if (value.costSource !== "publicPrice" && value.costSource !== "native") {
|
|
20346
|
+
throw new Error("Harness Usage 'costSource' must be 'publicPrice' or 'native'");
|
|
20347
|
+
}
|
|
20348
|
+
if (value.totalCostUsd === void 0) {
|
|
20349
|
+
throw new Error("Harness Usage 'costSource' must be provided with 'totalCostUsd'");
|
|
20350
|
+
}
|
|
20351
|
+
}
|
|
20352
|
+
if (value.unpricedModels !== void 0) {
|
|
20353
|
+
const models = value.unpricedModels;
|
|
20354
|
+
if (!Array.isArray(models) || models.length === 0 || !models.every((model2) => typeof model2 === "string" && model2.length > 0)) {
|
|
20355
|
+
throw new Error("Harness Usage 'unpricedModels' must be a non-empty list of Model IDs");
|
|
20356
|
+
}
|
|
20357
|
+
if (value.costSource !== "publicPrice") {
|
|
20358
|
+
throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
|
|
20359
|
+
}
|
|
20360
|
+
return { ...value, unpricedModels: [...models] };
|
|
20361
|
+
}
|
|
20052
20362
|
return { ...value };
|
|
20053
20363
|
}
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20063
|
-
},
|
|
20064
|
-
{
|
|
20065
|
-
id: "dsh.goal",
|
|
20066
|
-
invocation: "/dsh-goal",
|
|
20067
|
-
label: "Goal",
|
|
20068
|
-
description: "Set or view the goal for a long-running task",
|
|
20069
|
-
argumentMode: "text"
|
|
20070
|
-
},
|
|
20071
|
-
{
|
|
20072
|
-
id: "dsh.plan",
|
|
20073
|
-
invocation: "/plan",
|
|
20074
|
-
label: "Plan mode",
|
|
20075
|
-
description: "Enter or leave plan mode",
|
|
20076
|
-
argumentMode: "text"
|
|
20077
|
-
}
|
|
20364
|
+
var requestTokenFields = [
|
|
20365
|
+
"inputTokens",
|
|
20366
|
+
"cachedInputTokens",
|
|
20367
|
+
"cacheWriteInputTokens",
|
|
20368
|
+
"cacheWrite1hInputTokens",
|
|
20369
|
+
"outputTokens",
|
|
20370
|
+
"reasoningOutputTokens",
|
|
20371
|
+
"startedAtMs",
|
|
20372
|
+
"completedAtMs"
|
|
20078
20373
|
];
|
|
20079
|
-
|
|
20080
|
-
|
|
20081
|
-
|
|
20082
|
-
|
|
20083
|
-
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
|
|
20089
|
-
|
|
20090
|
-
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
return {
|
|
20094
|
-
ok: false,
|
|
20095
|
-
error: {
|
|
20096
|
-
code: "unsupported",
|
|
20097
|
-
message: `DeepSeek Harness does not expose command '${command.commandId}'`,
|
|
20098
|
-
retryable: false
|
|
20099
|
-
}
|
|
20100
|
-
};
|
|
20101
|
-
}
|
|
20102
|
-
const nativeInvocation = definition.id === "dsh.goal" ? "/goal" : definition.invocation;
|
|
20103
|
-
const arguments_ = command.arguments;
|
|
20104
|
-
if (definition.argumentMode === "none") {
|
|
20105
|
-
return arguments_ && Object.keys(arguments_).length > 0 ? invalidArguments(`DeepSeek Harness ${nativeInvocation} command does not accept arguments`) : { ok: true, value: { commandId: definition.id, line: nativeInvocation } };
|
|
20106
|
-
}
|
|
20107
|
-
if (arguments_?.text !== void 0 && typeof arguments_.text !== "string") {
|
|
20108
|
-
return invalidArguments(`DeepSeek Harness ${nativeInvocation} command argument 'text' must be a string`);
|
|
20374
|
+
var requestFields = /* @__PURE__ */ new Set([
|
|
20375
|
+
...requestTokenFields,
|
|
20376
|
+
"requestId",
|
|
20377
|
+
"historical",
|
|
20378
|
+
"model",
|
|
20379
|
+
"provider"
|
|
20380
|
+
]);
|
|
20381
|
+
function parseHostUsageRequest(value) {
|
|
20382
|
+
if (!isRecord(value))
|
|
20383
|
+
throw new Error("Harness Usage request must be an object");
|
|
20384
|
+
for (const key of Object.keys(value)) {
|
|
20385
|
+
if (!requestFields.has(key)) {
|
|
20386
|
+
throw new Error(`Harness Usage request contains unknown field '${key}'`);
|
|
20387
|
+
}
|
|
20109
20388
|
}
|
|
20110
|
-
if (
|
|
20111
|
-
|
|
20389
|
+
if (typeof value.requestId !== "string" || value.requestId.length === 0) {
|
|
20390
|
+
throw new Error("Harness Usage request 'requestId' must be a non-empty string");
|
|
20112
20391
|
}
|
|
20113
|
-
const
|
|
20114
|
-
|
|
20115
|
-
|
|
20116
|
-
|
|
20117
|
-
return {
|
|
20118
|
-
ok: true,
|
|
20119
|
-
value: {
|
|
20120
|
-
commandId: definition.id,
|
|
20121
|
-
line: text.length > 0 ? `${nativeInvocation} ${text}` : nativeInvocation
|
|
20392
|
+
for (const field of ["model", "provider"]) {
|
|
20393
|
+
const candidate = value[field];
|
|
20394
|
+
if (candidate !== void 0 && (typeof candidate !== "string" || candidate.length === 0)) {
|
|
20395
|
+
throw new Error(`Harness Usage request '${field}' must be a non-empty string`);
|
|
20122
20396
|
}
|
|
20123
|
-
};
|
|
20124
|
-
}
|
|
20125
|
-
|
|
20126
|
-
// dist/generation-selector.js
|
|
20127
|
-
import { spawn } from "node:child_process";
|
|
20128
|
-
|
|
20129
|
-
// dist/executable.js
|
|
20130
|
-
import { spawnSync } from "node:child_process";
|
|
20131
|
-
import { accessSync, constants, statSync } from "node:fs";
|
|
20132
|
-
import path5 from "node:path";
|
|
20133
|
-
function environmentValue2(environment, name) {
|
|
20134
|
-
return Object.entries(environment).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
20135
|
-
}
|
|
20136
|
-
function executableCandidates(command, environment) {
|
|
20137
|
-
const targetPath2 = process.platform === "win32" ? path5.win32 : path5.posix;
|
|
20138
|
-
if (targetPath2.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
20139
|
-
return [command];
|
|
20140
20397
|
}
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
}
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
accessSync(candidate, accessMode);
|
|
20149
|
-
if (statSync(candidate).isFile())
|
|
20150
|
-
return candidate;
|
|
20151
|
-
} catch {
|
|
20398
|
+
if (value.historical !== void 0 && typeof value.historical !== "boolean") {
|
|
20399
|
+
throw new Error("Harness Usage request 'historical' must be a boolean");
|
|
20400
|
+
}
|
|
20401
|
+
for (const field of requestTokenFields) {
|
|
20402
|
+
const candidate = value[field];
|
|
20403
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
20404
|
+
throw new Error(`Harness Usage request '${field}' must be a non-negative safe integer`);
|
|
20152
20405
|
}
|
|
20153
20406
|
}
|
|
20154
|
-
|
|
20155
|
-
|
|
20156
|
-
function resolveDeepSeekCommand(configured, environment) {
|
|
20157
|
-
if (configured) {
|
|
20158
|
-
const command = resolveExecutable(configured, environment);
|
|
20159
|
-
return command ? { command, arguments: [], kind: "configured" } : null;
|
|
20407
|
+
if (value.inputTokens === void 0 || value.outputTokens === void 0) {
|
|
20408
|
+
throw new Error("Harness Usage request must contain 'inputTokens' and 'outputTokens'");
|
|
20160
20409
|
}
|
|
20161
|
-
const
|
|
20162
|
-
if (
|
|
20163
|
-
|
|
20164
|
-
const npx = resolveExecutable(process.platform === "win32" ? "npx.cmd" : "npx", environment);
|
|
20165
|
-
return npx ? {
|
|
20166
|
-
command: npx,
|
|
20167
|
-
arguments: ["--offline", "--no-install", "@deepseek-ai/dsh"],
|
|
20168
|
-
kind: "npx"
|
|
20169
|
-
} : null;
|
|
20170
|
-
}
|
|
20171
|
-
function deepSeekProcessInvocation(command, arguments_, environment, platform = process.platform) {
|
|
20172
|
-
const extension2 = path5.win32.extname(command).toLowerCase();
|
|
20173
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension2)) {
|
|
20174
|
-
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
20410
|
+
const request = value;
|
|
20411
|
+
if ((request.cachedInputTokens ?? 0) + (request.cacheWriteInputTokens ?? 0) > request.inputTokens) {
|
|
20412
|
+
throw new Error("Harness Usage request cache Tokens must not exceed 'inputTokens'");
|
|
20175
20413
|
}
|
|
20176
|
-
|
|
20177
|
-
|
|
20178
|
-
return {
|
|
20179
|
-
command: environmentValue2(environment, "ComSpec") ?? "cmd.exe",
|
|
20180
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
20181
|
-
windowsVerbatimArguments: true
|
|
20182
|
-
};
|
|
20183
|
-
}
|
|
20184
|
-
function resolveWindowsTaskkillPath(environment) {
|
|
20185
|
-
const systemRoot = environmentValue2(environment, "SystemRoot") ?? environmentValue2(environment, "windir");
|
|
20186
|
-
if (!systemRoot || !/^[A-Za-z]:[\\/]/u.test(systemRoot)) {
|
|
20187
|
-
throw new Error("Windows SystemRoot is unavailable or invalid");
|
|
20414
|
+
if ((request.reasoningOutputTokens ?? 0) > request.outputTokens) {
|
|
20415
|
+
throw new Error("Harness Usage request 'reasoningOutputTokens' must not exceed 'outputTokens'");
|
|
20188
20416
|
}
|
|
20189
|
-
|
|
20190
|
-
|
|
20191
|
-
function killDeepSeekProcessTree(child, platform, timeoutMs) {
|
|
20192
|
-
if (!child.pid) {
|
|
20193
|
-
if (child.exitCode === null && child.signalCode === null)
|
|
20194
|
-
child.kill("SIGKILL");
|
|
20195
|
-
return;
|
|
20417
|
+
if (request.cacheWrite1hInputTokens !== void 0 && request.cacheWrite1hInputTokens > (request.cacheWriteInputTokens ?? -1)) {
|
|
20418
|
+
throw new Error("Harness Usage request 'cacheWrite1hInputTokens' must not exceed 'cacheWriteInputTokens'");
|
|
20196
20419
|
}
|
|
20197
|
-
if (
|
|
20198
|
-
|
|
20199
|
-
stdio: "ignore",
|
|
20200
|
-
windowsHide: true,
|
|
20201
|
-
timeout: timeoutMs
|
|
20202
|
-
});
|
|
20203
|
-
if (result.error)
|
|
20204
|
-
throw result.error;
|
|
20205
|
-
return;
|
|
20420
|
+
if (request.startedAtMs === void 0 !== (request.completedAtMs === void 0)) {
|
|
20421
|
+
throw new Error("Harness Usage request timing fields must be provided together");
|
|
20206
20422
|
}
|
|
20207
|
-
|
|
20208
|
-
|
|
20209
|
-
} catch (error51) {
|
|
20210
|
-
if (typeof error51 !== "object" || error51 === null || Reflect.get(error51, "code") !== "ESRCH") {
|
|
20211
|
-
throw error51;
|
|
20212
|
-
}
|
|
20423
|
+
if (request.startedAtMs !== void 0 && request.completedAtMs !== void 0 && request.completedAtMs < request.startedAtMs) {
|
|
20424
|
+
throw new Error("Harness Usage request 'completedAtMs' must not precede 'startedAtMs'");
|
|
20213
20425
|
}
|
|
20426
|
+
return { ...request };
|
|
20214
20427
|
}
|
|
20215
20428
|
|
|
20216
20429
|
// dist/profiles/v4.js
|
|
@@ -20587,16 +20800,16 @@ var Diff = class {
|
|
|
20587
20800
|
}
|
|
20588
20801
|
}
|
|
20589
20802
|
}
|
|
20590
|
-
addToPath(
|
|
20591
|
-
const last =
|
|
20803
|
+
addToPath(path9, added, removed, oldPosInc, options) {
|
|
20804
|
+
const last = path9.lastComponent;
|
|
20592
20805
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
20593
20806
|
return {
|
|
20594
|
-
oldPos:
|
|
20807
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20595
20808
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
20596
20809
|
};
|
|
20597
20810
|
} else {
|
|
20598
20811
|
return {
|
|
20599
|
-
oldPos:
|
|
20812
|
+
oldPos: path9.oldPos + oldPosInc,
|
|
20600
20813
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
20601
20814
|
};
|
|
20602
20815
|
}
|
|
@@ -21793,6 +22006,351 @@ var DEEPSEEK_V4_PROFILE = Object.freeze({
|
|
|
21793
22006
|
settlementUsage
|
|
21794
22007
|
});
|
|
21795
22008
|
|
|
22009
|
+
// dist/modern/usage-metering.js
|
|
22010
|
+
function isRecord5(value) {
|
|
22011
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22012
|
+
}
|
|
22013
|
+
function count2(value) {
|
|
22014
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
22015
|
+
}
|
|
22016
|
+
function firstTokenTime(chunks) {
|
|
22017
|
+
for (const { time: time3, chunk } of chunks) {
|
|
22018
|
+
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) {
|
|
22019
|
+
return time3;
|
|
22020
|
+
}
|
|
22021
|
+
}
|
|
22022
|
+
return null;
|
|
22023
|
+
}
|
|
22024
|
+
function deepSeekUsageRecord(event, historical) {
|
|
22025
|
+
if (event.type !== "assistant/message" || event.surfaceOp !== "append")
|
|
22026
|
+
return { kind: "none" };
|
|
22027
|
+
const data = isRecord5(event.data) ? event.data : null;
|
|
22028
|
+
const message = data && isRecord5(data.message) ? data.message : null;
|
|
22029
|
+
const source = message && isRecord5(message.source) ? message.source : null;
|
|
22030
|
+
if (!data || !message || source?.kind !== "model")
|
|
22031
|
+
return { kind: "none" };
|
|
22032
|
+
if (typeof message.id !== "string" || message.id.length === 0)
|
|
22033
|
+
return { kind: "missing" };
|
|
22034
|
+
if (typeof source.model !== "string" || source.model.length === 0)
|
|
22035
|
+
return { kind: "missing" };
|
|
22036
|
+
let chunks;
|
|
22037
|
+
try {
|
|
22038
|
+
chunks = expandAssistantStream(data.stream);
|
|
22039
|
+
} catch {
|
|
22040
|
+
return { kind: "missing" };
|
|
22041
|
+
}
|
|
22042
|
+
let usage = data.usage;
|
|
22043
|
+
for (const { chunk } of chunks)
|
|
22044
|
+
if (chunk.type === "usage")
|
|
22045
|
+
usage = chunk.usage;
|
|
22046
|
+
if (usage === void 0)
|
|
22047
|
+
return data.interrupted === true ? { kind: "none" } : { kind: "missing" };
|
|
22048
|
+
if (!isRecord5(usage))
|
|
22049
|
+
return { kind: "missing" };
|
|
22050
|
+
const input = count2(usage.inputTokens);
|
|
22051
|
+
const output = count2(usage.outputTokens);
|
|
22052
|
+
const cacheRead = count2(usage.cacheReadTokens ?? 0);
|
|
22053
|
+
const cacheWrite = count2(usage.cacheWriteTokens ?? 0);
|
|
22054
|
+
const reasoning2 = usage.reasoningTokens === void 0 ? null : count2(usage.reasoningTokens);
|
|
22055
|
+
if (input === null || output === null || cacheRead === null || cacheWrite === null) {
|
|
22056
|
+
return { kind: "missing" };
|
|
22057
|
+
}
|
|
22058
|
+
const startedAtMs = historical ? null : firstTokenTime(chunks);
|
|
22059
|
+
const completedAtMs = typeof event.time === "number" ? event.time : null;
|
|
22060
|
+
try {
|
|
22061
|
+
return {
|
|
22062
|
+
kind: "request",
|
|
22063
|
+
request: parseHostUsageRequest({
|
|
22064
|
+
requestId: message.id,
|
|
22065
|
+
...historical ? { historical: true } : {},
|
|
22066
|
+
model: source.model,
|
|
22067
|
+
inputTokens: input + cacheRead + cacheWrite,
|
|
22068
|
+
cachedInputTokens: cacheRead,
|
|
22069
|
+
cacheWriteInputTokens: cacheWrite,
|
|
22070
|
+
outputTokens: output,
|
|
22071
|
+
...reasoning2 !== null && reasoning2 <= output ? { reasoningOutputTokens: reasoning2 } : {},
|
|
22072
|
+
...startedAtMs !== null && completedAtMs !== null && completedAtMs >= startedAtMs ? { startedAtMs, completedAtMs } : {}
|
|
22073
|
+
})
|
|
22074
|
+
};
|
|
22075
|
+
} catch {
|
|
22076
|
+
return { kind: "missing" };
|
|
22077
|
+
}
|
|
22078
|
+
}
|
|
22079
|
+
function deepSeekUsageHistory(events) {
|
|
22080
|
+
const requests = /* @__PURE__ */ new Map();
|
|
22081
|
+
let complete = true;
|
|
22082
|
+
for (const event of events) {
|
|
22083
|
+
const record2 = deepSeekUsageRecord(event, true);
|
|
22084
|
+
if (record2.kind === "request")
|
|
22085
|
+
requests.set(record2.request.requestId, record2.request);
|
|
22086
|
+
else if (record2.kind === "missing")
|
|
22087
|
+
complete = false;
|
|
22088
|
+
}
|
|
22089
|
+
return { requests: [...requests.values()], complete };
|
|
22090
|
+
}
|
|
22091
|
+
|
|
22092
|
+
// dist/modern/usage-statistics.js
|
|
22093
|
+
var SESSION_FILE = /^session(?:\.v(\d+))?\.jsonl(\.zstd)?$/u;
|
|
22094
|
+
var ZSTD_MAGIC = 4247762216;
|
|
22095
|
+
function dshHome(environment) {
|
|
22096
|
+
return environment.DSH_HOME || path5.join(environment.HOME || os2.homedir(), ".dsh");
|
|
22097
|
+
}
|
|
22098
|
+
function zstdFrames(buffer) {
|
|
22099
|
+
const frames = [];
|
|
22100
|
+
let offset = 0;
|
|
22101
|
+
while (offset + 8 <= buffer.length) {
|
|
22102
|
+
const magic = buffer.readUInt32LE(offset);
|
|
22103
|
+
if ((magic & 4294967280) === 407710288) {
|
|
22104
|
+
offset += 8 + buffer.readUInt32LE(offset + 4);
|
|
22105
|
+
continue;
|
|
22106
|
+
}
|
|
22107
|
+
if (magic !== ZSTD_MAGIC)
|
|
22108
|
+
throw new Error("dsh session file is not zstd");
|
|
22109
|
+
const start = offset;
|
|
22110
|
+
const descriptor = buffer[offset + 4] ?? 0;
|
|
22111
|
+
const single = descriptor >> 5 & 1;
|
|
22112
|
+
offset += 5 + (single ? 0 : 1);
|
|
22113
|
+
offset += [0, 1, 2, 4][descriptor & 3] ?? 0;
|
|
22114
|
+
offset += [single, 2, 4, 8][descriptor >> 6] ?? 0;
|
|
22115
|
+
for (; ; ) {
|
|
22116
|
+
if (offset + 3 > buffer.length)
|
|
22117
|
+
return frames;
|
|
22118
|
+
const header = buffer.readUIntLE(offset, 3);
|
|
22119
|
+
const type = header >> 1 & 3;
|
|
22120
|
+
if (type === 3)
|
|
22121
|
+
throw new Error("dsh session file has a reserved zstd block");
|
|
22122
|
+
offset += 3 + (type === 1 ? 1 : header >>> 3);
|
|
22123
|
+
if (header & 1)
|
|
22124
|
+
break;
|
|
22125
|
+
}
|
|
22126
|
+
if (descriptor >> 2 & 1)
|
|
22127
|
+
offset += 4;
|
|
22128
|
+
if (offset > buffer.length)
|
|
22129
|
+
return frames;
|
|
22130
|
+
frames.push(buffer.subarray(start, offset));
|
|
22131
|
+
}
|
|
22132
|
+
return frames;
|
|
22133
|
+
}
|
|
22134
|
+
async function readDshUsage(file2) {
|
|
22135
|
+
const buffer = await readFile2(file2);
|
|
22136
|
+
const text = file2.endsWith(".zstd") ? zstdFrames(buffer).map((frame) => zstdDecompressSync(frame).toString("utf8")).join("") : buffer.toString("utf8");
|
|
22137
|
+
const entries = [];
|
|
22138
|
+
let session = {};
|
|
22139
|
+
for (const line of text.split("\n")) {
|
|
22140
|
+
if (entries.length === 0 && line.startsWith('{"type":"session"')) {
|
|
22141
|
+
try {
|
|
22142
|
+
const header = JSON.parse(line);
|
|
22143
|
+
const title = usageSessionTitle(header.title ?? header.name);
|
|
22144
|
+
session = {
|
|
22145
|
+
...typeof header.id === "string" ? { sessionId: header.id } : {},
|
|
22146
|
+
...typeof header.cwd === "string" ? { cwd: header.cwd } : {},
|
|
22147
|
+
...title ? { title } : {}
|
|
22148
|
+
};
|
|
22149
|
+
} catch {
|
|
22150
|
+
}
|
|
22151
|
+
continue;
|
|
22152
|
+
}
|
|
22153
|
+
if (!line.includes('"assistant/message"'))
|
|
22154
|
+
continue;
|
|
22155
|
+
let event;
|
|
22156
|
+
try {
|
|
22157
|
+
event = JSON.parse(line);
|
|
22158
|
+
} catch {
|
|
22159
|
+
continue;
|
|
22160
|
+
}
|
|
22161
|
+
const record2 = deepSeekUsageRecord(event, true);
|
|
22162
|
+
const entry = record2.kind === "request" && usageEntryFromRequest(record2.request, event.time);
|
|
22163
|
+
if (entry)
|
|
22164
|
+
entries.push(withUsageSession(entry, session));
|
|
22165
|
+
}
|
|
22166
|
+
return entries;
|
|
22167
|
+
}
|
|
22168
|
+
function createDshUsageStatistics(environment) {
|
|
22169
|
+
return Object.freeze({
|
|
22170
|
+
async listSources(signal) {
|
|
22171
|
+
const root = path5.join(dshHome(environment), "sessions");
|
|
22172
|
+
const sources = [];
|
|
22173
|
+
for (const project2 of await readdir(root).catch(() => [])) {
|
|
22174
|
+
for (const session of await readdir(path5.join(root, project2)).catch(() => [])) {
|
|
22175
|
+
signal.throwIfAborted();
|
|
22176
|
+
const directory = path5.join(root, project2, session);
|
|
22177
|
+
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];
|
|
22178
|
+
if (!latest)
|
|
22179
|
+
continue;
|
|
22180
|
+
const file2 = path5.join(directory, latest.name);
|
|
22181
|
+
const info = await lstat(file2).catch(() => null);
|
|
22182
|
+
if (info?.isFile() && info.size > 0) {
|
|
22183
|
+
sources.push({ id: file2, fingerprint: `${info.ino}:${info.size}:${info.mtimeMs}` });
|
|
22184
|
+
}
|
|
22185
|
+
}
|
|
22186
|
+
}
|
|
22187
|
+
return sources;
|
|
22188
|
+
},
|
|
22189
|
+
readSource: (id) => readDshUsage(id)
|
|
22190
|
+
});
|
|
22191
|
+
}
|
|
22192
|
+
|
|
22193
|
+
// dist/harness-commands.js
|
|
22194
|
+
var commandDefinitions = [
|
|
22195
|
+
{
|
|
22196
|
+
id: "dsh.compact",
|
|
22197
|
+
invocation: "/compact",
|
|
22198
|
+
label: "Compact context",
|
|
22199
|
+
description: "Compact the current conversation context",
|
|
22200
|
+
argumentMode: "none"
|
|
22201
|
+
},
|
|
22202
|
+
{
|
|
22203
|
+
id: "dsh.goal",
|
|
22204
|
+
invocation: "/dsh-goal",
|
|
22205
|
+
label: "Goal",
|
|
22206
|
+
description: "Set or view the goal for a long-running task",
|
|
22207
|
+
argumentMode: "text"
|
|
22208
|
+
},
|
|
22209
|
+
{
|
|
22210
|
+
id: "dsh.plan",
|
|
22211
|
+
invocation: "/plan",
|
|
22212
|
+
label: "Plan mode",
|
|
22213
|
+
description: "Enter or leave plan mode",
|
|
22214
|
+
argumentMode: "text"
|
|
22215
|
+
}
|
|
22216
|
+
];
|
|
22217
|
+
function invalidArguments(message) {
|
|
22218
|
+
return {
|
|
22219
|
+
ok: false,
|
|
22220
|
+
error: { code: "invalidRequest", message, retryable: false }
|
|
22221
|
+
};
|
|
22222
|
+
}
|
|
22223
|
+
function deepSeekHarnessCommandCatalog() {
|
|
22224
|
+
return harnessCommandCatalogSchema.parse({
|
|
22225
|
+
commands: commandDefinitions
|
|
22226
|
+
});
|
|
22227
|
+
}
|
|
22228
|
+
function parseDeepSeekHarnessCommand(command) {
|
|
22229
|
+
const definition = commandDefinitions.find(({ id }) => id === command.commandId);
|
|
22230
|
+
if (!definition) {
|
|
22231
|
+
return {
|
|
22232
|
+
ok: false,
|
|
22233
|
+
error: {
|
|
22234
|
+
code: "unsupported",
|
|
22235
|
+
message: `DeepSeek Harness does not expose command '${command.commandId}'`,
|
|
22236
|
+
retryable: false
|
|
22237
|
+
}
|
|
22238
|
+
};
|
|
22239
|
+
}
|
|
22240
|
+
const nativeInvocation = definition.id === "dsh.goal" ? "/goal" : definition.invocation;
|
|
22241
|
+
const arguments_ = command.arguments;
|
|
22242
|
+
if (definition.argumentMode === "none") {
|
|
22243
|
+
return arguments_ && Object.keys(arguments_).length > 0 ? invalidArguments(`DeepSeek Harness ${nativeInvocation} command does not accept arguments`) : { ok: true, value: { commandId: definition.id, line: nativeInvocation } };
|
|
22244
|
+
}
|
|
22245
|
+
if (arguments_?.text !== void 0 && typeof arguments_.text !== "string") {
|
|
22246
|
+
return invalidArguments(`DeepSeek Harness ${nativeInvocation} command argument 'text' must be a string`);
|
|
22247
|
+
}
|
|
22248
|
+
if (arguments_ && Object.keys(arguments_).some((key) => key !== "text")) {
|
|
22249
|
+
return invalidArguments(`DeepSeek Harness ${nativeInvocation} command has an unknown argument`);
|
|
22250
|
+
}
|
|
22251
|
+
const text = arguments_?.text?.trim() ?? "";
|
|
22252
|
+
if (definition.id === "dsh.goal" && text.toLowerCase() === "edit") {
|
|
22253
|
+
return invalidArguments("DeepSeek Harness /goal edit command requires a replacement objective");
|
|
22254
|
+
}
|
|
22255
|
+
return {
|
|
22256
|
+
ok: true,
|
|
22257
|
+
value: {
|
|
22258
|
+
commandId: definition.id,
|
|
22259
|
+
line: text.length > 0 ? `${nativeInvocation} ${text}` : nativeInvocation
|
|
22260
|
+
}
|
|
22261
|
+
};
|
|
22262
|
+
}
|
|
22263
|
+
|
|
22264
|
+
// dist/generation-selector.js
|
|
22265
|
+
import { spawn } from "node:child_process";
|
|
22266
|
+
|
|
22267
|
+
// dist/executable.js
|
|
22268
|
+
import { spawnSync } from "node:child_process";
|
|
22269
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
22270
|
+
import path6 from "node:path";
|
|
22271
|
+
function environmentValue2(environment, name) {
|
|
22272
|
+
return Object.entries(environment).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
22273
|
+
}
|
|
22274
|
+
function executableCandidates(command, environment) {
|
|
22275
|
+
const targetPath2 = process.platform === "win32" ? path6.win32 : path6.posix;
|
|
22276
|
+
if (targetPath2.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
22277
|
+
return [command];
|
|
22278
|
+
}
|
|
22279
|
+
const extensions = process.platform === "win32" && targetPath2.extname(command) === "" ? (environmentValue2(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension2) => extension2.trim()).filter(Boolean) : [""];
|
|
22280
|
+
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)));
|
|
22281
|
+
}
|
|
22282
|
+
function resolveExecutable(command, environment) {
|
|
22283
|
+
const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
22284
|
+
for (const candidate of executableCandidates(command, environment)) {
|
|
22285
|
+
try {
|
|
22286
|
+
accessSync(candidate, accessMode);
|
|
22287
|
+
if (statSync(candidate).isFile())
|
|
22288
|
+
return candidate;
|
|
22289
|
+
} catch {
|
|
22290
|
+
}
|
|
22291
|
+
}
|
|
22292
|
+
return null;
|
|
22293
|
+
}
|
|
22294
|
+
function resolveDeepSeekCommand(configured, environment) {
|
|
22295
|
+
if (configured) {
|
|
22296
|
+
const command = resolveExecutable(configured, environment);
|
|
22297
|
+
return command ? { command, arguments: [], kind: "configured" } : null;
|
|
22298
|
+
}
|
|
22299
|
+
const dsh = resolveExecutable("dsh", environment);
|
|
22300
|
+
if (dsh)
|
|
22301
|
+
return { command: dsh, arguments: [], kind: "dsh" };
|
|
22302
|
+
const npx = resolveExecutable(process.platform === "win32" ? "npx.cmd" : "npx", environment);
|
|
22303
|
+
return npx ? {
|
|
22304
|
+
command: npx,
|
|
22305
|
+
arguments: ["--offline", "--no-install", "@deepseek-ai/dsh"],
|
|
22306
|
+
kind: "npx"
|
|
22307
|
+
} : null;
|
|
22308
|
+
}
|
|
22309
|
+
function deepSeekProcessInvocation(command, arguments_, environment, platform = process.platform) {
|
|
22310
|
+
const extension2 = path6.win32.extname(command).toLowerCase();
|
|
22311
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension2)) {
|
|
22312
|
+
return { command, arguments: arguments_, windowsVerbatimArguments: false };
|
|
22313
|
+
}
|
|
22314
|
+
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
22315
|
+
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
22316
|
+
return {
|
|
22317
|
+
command: environmentValue2(environment, "ComSpec") ?? "cmd.exe",
|
|
22318
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
22319
|
+
windowsVerbatimArguments: true
|
|
22320
|
+
};
|
|
22321
|
+
}
|
|
22322
|
+
function resolveWindowsTaskkillPath(environment) {
|
|
22323
|
+
const systemRoot = environmentValue2(environment, "SystemRoot") ?? environmentValue2(environment, "windir");
|
|
22324
|
+
if (!systemRoot || !/^[A-Za-z]:[\\/]/u.test(systemRoot)) {
|
|
22325
|
+
throw new Error("Windows SystemRoot is unavailable or invalid");
|
|
22326
|
+
}
|
|
22327
|
+
return path6.win32.join(systemRoot, "System32", "taskkill.exe");
|
|
22328
|
+
}
|
|
22329
|
+
function killDeepSeekProcessTree(child, platform, timeoutMs) {
|
|
22330
|
+
if (!child.pid) {
|
|
22331
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
22332
|
+
child.kill("SIGKILL");
|
|
22333
|
+
return;
|
|
22334
|
+
}
|
|
22335
|
+
if (platform === "win32") {
|
|
22336
|
+
const result = spawnSync(resolveWindowsTaskkillPath(process.env), ["/pid", String(child.pid), "/t", "/f"], {
|
|
22337
|
+
stdio: "ignore",
|
|
22338
|
+
windowsHide: true,
|
|
22339
|
+
timeout: timeoutMs
|
|
22340
|
+
});
|
|
22341
|
+
if (result.error)
|
|
22342
|
+
throw result.error;
|
|
22343
|
+
return;
|
|
22344
|
+
}
|
|
22345
|
+
try {
|
|
22346
|
+
process.kill(-child.pid, "SIGKILL");
|
|
22347
|
+
} catch (error51) {
|
|
22348
|
+
if (typeof error51 !== "object" || error51 === null || Reflect.get(error51, "code") !== "ESRCH") {
|
|
22349
|
+
throw error51;
|
|
22350
|
+
}
|
|
22351
|
+
}
|
|
22352
|
+
}
|
|
22353
|
+
|
|
21796
22354
|
// dist/profiles/profile.js
|
|
21797
22355
|
var DEEPSEEK_MINIMUM_VERSION = DEEPSEEK_V4_FIRST_VERSION;
|
|
21798
22356
|
var MINIMUM = parseSemVer(DEEPSEEK_MINIMUM_VERSION);
|
|
@@ -22165,7 +22723,7 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
|
|
|
22165
22723
|
|
|
22166
22724
|
// dist/modern/deepseek-harness-adapter.js
|
|
22167
22725
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22168
|
-
import
|
|
22726
|
+
import path8 from "node:path";
|
|
22169
22727
|
|
|
22170
22728
|
// dist/modern/catalog.js
|
|
22171
22729
|
import { Buffer as Buffer3 } from "node:buffer";
|
|
@@ -22173,9 +22731,9 @@ import { Buffer as Buffer3 } from "node:buffer";
|
|
|
22173
22731
|
// dist/model-catalog.js
|
|
22174
22732
|
import { Buffer as Buffer2 } from "node:buffer";
|
|
22175
22733
|
var MODEL_REF_PREFIX = "deepseek-harness-model-v2.";
|
|
22176
|
-
function encodeDeepSeekHarnessModelRef(
|
|
22177
|
-
const provider =
|
|
22178
|
-
const modelId =
|
|
22734
|
+
function encodeDeepSeekHarnessModelRef(model2) {
|
|
22735
|
+
const provider = model2.provider.trim();
|
|
22736
|
+
const modelId = model2.model.trim();
|
|
22179
22737
|
if (!provider || !modelId)
|
|
22180
22738
|
throw new Error("DeepSeek Harness Model identity must not be empty");
|
|
22181
22739
|
const encoded = Buffer2.from(JSON.stringify([provider, modelId]), "utf8").toString("base64url");
|
|
@@ -22214,8 +22772,8 @@ function parseDeepSeekThinkingOptionId(value) {
|
|
|
22214
22772
|
}
|
|
22215
22773
|
function normalizeDeepSeekThinkingOptions(models) {
|
|
22216
22774
|
const group = models.groups.find((candidate) => candidate.id === models.current.provider);
|
|
22217
|
-
const
|
|
22218
|
-
return (
|
|
22775
|
+
const model2 = group?.models.find((candidate) => candidate.id === models.current.model);
|
|
22776
|
+
return (model2?.reasoning?.efforts ?? []).flatMap((effort) => {
|
|
22219
22777
|
const parsedId = harnessThinkingOptionIdSchema.safeParse(effort.id);
|
|
22220
22778
|
return parsedId.success ? [{ id: parsedId.data, label: effort.name }] : [];
|
|
22221
22779
|
});
|
|
@@ -22224,8 +22782,8 @@ function normalizeDeepSeekModelCatalog(groups2, selection2) {
|
|
|
22224
22782
|
const thinkingOptions = [];
|
|
22225
22783
|
const knownEffortIds = /* @__PURE__ */ new Set();
|
|
22226
22784
|
for (const group of groups2) {
|
|
22227
|
-
for (const
|
|
22228
|
-
for (const effort of
|
|
22785
|
+
for (const model2 of group.models) {
|
|
22786
|
+
for (const effort of model2.reasoning?.efforts ?? []) {
|
|
22229
22787
|
if (knownEffortIds.has(effort.id))
|
|
22230
22788
|
continue;
|
|
22231
22789
|
const parsedId = harnessThinkingOptionIdSchema.safeParse(effort.id);
|
|
@@ -22236,16 +22794,16 @@ function normalizeDeepSeekModelCatalog(groups2, selection2) {
|
|
|
22236
22794
|
}
|
|
22237
22795
|
}
|
|
22238
22796
|
}
|
|
22239
|
-
const models = groups2.flatMap((group) => group.models.map((
|
|
22240
|
-
ref: encodeDeepSeekHarnessModelRef({ provider: group.id, model:
|
|
22241
|
-
label: `${group.name} / ${
|
|
22242
|
-
...
|
|
22797
|
+
const models = groups2.flatMap((group) => group.models.map((model2) => ({
|
|
22798
|
+
ref: encodeDeepSeekHarnessModelRef({ provider: group.id, model: model2.id }),
|
|
22799
|
+
label: `${group.name} / ${model2.name}`,
|
|
22800
|
+
...model2.reasoning && model2.reasoning.efforts.length > 0 ? { supportedThinkingOptionIds: model2.reasoning.efforts.map((effort) => effort.id) } : {}
|
|
22243
22801
|
})));
|
|
22244
22802
|
const defaultModel = selection2 ? encodeDeepSeekHarnessModelRef(selection2) : void 0;
|
|
22245
|
-
if (selection2 && defaultModel && !models.some((
|
|
22803
|
+
if (selection2 && defaultModel && !models.some((model2) => model2.ref.id === defaultModel.id)) {
|
|
22246
22804
|
models.unshift({ ref: defaultModel, label: `${selection2.provider} / ${selection2.model}` });
|
|
22247
22805
|
}
|
|
22248
|
-
const defaultReasoning = selection2 ? groups2.find((group) => group.id === selection2.provider)?.models.find((
|
|
22806
|
+
const defaultReasoning = selection2 ? groups2.find((group) => group.id === selection2.provider)?.models.find((model2) => model2.id === selection2.model)?.reasoning : void 0;
|
|
22249
22807
|
const defaultThinkingOptionId = parseDeepSeekThinkingOptionId(selection2?.reasoningEffort ?? defaultReasoning?.defaultEffort);
|
|
22250
22808
|
return harnessModelCatalogSchema.parse({
|
|
22251
22809
|
models,
|
|
@@ -23430,32 +23988,32 @@ function groups(value, routable) {
|
|
|
23430
23988
|
throw catalogError("protocolError", "DeepSeek Harness returned a non-routable Model group");
|
|
23431
23989
|
}
|
|
23432
23990
|
const name = boundedString(candidate.name, MAX_NAME_LENGTH, "Model provider name");
|
|
23433
|
-
const models = array2(candidate.models, MAX_MODELS, "Model list").map((
|
|
23991
|
+
const models = array2(candidate.models, MAX_MODELS, "Model list").map((model2) => {
|
|
23434
23992
|
modelCount += 1;
|
|
23435
23993
|
if (modelCount > MAX_MODELS) {
|
|
23436
23994
|
throw catalogError("limitExceeded", "DeepSeek Harness Model list exceeded its item bound");
|
|
23437
23995
|
}
|
|
23438
|
-
if (!isPlainRecord(
|
|
23996
|
+
if (!isPlainRecord(model2) || !exactKeys2(model2, ["id", "name"], ["description", "reasoning"])) {
|
|
23439
23997
|
throw catalogError("protocolError", "DeepSeek Harness returned an invalid Model");
|
|
23440
23998
|
}
|
|
23441
|
-
const modelId = boundedString(
|
|
23442
|
-
const modelName = boundedString(
|
|
23999
|
+
const modelId = boundedString(model2.id, MAX_ID_LENGTH, "Model id");
|
|
24000
|
+
const modelName = boundedString(model2.name, MAX_NAME_LENGTH, "Model name");
|
|
23443
24001
|
if (`${name} / ${modelName}`.length > HARNESS_MODEL_LABEL_MAX_LENGTH) {
|
|
23444
24002
|
throw catalogError("protocolError", "DeepSeek Harness returned a Model label that is too long");
|
|
23445
24003
|
}
|
|
23446
24004
|
return {
|
|
23447
24005
|
id: modelId,
|
|
23448
24006
|
name: modelName,
|
|
23449
|
-
...
|
|
23450
|
-
description: boundedString(
|
|
24007
|
+
...model2.description === void 0 ? {} : {
|
|
24008
|
+
description: boundedString(model2.description, MAX_DESCRIPTION_LENGTH, "Model description", true)
|
|
23451
24009
|
},
|
|
23452
|
-
...
|
|
24010
|
+
...model2.reasoning === void 0 ? {} : { reasoning: reasoning(model2.reasoning) }
|
|
23453
24011
|
};
|
|
23454
24012
|
});
|
|
23455
24013
|
if (models.length === 0) {
|
|
23456
24014
|
throw catalogError("protocolError", "DeepSeek Harness returned an empty Model provider group");
|
|
23457
24015
|
}
|
|
23458
|
-
const modelIds = models.map((
|
|
24016
|
+
const modelIds = models.map((model2) => model2.id);
|
|
23459
24017
|
if (new Set(modelIds).size !== modelIds.length) {
|
|
23460
24018
|
throw catalogError("protocolError", "DeepSeek Harness returned duplicate Model ids");
|
|
23461
24019
|
}
|
|
@@ -23666,11 +24224,11 @@ function sanitizedError(error51, fallback) {
|
|
|
23666
24224
|
failure.name = redactModernCredential(error51 instanceof Error ? error51.name : "Error");
|
|
23667
24225
|
return failure;
|
|
23668
24226
|
}
|
|
23669
|
-
function
|
|
24227
|
+
function isRecord6(value) {
|
|
23670
24228
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23671
24229
|
}
|
|
23672
24230
|
function isPlainRecord3(value) {
|
|
23673
|
-
if (!
|
|
24231
|
+
if (!isRecord6(value))
|
|
23674
24232
|
return false;
|
|
23675
24233
|
const prototype = Object.getPrototypeOf(value);
|
|
23676
24234
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -23820,7 +24378,7 @@ function projectionRow(value, seq) {
|
|
|
23820
24378
|
return Object.freeze({ value: detachedJson(value), seq });
|
|
23821
24379
|
}
|
|
23822
24380
|
function parseProjectionBaseline(value, maxKeys) {
|
|
23823
|
-
if (!
|
|
24381
|
+
if (!isRecord6(value) || !hasExactKeys4(value, ["asOfSeq", "values"])) {
|
|
23824
24382
|
throw storeError("protocolError", "DeepSeek Harness control baseline has invalid projections");
|
|
23825
24383
|
}
|
|
23826
24384
|
if (!validCursor(value.asOfSeq) || !isPlainRecord3(value.values)) {
|
|
@@ -23846,7 +24404,7 @@ function parseProjectionBaseline(value, maxKeys) {
|
|
|
23846
24404
|
return { asOfSeq: value.asOfSeq, values, rowBytes };
|
|
23847
24405
|
}
|
|
23848
24406
|
function parseBaseline(value, maxSessions, maxKeys) {
|
|
23849
|
-
if (!
|
|
24407
|
+
if (!isRecord6(value) || !hasExactKeys4(value, ["projections"]) || !isPlainRecord3(value.projections)) {
|
|
23850
24408
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid baseline");
|
|
23851
24409
|
}
|
|
23852
24410
|
const sessions = /* @__PURE__ */ new Set();
|
|
@@ -23864,7 +24422,7 @@ function parseBaseline(value, maxSessions, maxKeys) {
|
|
|
23864
24422
|
return { projections };
|
|
23865
24423
|
}
|
|
23866
24424
|
function parseControlFrame(value, maxSessions, maxKeys) {
|
|
23867
|
-
if (!
|
|
24425
|
+
if (!isRecord6(value) || typeof value.type !== "string") {
|
|
23868
24426
|
throw storeError("protocolError", "DeepSeek Harness control stream emitted an invalid frame");
|
|
23869
24427
|
}
|
|
23870
24428
|
if (value.type === "baseline" && hasExactKeys4(value, ["type", "value"])) {
|
|
@@ -24589,14 +25147,14 @@ function parseSelection(value, area) {
|
|
|
24589
25147
|
throw configurationError("protocolError", `DeepSeek Harness returned an invalid ${area}`);
|
|
24590
25148
|
}
|
|
24591
25149
|
const provider = boundedSelectionString(value.provider, `${area} provider`);
|
|
24592
|
-
const
|
|
25150
|
+
const model2 = boundedSelectionString(value.model, `${area} Model`);
|
|
24593
25151
|
if (value.reasoningEffort === void 0)
|
|
24594
|
-
return { provider, model };
|
|
25152
|
+
return { provider, model: model2 };
|
|
24595
25153
|
const effort = harnessThinkingOptionIdSchema.safeParse(value.reasoningEffort);
|
|
24596
25154
|
if (!effort.success) {
|
|
24597
25155
|
throw configurationError("protocolError", `DeepSeek Harness returned an invalid ${area} reasoning effort`);
|
|
24598
25156
|
}
|
|
24599
|
-
return { provider, model, reasoningEffort: effort.data };
|
|
25157
|
+
return { provider, model: model2, reasoningEffort: effort.data };
|
|
24600
25158
|
}
|
|
24601
25159
|
function parseOptionalSelection(value, area) {
|
|
24602
25160
|
return value === null ? null : parseSelection(value, area);
|
|
@@ -24659,22 +25217,22 @@ function readModernConfigurationSnapshot(input) {
|
|
|
24659
25217
|
if (!rows) {
|
|
24660
25218
|
throw configurationError("protocolError", "DeepSeek Harness control state is detached");
|
|
24661
25219
|
}
|
|
24662
|
-
const
|
|
25220
|
+
const model2 = readModernModelSelectionState(rows[MODERN_MODEL_SELECTION_PROJECTION_KEY], input.modelCatalog);
|
|
24663
25221
|
const permission = readModernPermissionModeState(rows[MODERN_PERMISSION_PROJECTION_KEY], input.permissionModes);
|
|
24664
25222
|
return {
|
|
24665
|
-
model,
|
|
24666
|
-
state: stateForSelection(input.nativeRef,
|
|
25223
|
+
model: model2,
|
|
25224
|
+
state: stateForSelection(input.nativeRef, model2.selection, input.modelCatalog, permission?.permissionModeId),
|
|
24667
25225
|
...permission ? { permissionProjectionSeq: permission.projectionSeq } : {}
|
|
24668
25226
|
};
|
|
24669
25227
|
}
|
|
24670
|
-
function modernSelectionForModel(catalog,
|
|
25228
|
+
function modernSelectionForModel(catalog, model2, thinkingOptionId) {
|
|
24671
25229
|
let native;
|
|
24672
25230
|
try {
|
|
24673
|
-
native = decodeDeepSeekHarnessModelRef(
|
|
25231
|
+
native = decodeDeepSeekHarnessModelRef(model2);
|
|
24674
25232
|
} catch (error51) {
|
|
24675
25233
|
throw configurationError("invalidRequest", error51 instanceof Error ? error51.message : "DeepSeek Harness Model is invalid");
|
|
24676
25234
|
}
|
|
24677
|
-
const catalogModel = catalog.catalog.models.find(({ ref }) => ref.id ===
|
|
25235
|
+
const catalogModel = catalog.catalog.models.find(({ ref }) => ref.id === model2.id);
|
|
24678
25236
|
if (!catalogModel) {
|
|
24679
25237
|
throw configurationError("invalidRequest", "DeepSeek Harness Model is unavailable");
|
|
24680
25238
|
}
|
|
@@ -25753,11 +26311,11 @@ function malformedOutcome(event) {
|
|
|
25753
26311
|
function isApprovalOutcome(value) {
|
|
25754
26312
|
return value === "allowed-once" || value === "rejected" || value === "cancelled" || value === "unavailable";
|
|
25755
26313
|
}
|
|
25756
|
-
function
|
|
26314
|
+
function isRecord7(value) {
|
|
25757
26315
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25758
26316
|
}
|
|
25759
26317
|
function isPlainRecord6(value) {
|
|
25760
|
-
if (!
|
|
26318
|
+
if (!isRecord7(value))
|
|
25761
26319
|
return false;
|
|
25762
26320
|
const prototype = Object.getPrototypeOf(value);
|
|
25763
26321
|
return prototype === Object.prototype || prototype === null;
|
|
@@ -28034,6 +28592,10 @@ var ModernHarnessSession = class {
|
|
|
28034
28592
|
this.#fallbackThinkingOptionId = configuration.state.effectiveThinkingOptionId;
|
|
28035
28593
|
this.capabilities = modernSessionCapabilities(this.#permissionModes);
|
|
28036
28594
|
this.outputs = this.#channel.outputs;
|
|
28595
|
+
const usageHistory = deepSeekUsageHistory(this.#events);
|
|
28596
|
+
for (const request of usageHistory.requests)
|
|
28597
|
+
this.#emit({ type: "usage.request", request });
|
|
28598
|
+
this.#emit({ type: "usage.history", complete: usageHistory.complete });
|
|
28037
28599
|
this.commands = {
|
|
28038
28600
|
list: () => this.#listHarnessCommands(),
|
|
28039
28601
|
execute: (command) => this.#executeHarnessCommand(command)
|
|
@@ -29019,6 +29581,7 @@ ${question.detail}` : question.question;
|
|
|
29019
29581
|
this.#validator.accept(event);
|
|
29020
29582
|
this.#observeAssistantSettlement(event);
|
|
29021
29583
|
this.#events.push(event);
|
|
29584
|
+
this.#meterUsage(event);
|
|
29022
29585
|
this.#historyBytes += bytes;
|
|
29023
29586
|
this.#receive(event);
|
|
29024
29587
|
}
|
|
@@ -30068,6 +30631,14 @@ ${question.detail}` : question.question;
|
|
|
30068
30631
|
#emit(event) {
|
|
30069
30632
|
this.#channel.emit({ kind: "event", event });
|
|
30070
30633
|
}
|
|
30634
|
+
/** Publishes a live model request settled in the journal to Host usage metering. */
|
|
30635
|
+
#meterUsage(event) {
|
|
30636
|
+
const record2 = deepSeekUsageRecord(event, false);
|
|
30637
|
+
if (record2.kind === "request")
|
|
30638
|
+
this.#emit({ type: "usage.request", request: record2.request });
|
|
30639
|
+
else if (record2.kind === "missing")
|
|
30640
|
+
this.#emit({ type: "usage.history", complete: false });
|
|
30641
|
+
}
|
|
30071
30642
|
};
|
|
30072
30643
|
var OperationAborted = class extends Error {
|
|
30073
30644
|
constructor() {
|
|
@@ -30392,7 +30963,7 @@ function safeTimerDelay(value, name) {
|
|
|
30392
30963
|
|
|
30393
30964
|
// dist/modern/session-list.js
|
|
30394
30965
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
30395
|
-
import
|
|
30966
|
+
import path7 from "node:path";
|
|
30396
30967
|
var MAX_SESSION_LIST_BYTES = 32 * 1024 * 1024;
|
|
30397
30968
|
var MAX_SESSION_LIST_DEPTH = 64;
|
|
30398
30969
|
var MAX_SESSION_LIST_NODES = 2e5;
|
|
@@ -30511,7 +31082,7 @@ function parseSummary(value) {
|
|
|
30511
31082
|
};
|
|
30512
31083
|
}
|
|
30513
31084
|
function isCanonicalAbsoluteCwd(value) {
|
|
30514
|
-
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") &&
|
|
31085
|
+
return value !== void 0 && value.trim().length > 0 && !value.includes("\0") && path7.isAbsolute(value) && path7.resolve(value) === value;
|
|
30515
31086
|
}
|
|
30516
31087
|
function parseModernSessionCandidates(value) {
|
|
30517
31088
|
assertBoundedJson4(value);
|
|
@@ -30709,7 +31280,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30709
31280
|
let session;
|
|
30710
31281
|
let forkExpectation;
|
|
30711
31282
|
try {
|
|
30712
|
-
const cwd =
|
|
31283
|
+
const cwd = path8.resolve(input.cwd);
|
|
30713
31284
|
let forkInput = input.kind === "fork" ? parseModernForkInput(input, this.#profile) : void 0;
|
|
30714
31285
|
const rollbackSourceSessionId = input.kind === "rollbackLastTurn" ? modernSessionId(input.sourceRef, "roll back") : void 0;
|
|
30715
31286
|
let rollbackPlan;
|
|
@@ -30870,6 +31441,14 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30870
31441
|
this.#sessions.add(openedSession);
|
|
30871
31442
|
await this.#startEvents();
|
|
30872
31443
|
this.#assertAccepting();
|
|
31444
|
+
if (input.kind === "resume" && input.permissionModeId) {
|
|
31445
|
+
const restored = await openedSession.execute({
|
|
31446
|
+
type: "permissionMode.select",
|
|
31447
|
+
permissionModeId: input.permissionModeId
|
|
31448
|
+
});
|
|
31449
|
+
if (!restored.ok)
|
|
31450
|
+
throw new AdapterOperationError(restored.error);
|
|
31451
|
+
}
|
|
30873
31452
|
return { ok: true, value: openedSession };
|
|
30874
31453
|
} catch (error51) {
|
|
30875
31454
|
await session?.close().catch(() => void 0);
|
|
@@ -30912,7 +31491,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30912
31491
|
});
|
|
30913
31492
|
if (!result.ok)
|
|
30914
31493
|
throw new AdapterOperationError(remoteFailure2("session/create", result.error));
|
|
30915
|
-
if (!
|
|
31494
|
+
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) {
|
|
30916
31495
|
throw new AdapterOperationError({
|
|
30917
31496
|
code: "protocolError",
|
|
30918
31497
|
message: "DeepSeek Harness session/create returned an invalid Session identity",
|
|
@@ -30996,7 +31575,7 @@ var ModernDeepSeekHarnessAdapter = class {
|
|
|
30996
31575
|
const result = await this.#connection.call("session/fork", { request: { sessionId: input.sourceSessionId, atSeq } }, this.#lifetime.signal);
|
|
30997
31576
|
if (!result.ok)
|
|
30998
31577
|
throw new AdapterOperationError(forkRemoteFailure(result.error));
|
|
30999
|
-
if (!
|
|
31578
|
+
if (!isRecord8(result.value) || !hasExactOptionalKeys(result.value, ["sessionId"], []) || typeof result.value.sessionId !== "string" || result.value.sessionId.trim() === "" || result.value.sessionId === input.sourceSessionId) {
|
|
31000
31579
|
throw forkProtocolError();
|
|
31001
31580
|
}
|
|
31002
31581
|
return {
|
|
@@ -31230,7 +31809,7 @@ function verifyCreateConfiguration(requested, observed) {
|
|
|
31230
31809
|
}
|
|
31231
31810
|
}
|
|
31232
31811
|
function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
31233
|
-
let
|
|
31812
|
+
let model2;
|
|
31234
31813
|
if (input.model || input.thinkingOptionId) {
|
|
31235
31814
|
const requestedModel = input.model ?? modelCatalog.catalog.defaultModel;
|
|
31236
31815
|
if (!requestedModel) {
|
|
@@ -31240,7 +31819,7 @@ function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
|
31240
31819
|
retryable: false
|
|
31241
31820
|
});
|
|
31242
31821
|
}
|
|
31243
|
-
|
|
31822
|
+
model2 = modernSelectionForModel(modelCatalog, requestedModel, input.thinkingOptionId);
|
|
31244
31823
|
}
|
|
31245
31824
|
const unattended = input.executionPolicy === "unattended-full-access";
|
|
31246
31825
|
const permissionModeId = input.permissionModeId ?? (unattended ? harnessPermissionModeIdSchema.parse(DELEGATION_PERMISSION_PRESET) : void 0);
|
|
@@ -31252,7 +31831,7 @@ function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
|
|
|
31252
31831
|
});
|
|
31253
31832
|
}
|
|
31254
31833
|
return {
|
|
31255
|
-
...
|
|
31834
|
+
...model2 ? { model: model2 } : {},
|
|
31256
31835
|
...permissionModeId ? { permissionModeId } : {},
|
|
31257
31836
|
unattended
|
|
31258
31837
|
};
|
|
@@ -31262,7 +31841,7 @@ function delegationPermissionIsApplied(events) {
|
|
|
31262
31841
|
let sandboxMode;
|
|
31263
31842
|
let approvalPolicy;
|
|
31264
31843
|
for (const event of events) {
|
|
31265
|
-
if (!
|
|
31844
|
+
if (!isRecord8(event.data))
|
|
31266
31845
|
continue;
|
|
31267
31846
|
if (event.type === "permission/preset" && typeof event.data.preset === "string") {
|
|
31268
31847
|
preset = event.data.preset;
|
|
@@ -31301,10 +31880,10 @@ function parseModernForkInput(input, profile) {
|
|
|
31301
31880
|
};
|
|
31302
31881
|
}
|
|
31303
31882
|
function sessionLocatorMatches(locator) {
|
|
31304
|
-
return locator === void 0 ||
|
|
31883
|
+
return locator === void 0 || isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && typeof locator.dshVersion === "string" && isDeepSeekSemVer(locator.dshVersion);
|
|
31305
31884
|
}
|
|
31306
31885
|
function checkpointLocatorMatches(locator, profile) {
|
|
31307
|
-
return
|
|
31886
|
+
return isRecord8(locator) && Reflect.ownKeys(locator).length === 1 && locator.dshVersion === profile.version;
|
|
31308
31887
|
}
|
|
31309
31888
|
function forkCheckpointError() {
|
|
31310
31889
|
return new AdapterOperationError({
|
|
@@ -31466,7 +32045,7 @@ function sanitizedHarnessError2(error51) {
|
|
|
31466
32045
|
...error51.stderrTail ? { stderrTail: sanitizeDiagnosticTail(redactModernCredential(error51.stderrTail)) } : {}
|
|
31467
32046
|
};
|
|
31468
32047
|
}
|
|
31469
|
-
function
|
|
32048
|
+
function isRecord8(value) {
|
|
31470
32049
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31471
32050
|
}
|
|
31472
32051
|
function hasExactOptionalKeys(value, required2, optional2) {
|
|
@@ -31488,6 +32067,7 @@ var DelegateSelectionError = class extends Error {
|
|
|
31488
32067
|
var DeepSeekHarnessAdapter = class {
|
|
31489
32068
|
commandCatalog = deepSeekHarnessCommandCatalog();
|
|
31490
32069
|
harnessId = DEEPSEEK_HARNESS_ID4;
|
|
32070
|
+
usageStatistics;
|
|
31491
32071
|
sessionImport = Object.freeze({
|
|
31492
32072
|
listCandidates: () => this.#listSessionImportCandidates(),
|
|
31493
32073
|
resolveCandidate: async (nativeSessionId) => {
|
|
@@ -31534,6 +32114,7 @@ var DeepSeekHarnessAdapter = class {
|
|
|
31534
32114
|
#terminalFailure;
|
|
31535
32115
|
constructor(options = {}, dependencies = {}) {
|
|
31536
32116
|
this.#options = options;
|
|
32117
|
+
this.usageStatistics = createDshUsageStatistics(options.environment ?? process.env);
|
|
31537
32118
|
this.#probeExecutable = dependencies.probeExecutable ?? ((input) => probeDeepSeekExecutableGeneration(input));
|
|
31538
32119
|
this.#createModernAdapter = dependencies.createModernAdapter ?? ((modernOptions2) => new ModernDeepSeekHarnessAdapter(modernOptions2));
|
|
31539
32120
|
}
|