@codexhost/cli-darwin-x64 0.10.1 → 0.11.0
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 +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17959 -0
- package/app/console-web.js +25950 -0
- package/app/desktop-controller.mjs +154 -14
- package/app/host-runtime.mjs +3176 -1070
- package/app/plugins/antigravity/plugin.mjs +345 -72
- package/app/plugins/claude-code/plugin.mjs +2153 -1465
- package/app/plugins/codebuddy/plugin.mjs +426 -93
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1134 -495
- package/app/plugins/deepseek-harness/plugin.mjs +604 -36
- package/app/plugins/grok/plugin.mjs +290 -78
- package/app/plugins/hermes/plugin.mjs +311 -85
- package/app/plugins/kimi-code/plugin.mjs +659 -74
- package/app/plugins/kiro-cli/plugin.mjs +227 -55
- package/app/plugins/omp/plugin.mjs +300 -45
- package/app/plugins/opencode/plugin.mjs +3600 -206
- package/app/plugins/pi/plugin.mjs +897 -275
- package/app/plugins/qoder/plugin.mjs +397 -46
- package/app/plugins/qoder-cn/plugin.mjs +404 -47
- package/app/plugins/workbuddy/plugin.mjs +116 -6
- package/app/renderer-extension.js +2379 -1294
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -0
- package/package.json +1 -1
|
@@ -4475,10 +4475,10 @@ function mergeDefs(...defs) {
|
|
|
4475
4475
|
function cloneDef(schema) {
|
|
4476
4476
|
return mergeDefs(schema._zod.def);
|
|
4477
4477
|
}
|
|
4478
|
-
function getElementAtPath(obj,
|
|
4479
|
-
if (!
|
|
4478
|
+
function getElementAtPath(obj, path8) {
|
|
4479
|
+
if (!path8)
|
|
4480
4480
|
return obj;
|
|
4481
|
-
return
|
|
4481
|
+
return path8.reduce((acc, key) => acc?.[key], obj);
|
|
4482
4482
|
}
|
|
4483
4483
|
function promiseAllObject(promisesObj) {
|
|
4484
4484
|
const keys = Object.keys(promisesObj);
|
|
@@ -4887,11 +4887,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
4887
4887
|
}
|
|
4888
4888
|
return false;
|
|
4889
4889
|
}
|
|
4890
|
-
function prefixIssues(
|
|
4890
|
+
function prefixIssues(path8, issues) {
|
|
4891
4891
|
return issues.map((iss) => {
|
|
4892
4892
|
var _a3;
|
|
4893
4893
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
4894
|
-
iss.path.unshift(
|
|
4894
|
+
iss.path.unshift(path8);
|
|
4895
4895
|
return iss;
|
|
4896
4896
|
});
|
|
4897
4897
|
}
|
|
@@ -5038,16 +5038,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5038
5038
|
}
|
|
5039
5039
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
5040
5040
|
const fieldErrors = { _errors: [] };
|
|
5041
|
-
const processError = (error52,
|
|
5041
|
+
const processError = (error52, path8 = []) => {
|
|
5042
5042
|
for (const issue2 of error52.issues) {
|
|
5043
5043
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
5044
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
5044
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
5045
5045
|
} else if (issue2.code === "invalid_key") {
|
|
5046
|
-
processError({ issues: issue2.issues }, [...
|
|
5046
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
5047
5047
|
} else if (issue2.code === "invalid_element") {
|
|
5048
|
-
processError({ issues: issue2.issues }, [...
|
|
5048
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
5049
5049
|
} else {
|
|
5050
|
-
const fullpath = [...
|
|
5050
|
+
const fullpath = [...path8, ...issue2.path];
|
|
5051
5051
|
if (fullpath.length === 0) {
|
|
5052
5052
|
fieldErrors._errors.push(mapper(issue2));
|
|
5053
5053
|
} else {
|
|
@@ -5074,17 +5074,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5074
5074
|
}
|
|
5075
5075
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
5076
5076
|
const result = { errors: [] };
|
|
5077
|
-
const processError = (error52,
|
|
5077
|
+
const processError = (error52, path8 = []) => {
|
|
5078
5078
|
var _a3, _b;
|
|
5079
5079
|
for (const issue2 of error52.issues) {
|
|
5080
5080
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
5081
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
5081
|
+
issue2.errors.map((issues) => processError({ issues }, [...path8, ...issue2.path]));
|
|
5082
5082
|
} else if (issue2.code === "invalid_key") {
|
|
5083
|
-
processError({ issues: issue2.issues }, [...
|
|
5083
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
5084
5084
|
} else if (issue2.code === "invalid_element") {
|
|
5085
|
-
processError({ issues: issue2.issues }, [...
|
|
5085
|
+
processError({ issues: issue2.issues }, [...path8, ...issue2.path]);
|
|
5086
5086
|
} else {
|
|
5087
|
-
const fullpath = [...
|
|
5087
|
+
const fullpath = [...path8, ...issue2.path];
|
|
5088
5088
|
if (fullpath.length === 0) {
|
|
5089
5089
|
result.errors.push(mapper(issue2));
|
|
5090
5090
|
continue;
|
|
@@ -5116,8 +5116,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
5116
5116
|
}
|
|
5117
5117
|
function toDotPath(_path) {
|
|
5118
5118
|
const segs = [];
|
|
5119
|
-
const
|
|
5120
|
-
for (const seg of
|
|
5119
|
+
const path8 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
5120
|
+
for (const seg of path8) {
|
|
5121
5121
|
if (typeof seg === "number")
|
|
5122
5122
|
segs.push(`[${seg}]`);
|
|
5123
5123
|
else if (typeof seg === "symbol")
|
|
@@ -17809,13 +17809,13 @@ function resolveRef(ref, ctx) {
|
|
|
17809
17809
|
if (!ref.startsWith("#")) {
|
|
17810
17810
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
17811
17811
|
}
|
|
17812
|
-
const
|
|
17813
|
-
if (
|
|
17812
|
+
const path8 = ref.slice(1).split("/").filter(Boolean);
|
|
17813
|
+
if (path8.length === 0) {
|
|
17814
17814
|
return ctx.rootSchema;
|
|
17815
17815
|
}
|
|
17816
17816
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
17817
|
-
if (
|
|
17818
|
-
const key =
|
|
17817
|
+
if (path8[0] === defsKey) {
|
|
17818
|
+
const key = path8[1];
|
|
17819
17819
|
if (!key || !ctx.defs[key]) {
|
|
17820
17820
|
throw new Error(`Reference not found: ${ref}`);
|
|
17821
17821
|
}
|
|
@@ -18278,6 +18278,55 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
18278
18278
|
request: credentialImportsRequestSchema
|
|
18279
18279
|
}).strict();
|
|
18280
18280
|
|
|
18281
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
18282
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
18283
|
+
agent: external_exports.string().min(1).max(128),
|
|
18284
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
18285
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
18286
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
18287
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
18288
|
+
});
|
|
18289
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
18290
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
18291
|
+
entries: harnessDisplayEntriesSchema,
|
|
18292
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
18293
|
+
initializeOnly: external_exports.boolean().optional()
|
|
18294
|
+
});
|
|
18295
|
+
|
|
18296
|
+
// ../../shared-contracts/dist/console.js
|
|
18297
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
18298
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
18299
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
18300
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
18301
|
+
});
|
|
18302
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
18303
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
18304
|
+
/** The console address. */
|
|
18305
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
18306
|
+
});
|
|
18307
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
18308
|
+
"codexhost/harness/plugins/list",
|
|
18309
|
+
"codexhost/harness/display-settings/get",
|
|
18310
|
+
"codexhost/harness/display-settings/set",
|
|
18311
|
+
"codexhost/harness/inspect",
|
|
18312
|
+
"codexhost/harness/launch-settings/get",
|
|
18313
|
+
"codexhost/harness/launch-settings/set",
|
|
18314
|
+
"codexhost/harness/web-ui/open",
|
|
18315
|
+
"codexhost/harness/accounts/sources",
|
|
18316
|
+
"codexhost/harness/accounts/list",
|
|
18317
|
+
"codexhost/harness/accounts/inspect",
|
|
18318
|
+
"codexhost/harness/credential-imports",
|
|
18319
|
+
"codexhost/harness/session-import/sources",
|
|
18320
|
+
"codexhost/harness/session-import/list",
|
|
18321
|
+
"codexhost/harness/session-import/import",
|
|
18322
|
+
"codexhost/account/list",
|
|
18323
|
+
"codexhost/account/refresh",
|
|
18324
|
+
"codexhost/account/usage/inspect",
|
|
18325
|
+
"codexhost/update/check",
|
|
18326
|
+
"codexhost/update/start",
|
|
18327
|
+
"codexhost/update/status"
|
|
18328
|
+
]);
|
|
18329
|
+
|
|
18281
18330
|
// ../../shared-contracts/dist/version.js
|
|
18282
18331
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
18283
18332
|
|
|
@@ -18331,6 +18380,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
18331
18380
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
18332
18381
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
18333
18382
|
|
|
18383
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
18384
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
18385
|
+
threadId: hostThreadIdSchema,
|
|
18386
|
+
turnId: hostTurnIdSchema
|
|
18387
|
+
});
|
|
18388
|
+
|
|
18334
18389
|
// ../../shared-contracts/dist/thread-usage.js
|
|
18335
18390
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
18336
18391
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -18391,6 +18446,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
18391
18446
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
18392
18447
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
18393
18448
|
product: external_exports.string().min(1),
|
|
18449
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
18450
|
+
// Zero is a real empty cap, not an absent field.
|
|
18451
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
18452
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
18394
18453
|
usagePercent: usagePercentSchema,
|
|
18395
18454
|
resetsAt: external_exports.string().min(1).optional()
|
|
18396
18455
|
}).strict();
|
|
@@ -18400,6 +18459,10 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
18400
18459
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
18401
18460
|
}).strict();
|
|
18402
18461
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
18462
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
18463
|
+
// Zero is a real empty cap, not an absent field.
|
|
18464
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
18465
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
18403
18466
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
18404
18467
|
label: external_exports.string().min(1).optional(),
|
|
18405
18468
|
usedPercent: usagePercentSchema,
|
|
@@ -18419,12 +18482,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
18419
18482
|
}).strict();
|
|
18420
18483
|
|
|
18421
18484
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
18422
|
-
var
|
|
18485
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
18486
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
18487
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
18488
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
18489
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
18490
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
18491
|
+
}).strict();
|
|
18492
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
18423
18493
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
18424
18494
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
18425
18495
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
18426
|
-
credits: accountCreditsSnapshotSchema
|
|
18496
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
18497
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
18427
18498
|
}).strict();
|
|
18499
|
+
function requireReportedQuota(schema) {
|
|
18500
|
+
return schema.refine((value) => {
|
|
18501
|
+
const reported = value;
|
|
18502
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
18503
|
+
}, { message: "Account must report either credits or a balance" });
|
|
18504
|
+
}
|
|
18505
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
18428
18506
|
var harnessAccountIdentityShape = {
|
|
18429
18507
|
harnessId: harnessIdSchema,
|
|
18430
18508
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -18435,11 +18513,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
18435
18513
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
18436
18514
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
18437
18515
|
...harnessAccountIdentityShape,
|
|
18438
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
18516
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
18517
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
18518
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
18439
18519
|
}).strict();
|
|
18440
18520
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
18441
18521
|
var harnessAccountListResultSchema = external_exports.object({
|
|
18442
|
-
accounts: external_exports.array(
|
|
18522
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
18443
18523
|
}).strict();
|
|
18444
18524
|
|
|
18445
18525
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -18577,6 +18657,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
18577
18657
|
ref: harnessModelRefSchema,
|
|
18578
18658
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
18579
18659
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
18660
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
18661
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
18580
18662
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
18581
18663
|
}).strict();
|
|
18582
18664
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -18609,6 +18691,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
18609
18691
|
});
|
|
18610
18692
|
}
|
|
18611
18693
|
refs.add(model.ref.id);
|
|
18694
|
+
if (model.fastModel) {
|
|
18695
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
18696
|
+
context.addIssue({
|
|
18697
|
+
code: "custom",
|
|
18698
|
+
message: "Fast Model refs must be distinct and unique",
|
|
18699
|
+
path: ["models", index, "fastModel"]
|
|
18700
|
+
});
|
|
18701
|
+
}
|
|
18702
|
+
refs.add(model.fastModel.id);
|
|
18703
|
+
}
|
|
18612
18704
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
18613
18705
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
18614
18706
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -18728,11 +18820,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
18728
18820
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
18729
18821
|
}).strict();
|
|
18730
18822
|
var threadInspectionParamsSchema = external_exports.object({
|
|
18731
|
-
threadId: hostThreadIdSchema
|
|
18823
|
+
threadId: hostThreadIdSchema,
|
|
18824
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
18732
18825
|
}).strict();
|
|
18733
18826
|
var codexThreadInspectionSchema = external_exports.object({
|
|
18734
18827
|
owner: external_exports.literal("codex"),
|
|
18735
|
-
locked: external_exports.literal(true)
|
|
18828
|
+
locked: external_exports.literal(true),
|
|
18829
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
18736
18830
|
}).strict();
|
|
18737
18831
|
var externalThreadInspectionSchema = external_exports.object({
|
|
18738
18832
|
owner: external_exports.literal("external"),
|
|
@@ -18858,6 +18952,19 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
18858
18952
|
restartRequired: external_exports.boolean()
|
|
18859
18953
|
}).strict();
|
|
18860
18954
|
|
|
18955
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
18956
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
18957
|
+
harnessId: harnessIdSchema,
|
|
18958
|
+
action: external_exports.enum(["check", "update"])
|
|
18959
|
+
}).strict();
|
|
18960
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
18961
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
18962
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
18963
|
+
updateAvailable: external_exports.boolean(),
|
|
18964
|
+
canUpdate: external_exports.boolean(),
|
|
18965
|
+
message: external_exports.string().max(2048).optional()
|
|
18966
|
+
}).strict();
|
|
18967
|
+
|
|
18861
18968
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
18862
18969
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
18863
18970
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
@@ -19460,12 +19567,12 @@ function environmentValue(environment, name) {
|
|
|
19460
19567
|
return Object.entries(environment).find(([key]) => key.toLowerCase() === name.toLowerCase())?.[1];
|
|
19461
19568
|
}
|
|
19462
19569
|
function executableCandidates(command, environment) {
|
|
19463
|
-
const
|
|
19464
|
-
if (
|
|
19570
|
+
const targetPath2 = process.platform === "win32" ? path.win32 : path.posix;
|
|
19571
|
+
if (targetPath2.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
19465
19572
|
return [command];
|
|
19466
19573
|
}
|
|
19467
|
-
const extensions = process.platform === "win32" &&
|
|
19468
|
-
return (environmentValue(environment, "PATH") ?? "").split(
|
|
19574
|
+
const extensions = process.platform === "win32" && targetPath2.extname(command) === "" ? (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension2) => extension2.trim()).filter(Boolean) : [""];
|
|
19575
|
+
return (environmentValue(environment, "PATH") ?? "").split(targetPath2.delimiter).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean).flatMap((directory) => extensions.map((extension2) => targetPath2.join(directory, command + extension2)));
|
|
19469
19576
|
}
|
|
19470
19577
|
function resolveExecutable(command, environment) {
|
|
19471
19578
|
const accessMode = process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
@@ -21584,16 +21691,16 @@ var Diff = class {
|
|
|
21584
21691
|
}
|
|
21585
21692
|
}
|
|
21586
21693
|
}
|
|
21587
|
-
addToPath(
|
|
21588
|
-
const last =
|
|
21694
|
+
addToPath(path8, added, removed, oldPosInc, options) {
|
|
21695
|
+
const last = path8.lastComponent;
|
|
21589
21696
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
21590
21697
|
return {
|
|
21591
|
-
oldPos:
|
|
21698
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
21592
21699
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
21593
21700
|
};
|
|
21594
21701
|
} else {
|
|
21595
21702
|
return {
|
|
21596
|
-
oldPos:
|
|
21703
|
+
oldPos: path8.oldPos + oldPosInc,
|
|
21597
21704
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
21598
21705
|
};
|
|
21599
21706
|
}
|
|
@@ -32072,17 +32179,478 @@ function closedError2() {
|
|
|
32072
32179
|
};
|
|
32073
32180
|
}
|
|
32074
32181
|
|
|
32182
|
+
// ../../harness-discovery/dist/environment.js
|
|
32183
|
+
import fs from "node:fs";
|
|
32184
|
+
import path4 from "node:path";
|
|
32185
|
+
function targetPath(platform) {
|
|
32186
|
+
return platform === "win32" ? path4.win32 : path4.posix;
|
|
32187
|
+
}
|
|
32188
|
+
function environmentValue2(environment, name) {
|
|
32189
|
+
const lowered = name.toLowerCase();
|
|
32190
|
+
for (const [key, value] of Object.entries(environment)) {
|
|
32191
|
+
if (key.toLowerCase() === lowered)
|
|
32192
|
+
return value;
|
|
32193
|
+
}
|
|
32194
|
+
return void 0;
|
|
32195
|
+
}
|
|
32196
|
+
function pathDelimiter(platform) {
|
|
32197
|
+
return platform === "win32" ? ";" : ":";
|
|
32198
|
+
}
|
|
32199
|
+
function pathDirectories(environment, platform) {
|
|
32200
|
+
return (environmentValue2(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
32201
|
+
}
|
|
32202
|
+
function executableExtensions(command, platform, environment) {
|
|
32203
|
+
if (platform !== "win32")
|
|
32204
|
+
return [""];
|
|
32205
|
+
if (targetPath(platform).extname(command) !== "")
|
|
32206
|
+
return [""];
|
|
32207
|
+
return (environmentValue2(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension2) => extension2.trim()).filter(Boolean);
|
|
32208
|
+
}
|
|
32209
|
+
function isExecutableFile(filePath, platform) {
|
|
32210
|
+
try {
|
|
32211
|
+
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
32212
|
+
return fs.statSync(filePath).isFile();
|
|
32213
|
+
} catch {
|
|
32214
|
+
return false;
|
|
32215
|
+
}
|
|
32216
|
+
}
|
|
32217
|
+
function subdirectoryNames(directory) {
|
|
32218
|
+
try {
|
|
32219
|
+
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
32220
|
+
} catch {
|
|
32221
|
+
return [];
|
|
32222
|
+
}
|
|
32223
|
+
}
|
|
32224
|
+
function newestFirst(names) {
|
|
32225
|
+
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
32226
|
+
}
|
|
32227
|
+
|
|
32228
|
+
// ../../harness-discovery/dist/invocation.js
|
|
32229
|
+
import path5 from "node:path";
|
|
32230
|
+
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
32231
|
+
const extension2 = path5.win32.extname(command).toLowerCase();
|
|
32232
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension2)) {
|
|
32233
|
+
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
32234
|
+
}
|
|
32235
|
+
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
32236
|
+
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
32237
|
+
return {
|
|
32238
|
+
command: environmentValue2(environment, "ComSpec") ?? "cmd.exe",
|
|
32239
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
32240
|
+
windowsVerbatimArguments: true
|
|
32241
|
+
};
|
|
32242
|
+
}
|
|
32243
|
+
|
|
32244
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
32245
|
+
import path6 from "node:path";
|
|
32246
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
32247
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
32248
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
32249
|
+
const runtimeDirectory = path6.dirname(runtimeExecutable);
|
|
32250
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
32251
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
32252
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
32253
|
+
directories.push(runtimeDirectory);
|
|
32254
|
+
}
|
|
32255
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
32256
|
+
}
|
|
32257
|
+
|
|
32258
|
+
// ../../harness-discovery/dist/resolve.js
|
|
32259
|
+
import os from "node:os";
|
|
32260
|
+
|
|
32261
|
+
// ../../harness-discovery/dist/version-managers.js
|
|
32262
|
+
function versionManagerBinaryDirectories(context) {
|
|
32263
|
+
const { platform, environment, home } = context;
|
|
32264
|
+
const list = context.subdirectories ?? subdirectoryNames;
|
|
32265
|
+
const pathFlavor = targetPath(platform);
|
|
32266
|
+
const value = (name) => environmentValue2(environment, name);
|
|
32267
|
+
const directories = [];
|
|
32268
|
+
const versioned = (root, ...tail) => {
|
|
32269
|
+
for (const version2 of newestFirst(list(root))) {
|
|
32270
|
+
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
32271
|
+
}
|
|
32272
|
+
};
|
|
32273
|
+
if (platform === "win32") {
|
|
32274
|
+
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
32275
|
+
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
32276
|
+
versioned(pathFlavor.join(appData, "nvm"));
|
|
32277
|
+
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
32278
|
+
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
32279
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
32280
|
+
const pnpmHome2 = value("PNPM_HOME");
|
|
32281
|
+
if (pnpmHome2)
|
|
32282
|
+
directories.push(pnpmHome2);
|
|
32283
|
+
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
32284
|
+
return directories;
|
|
32285
|
+
}
|
|
32286
|
+
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
32287
|
+
const fnmRoots = [
|
|
32288
|
+
value("FNM_DIR"),
|
|
32289
|
+
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
32290
|
+
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
32291
|
+
].filter((root) => root !== void 0);
|
|
32292
|
+
for (const root of fnmRoots) {
|
|
32293
|
+
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
32294
|
+
}
|
|
32295
|
+
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
32296
|
+
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
32297
|
+
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
32298
|
+
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
32299
|
+
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
32300
|
+
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
32301
|
+
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
32302
|
+
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
32303
|
+
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
32304
|
+
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
32305
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
32306
|
+
const pnpmHome = value("PNPM_HOME");
|
|
32307
|
+
if (pnpmHome)
|
|
32308
|
+
directories.push(pnpmHome);
|
|
32309
|
+
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
32310
|
+
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
32311
|
+
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
32312
|
+
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
32313
|
+
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
32314
|
+
}
|
|
32315
|
+
}
|
|
32316
|
+
return directories;
|
|
32317
|
+
}
|
|
32318
|
+
|
|
32319
|
+
// ../../harness-discovery/dist/resolve.js
|
|
32320
|
+
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
32321
|
+
function installRootExtensions(platform) {
|
|
32322
|
+
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
32323
|
+
}
|
|
32324
|
+
function resolveHomeDirectory(input) {
|
|
32325
|
+
return input.homeDirectory ?? environmentValue2(input.environment, "HOME") ?? environmentValue2(input.environment, "USERPROFILE") ?? os.homedir();
|
|
32326
|
+
}
|
|
32327
|
+
function templateVariables(environment, platform, home) {
|
|
32328
|
+
const pathFlavor = targetPath(platform);
|
|
32329
|
+
return {
|
|
32330
|
+
HOME: home,
|
|
32331
|
+
USERPROFILE: home,
|
|
32332
|
+
APPDATA: environmentValue2(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
32333
|
+
LOCALAPPDATA: environmentValue2(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
32334
|
+
};
|
|
32335
|
+
}
|
|
32336
|
+
function joinTemplate(platform, value) {
|
|
32337
|
+
const pathFlavor = targetPath(platform);
|
|
32338
|
+
const segments = value.split("/");
|
|
32339
|
+
const head = segments[0] ?? "";
|
|
32340
|
+
const tail = segments.slice(1);
|
|
32341
|
+
if (head === "")
|
|
32342
|
+
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
32343
|
+
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
32344
|
+
}
|
|
32345
|
+
function expandInstallRoot(template, environment, platform, home) {
|
|
32346
|
+
const variables = templateVariables(environment, platform, home);
|
|
32347
|
+
let unresolved = false;
|
|
32348
|
+
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
32349
|
+
const value = variables[name] ?? environmentValue2(environment, name);
|
|
32350
|
+
if (value === void 0 || value === "") {
|
|
32351
|
+
unresolved = true;
|
|
32352
|
+
return "";
|
|
32353
|
+
}
|
|
32354
|
+
return value;
|
|
32355
|
+
});
|
|
32356
|
+
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
32357
|
+
}
|
|
32358
|
+
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
32359
|
+
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
32360
|
+
const directories = [];
|
|
32361
|
+
for (const template of templates) {
|
|
32362
|
+
if (template === VERSION_MANAGER_ROOTS) {
|
|
32363
|
+
directories.push(...versionManagerBinaryDirectories({
|
|
32364
|
+
platform,
|
|
32365
|
+
environment: input.environment,
|
|
32366
|
+
home,
|
|
32367
|
+
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
32368
|
+
}));
|
|
32369
|
+
continue;
|
|
32370
|
+
}
|
|
32371
|
+
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
32372
|
+
if (directory !== void 0)
|
|
32373
|
+
directories.push(directory);
|
|
32374
|
+
}
|
|
32375
|
+
return directories;
|
|
32376
|
+
}
|
|
32377
|
+
function harnessCandidates(spec, input, dependencies = {}) {
|
|
32378
|
+
const platform = input.platform ?? process.platform;
|
|
32379
|
+
const pathFlavor = targetPath(platform);
|
|
32380
|
+
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue2(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
32381
|
+
const command = configured ?? spec.command;
|
|
32382
|
+
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
32383
|
+
return [{ candidate: command, source: "configured" }];
|
|
32384
|
+
}
|
|
32385
|
+
const candidates = [];
|
|
32386
|
+
const extensions = executableExtensions(command, platform, input.environment);
|
|
32387
|
+
for (const directory of pathDirectories(input.environment, platform)) {
|
|
32388
|
+
for (const extension2 of extensions) {
|
|
32389
|
+
candidates.push({
|
|
32390
|
+
candidate: pathFlavor.join(directory, command + extension2),
|
|
32391
|
+
source: "path"
|
|
32392
|
+
});
|
|
32393
|
+
}
|
|
32394
|
+
}
|
|
32395
|
+
if (configured !== void 0)
|
|
32396
|
+
return candidates;
|
|
32397
|
+
const home = resolveHomeDirectory(input);
|
|
32398
|
+
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
32399
|
+
for (const extension2 of installRootExtensions(platform)) {
|
|
32400
|
+
candidates.push({
|
|
32401
|
+
candidate: pathFlavor.join(directory, spec.command + extension2),
|
|
32402
|
+
source: "install-root"
|
|
32403
|
+
});
|
|
32404
|
+
}
|
|
32405
|
+
}
|
|
32406
|
+
return candidates;
|
|
32407
|
+
}
|
|
32408
|
+
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
32409
|
+
const platform = input.platform ?? process.platform;
|
|
32410
|
+
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
32411
|
+
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
32412
|
+
const context = { platform, isExecutable };
|
|
32413
|
+
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
32414
|
+
const executable = runnable(candidate, context);
|
|
32415
|
+
if (executable !== void 0 && isExecutable(executable))
|
|
32416
|
+
return { executable, source };
|
|
32417
|
+
}
|
|
32418
|
+
return void 0;
|
|
32419
|
+
}
|
|
32420
|
+
|
|
32421
|
+
// ../../harness-discovery/dist/installation.js
|
|
32422
|
+
import { execFile } from "node:child_process";
|
|
32423
|
+
import { homedir } from "node:os";
|
|
32424
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
32425
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
32426
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
32427
|
+
return new Promise((resolve2, reject) => {
|
|
32428
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
32429
|
+
env,
|
|
32430
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
32431
|
+
encoding: "utf8",
|
|
32432
|
+
timeout,
|
|
32433
|
+
killSignal: "SIGKILL",
|
|
32434
|
+
maxBuffer: 1024 * 1024,
|
|
32435
|
+
windowsHide: true,
|
|
32436
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
32437
|
+
}, (error51, stdout, stderr) => {
|
|
32438
|
+
if (error51)
|
|
32439
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
32440
|
+
else
|
|
32441
|
+
resolve2((stdout || stderr).trim());
|
|
32442
|
+
});
|
|
32443
|
+
child.stdin?.end();
|
|
32444
|
+
});
|
|
32445
|
+
}
|
|
32446
|
+
function installationVersion(value) {
|
|
32447
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
32448
|
+
throw new Error("Harness returned an invalid version");
|
|
32449
|
+
return value.trim().replace(/^v/, "");
|
|
32450
|
+
}
|
|
32451
|
+
function versionFromOutput(output) {
|
|
32452
|
+
return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
|
|
32453
|
+
}
|
|
32454
|
+
function newerInstallationVersion(current, latest) {
|
|
32455
|
+
const a = installationVersion(current).replace(/\+.*/, "");
|
|
32456
|
+
const b = installationVersion(latest).replace(/\+.*/, "");
|
|
32457
|
+
const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
|
|
32458
|
+
const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
|
|
32459
|
+
for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
|
|
32460
|
+
if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
|
|
32461
|
+
return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
|
|
32462
|
+
}
|
|
32463
|
+
const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
|
|
32464
|
+
const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
|
|
32465
|
+
if (!preA.length || !preB.length)
|
|
32466
|
+
return !!preA.length && !preB.length;
|
|
32467
|
+
for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
|
|
32468
|
+
const x = preA[i];
|
|
32469
|
+
const y = preB[i];
|
|
32470
|
+
if (x === y)
|
|
32471
|
+
continue;
|
|
32472
|
+
if (x === void 0 || y === void 0)
|
|
32473
|
+
return x === void 0;
|
|
32474
|
+
const numericX = /^\d+$/.test(x);
|
|
32475
|
+
const numericY = /^\d+$/.test(y);
|
|
32476
|
+
if (numericX && numericY) {
|
|
32477
|
+
if (BigInt(x) === BigInt(y))
|
|
32478
|
+
continue;
|
|
32479
|
+
return BigInt(y) > BigInt(x);
|
|
32480
|
+
}
|
|
32481
|
+
if (numericX !== numericY)
|
|
32482
|
+
return numericX;
|
|
32483
|
+
return y > x;
|
|
32484
|
+
}
|
|
32485
|
+
return false;
|
|
32486
|
+
}
|
|
32487
|
+
function createInstallationManager(options) {
|
|
32488
|
+
let checking;
|
|
32489
|
+
let updating;
|
|
32490
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
32491
|
+
checking = void 0;
|
|
32492
|
+
});
|
|
32493
|
+
return (action) => {
|
|
32494
|
+
if (updating)
|
|
32495
|
+
return updating;
|
|
32496
|
+
if (action === "check")
|
|
32497
|
+
return check2();
|
|
32498
|
+
updating = (async () => {
|
|
32499
|
+
const before = await check2();
|
|
32500
|
+
if (!before.updateAvailable)
|
|
32501
|
+
return before;
|
|
32502
|
+
if (!before.canUpdate)
|
|
32503
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
32504
|
+
await options.update(before);
|
|
32505
|
+
const after = await check2();
|
|
32506
|
+
if (after.currentVersion === before.currentVersion)
|
|
32507
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
32508
|
+
return after;
|
|
32509
|
+
})().finally(() => {
|
|
32510
|
+
updating = void 0;
|
|
32511
|
+
});
|
|
32512
|
+
return updating;
|
|
32513
|
+
};
|
|
32514
|
+
}
|
|
32515
|
+
async function fetchInstallationText(url2) {
|
|
32516
|
+
const request = async () => {
|
|
32517
|
+
const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
|
|
32518
|
+
if (!response.ok)
|
|
32519
|
+
throw new Error("Could not check the latest Harness version");
|
|
32520
|
+
return response.text();
|
|
32521
|
+
};
|
|
32522
|
+
try {
|
|
32523
|
+
return await request();
|
|
32524
|
+
} catch (error51) {
|
|
32525
|
+
if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
|
|
32526
|
+
throw error51;
|
|
32527
|
+
return request();
|
|
32528
|
+
}
|
|
32529
|
+
}
|
|
32530
|
+
|
|
32531
|
+
// ../../harness-discovery/dist/npm-installation.js
|
|
32532
|
+
import { readFile, realpath } from "node:fs/promises";
|
|
32533
|
+
import path7 from "node:path";
|
|
32534
|
+
function referencesNpmBin(shim, name, bin) {
|
|
32535
|
+
if (bin.includes(".."))
|
|
32536
|
+
return false;
|
|
32537
|
+
const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
|
|
32538
|
+
const text = shim.replaceAll("\\", "/").toLowerCase();
|
|
32539
|
+
return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
|
|
32540
|
+
}
|
|
32541
|
+
async function npmInstallation(command, packages, environment) {
|
|
32542
|
+
let selected = await realpath(command);
|
|
32543
|
+
if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
|
|
32544
|
+
const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
|
|
32545
|
+
const root = path7.dirname(selected);
|
|
32546
|
+
for (const name of packages) {
|
|
32547
|
+
const directory2 = path7.join(root, "node_modules", ...name.split("/"));
|
|
32548
|
+
const metadata = await readFile(path7.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
32549
|
+
const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
|
|
32550
|
+
const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
|
|
32551
|
+
if (bin) {
|
|
32552
|
+
selected = await realpath(path7.join(directory2, bin));
|
|
32553
|
+
break;
|
|
32554
|
+
}
|
|
32555
|
+
}
|
|
32556
|
+
}
|
|
32557
|
+
let directory = path7.dirname(selected);
|
|
32558
|
+
for (let depth = 0; depth < 8; depth++) {
|
|
32559
|
+
const metadata = await readFile(path7.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
|
|
32560
|
+
if (metadata?.name && packages.includes(metadata.name)) {
|
|
32561
|
+
const name = metadata.name;
|
|
32562
|
+
const currentVersion = installationVersion(metadata.version);
|
|
32563
|
+
const segments = name.split("/");
|
|
32564
|
+
let modules = directory;
|
|
32565
|
+
for (let index = 0; index < segments.length; index++)
|
|
32566
|
+
modules = path7.dirname(modules);
|
|
32567
|
+
const prefix = process.platform === "win32" ? path7.dirname(modules) : path7.dirname(path7.dirname(modules));
|
|
32568
|
+
const globalRoot = process.platform === "win32" ? path7.join(prefix, "node_modules") : path7.join(prefix, "lib", "node_modules");
|
|
32569
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
32570
|
+
const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
|
|
32571
|
+
let globalInstall = modules === globalRoot;
|
|
32572
|
+
if (process.platform === "win32") {
|
|
32573
|
+
const project = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path7.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
|
|
32574
|
+
const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
|
|
32575
|
+
const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
|
|
32576
|
+
if (path7.basename(bin) !== bin || entry.includes(".."))
|
|
32577
|
+
return false;
|
|
32578
|
+
const target = await realpath(path7.join(directory, entry)).catch(() => "");
|
|
32579
|
+
if (target.toLowerCase() !== selected.toLowerCase())
|
|
32580
|
+
return false;
|
|
32581
|
+
const shim = await readFile(path7.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
|
|
32582
|
+
return referencesNpmBin(shim, name, entry);
|
|
32583
|
+
}));
|
|
32584
|
+
globalInstall = globalInstall && !project && launchers.some(Boolean);
|
|
32585
|
+
}
|
|
32586
|
+
const canUpdate = globalInstall && !!npm;
|
|
32587
|
+
return {
|
|
32588
|
+
prefix,
|
|
32589
|
+
currentVersion,
|
|
32590
|
+
canUpdate,
|
|
32591
|
+
latest: async () => {
|
|
32592
|
+
const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
|
|
32593
|
+
return installationVersion(data.version);
|
|
32594
|
+
},
|
|
32595
|
+
update: async (version2) => {
|
|
32596
|
+
if (!canUpdate || !npm)
|
|
32597
|
+
throw new Error("Use the original package manager to update this installation");
|
|
32598
|
+
await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
|
|
32599
|
+
}
|
|
32600
|
+
};
|
|
32601
|
+
}
|
|
32602
|
+
const parent = path7.dirname(directory);
|
|
32603
|
+
if (parent === directory)
|
|
32604
|
+
break;
|
|
32605
|
+
directory = parent;
|
|
32606
|
+
}
|
|
32607
|
+
return null;
|
|
32608
|
+
}
|
|
32609
|
+
|
|
32610
|
+
// dist/installation.js
|
|
32611
|
+
function createDeepSeekInstallation(environment, command) {
|
|
32612
|
+
let update;
|
|
32613
|
+
return createInstallationManager({
|
|
32614
|
+
async check() {
|
|
32615
|
+
const invocation = resolveDeepSeekCommand(command, environment);
|
|
32616
|
+
if (!invocation)
|
|
32617
|
+
throw new Error("DeepSeek Harness is not installed");
|
|
32618
|
+
const currentVersion = versionFromOutput(await runInstallationCommand(invocation.command, [...invocation.arguments, "--version"], environment));
|
|
32619
|
+
const npm = invocation.kind === "npx" ? null : await npmInstallation(invocation.command, ["@deepseek-ai/dsh"], environment);
|
|
32620
|
+
update = npm?.update;
|
|
32621
|
+
const latestVersion = npm ? await npm.latest() : "Unknown";
|
|
32622
|
+
const canUpdate = npm?.canUpdate ?? false;
|
|
32623
|
+
return {
|
|
32624
|
+
currentVersion,
|
|
32625
|
+
latestVersion,
|
|
32626
|
+
updateAvailable: !!npm && newerInstallationVersion(currentVersion, latestVersion),
|
|
32627
|
+
canUpdate,
|
|
32628
|
+
...!canUpdate ? {
|
|
32629
|
+
message: "Update with the original installer. Offline npx, Python, desktop, and project-local installations are not upgraded through global npm."
|
|
32630
|
+
} : {}
|
|
32631
|
+
};
|
|
32632
|
+
},
|
|
32633
|
+
async update(state) {
|
|
32634
|
+
if (!update)
|
|
32635
|
+
throw new Error("This DeepSeek installation requires a manual update");
|
|
32636
|
+
await update(state.latestVersion);
|
|
32637
|
+
}
|
|
32638
|
+
});
|
|
32639
|
+
}
|
|
32640
|
+
|
|
32075
32641
|
// dist/plugin.js
|
|
32076
32642
|
var DEEPSEEK_HARNESS_COMMAND_ENV = "CODEXHOST_DEEPSEEK_HARNESS_COMMAND";
|
|
32077
32643
|
var DEEPSEEK_HARNESS_ENDPOINT_ENV = "CODEXHOST_DEEPSEEK_HARNESS_ENDPOINT";
|
|
32078
32644
|
function createHarnessAdapter(context) {
|
|
32079
32645
|
const environment = { ...context.environment };
|
|
32080
32646
|
const openLocalUrl = context.openLocalUrl;
|
|
32081
|
-
return new DeepSeekHarnessAdapter({
|
|
32647
|
+
return Object.assign(new DeepSeekHarnessAdapter({
|
|
32082
32648
|
...environment[DEEPSEEK_HARNESS_COMMAND_ENV] ? { command: environment[DEEPSEEK_HARNESS_COMMAND_ENV] } : {},
|
|
32083
32649
|
...environment[DEEPSEEK_HARNESS_ENDPOINT_ENV] ? { endpoint: environment[DEEPSEEK_HARNESS_ENDPOINT_ENV] } : {},
|
|
32084
32650
|
environment,
|
|
32085
32651
|
...!context.managedRemoteHost && openLocalUrl ? { openWebUi: (url2) => openLocalUrl(url2.href) } : {}
|
|
32652
|
+
}), {
|
|
32653
|
+
installation: createDeepSeekInstallation(environment, environment[DEEPSEEK_HARNESS_COMMAND_ENV])
|
|
32086
32654
|
});
|
|
32087
32655
|
}
|
|
32088
32656
|
export {
|