@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
|
@@ -3229,8 +3229,8 @@ var require_utils = __commonJS({
|
|
|
3229
3229
|
}
|
|
3230
3230
|
return ind;
|
|
3231
3231
|
}
|
|
3232
|
-
function removeDotSegments(
|
|
3233
|
-
let input =
|
|
3232
|
+
function removeDotSegments(path12) {
|
|
3233
|
+
let input = path12;
|
|
3234
3234
|
const output = [];
|
|
3235
3235
|
let nextSlash = -1;
|
|
3236
3236
|
let len = 0;
|
|
@@ -3482,8 +3482,8 @@ var require_schemes = __commonJS({
|
|
|
3482
3482
|
wsComponent.secure = void 0;
|
|
3483
3483
|
}
|
|
3484
3484
|
if (wsComponent.resourceName) {
|
|
3485
|
-
const [
|
|
3486
|
-
wsComponent.path =
|
|
3485
|
+
const [path12, query] = wsComponent.resourceName.split("?");
|
|
3486
|
+
wsComponent.path = path12 && path12 !== "/" ? path12 : void 0;
|
|
3487
3487
|
wsComponent.query = query;
|
|
3488
3488
|
wsComponent.resourceName = void 0;
|
|
3489
3489
|
}
|
|
@@ -13460,10 +13460,10 @@ function mergeDefs(...defs) {
|
|
|
13460
13460
|
function cloneDef(schema) {
|
|
13461
13461
|
return mergeDefs(schema._zod.def);
|
|
13462
13462
|
}
|
|
13463
|
-
function getElementAtPath(obj2,
|
|
13464
|
-
if (!
|
|
13463
|
+
function getElementAtPath(obj2, path12) {
|
|
13464
|
+
if (!path12)
|
|
13465
13465
|
return obj2;
|
|
13466
|
-
return
|
|
13466
|
+
return path12.reduce((acc, key) => acc?.[key], obj2);
|
|
13467
13467
|
}
|
|
13468
13468
|
function promiseAllObject(promisesObj) {
|
|
13469
13469
|
const keys = Object.keys(promisesObj);
|
|
@@ -13872,11 +13872,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
13872
13872
|
}
|
|
13873
13873
|
return false;
|
|
13874
13874
|
}
|
|
13875
|
-
function prefixIssues(
|
|
13875
|
+
function prefixIssues(path12, issues) {
|
|
13876
13876
|
return issues.map((iss) => {
|
|
13877
13877
|
var _a3;
|
|
13878
13878
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
13879
|
-
iss.path.unshift(
|
|
13879
|
+
iss.path.unshift(path12);
|
|
13880
13880
|
return iss;
|
|
13881
13881
|
});
|
|
13882
13882
|
}
|
|
@@ -14023,16 +14023,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14023
14023
|
}
|
|
14024
14024
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
14025
14025
|
const fieldErrors = { _errors: [] };
|
|
14026
|
-
const processError = (error52,
|
|
14026
|
+
const processError = (error52, path12 = []) => {
|
|
14027
14027
|
for (const issue2 of error52.issues) {
|
|
14028
14028
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14029
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
14029
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
14030
14030
|
} else if (issue2.code === "invalid_key") {
|
|
14031
|
-
processError({ issues: issue2.issues }, [...
|
|
14031
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14032
14032
|
} else if (issue2.code === "invalid_element") {
|
|
14033
|
-
processError({ issues: issue2.issues }, [...
|
|
14033
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14034
14034
|
} else {
|
|
14035
|
-
const fullpath = [...
|
|
14035
|
+
const fullpath = [...path12, ...issue2.path];
|
|
14036
14036
|
if (fullpath.length === 0) {
|
|
14037
14037
|
fieldErrors._errors.push(mapper(issue2));
|
|
14038
14038
|
} else {
|
|
@@ -14059,17 +14059,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14059
14059
|
}
|
|
14060
14060
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
14061
14061
|
const result = { errors: [] };
|
|
14062
|
-
const processError = (error52,
|
|
14062
|
+
const processError = (error52, path12 = []) => {
|
|
14063
14063
|
var _a3, _b;
|
|
14064
14064
|
for (const issue2 of error52.issues) {
|
|
14065
14065
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14066
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
14066
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
14067
14067
|
} else if (issue2.code === "invalid_key") {
|
|
14068
|
-
processError({ issues: issue2.issues }, [...
|
|
14068
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14069
14069
|
} else if (issue2.code === "invalid_element") {
|
|
14070
|
-
processError({ issues: issue2.issues }, [...
|
|
14070
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
14071
14071
|
} else {
|
|
14072
|
-
const fullpath = [...
|
|
14072
|
+
const fullpath = [...path12, ...issue2.path];
|
|
14073
14073
|
if (fullpath.length === 0) {
|
|
14074
14074
|
result.errors.push(mapper(issue2));
|
|
14075
14075
|
continue;
|
|
@@ -14101,8 +14101,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
14101
14101
|
}
|
|
14102
14102
|
function toDotPath(_path) {
|
|
14103
14103
|
const segs = [];
|
|
14104
|
-
const
|
|
14105
|
-
for (const seg of
|
|
14104
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
14105
|
+
for (const seg of path12) {
|
|
14106
14106
|
if (typeof seg === "number")
|
|
14107
14107
|
segs.push(`[${seg}]`);
|
|
14108
14108
|
else if (typeof seg === "symbol")
|
|
@@ -26794,13 +26794,13 @@ function resolveRef(ref, ctx) {
|
|
|
26794
26794
|
if (!ref.startsWith("#")) {
|
|
26795
26795
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
26796
26796
|
}
|
|
26797
|
-
const
|
|
26798
|
-
if (
|
|
26797
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
26798
|
+
if (path12.length === 0) {
|
|
26799
26799
|
return ctx.rootSchema;
|
|
26800
26800
|
}
|
|
26801
26801
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
26802
|
-
if (
|
|
26803
|
-
const key =
|
|
26802
|
+
if (path12[0] === defsKey) {
|
|
26803
|
+
const key = path12[1];
|
|
26804
26804
|
if (!key || !ctx.defs[key]) {
|
|
26805
26805
|
throw new Error(`Reference not found: ${ref}`);
|
|
26806
26806
|
}
|
|
@@ -27263,6 +27263,55 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
27263
27263
|
request: credentialImportsRequestSchema
|
|
27264
27264
|
}).strict();
|
|
27265
27265
|
|
|
27266
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
27267
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
27268
|
+
agent: external_exports.string().min(1).max(128),
|
|
27269
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
27270
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
27271
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
27272
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
27273
|
+
});
|
|
27274
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
27275
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
27276
|
+
entries: harnessDisplayEntriesSchema,
|
|
27277
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
27278
|
+
initializeOnly: external_exports.boolean().optional()
|
|
27279
|
+
});
|
|
27280
|
+
|
|
27281
|
+
// ../../shared-contracts/dist/console.js
|
|
27282
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
27283
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
27284
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
27285
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
27286
|
+
});
|
|
27287
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
27288
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
27289
|
+
/** The console address. */
|
|
27290
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
27291
|
+
});
|
|
27292
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
27293
|
+
"codexhost/harness/plugins/list",
|
|
27294
|
+
"codexhost/harness/display-settings/get",
|
|
27295
|
+
"codexhost/harness/display-settings/set",
|
|
27296
|
+
"codexhost/harness/inspect",
|
|
27297
|
+
"codexhost/harness/launch-settings/get",
|
|
27298
|
+
"codexhost/harness/launch-settings/set",
|
|
27299
|
+
"codexhost/harness/web-ui/open",
|
|
27300
|
+
"codexhost/harness/accounts/sources",
|
|
27301
|
+
"codexhost/harness/accounts/list",
|
|
27302
|
+
"codexhost/harness/accounts/inspect",
|
|
27303
|
+
"codexhost/harness/credential-imports",
|
|
27304
|
+
"codexhost/harness/session-import/sources",
|
|
27305
|
+
"codexhost/harness/session-import/list",
|
|
27306
|
+
"codexhost/harness/session-import/import",
|
|
27307
|
+
"codexhost/account/list",
|
|
27308
|
+
"codexhost/account/refresh",
|
|
27309
|
+
"codexhost/account/usage/inspect",
|
|
27310
|
+
"codexhost/update/check",
|
|
27311
|
+
"codexhost/update/start",
|
|
27312
|
+
"codexhost/update/status"
|
|
27313
|
+
]);
|
|
27314
|
+
|
|
27266
27315
|
// ../../shared-contracts/dist/version.js
|
|
27267
27316
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
27268
27317
|
|
|
@@ -27316,6 +27365,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
|
27316
27365
|
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
27317
27366
|
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
27318
27367
|
|
|
27368
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
27369
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
27370
|
+
threadId: hostThreadIdSchema,
|
|
27371
|
+
turnId: hostTurnIdSchema
|
|
27372
|
+
});
|
|
27373
|
+
|
|
27319
27374
|
// ../../shared-contracts/dist/thread-usage.js
|
|
27320
27375
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
27321
27376
|
var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
|
|
@@ -27376,6 +27431,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
27376
27431
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
27377
27432
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
27378
27433
|
product: external_exports.string().min(1),
|
|
27434
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27435
|
+
// Zero is a real empty cap, not an absent field.
|
|
27436
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27437
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
27379
27438
|
usagePercent: usagePercentSchema,
|
|
27380
27439
|
resetsAt: external_exports.string().min(1).optional()
|
|
27381
27440
|
}).strict();
|
|
@@ -27385,6 +27444,10 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
27385
27444
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
27386
27445
|
}).strict();
|
|
27387
27446
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
27447
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
27448
|
+
// Zero is a real empty cap, not an absent field.
|
|
27449
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
27450
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
27388
27451
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
27389
27452
|
label: external_exports.string().min(1).optional(),
|
|
27390
27453
|
usedPercent: usagePercentSchema,
|
|
@@ -27404,12 +27467,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
27404
27467
|
}).strict();
|
|
27405
27468
|
|
|
27406
27469
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
27407
|
-
var
|
|
27470
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
27471
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
27472
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
27473
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
27474
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
27475
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
27476
|
+
}).strict();
|
|
27477
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
27408
27478
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
27409
27479
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
27410
27480
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
27411
|
-
credits: accountCreditsSnapshotSchema
|
|
27481
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
27482
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
27412
27483
|
}).strict();
|
|
27484
|
+
function requireReportedQuota(schema) {
|
|
27485
|
+
return schema.refine((value) => {
|
|
27486
|
+
const reported = value;
|
|
27487
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
27488
|
+
}, { message: "Account must report either credits or a balance" });
|
|
27489
|
+
}
|
|
27490
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
27413
27491
|
var harnessAccountIdentityShape = {
|
|
27414
27492
|
harnessId: harnessIdSchema,
|
|
27415
27493
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -27420,11 +27498,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
27420
27498
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
27421
27499
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
27422
27500
|
...harnessAccountIdentityShape,
|
|
27423
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
27501
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
27502
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
27503
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
27424
27504
|
}).strict();
|
|
27425
27505
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
27426
27506
|
var harnessAccountListResultSchema = external_exports.object({
|
|
27427
|
-
accounts: external_exports.array(
|
|
27507
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
27428
27508
|
}).strict();
|
|
27429
27509
|
|
|
27430
27510
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -27562,6 +27642,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
27562
27642
|
ref: harnessModelRefSchema,
|
|
27563
27643
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
27564
27644
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
27645
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
27646
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
27565
27647
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
27566
27648
|
}).strict();
|
|
27567
27649
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -27594,6 +27676,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
27594
27676
|
});
|
|
27595
27677
|
}
|
|
27596
27678
|
refs.add(model.ref.id);
|
|
27679
|
+
if (model.fastModel) {
|
|
27680
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
27681
|
+
context.addIssue({
|
|
27682
|
+
code: "custom",
|
|
27683
|
+
message: "Fast Model refs must be distinct and unique",
|
|
27684
|
+
path: ["models", index, "fastModel"]
|
|
27685
|
+
});
|
|
27686
|
+
}
|
|
27687
|
+
refs.add(model.fastModel.id);
|
|
27688
|
+
}
|
|
27597
27689
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
27598
27690
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
27599
27691
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -27713,11 +27805,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
27713
27805
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
27714
27806
|
}).strict();
|
|
27715
27807
|
var threadInspectionParamsSchema = external_exports.object({
|
|
27716
|
-
threadId: hostThreadIdSchema
|
|
27808
|
+
threadId: hostThreadIdSchema,
|
|
27809
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
27717
27810
|
}).strict();
|
|
27718
27811
|
var codexThreadInspectionSchema = external_exports.object({
|
|
27719
27812
|
owner: external_exports.literal("codex"),
|
|
27720
|
-
locked: external_exports.literal(true)
|
|
27813
|
+
locked: external_exports.literal(true),
|
|
27814
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
27721
27815
|
}).strict();
|
|
27722
27816
|
var externalThreadInspectionSchema = external_exports.object({
|
|
27723
27817
|
owner: external_exports.literal("external"),
|
|
@@ -27843,6 +27937,19 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
27843
27937
|
restartRequired: external_exports.boolean()
|
|
27844
27938
|
}).strict();
|
|
27845
27939
|
|
|
27940
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
27941
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
27942
|
+
harnessId: harnessIdSchema,
|
|
27943
|
+
action: external_exports.enum(["check", "update"])
|
|
27944
|
+
}).strict();
|
|
27945
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
27946
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
27947
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
27948
|
+
updateAvailable: external_exports.boolean(),
|
|
27949
|
+
canUpdate: external_exports.boolean(),
|
|
27950
|
+
message: external_exports.string().max(2048).optional()
|
|
27951
|
+
}).strict();
|
|
27952
|
+
|
|
27846
27953
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
27847
27954
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
27848
27955
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
@@ -28480,9 +28587,778 @@ function cursorCommandPrompt(command, catalog) {
|
|
|
28480
28587
|
return { ok: true, value: `${descriptor.invocation}${text2 ? ` ${text2}` : ""}` };
|
|
28481
28588
|
}
|
|
28482
28589
|
|
|
28590
|
+
// ../../harness-discovery/dist/environment.js
|
|
28591
|
+
import fs from "node:fs";
|
|
28592
|
+
import path from "node:path";
|
|
28593
|
+
function targetPath(platform) {
|
|
28594
|
+
return platform === "win32" ? path.win32 : path.posix;
|
|
28595
|
+
}
|
|
28596
|
+
function environmentValue(environment, name) {
|
|
28597
|
+
const lowered = name.toLowerCase();
|
|
28598
|
+
for (const [key, value] of Object.entries(environment)) {
|
|
28599
|
+
if (key.toLowerCase() === lowered)
|
|
28600
|
+
return value;
|
|
28601
|
+
}
|
|
28602
|
+
return void 0;
|
|
28603
|
+
}
|
|
28604
|
+
function pathDelimiter(platform) {
|
|
28605
|
+
return platform === "win32" ? ";" : ":";
|
|
28606
|
+
}
|
|
28607
|
+
function pathDirectories(environment, platform) {
|
|
28608
|
+
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
28609
|
+
}
|
|
28610
|
+
function executableExtensions(command, platform, environment) {
|
|
28611
|
+
if (platform !== "win32")
|
|
28612
|
+
return [""];
|
|
28613
|
+
if (targetPath(platform).extname(command) !== "")
|
|
28614
|
+
return [""];
|
|
28615
|
+
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
28616
|
+
}
|
|
28617
|
+
function isExecutableFile(filePath, platform) {
|
|
28618
|
+
try {
|
|
28619
|
+
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
28620
|
+
return fs.statSync(filePath).isFile();
|
|
28621
|
+
} catch {
|
|
28622
|
+
return false;
|
|
28623
|
+
}
|
|
28624
|
+
}
|
|
28625
|
+
function subdirectoryNames(directory) {
|
|
28626
|
+
try {
|
|
28627
|
+
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
28628
|
+
} catch {
|
|
28629
|
+
return [];
|
|
28630
|
+
}
|
|
28631
|
+
}
|
|
28632
|
+
function newestFirst(names) {
|
|
28633
|
+
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
28634
|
+
}
|
|
28635
|
+
|
|
28636
|
+
// ../../harness-discovery/dist/invocation.js
|
|
28637
|
+
import path2 from "node:path";
|
|
28638
|
+
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
28639
|
+
const extension = path2.win32.extname(command).toLowerCase();
|
|
28640
|
+
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
28641
|
+
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
28642
|
+
}
|
|
28643
|
+
const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
28644
|
+
const commandLine = [command, ...arguments_].map(quote2).join(" ");
|
|
28645
|
+
return {
|
|
28646
|
+
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
28647
|
+
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
28648
|
+
windowsVerbatimArguments: true
|
|
28649
|
+
};
|
|
28650
|
+
}
|
|
28651
|
+
|
|
28652
|
+
// ../../harness-discovery/dist/node-runtime.js
|
|
28653
|
+
import path3 from "node:path";
|
|
28654
|
+
function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
|
|
28655
|
+
const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
|
|
28656
|
+
const delimiter = platform === "win32" ? ";" : ":";
|
|
28657
|
+
const runtimeDirectory = path3.dirname(runtimeExecutable);
|
|
28658
|
+
const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
|
|
28659
|
+
const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
|
|
28660
|
+
if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
|
|
28661
|
+
directories.push(runtimeDirectory);
|
|
28662
|
+
}
|
|
28663
|
+
return { ...environment, [pathKey]: directories.join(delimiter) };
|
|
28664
|
+
}
|
|
28665
|
+
|
|
28666
|
+
// ../../harness-discovery/dist/resolve.js
|
|
28667
|
+
import os from "node:os";
|
|
28668
|
+
|
|
28669
|
+
// ../../harness-discovery/dist/version-managers.js
|
|
28670
|
+
function versionManagerBinaryDirectories(context) {
|
|
28671
|
+
const { platform, environment, home } = context;
|
|
28672
|
+
const list = context.subdirectories ?? subdirectoryNames;
|
|
28673
|
+
const pathFlavor = targetPath(platform);
|
|
28674
|
+
const value = (name) => environmentValue(environment, name);
|
|
28675
|
+
const directories = [];
|
|
28676
|
+
const versioned = (root, ...tail) => {
|
|
28677
|
+
for (const version2 of newestFirst(list(root))) {
|
|
28678
|
+
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
28679
|
+
}
|
|
28680
|
+
};
|
|
28681
|
+
if (platform === "win32") {
|
|
28682
|
+
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
28683
|
+
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
28684
|
+
versioned(pathFlavor.join(appData, "nvm"));
|
|
28685
|
+
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
28686
|
+
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
28687
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
28688
|
+
const pnpmHome2 = value("PNPM_HOME");
|
|
28689
|
+
if (pnpmHome2)
|
|
28690
|
+
directories.push(pnpmHome2);
|
|
28691
|
+
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
28692
|
+
return directories;
|
|
28693
|
+
}
|
|
28694
|
+
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
28695
|
+
const fnmRoots = [
|
|
28696
|
+
value("FNM_DIR"),
|
|
28697
|
+
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
28698
|
+
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
28699
|
+
].filter((root) => root !== void 0);
|
|
28700
|
+
for (const root of fnmRoots) {
|
|
28701
|
+
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
28702
|
+
}
|
|
28703
|
+
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
28704
|
+
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
28705
|
+
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
28706
|
+
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
28707
|
+
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
28708
|
+
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
28709
|
+
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
28710
|
+
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
28711
|
+
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
28712
|
+
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
28713
|
+
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
28714
|
+
const pnpmHome = value("PNPM_HOME");
|
|
28715
|
+
if (pnpmHome)
|
|
28716
|
+
directories.push(pnpmHome);
|
|
28717
|
+
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
28718
|
+
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
28719
|
+
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
28720
|
+
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
28721
|
+
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
28722
|
+
}
|
|
28723
|
+
}
|
|
28724
|
+
return directories;
|
|
28725
|
+
}
|
|
28726
|
+
|
|
28727
|
+
// ../../harness-discovery/dist/resolve.js
|
|
28728
|
+
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
28729
|
+
function installRootExtensions(platform) {
|
|
28730
|
+
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
28731
|
+
}
|
|
28732
|
+
function resolveHomeDirectory(input) {
|
|
28733
|
+
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
28734
|
+
}
|
|
28735
|
+
function templateVariables(environment, platform, home) {
|
|
28736
|
+
const pathFlavor = targetPath(platform);
|
|
28737
|
+
return {
|
|
28738
|
+
HOME: home,
|
|
28739
|
+
USERPROFILE: home,
|
|
28740
|
+
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
28741
|
+
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
28742
|
+
};
|
|
28743
|
+
}
|
|
28744
|
+
function joinTemplate(platform, value) {
|
|
28745
|
+
const pathFlavor = targetPath(platform);
|
|
28746
|
+
const segments = value.split("/");
|
|
28747
|
+
const head = segments[0] ?? "";
|
|
28748
|
+
const tail = segments.slice(1);
|
|
28749
|
+
if (head === "")
|
|
28750
|
+
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
28751
|
+
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
28752
|
+
}
|
|
28753
|
+
function expandInstallRoot(template, environment, platform, home) {
|
|
28754
|
+
const variables = templateVariables(environment, platform, home);
|
|
28755
|
+
let unresolved = false;
|
|
28756
|
+
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
28757
|
+
const value = variables[name] ?? environmentValue(environment, name);
|
|
28758
|
+
if (value === void 0 || value === "") {
|
|
28759
|
+
unresolved = true;
|
|
28760
|
+
return "";
|
|
28761
|
+
}
|
|
28762
|
+
return value;
|
|
28763
|
+
});
|
|
28764
|
+
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
28765
|
+
}
|
|
28766
|
+
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
28767
|
+
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
28768
|
+
const directories = [];
|
|
28769
|
+
for (const template of templates) {
|
|
28770
|
+
if (template === VERSION_MANAGER_ROOTS) {
|
|
28771
|
+
directories.push(...versionManagerBinaryDirectories({
|
|
28772
|
+
platform,
|
|
28773
|
+
environment: input.environment,
|
|
28774
|
+
home,
|
|
28775
|
+
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
28776
|
+
}));
|
|
28777
|
+
continue;
|
|
28778
|
+
}
|
|
28779
|
+
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
28780
|
+
if (directory !== void 0)
|
|
28781
|
+
directories.push(directory);
|
|
28782
|
+
}
|
|
28783
|
+
return directories;
|
|
28784
|
+
}
|
|
28785
|
+
function harnessCandidates(spec, input, dependencies = {}) {
|
|
28786
|
+
const platform = input.platform ?? process.platform;
|
|
28787
|
+
const pathFlavor = targetPath(platform);
|
|
28788
|
+
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
28789
|
+
const command = configured ?? spec.command;
|
|
28790
|
+
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
28791
|
+
return [{ candidate: command, source: "configured" }];
|
|
28792
|
+
}
|
|
28793
|
+
const candidates = [];
|
|
28794
|
+
const extensions = executableExtensions(command, platform, input.environment);
|
|
28795
|
+
for (const directory of pathDirectories(input.environment, platform)) {
|
|
28796
|
+
for (const extension of extensions) {
|
|
28797
|
+
candidates.push({
|
|
28798
|
+
candidate: pathFlavor.join(directory, command + extension),
|
|
28799
|
+
source: "path"
|
|
28800
|
+
});
|
|
28801
|
+
}
|
|
28802
|
+
}
|
|
28803
|
+
if (configured !== void 0)
|
|
28804
|
+
return candidates;
|
|
28805
|
+
const home = resolveHomeDirectory(input);
|
|
28806
|
+
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
28807
|
+
for (const extension of installRootExtensions(platform)) {
|
|
28808
|
+
candidates.push({
|
|
28809
|
+
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
28810
|
+
source: "install-root"
|
|
28811
|
+
});
|
|
28812
|
+
}
|
|
28813
|
+
}
|
|
28814
|
+
return candidates;
|
|
28815
|
+
}
|
|
28816
|
+
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
28817
|
+
const platform = input.platform ?? process.platform;
|
|
28818
|
+
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
28819
|
+
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
28820
|
+
const context = { platform, isExecutable };
|
|
28821
|
+
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
28822
|
+
const executable = runnable(candidate, context);
|
|
28823
|
+
if (executable !== void 0 && isExecutable(executable))
|
|
28824
|
+
return { executable, source };
|
|
28825
|
+
}
|
|
28826
|
+
return void 0;
|
|
28827
|
+
}
|
|
28828
|
+
|
|
28829
|
+
// ../../harness-discovery/dist/installation.js
|
|
28830
|
+
import { execFile } from "node:child_process";
|
|
28831
|
+
import { homedir } from "node:os";
|
|
28832
|
+
function runInstallationCommand(command, args, environment, timeout = 3e4) {
|
|
28833
|
+
const env = withNodeRuntimeOnPath(environment);
|
|
28834
|
+
const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
|
|
28835
|
+
return new Promise((resolve, reject) => {
|
|
28836
|
+
const child = execFile(invocation.command, invocation.arguments, {
|
|
28837
|
+
env,
|
|
28838
|
+
cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
|
|
28839
|
+
encoding: "utf8",
|
|
28840
|
+
timeout,
|
|
28841
|
+
killSignal: "SIGKILL",
|
|
28842
|
+
maxBuffer: 1024 * 1024,
|
|
28843
|
+
windowsHide: true,
|
|
28844
|
+
windowsVerbatimArguments: invocation.windowsVerbatimArguments
|
|
28845
|
+
}, (error51, stdout, stderr) => {
|
|
28846
|
+
if (error51)
|
|
28847
|
+
reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
|
|
28848
|
+
else
|
|
28849
|
+
resolve((stdout || stderr).trim());
|
|
28850
|
+
});
|
|
28851
|
+
child.stdin?.end();
|
|
28852
|
+
});
|
|
28853
|
+
}
|
|
28854
|
+
function installationVersion(value) {
|
|
28855
|
+
if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
|
|
28856
|
+
throw new Error("Harness returned an invalid version");
|
|
28857
|
+
return value.trim().replace(/^v/, "");
|
|
28858
|
+
}
|
|
28859
|
+
function createInstallationManager(options) {
|
|
28860
|
+
let checking;
|
|
28861
|
+
let updating;
|
|
28862
|
+
const check2 = () => checking ??= options.check().finally(() => {
|
|
28863
|
+
checking = void 0;
|
|
28864
|
+
});
|
|
28865
|
+
return (action) => {
|
|
28866
|
+
if (updating)
|
|
28867
|
+
return updating;
|
|
28868
|
+
if (action === "check")
|
|
28869
|
+
return check2();
|
|
28870
|
+
updating = (async () => {
|
|
28871
|
+
const before = await check2();
|
|
28872
|
+
if (!before.updateAvailable)
|
|
28873
|
+
return before;
|
|
28874
|
+
if (!before.canUpdate)
|
|
28875
|
+
throw new Error(before.message ?? "This installation cannot be updated automatically");
|
|
28876
|
+
await options.update(before);
|
|
28877
|
+
const after = await check2();
|
|
28878
|
+
if (after.currentVersion === before.currentVersion)
|
|
28879
|
+
throw new Error("The Harness version did not change; check the native updater and retry");
|
|
28880
|
+
return after;
|
|
28881
|
+
})().finally(() => {
|
|
28882
|
+
updating = void 0;
|
|
28883
|
+
});
|
|
28884
|
+
return updating;
|
|
28885
|
+
};
|
|
28886
|
+
}
|
|
28887
|
+
|
|
28888
|
+
// dist/command.js
|
|
28889
|
+
import { existsSync, readdirSync } from "node:fs";
|
|
28890
|
+
import path4 from "node:path";
|
|
28891
|
+
var PINNED_VERSION_AGENT = /[/\\]cursor-agent[/\\]versions[/\\][^/\\]+[/\\]cursor-agent(?:\.exe)?$/iu;
|
|
28892
|
+
function cursorDiscoverySpec(skipPinnedVersions) {
|
|
28893
|
+
return {
|
|
28894
|
+
id: "cursor-cli",
|
|
28895
|
+
command: "cursor-agent",
|
|
28896
|
+
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
28897
|
+
installRoots: {
|
|
28898
|
+
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
28899
|
+
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
28900
|
+
},
|
|
28901
|
+
...skipPinnedVersions ? {
|
|
28902
|
+
runnableCandidate: (candidate) => PINNED_VERSION_AGENT.test(candidate) ? void 0 : candidate
|
|
28903
|
+
} : {}
|
|
28904
|
+
};
|
|
28905
|
+
}
|
|
28906
|
+
function resolveCursorExecutable(environment, command) {
|
|
28907
|
+
const input = { environment, ...command ? { command } : {} };
|
|
28908
|
+
const pinned = resolveHarnessExecutable(cursorDiscoverySpec(false), input);
|
|
28909
|
+
if (!pinned)
|
|
28910
|
+
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
28911
|
+
const explicit = command?.trim() || environment.CODEXHOST_CURSOR_COMMAND?.trim();
|
|
28912
|
+
if (explicit || !PINNED_VERSION_AGENT.test(pinned.executable))
|
|
28913
|
+
return pinned;
|
|
28914
|
+
return resolveHarnessExecutable(cursorDiscoverySpec(true), input) ?? pinned;
|
|
28915
|
+
}
|
|
28916
|
+
function cursorInvocation(environment, command, args) {
|
|
28917
|
+
const resolution = resolveCursorExecutable(environment, command);
|
|
28918
|
+
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
28919
|
+
const root = path4.dirname(resolution.executable);
|
|
28920
|
+
const versions = path4.join(root, "versions");
|
|
28921
|
+
if (existsSync(versions)) {
|
|
28922
|
+
const version2 = readdirSync(versions).filter((name) => /^\d{4}\.\d{2}\.\d{2}-(?:\d{2}-\d{2}-\d{2}-)?[a-f0-9]+$/u.test(name)).sort().reverse().find((name) => existsSync(path4.join(versions, name, "node.exe")) && existsSync(path4.join(versions, name, "index.js")));
|
|
28923
|
+
if (version2)
|
|
28924
|
+
return {
|
|
28925
|
+
command: path4.join(versions, version2, "node.exe"),
|
|
28926
|
+
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
28927
|
+
windowsVerbatimArguments: false
|
|
28928
|
+
};
|
|
28929
|
+
}
|
|
28930
|
+
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
28931
|
+
}
|
|
28932
|
+
return commandInvocation(resolution.executable, args, environment);
|
|
28933
|
+
}
|
|
28934
|
+
|
|
28935
|
+
// dist/installation.js
|
|
28936
|
+
function createCursorInstallation(environment) {
|
|
28937
|
+
const run = (args, timeout) => {
|
|
28938
|
+
const invocation = cursorInvocation(environment, void 0, args);
|
|
28939
|
+
return runInstallationCommand(invocation.command, invocation.arguments, environment, timeout);
|
|
28940
|
+
};
|
|
28941
|
+
return createInstallationManager({
|
|
28942
|
+
async check() {
|
|
28943
|
+
const state = JSON.parse(await run(["about", "--format", "json"]));
|
|
28944
|
+
if (state.latestStatus !== "up_to_date" && state.latestStatus !== "update_available")
|
|
28945
|
+
throw new Error("Cursor update checks are disabled or unavailable");
|
|
28946
|
+
return {
|
|
28947
|
+
currentVersion: installationVersion(state.cliVersion),
|
|
28948
|
+
latestVersion: installationVersion(state.latestVersion),
|
|
28949
|
+
updateAvailable: state.latestStatus === "update_available",
|
|
28950
|
+
canUpdate: true
|
|
28951
|
+
};
|
|
28952
|
+
},
|
|
28953
|
+
async update() {
|
|
28954
|
+
await run(["update"], 3e5);
|
|
28955
|
+
}
|
|
28956
|
+
});
|
|
28957
|
+
}
|
|
28958
|
+
|
|
28483
28959
|
// dist/adapter.js
|
|
28960
|
+
import path10 from "node:path";
|
|
28961
|
+
|
|
28962
|
+
// dist/account-usage.js
|
|
28963
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
28964
|
+
import { readFile } from "node:fs/promises";
|
|
28965
|
+
import { homedir as homedir2 } from "node:os";
|
|
28966
|
+
import path5 from "node:path";
|
|
28967
|
+
import { promisify } from "node:util";
|
|
28968
|
+
var execute = promisify(execFile2);
|
|
28969
|
+
var ENDPOINT = "https://api2.cursor.sh/aiserver.v1.DashboardService/";
|
|
28970
|
+
var record2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
28971
|
+
var percent = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(100, value) : void 0;
|
|
28972
|
+
function projectCursorAccountUsage(usage, identity, plan) {
|
|
28973
|
+
const data = record2(usage);
|
|
28974
|
+
const buckets = record2(data.planUsage);
|
|
28975
|
+
const usedPercent = percent(buckets.autoPercentUsed);
|
|
28976
|
+
if (usedPercent === void 0)
|
|
28977
|
+
return null;
|
|
28978
|
+
const end = typeof data.billingCycleEnd === "string" || typeof data.billingCycleEnd === "number" ? Number(data.billingCycleEnd) : NaN;
|
|
28979
|
+
const date5 = new Date(end);
|
|
28980
|
+
const resetsAt = Number.isFinite(date5.getTime()) && end > 0 ? date5.toISOString() : void 0;
|
|
28981
|
+
const apiPercent = percent(buckets.apiPercentUsed);
|
|
28982
|
+
const email3 = record2(identity).email;
|
|
28983
|
+
const planName = record2(record2(plan).planInfo).planName;
|
|
28984
|
+
const result = harnessAccountSnapshotSchema.safeParse({
|
|
28985
|
+
...typeof email3 === "string" && email3.trim() ? { email: email3 } : {},
|
|
28986
|
+
...typeof planName === "string" && planName.trim() ? { plan: planName } : {},
|
|
28987
|
+
credits: {
|
|
28988
|
+
usedPercent,
|
|
28989
|
+
label: "Auto · monthly",
|
|
28990
|
+
periodType: "monthly",
|
|
28991
|
+
...resetsAt ? { resetsAt } : {},
|
|
28992
|
+
...apiPercent === void 0 ? {} : {
|
|
28993
|
+
productUsage: [
|
|
28994
|
+
{
|
|
28995
|
+
product: "API · monthly",
|
|
28996
|
+
usagePercent: apiPercent,
|
|
28997
|
+
...resetsAt ? { resetsAt } : {}
|
|
28998
|
+
}
|
|
28999
|
+
]
|
|
29000
|
+
}
|
|
29001
|
+
}
|
|
29002
|
+
});
|
|
29003
|
+
return result.success ? result.data : null;
|
|
29004
|
+
}
|
|
29005
|
+
async function accessToken(environment) {
|
|
29006
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29007
|
+
return void 0;
|
|
29008
|
+
if (process.platform === "darwin" && environment.AGENT_CLI_CREDENTIAL_STORE !== "file") {
|
|
29009
|
+
const result = await execute("/usr/bin/security", ["find-generic-password", "-s", "cursor-access-token", "-a", "cursor-user", "-w"], { timeout: 5e3, maxBuffer: 64 * 1024 });
|
|
29010
|
+
return result.stdout.trim() || void 0;
|
|
29011
|
+
}
|
|
29012
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir2();
|
|
29013
|
+
const authPath = process.platform === "darwin" ? path5.join(home, ".cursor", "auth.json") : process.platform === "win32" ? path5.join(environment.APPDATA ?? path5.join(home, "AppData", "Roaming"), "Cursor", "auth.json") : path5.join(environment.XDG_CONFIG_HOME ?? path5.join(home, ".config"), "cursor", "auth.json");
|
|
29014
|
+
const auth = record2(JSON.parse(await readFile(authPath, "utf8")));
|
|
29015
|
+
return typeof auth.accessToken === "string" && auth.accessToken.trim() ? auth.accessToken : void 0;
|
|
29016
|
+
}
|
|
29017
|
+
async function fetchCursorAccount(input = {}) {
|
|
29018
|
+
try {
|
|
29019
|
+
const environment = input.environment ?? process.env;
|
|
29020
|
+
if (environment.CURSOR_API_KEY?.trim() || environment.AGENT_CLI_CREDENTIAL_STORE === "memory")
|
|
29021
|
+
return null;
|
|
29022
|
+
const token = await (input.readAccessToken ? input.readAccessToken() : accessToken(environment));
|
|
29023
|
+
if (!token)
|
|
29024
|
+
return null;
|
|
29025
|
+
const signal = input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(1e4)]) : AbortSignal.timeout(1e4);
|
|
29026
|
+
const request = async (method) => {
|
|
29027
|
+
const response = await (input.fetch ?? fetch)(ENDPOINT + method, {
|
|
29028
|
+
method: "POST",
|
|
29029
|
+
headers: {
|
|
29030
|
+
Authorization: `Bearer ${token}`,
|
|
29031
|
+
"Content-Type": "application/json",
|
|
29032
|
+
"Connect-Protocol-Version": "1"
|
|
29033
|
+
},
|
|
29034
|
+
body: "{}",
|
|
29035
|
+
signal
|
|
29036
|
+
});
|
|
29037
|
+
return response.ok ? response.json() : null;
|
|
29038
|
+
};
|
|
29039
|
+
const [usage, identity, plan] = await Promise.all([
|
|
29040
|
+
request("GetCurrentPeriodUsage"),
|
|
29041
|
+
request("GetMe").catch(() => null),
|
|
29042
|
+
request("GetPlanInfo").catch(() => null)
|
|
29043
|
+
]);
|
|
29044
|
+
return projectCursorAccountUsage(usage, identity, plan);
|
|
29045
|
+
} catch {
|
|
29046
|
+
return null;
|
|
29047
|
+
}
|
|
29048
|
+
}
|
|
29049
|
+
|
|
29050
|
+
// dist/session-import.js
|
|
29051
|
+
import { lstat, opendir, readFile as readFile2, realpath, stat } from "node:fs/promises";
|
|
28484
29052
|
import path7 from "node:path";
|
|
28485
29053
|
|
|
29054
|
+
// dist/native-history.js
|
|
29055
|
+
import { existsSync as existsSync2, readFileSync, realpathSync } from "node:fs";
|
|
29056
|
+
import os2 from "node:os";
|
|
29057
|
+
import path6 from "node:path";
|
|
29058
|
+
import { DatabaseSync } from "node:sqlite";
|
|
29059
|
+
function cursorConfigDirectory(environment) {
|
|
29060
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
29061
|
+
return environment.CURSOR_CONFIG_DIR?.trim() ? path6.resolve(environment.CURSOR_CONFIG_DIR) : environment.XDG_CONFIG_HOME?.trim() ? path6.resolve(environment.XDG_CONFIG_HOME, "cursor") : path6.join(home, ".cursor");
|
|
29062
|
+
}
|
|
29063
|
+
function cursorSessionDirectory(sessionId, environment) {
|
|
29064
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
29065
|
+
throw new Error("Unsupported Cursor native session ID");
|
|
29066
|
+
return path6.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
29067
|
+
}
|
|
29068
|
+
function cursorSameWorkspace(left, right) {
|
|
29069
|
+
return path6.resolve(left) === path6.resolve(right) || existsSync2(left) && existsSync2(right) && realpathSync(left) === realpathSync(right);
|
|
29070
|
+
}
|
|
29071
|
+
function protobufBytes(data) {
|
|
29072
|
+
if (data.length > 32 * 1024 * 1024)
|
|
29073
|
+
throw new Error("Cursor native record is too large");
|
|
29074
|
+
let offset = 0;
|
|
29075
|
+
const varint = () => {
|
|
29076
|
+
let result = 0;
|
|
29077
|
+
for (let shift = 0; shift < 70; shift += 7) {
|
|
29078
|
+
const value = data[offset++];
|
|
29079
|
+
if (value === void 0)
|
|
29080
|
+
throw new Error("Truncated Cursor native record");
|
|
29081
|
+
result += (value & 127) * 2 ** shift;
|
|
29082
|
+
if (!(value & 128))
|
|
29083
|
+
return result;
|
|
29084
|
+
}
|
|
29085
|
+
throw new Error("Invalid Cursor native varint");
|
|
29086
|
+
};
|
|
29087
|
+
const fields = /* @__PURE__ */ new Map();
|
|
29088
|
+
while (offset < data.length) {
|
|
29089
|
+
const tag = varint();
|
|
29090
|
+
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
29091
|
+
if (!Number.isSafeInteger(tag) || field === 0)
|
|
29092
|
+
throw new Error("Invalid Cursor native field");
|
|
29093
|
+
if (wire === 0) {
|
|
29094
|
+
varint();
|
|
29095
|
+
continue;
|
|
29096
|
+
}
|
|
29097
|
+
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
29098
|
+
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
29099
|
+
throw new Error("Unsupported Cursor native record");
|
|
29100
|
+
if (wire === 2) {
|
|
29101
|
+
const values = fields.get(field) ?? [];
|
|
29102
|
+
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
29103
|
+
fields.set(field, values);
|
|
29104
|
+
}
|
|
29105
|
+
offset += length;
|
|
29106
|
+
}
|
|
29107
|
+
return fields;
|
|
29108
|
+
}
|
|
29109
|
+
function one(fields, field) {
|
|
29110
|
+
const values = fields.get(field);
|
|
29111
|
+
if (values?.length !== 1 || !values[0])
|
|
29112
|
+
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
29113
|
+
return values[0];
|
|
29114
|
+
}
|
|
29115
|
+
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
29116
|
+
const directory = cursorSessionDirectory(sessionId, environment);
|
|
29117
|
+
const filename = path6.join(directory, "store.db");
|
|
29118
|
+
if (allowMissing && !existsSync2(filename))
|
|
29119
|
+
return { revision: void 0, turns: [] };
|
|
29120
|
+
const info = JSON.parse(readFileSync(path6.join(directory, "meta.json"), "utf8"));
|
|
29121
|
+
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
29122
|
+
throw new Error("Cursor session workspace does not match");
|
|
29123
|
+
const db = new DatabaseSync(filename, { readOnly: true });
|
|
29124
|
+
try {
|
|
29125
|
+
db.exec("BEGIN");
|
|
29126
|
+
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
29127
|
+
if (!row && allowMissing)
|
|
29128
|
+
return { revision: void 0, turns: [] };
|
|
29129
|
+
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
29130
|
+
throw new Error("Unsupported Cursor native metadata");
|
|
29131
|
+
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
29132
|
+
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
29133
|
+
throw new Error("Cursor native session identity mismatch");
|
|
29134
|
+
const get = (id) => {
|
|
29135
|
+
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
29136
|
+
throw new Error("Invalid Cursor native blob reference");
|
|
29137
|
+
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
29138
|
+
if (!(blob instanceof Uint8Array))
|
|
29139
|
+
throw new Error("Cursor native history blob is missing");
|
|
29140
|
+
return protobufBytes(blob);
|
|
29141
|
+
};
|
|
29142
|
+
const root = get(metadata.latestRootBlobId);
|
|
29143
|
+
const result = [];
|
|
29144
|
+
for (const ref of root.get(8) ?? []) {
|
|
29145
|
+
if (ref.length !== 32)
|
|
29146
|
+
throw new Error("Unsupported Cursor turn reference");
|
|
29147
|
+
const container = get(ref.toString("hex"));
|
|
29148
|
+
for (const record3 of container.get(1) ?? []) {
|
|
29149
|
+
const turn = protobufBytes(record3);
|
|
29150
|
+
const user = get(one(turn, 1).toString("hex"));
|
|
29151
|
+
const id = one(user, 2).toString("utf8");
|
|
29152
|
+
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
29153
|
+
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
29154
|
+
const anchor = user.get(10)?.[0];
|
|
29155
|
+
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
29156
|
+
result.push({
|
|
29157
|
+
id,
|
|
29158
|
+
text: one(user, 1).toString("utf8"),
|
|
29159
|
+
...rewindRoot ? { rewindRoot } : {}
|
|
29160
|
+
});
|
|
29161
|
+
}
|
|
29162
|
+
}
|
|
29163
|
+
return { revision: metadata.latestRootBlobId, turns: result };
|
|
29164
|
+
} finally {
|
|
29165
|
+
db.close();
|
|
29166
|
+
}
|
|
29167
|
+
}
|
|
29168
|
+
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
29169
|
+
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
29170
|
+
}
|
|
29171
|
+
|
|
29172
|
+
// dist/session-ref.js
|
|
29173
|
+
var cursorHarnessId = harnessIdSchema.parse("cursor-cli");
|
|
29174
|
+
var cursorSessionLocatorSchema = external_exports.strictObject({
|
|
29175
|
+
executionPolicy: external_exports.enum(["default", "unattended-full-access"])
|
|
29176
|
+
});
|
|
29177
|
+
function cursorNativeSessionRef(nativeSessionId, executionPolicy) {
|
|
29178
|
+
return nativeSessionRefSchema.parse({
|
|
29179
|
+
harnessId: cursorHarnessId,
|
|
29180
|
+
nativeSessionId,
|
|
29181
|
+
locator: { executionPolicy },
|
|
29182
|
+
formatVersion: 1
|
|
29183
|
+
});
|
|
29184
|
+
}
|
|
29185
|
+
function cursorExecutionPolicy(ref) {
|
|
29186
|
+
if (ref.harnessId !== cursorHarnessId || ref.formatVersion !== 1)
|
|
29187
|
+
throw new Error("Invalid Cursor Native Session Ref");
|
|
29188
|
+
if (ref.locator === void 0)
|
|
29189
|
+
return "default";
|
|
29190
|
+
const locator = cursorSessionLocatorSchema.safeParse(ref.locator);
|
|
29191
|
+
if (!locator.success)
|
|
29192
|
+
throw new Error("Invalid Cursor Native Session locator");
|
|
29193
|
+
return locator.data.executionPolicy;
|
|
29194
|
+
}
|
|
29195
|
+
|
|
29196
|
+
// dist/session-import.js
|
|
29197
|
+
var SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
29198
|
+
var MAX_METADATA_BYTES = 1024 * 1024;
|
|
29199
|
+
var CursorSessionChangedError = class extends Error {
|
|
29200
|
+
};
|
|
29201
|
+
function errorCode(error51) {
|
|
29202
|
+
return typeof error51 === "object" && error51 !== null && "code" in error51 && typeof error51.code === "string" ? error51.code : void 0;
|
|
29203
|
+
}
|
|
29204
|
+
async function optionalStat(file2) {
|
|
29205
|
+
try {
|
|
29206
|
+
return await lstat(file2);
|
|
29207
|
+
} catch (error51) {
|
|
29208
|
+
if (errorCode(error51) === "ENOENT")
|
|
29209
|
+
return null;
|
|
29210
|
+
throw error51;
|
|
29211
|
+
}
|
|
29212
|
+
}
|
|
29213
|
+
function sameFile(left, right) {
|
|
29214
|
+
return left === null || right === null ? left === right : left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeMs === right.mtimeMs && left.ctimeMs === right.ctimeMs;
|
|
29215
|
+
}
|
|
29216
|
+
var CursorSessionImport = class {
|
|
29217
|
+
#environment;
|
|
29218
|
+
#abort = new AbortController();
|
|
29219
|
+
#pending = /* @__PURE__ */ new Set();
|
|
29220
|
+
constructor(environment) {
|
|
29221
|
+
this.#environment = { ...environment };
|
|
29222
|
+
}
|
|
29223
|
+
listCandidates() {
|
|
29224
|
+
return this.#read(async (signal) => {
|
|
29225
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29226
|
+
const info = await optionalStat(root);
|
|
29227
|
+
if (!info)
|
|
29228
|
+
return [];
|
|
29229
|
+
if (!info.isDirectory())
|
|
29230
|
+
throw new Error("Cursor ACP store is not a directory");
|
|
29231
|
+
const candidates = [];
|
|
29232
|
+
const entries = await opendir(root);
|
|
29233
|
+
for await (const entry of entries) {
|
|
29234
|
+
signal.throwIfAborted();
|
|
29235
|
+
if (!entry.isDirectory() || !SESSION_ID.test(entry.name))
|
|
29236
|
+
continue;
|
|
29237
|
+
try {
|
|
29238
|
+
const candidate = await this.#candidate(entry.name, signal);
|
|
29239
|
+
if (candidate)
|
|
29240
|
+
candidates.push(candidate);
|
|
29241
|
+
} catch (error51) {
|
|
29242
|
+
if (!(error51 instanceof CursorSessionChangedError))
|
|
29243
|
+
throw error51;
|
|
29244
|
+
}
|
|
29245
|
+
}
|
|
29246
|
+
return candidates;
|
|
29247
|
+
});
|
|
29248
|
+
}
|
|
29249
|
+
async resolveCandidate(nativeSessionId) {
|
|
29250
|
+
if (!SESSION_ID.test(nativeSessionId))
|
|
29251
|
+
return {
|
|
29252
|
+
ok: false,
|
|
29253
|
+
error: {
|
|
29254
|
+
code: "invalidRequest",
|
|
29255
|
+
message: "Invalid Cursor ACP Session ID",
|
|
29256
|
+
retryable: false
|
|
29257
|
+
}
|
|
29258
|
+
};
|
|
29259
|
+
const result = await this.#read((signal) => this.#candidate(nativeSessionId, signal));
|
|
29260
|
+
if (!result.ok)
|
|
29261
|
+
return result;
|
|
29262
|
+
if (!result.value)
|
|
29263
|
+
return {
|
|
29264
|
+
ok: false,
|
|
29265
|
+
error: {
|
|
29266
|
+
code: "sessionNotFound",
|
|
29267
|
+
message: "Cursor ACP Session is no longer importable",
|
|
29268
|
+
retryable: false
|
|
29269
|
+
}
|
|
29270
|
+
};
|
|
29271
|
+
return {
|
|
29272
|
+
ok: true,
|
|
29273
|
+
value: {
|
|
29274
|
+
candidate: result.value,
|
|
29275
|
+
// Native ACP stores do not attest to --force. Imported sessions must not
|
|
29276
|
+
// acquire unattended privileges from UI defaults or a guessed locator.
|
|
29277
|
+
nativeRef: cursorNativeSessionRef(nativeSessionId, "default")
|
|
29278
|
+
}
|
|
29279
|
+
};
|
|
29280
|
+
}
|
|
29281
|
+
async #candidate(id, signal) {
|
|
29282
|
+
signal.throwIfAborted();
|
|
29283
|
+
const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
|
|
29284
|
+
if (!(await optionalStat(root))?.isDirectory())
|
|
29285
|
+
return null;
|
|
29286
|
+
const directory = cursorSessionDirectory(id, this.#environment);
|
|
29287
|
+
const files = [
|
|
29288
|
+
directory,
|
|
29289
|
+
path7.join(directory, "meta.json"),
|
|
29290
|
+
path7.join(directory, "store.db"),
|
|
29291
|
+
path7.join(directory, "store.db-wal")
|
|
29292
|
+
];
|
|
29293
|
+
const before = await Promise.all(files.map(optionalStat));
|
|
29294
|
+
const [folder, metadata, database, wal] = before;
|
|
29295
|
+
if (!folder?.isDirectory() || !metadata?.isFile() || !database?.isFile() || wal && !wal.isFile() || metadata.size > MAX_METADATA_BYTES)
|
|
29296
|
+
return null;
|
|
29297
|
+
let cwd;
|
|
29298
|
+
let title;
|
|
29299
|
+
try {
|
|
29300
|
+
const raw = JSON.parse(await readFile2(files[1], { encoding: "utf8", signal }));
|
|
29301
|
+
if (!raw || typeof raw !== "object" || !("cwd" in raw) || typeof raw.cwd !== "string" || !path7.isAbsolute(raw.cwd) || raw.cwd.includes("\0"))
|
|
29302
|
+
return null;
|
|
29303
|
+
cwd = await realpath(raw.cwd);
|
|
29304
|
+
if (!(await stat(cwd)).isDirectory())
|
|
29305
|
+
return null;
|
|
29306
|
+
signal.throwIfAborted();
|
|
29307
|
+
const turns = readCursorNativeTurns(id, cwd, this.#environment);
|
|
29308
|
+
if (!turns.length)
|
|
29309
|
+
return null;
|
|
29310
|
+
title = turns[0]?.text.replaceAll("\0", "").replace(/\s+/gu, " ").trim().slice(0, HARNESS_SESSION_IMPORT_TITLE_MAX_LENGTH) || null;
|
|
29311
|
+
} catch (error51) {
|
|
29312
|
+
signal.throwIfAborted();
|
|
29313
|
+
if (["EACCES", "EPERM", "EIO", "EMFILE", "ENFILE"].includes(errorCode(error51) ?? ""))
|
|
29314
|
+
throw error51;
|
|
29315
|
+
return null;
|
|
29316
|
+
}
|
|
29317
|
+
signal.throwIfAborted();
|
|
29318
|
+
const after = await Promise.all(files.map(optionalStat));
|
|
29319
|
+
if (before.some((info, index) => !sameFile(info, after[index] ?? null)))
|
|
29320
|
+
throw new CursorSessionChangedError("Cursor Session changed during discovery");
|
|
29321
|
+
const parsed = harnessSessionImportCandidateSchema.safeParse({
|
|
29322
|
+
nativeSessionId: id,
|
|
29323
|
+
cwd,
|
|
29324
|
+
title,
|
|
29325
|
+
updatedAt: Math.floor(Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)),
|
|
29326
|
+
// A stable read does not establish that another Cursor process is idle.
|
|
29327
|
+
running: null
|
|
29328
|
+
});
|
|
29329
|
+
return parsed.success ? parsed.data : null;
|
|
29330
|
+
}
|
|
29331
|
+
#read(operation) {
|
|
29332
|
+
const signal = this.#abort.signal;
|
|
29333
|
+
if (signal.aborted)
|
|
29334
|
+
return Promise.resolve({
|
|
29335
|
+
ok: false,
|
|
29336
|
+
error: {
|
|
29337
|
+
code: "invalidState",
|
|
29338
|
+
message: "Cursor Session import is closed",
|
|
29339
|
+
retryable: false
|
|
29340
|
+
}
|
|
29341
|
+
});
|
|
29342
|
+
const request = operation(signal).then((value) => {
|
|
29343
|
+
signal.throwIfAborted();
|
|
29344
|
+
return { ok: true, value };
|
|
29345
|
+
}).catch(() => ({
|
|
29346
|
+
ok: false,
|
|
29347
|
+
error: {
|
|
29348
|
+
code: signal.aborted ? "invalidState" : "unavailable",
|
|
29349
|
+
message: signal.aborted ? "Cursor Session import is closed" : "Cursor ACP sessions could not be read; close native clients, check storage access and retry",
|
|
29350
|
+
retryable: !signal.aborted
|
|
29351
|
+
}
|
|
29352
|
+
})).finally(() => this.#pending.delete(request));
|
|
29353
|
+
this.#pending.add(request);
|
|
29354
|
+
return request;
|
|
29355
|
+
}
|
|
29356
|
+
async close() {
|
|
29357
|
+
this.#abort.abort();
|
|
29358
|
+
await Promise.allSettled(this.#pending);
|
|
29359
|
+
}
|
|
29360
|
+
};
|
|
29361
|
+
|
|
28486
29362
|
// dist/thinking.js
|
|
28487
29363
|
var choices = (option) => option.type === "select" ? option.options.flatMap((entry) => "value" in entry ? [entry] : entry.options) : [];
|
|
28488
29364
|
function cursorThinking(options) {
|
|
@@ -28523,9 +29399,9 @@ function cursorThinkingState(info) {
|
|
|
28523
29399
|
}
|
|
28524
29400
|
|
|
28525
29401
|
// dist/fork-support.js
|
|
28526
|
-
import { existsSync } from "node:fs";
|
|
29402
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
28527
29403
|
function cursorForkAvailable() {
|
|
28528
|
-
return (process.platform === "darwin" || process.platform === "linux") &&
|
|
29404
|
+
return (process.platform === "darwin" || process.platform === "linux") && existsSync3("/usr/bin/script");
|
|
28529
29405
|
}
|
|
28530
29406
|
function cursorCheckpoint(sessionId, turnId) {
|
|
28531
29407
|
return nativeCheckpointRefSchema.parse({
|
|
@@ -32826,10 +33702,10 @@ var ClientSideConnection = class {
|
|
|
32826
33702
|
};
|
|
32827
33703
|
|
|
32828
33704
|
// dist/delegation-bridge.js
|
|
32829
|
-
import { execFile } from "node:child_process";
|
|
33705
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
32830
33706
|
import { randomBytes } from "node:crypto";
|
|
32831
33707
|
import { createServer } from "node:http";
|
|
32832
|
-
import
|
|
33708
|
+
import path8 from "node:path";
|
|
32833
33709
|
|
|
32834
33710
|
// ../../../node_modules/zod/v3/helpers/util.js
|
|
32835
33711
|
var util;
|
|
@@ -33190,8 +34066,8 @@ function getErrorMap2() {
|
|
|
33190
34066
|
|
|
33191
34067
|
// ../../../node_modules/zod/v3/helpers/parseUtil.js
|
|
33192
34068
|
var makeIssue = (params) => {
|
|
33193
|
-
const { data, path:
|
|
33194
|
-
const fullPath = [...
|
|
34069
|
+
const { data, path: path12, errorMaps, issueData } = params;
|
|
34070
|
+
const fullPath = [...path12, ...issueData.path || []];
|
|
33195
34071
|
const fullIssue = {
|
|
33196
34072
|
...issueData,
|
|
33197
34073
|
path: fullPath
|
|
@@ -33306,11 +34182,11 @@ var errorUtil;
|
|
|
33306
34182
|
|
|
33307
34183
|
// ../../../node_modules/zod/v3/types.js
|
|
33308
34184
|
var ParseInputLazyPath = class {
|
|
33309
|
-
constructor(parent, value,
|
|
34185
|
+
constructor(parent, value, path12, key) {
|
|
33310
34186
|
this._cachedPath = [];
|
|
33311
34187
|
this.parent = parent;
|
|
33312
34188
|
this.data = value;
|
|
33313
|
-
this._path =
|
|
34189
|
+
this._path = path12;
|
|
33314
34190
|
this._key = key;
|
|
33315
34191
|
}
|
|
33316
34192
|
get path() {
|
|
@@ -36837,11 +37713,11 @@ function normalizeObjectSchema(schema) {
|
|
|
36837
37713
|
}
|
|
36838
37714
|
return void 0;
|
|
36839
37715
|
}
|
|
36840
|
-
function getDotPath(
|
|
36841
|
-
if (
|
|
37716
|
+
function getDotPath(path12) {
|
|
37717
|
+
if (path12.length === 0) {
|
|
36842
37718
|
return "object root";
|
|
36843
37719
|
}
|
|
36844
|
-
return
|
|
37720
|
+
return path12.reduce((acc, seg, index) => {
|
|
36845
37721
|
if (index === 0) {
|
|
36846
37722
|
return String(seg);
|
|
36847
37723
|
}
|
|
@@ -44210,7 +45086,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44210
45086
|
const runtimeToken = environment.CODEXHOST_RUNTIME_TOKEN;
|
|
44211
45087
|
if (!cli || !environment.CODEXHOST_RUNTIME_ENDPOINT || !runtimeToken || !environment.CODEXHOST_THREAD_ID)
|
|
44212
45088
|
return void 0;
|
|
44213
|
-
if (!
|
|
45089
|
+
if (!path8.isAbsolute(cli))
|
|
44214
45090
|
throw new Error("Cursor delegation requires an absolute Host CLI path");
|
|
44215
45091
|
const token = randomBytes(32).toString("base64url");
|
|
44216
45092
|
const children = /* @__PURE__ */ new Set();
|
|
@@ -44225,7 +45101,7 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44225
45101
|
});
|
|
44226
45102
|
return;
|
|
44227
45103
|
}
|
|
44228
|
-
const child =
|
|
45104
|
+
const child = execFile3(cli, [...args, "--format", "compact"], {
|
|
44229
45105
|
cwd,
|
|
44230
45106
|
env: environment,
|
|
44231
45107
|
windowsHide: true,
|
|
@@ -44365,265 +45241,6 @@ async function createCursorDelegationBridge(cwd, environment, commandTimeoutMs =
|
|
|
44365
45241
|
};
|
|
44366
45242
|
}
|
|
44367
45243
|
|
|
44368
|
-
// dist/command.js
|
|
44369
|
-
import { existsSync as existsSync2, readdirSync } from "node:fs";
|
|
44370
|
-
import path4 from "node:path";
|
|
44371
|
-
|
|
44372
|
-
// ../../harness-discovery/dist/environment.js
|
|
44373
|
-
import fs from "node:fs";
|
|
44374
|
-
import path2 from "node:path";
|
|
44375
|
-
function targetPath(platform) {
|
|
44376
|
-
return platform === "win32" ? path2.win32 : path2.posix;
|
|
44377
|
-
}
|
|
44378
|
-
function environmentValue(environment, name) {
|
|
44379
|
-
const lowered = name.toLowerCase();
|
|
44380
|
-
for (const [key, value] of Object.entries(environment)) {
|
|
44381
|
-
if (key.toLowerCase() === lowered)
|
|
44382
|
-
return value;
|
|
44383
|
-
}
|
|
44384
|
-
return void 0;
|
|
44385
|
-
}
|
|
44386
|
-
function pathDelimiter(platform) {
|
|
44387
|
-
return platform === "win32" ? ";" : ":";
|
|
44388
|
-
}
|
|
44389
|
-
function pathDirectories(environment, platform) {
|
|
44390
|
-
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
44391
|
-
}
|
|
44392
|
-
function executableExtensions(command, platform, environment) {
|
|
44393
|
-
if (platform !== "win32")
|
|
44394
|
-
return [""];
|
|
44395
|
-
if (targetPath(platform).extname(command) !== "")
|
|
44396
|
-
return [""];
|
|
44397
|
-
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
44398
|
-
}
|
|
44399
|
-
function isExecutableFile(filePath, platform) {
|
|
44400
|
-
try {
|
|
44401
|
-
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
44402
|
-
return fs.statSync(filePath).isFile();
|
|
44403
|
-
} catch {
|
|
44404
|
-
return false;
|
|
44405
|
-
}
|
|
44406
|
-
}
|
|
44407
|
-
function subdirectoryNames(directory) {
|
|
44408
|
-
try {
|
|
44409
|
-
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
44410
|
-
} catch {
|
|
44411
|
-
return [];
|
|
44412
|
-
}
|
|
44413
|
-
}
|
|
44414
|
-
function newestFirst(names) {
|
|
44415
|
-
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
44416
|
-
}
|
|
44417
|
-
|
|
44418
|
-
// ../../harness-discovery/dist/invocation.js
|
|
44419
|
-
import path3 from "node:path";
|
|
44420
|
-
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
44421
|
-
const extension = path3.win32.extname(command).toLowerCase();
|
|
44422
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
44423
|
-
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
44424
|
-
}
|
|
44425
|
-
const quote2 = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
44426
|
-
const commandLine = [command, ...arguments_].map(quote2).join(" ");
|
|
44427
|
-
return {
|
|
44428
|
-
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
44429
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
44430
|
-
windowsVerbatimArguments: true
|
|
44431
|
-
};
|
|
44432
|
-
}
|
|
44433
|
-
|
|
44434
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44435
|
-
import os from "node:os";
|
|
44436
|
-
|
|
44437
|
-
// ../../harness-discovery/dist/version-managers.js
|
|
44438
|
-
function versionManagerBinaryDirectories(context) {
|
|
44439
|
-
const { platform, environment, home } = context;
|
|
44440
|
-
const list = context.subdirectories ?? subdirectoryNames;
|
|
44441
|
-
const pathFlavor = targetPath(platform);
|
|
44442
|
-
const value = (name) => environmentValue(environment, name);
|
|
44443
|
-
const directories = [];
|
|
44444
|
-
const versioned = (root, ...tail) => {
|
|
44445
|
-
for (const version2 of newestFirst(list(root))) {
|
|
44446
|
-
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
44447
|
-
}
|
|
44448
|
-
};
|
|
44449
|
-
if (platform === "win32") {
|
|
44450
|
-
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
44451
|
-
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
44452
|
-
versioned(pathFlavor.join(appData, "nvm"));
|
|
44453
|
-
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
44454
|
-
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
44455
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44456
|
-
const pnpmHome2 = value("PNPM_HOME");
|
|
44457
|
-
if (pnpmHome2)
|
|
44458
|
-
directories.push(pnpmHome2);
|
|
44459
|
-
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
44460
|
-
return directories;
|
|
44461
|
-
}
|
|
44462
|
-
versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
|
|
44463
|
-
const fnmRoots = [
|
|
44464
|
-
value("FNM_DIR"),
|
|
44465
|
-
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
44466
|
-
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
44467
|
-
].filter((root) => root !== void 0);
|
|
44468
|
-
for (const root of fnmRoots) {
|
|
44469
|
-
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
44470
|
-
}
|
|
44471
|
-
const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
|
|
44472
|
-
versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
|
|
44473
|
-
directories.push(pathFlavor.join(voltaHome, "bin"));
|
|
44474
|
-
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
44475
|
-
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
44476
|
-
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
44477
|
-
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
44478
|
-
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
44479
|
-
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
44480
|
-
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
44481
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
44482
|
-
const pnpmHome = value("PNPM_HOME");
|
|
44483
|
-
if (pnpmHome)
|
|
44484
|
-
directories.push(pnpmHome);
|
|
44485
|
-
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
44486
|
-
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
44487
|
-
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
44488
|
-
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
44489
|
-
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
44490
|
-
}
|
|
44491
|
-
}
|
|
44492
|
-
return directories;
|
|
44493
|
-
}
|
|
44494
|
-
|
|
44495
|
-
// ../../harness-discovery/dist/resolve.js
|
|
44496
|
-
var VERSION_MANAGER_ROOTS = "<version-managers>";
|
|
44497
|
-
function installRootExtensions(platform) {
|
|
44498
|
-
return platform === "win32" ? [".exe", ".cmd"] : [""];
|
|
44499
|
-
}
|
|
44500
|
-
function resolveHomeDirectory(input) {
|
|
44501
|
-
return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
|
|
44502
|
-
}
|
|
44503
|
-
function templateVariables(environment, platform, home) {
|
|
44504
|
-
const pathFlavor = targetPath(platform);
|
|
44505
|
-
return {
|
|
44506
|
-
HOME: home,
|
|
44507
|
-
USERPROFILE: home,
|
|
44508
|
-
APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
|
|
44509
|
-
LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
|
|
44510
|
-
};
|
|
44511
|
-
}
|
|
44512
|
-
function joinTemplate(platform, value) {
|
|
44513
|
-
const pathFlavor = targetPath(platform);
|
|
44514
|
-
const segments = value.split("/");
|
|
44515
|
-
const head = segments[0] ?? "";
|
|
44516
|
-
const tail = segments.slice(1);
|
|
44517
|
-
if (head === "")
|
|
44518
|
-
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
44519
|
-
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
44520
|
-
}
|
|
44521
|
-
function expandInstallRoot(template, environment, platform, home) {
|
|
44522
|
-
const variables = templateVariables(environment, platform, home);
|
|
44523
|
-
let unresolved = false;
|
|
44524
|
-
const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
|
|
44525
|
-
const value = variables[name] ?? environmentValue(environment, name);
|
|
44526
|
-
if (value === void 0 || value === "") {
|
|
44527
|
-
unresolved = true;
|
|
44528
|
-
return "";
|
|
44529
|
-
}
|
|
44530
|
-
return value;
|
|
44531
|
-
});
|
|
44532
|
-
return unresolved ? void 0 : joinTemplate(platform, substituted);
|
|
44533
|
-
}
|
|
44534
|
-
function installRootDirectories(spec, input, dependencies, platform, home) {
|
|
44535
|
-
const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
|
|
44536
|
-
const directories = [];
|
|
44537
|
-
for (const template of templates) {
|
|
44538
|
-
if (template === VERSION_MANAGER_ROOTS) {
|
|
44539
|
-
directories.push(...versionManagerBinaryDirectories({
|
|
44540
|
-
platform,
|
|
44541
|
-
environment: input.environment,
|
|
44542
|
-
home,
|
|
44543
|
-
...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
|
|
44544
|
-
}));
|
|
44545
|
-
continue;
|
|
44546
|
-
}
|
|
44547
|
-
const directory = expandInstallRoot(template, input.environment, platform, home);
|
|
44548
|
-
if (directory !== void 0)
|
|
44549
|
-
directories.push(directory);
|
|
44550
|
-
}
|
|
44551
|
-
return directories;
|
|
44552
|
-
}
|
|
44553
|
-
function harnessCandidates(spec, input, dependencies = {}) {
|
|
44554
|
-
const platform = input.platform ?? process.platform;
|
|
44555
|
-
const pathFlavor = targetPath(platform);
|
|
44556
|
-
const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
|
|
44557
|
-
const command = configured ?? spec.command;
|
|
44558
|
-
if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
|
|
44559
|
-
return [{ candidate: command, source: "configured" }];
|
|
44560
|
-
}
|
|
44561
|
-
const candidates = [];
|
|
44562
|
-
const extensions = executableExtensions(command, platform, input.environment);
|
|
44563
|
-
for (const directory of pathDirectories(input.environment, platform)) {
|
|
44564
|
-
for (const extension of extensions) {
|
|
44565
|
-
candidates.push({
|
|
44566
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
44567
|
-
source: "path"
|
|
44568
|
-
});
|
|
44569
|
-
}
|
|
44570
|
-
}
|
|
44571
|
-
if (configured !== void 0)
|
|
44572
|
-
return candidates;
|
|
44573
|
-
const home = resolveHomeDirectory(input);
|
|
44574
|
-
for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
|
|
44575
|
-
for (const extension of installRootExtensions(platform)) {
|
|
44576
|
-
candidates.push({
|
|
44577
|
-
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
44578
|
-
source: "install-root"
|
|
44579
|
-
});
|
|
44580
|
-
}
|
|
44581
|
-
}
|
|
44582
|
-
return candidates;
|
|
44583
|
-
}
|
|
44584
|
-
function resolveHarnessExecutable(spec, input, dependencies = {}) {
|
|
44585
|
-
const platform = input.platform ?? process.platform;
|
|
44586
|
-
const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
|
|
44587
|
-
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
44588
|
-
const context = { platform, isExecutable };
|
|
44589
|
-
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
44590
|
-
const executable = runnable(candidate, context);
|
|
44591
|
-
if (executable !== void 0 && isExecutable(executable))
|
|
44592
|
-
return { executable, source };
|
|
44593
|
-
}
|
|
44594
|
-
return void 0;
|
|
44595
|
-
}
|
|
44596
|
-
|
|
44597
|
-
// dist/command.js
|
|
44598
|
-
function cursorInvocation(environment, command, args = ["acp"]) {
|
|
44599
|
-
const resolution = resolveHarnessExecutable({
|
|
44600
|
-
id: "cursor-cli",
|
|
44601
|
-
command: "cursor-agent",
|
|
44602
|
-
commandEnvironmentVariable: "CODEXHOST_CURSOR_COMMAND",
|
|
44603
|
-
installRoots: {
|
|
44604
|
-
posix: ["~/.local/bin", "/usr/local/bin", "/opt/homebrew/bin"],
|
|
44605
|
-
windows: ["${LOCALAPPDATA}/cursor-agent"]
|
|
44606
|
-
}
|
|
44607
|
-
}, { environment, ...command ? { command } : {} });
|
|
44608
|
-
if (!resolution)
|
|
44609
|
-
throw new Error("Cursor CLI is not installed; install cursor-agent or set CODEXHOST_CURSOR_COMMAND");
|
|
44610
|
-
if (process.platform === "win32" && /\.(cmd|ps1)$/iu.test(resolution.executable)) {
|
|
44611
|
-
const root = path4.dirname(resolution.executable);
|
|
44612
|
-
const versions = path4.join(root, "versions");
|
|
44613
|
-
if (existsSync2(versions)) {
|
|
44614
|
-
const version2 = readdirSync(versions).filter((name) => /^\d{4}\.\d{2}\.\d{2}-(?:\d{2}-\d{2}-\d{2}-)?[a-f0-9]+$/u.test(name)).sort().reverse().find((name) => existsSync2(path4.join(versions, name, "node.exe")) && existsSync2(path4.join(versions, name, "index.js")));
|
|
44615
|
-
if (version2)
|
|
44616
|
-
return {
|
|
44617
|
-
command: path4.join(versions, version2, "node.exe"),
|
|
44618
|
-
arguments: [path4.join(versions, version2, "index.js"), ...args],
|
|
44619
|
-
windowsVerbatimArguments: false
|
|
44620
|
-
};
|
|
44621
|
-
}
|
|
44622
|
-
throw new Error("Cursor Windows launcher has no supported native bundle; configure a native executable");
|
|
44623
|
-
}
|
|
44624
|
-
return commandInvocation(resolution.executable, args, environment);
|
|
44625
|
-
}
|
|
44626
|
-
|
|
44627
45244
|
// dist/transport.js
|
|
44628
45245
|
var CursorTransport = class {
|
|
44629
45246
|
options;
|
|
@@ -44676,7 +45293,7 @@ var CursorTransport = class {
|
|
|
44676
45293
|
return this.#preparation ??= this.#prepare();
|
|
44677
45294
|
}
|
|
44678
45295
|
async #prepare() {
|
|
44679
|
-
const invocation = cursorInvocation(this.options.environment, this.options.command);
|
|
45296
|
+
const invocation = cursorInvocation(this.options.environment, this.options.command, this.options.executionPolicy === "unattended-full-access" ? ["--force", "acp"] : ["acp"]);
|
|
44680
45297
|
const child = spawn(invocation.command, invocation.arguments, {
|
|
44681
45298
|
cwd: this.options.cwd,
|
|
44682
45299
|
env: this.options.environment,
|
|
@@ -44857,124 +45474,6 @@ var CursorTransport = class {
|
|
|
44857
45474
|
}
|
|
44858
45475
|
};
|
|
44859
45476
|
|
|
44860
|
-
// dist/native-history.js
|
|
44861
|
-
import { existsSync as existsSync3, readFileSync, realpathSync } from "node:fs";
|
|
44862
|
-
import os2 from "node:os";
|
|
44863
|
-
import path5 from "node:path";
|
|
44864
|
-
import { DatabaseSync } from "node:sqlite";
|
|
44865
|
-
function cursorConfigDirectory(environment) {
|
|
44866
|
-
const home = environment.HOME ?? environment.USERPROFILE ?? os2.homedir();
|
|
44867
|
-
return environment.CURSOR_CONFIG_DIR?.trim() ? path5.resolve(environment.CURSOR_CONFIG_DIR) : environment.XDG_CONFIG_HOME?.trim() ? path5.resolve(environment.XDG_CONFIG_HOME, "cursor") : path5.join(home, ".cursor");
|
|
44868
|
-
}
|
|
44869
|
-
function cursorSessionDirectory(sessionId, environment) {
|
|
44870
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu.test(sessionId))
|
|
44871
|
-
throw new Error("Unsupported Cursor native session ID");
|
|
44872
|
-
return path5.join(cursorConfigDirectory(environment), "acp-sessions", sessionId);
|
|
44873
|
-
}
|
|
44874
|
-
function cursorSameWorkspace(left, right) {
|
|
44875
|
-
return path5.resolve(left) === path5.resolve(right) || existsSync3(left) && existsSync3(right) && realpathSync(left) === realpathSync(right);
|
|
44876
|
-
}
|
|
44877
|
-
function protobufBytes(data) {
|
|
44878
|
-
if (data.length > 32 * 1024 * 1024)
|
|
44879
|
-
throw new Error("Cursor native record is too large");
|
|
44880
|
-
let offset = 0;
|
|
44881
|
-
const varint = () => {
|
|
44882
|
-
let result = 0;
|
|
44883
|
-
for (let shift = 0; shift < 70; shift += 7) {
|
|
44884
|
-
const value = data[offset++];
|
|
44885
|
-
if (value === void 0)
|
|
44886
|
-
throw new Error("Truncated Cursor native record");
|
|
44887
|
-
result += (value & 127) * 2 ** shift;
|
|
44888
|
-
if (!(value & 128))
|
|
44889
|
-
return result;
|
|
44890
|
-
}
|
|
44891
|
-
throw new Error("Invalid Cursor native varint");
|
|
44892
|
-
};
|
|
44893
|
-
const fields = /* @__PURE__ */ new Map();
|
|
44894
|
-
while (offset < data.length) {
|
|
44895
|
-
const tag = varint();
|
|
44896
|
-
const field = Math.floor(tag / 8), wire = tag % 8;
|
|
44897
|
-
if (!Number.isSafeInteger(tag) || field === 0)
|
|
44898
|
-
throw new Error("Invalid Cursor native field");
|
|
44899
|
-
if (wire === 0) {
|
|
44900
|
-
varint();
|
|
44901
|
-
continue;
|
|
44902
|
-
}
|
|
44903
|
-
const length = wire === 2 ? varint() : wire === 1 ? 8 : wire === 5 ? 4 : -1;
|
|
44904
|
-
if (!Number.isSafeInteger(length) || length < 0 || offset + length > data.length)
|
|
44905
|
-
throw new Error("Unsupported Cursor native record");
|
|
44906
|
-
if (wire === 2) {
|
|
44907
|
-
const values = fields.get(field) ?? [];
|
|
44908
|
-
values.push(Buffer.from(data.subarray(offset, offset + length)));
|
|
44909
|
-
fields.set(field, values);
|
|
44910
|
-
}
|
|
44911
|
-
offset += length;
|
|
44912
|
-
}
|
|
44913
|
-
return fields;
|
|
44914
|
-
}
|
|
44915
|
-
function one(fields, field) {
|
|
44916
|
-
const values = fields.get(field);
|
|
44917
|
-
if (values?.length !== 1 || !values[0])
|
|
44918
|
-
throw new Error("Cursor native history identity is missing or ambiguous");
|
|
44919
|
-
return values[0];
|
|
44920
|
-
}
|
|
44921
|
-
function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = false) {
|
|
44922
|
-
const directory = cursorSessionDirectory(sessionId, environment);
|
|
44923
|
-
const filename = path5.join(directory, "store.db");
|
|
44924
|
-
if (allowMissing && !existsSync3(filename))
|
|
44925
|
-
return { revision: void 0, turns: [] };
|
|
44926
|
-
const info = JSON.parse(readFileSync(path5.join(directory, "meta.json"), "utf8"));
|
|
44927
|
-
if (!info || typeof info !== "object" || !("cwd" in info) || typeof info.cwd !== "string" || !cursorSameWorkspace(info.cwd, cwd))
|
|
44928
|
-
throw new Error("Cursor session workspace does not match");
|
|
44929
|
-
const db = new DatabaseSync(filename, { readOnly: true });
|
|
44930
|
-
try {
|
|
44931
|
-
db.exec("BEGIN");
|
|
44932
|
-
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("0");
|
|
44933
|
-
if (!row && allowMissing)
|
|
44934
|
-
return { revision: void 0, turns: [] };
|
|
44935
|
-
if (typeof row?.value !== "string" || row.value.length > 1e6)
|
|
44936
|
-
throw new Error("Unsupported Cursor native metadata");
|
|
44937
|
-
const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
|
|
44938
|
-
if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
|
|
44939
|
-
throw new Error("Cursor native session identity mismatch");
|
|
44940
|
-
const get = (id) => {
|
|
44941
|
-
if (!/^[0-9a-f]{64}$/u.test(id))
|
|
44942
|
-
throw new Error("Invalid Cursor native blob reference");
|
|
44943
|
-
const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
|
|
44944
|
-
if (!(blob instanceof Uint8Array))
|
|
44945
|
-
throw new Error("Cursor native history blob is missing");
|
|
44946
|
-
return protobufBytes(blob);
|
|
44947
|
-
};
|
|
44948
|
-
const root = get(metadata.latestRootBlobId);
|
|
44949
|
-
const result = [];
|
|
44950
|
-
for (const ref of root.get(8) ?? []) {
|
|
44951
|
-
if (ref.length !== 32)
|
|
44952
|
-
throw new Error("Unsupported Cursor turn reference");
|
|
44953
|
-
const container = get(ref.toString("hex"));
|
|
44954
|
-
for (const record2 of container.get(1) ?? []) {
|
|
44955
|
-
const turn = protobufBytes(record2);
|
|
44956
|
-
const user = get(one(turn, 1).toString("hex"));
|
|
44957
|
-
const id = one(user, 2).toString("utf8");
|
|
44958
|
-
if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
|
|
44959
|
-
throw new Error("Cursor native turn ID is invalid or duplicated");
|
|
44960
|
-
const anchor = user.get(10)?.[0];
|
|
44961
|
-
const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
|
|
44962
|
-
result.push({
|
|
44963
|
-
id,
|
|
44964
|
-
text: one(user, 1).toString("utf8"),
|
|
44965
|
-
...rewindRoot ? { rewindRoot } : {}
|
|
44966
|
-
});
|
|
44967
|
-
}
|
|
44968
|
-
}
|
|
44969
|
-
return { revision: metadata.latestRootBlobId, turns: result };
|
|
44970
|
-
} finally {
|
|
44971
|
-
db.close();
|
|
44972
|
-
}
|
|
44973
|
-
}
|
|
44974
|
-
function readCursorNativeTurns(sessionId, cwd, environment, allowMissing = false) {
|
|
44975
|
-
return readCursorNativeHistory(sessionId, cwd, environment, allowMissing).turns;
|
|
44976
|
-
}
|
|
44977
|
-
|
|
44978
45477
|
// ../../../node_modules/diff/libesm/diff/base.js
|
|
44979
45478
|
var Diff = class {
|
|
44980
45479
|
diff(oldStr, newStr, options = {}) {
|
|
@@ -45075,16 +45574,16 @@ var Diff = class {
|
|
|
45075
45574
|
}
|
|
45076
45575
|
}
|
|
45077
45576
|
}
|
|
45078
|
-
addToPath(
|
|
45079
|
-
const last =
|
|
45577
|
+
addToPath(path12, added, removed, oldPosInc, options) {
|
|
45578
|
+
const last = path12.lastComponent;
|
|
45080
45579
|
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
45081
45580
|
return {
|
|
45082
|
-
oldPos:
|
|
45581
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45083
45582
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
45084
45583
|
};
|
|
45085
45584
|
} else {
|
|
45086
45585
|
return {
|
|
45087
|
-
oldPos:
|
|
45586
|
+
oldPos: path12.oldPos + oldPosInc,
|
|
45088
45587
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
45089
45588
|
};
|
|
45090
45589
|
}
|
|
@@ -45602,6 +46101,42 @@ function cursorChildSnapshot(parentId, item, terminal, output) {
|
|
|
45602
46101
|
};
|
|
45603
46102
|
}
|
|
45604
46103
|
|
|
46104
|
+
// dist/stream-error.js
|
|
46105
|
+
var CLOSED_ERROR = /(?:^|\n\n)Error:\s*(?:(?:RetriableError|T):)?\s*WritableIterable is closed\s*$/u;
|
|
46106
|
+
var CLOSED_PREFIXES = [
|
|
46107
|
+
"\n\nError: RetriableError: WritableIterable is closed",
|
|
46108
|
+
"\n\nError: T: WritableIterable is closed",
|
|
46109
|
+
"\n\nError: WritableIterable is closed",
|
|
46110
|
+
"Error: RetriableError: WritableIterable is closed",
|
|
46111
|
+
"Error: T: WritableIterable is closed",
|
|
46112
|
+
"Error: WritableIterable is closed"
|
|
46113
|
+
];
|
|
46114
|
+
var LONGEST_PREFIX = Math.max(...CLOSED_PREFIXES.map((prefix) => prefix.length));
|
|
46115
|
+
function isCursorWritableIterableClosed(message) {
|
|
46116
|
+
return /WritableIterable is closed/iu.test(message);
|
|
46117
|
+
}
|
|
46118
|
+
function takeCursorWritableIterableClosed(text2, atMessageStart = true) {
|
|
46119
|
+
const match = text2.match(CLOSED_ERROR);
|
|
46120
|
+
if (!match || match.index === void 0 || match.index === 0 && !text2.startsWith("\n\n") && !atMessageStart)
|
|
46121
|
+
return { visible: text2, closed: false };
|
|
46122
|
+
return { visible: text2.slice(0, match.index), closed: true };
|
|
46123
|
+
}
|
|
46124
|
+
function holdCursorWritableIterablePrefix(text2, atMessageStart = true) {
|
|
46125
|
+
const taken = takeCursorWritableIterableClosed(text2, atMessageStart);
|
|
46126
|
+
if (taken.closed)
|
|
46127
|
+
return { emit: taken.visible, hold: text2.slice(taken.visible.length) };
|
|
46128
|
+
for (let size = Math.min(text2.length, LONGEST_PREFIX); size > 0; size -= 1) {
|
|
46129
|
+
const suffix = text2.slice(-size);
|
|
46130
|
+
const start = text2.length - size;
|
|
46131
|
+
if (!suffix.startsWith("\n") && !(start === 0 && atMessageStart) && text2.slice(Math.max(0, start - 2), start) !== "\n\n")
|
|
46132
|
+
continue;
|
|
46133
|
+
if (CLOSED_PREFIXES.some((candidate) => candidate.startsWith(suffix))) {
|
|
46134
|
+
return { emit: text2.slice(0, -size), hold: suffix };
|
|
46135
|
+
}
|
|
46136
|
+
}
|
|
46137
|
+
return { emit: text2, hold: "" };
|
|
46138
|
+
}
|
|
46139
|
+
|
|
45605
46140
|
// dist/projection.js
|
|
45606
46141
|
var TOOL_OUTPUT_LIMIT = 1e5;
|
|
45607
46142
|
function cursorFileChanges(content) {
|
|
@@ -45631,11 +46166,52 @@ var CursorTurnOutput = class {
|
|
|
45631
46166
|
#text;
|
|
45632
46167
|
#tools = /* @__PURE__ */ new Map();
|
|
45633
46168
|
#finishedTools = /* @__PURE__ */ new Set();
|
|
46169
|
+
#hold = "";
|
|
46170
|
+
#writableIterableClosed = false;
|
|
46171
|
+
#visibleAssistantText = false;
|
|
45634
46172
|
constructor(turnId, emit, nativeTurnIndex = 0) {
|
|
45635
46173
|
this.turnId = turnId;
|
|
45636
46174
|
this.emit = emit;
|
|
45637
46175
|
this.subagents = new CursorSubagents(turnId, emit, nativeTurnIndex);
|
|
45638
46176
|
}
|
|
46177
|
+
sawWritableIterableClosed() {
|
|
46178
|
+
return this.#writableIterableClosed || takeCursorWritableIterableClosed(this.#hold).closed;
|
|
46179
|
+
}
|
|
46180
|
+
hasVisibleAssistantText() {
|
|
46181
|
+
return this.#visibleAssistantText || takeCursorWritableIterableClosed(this.#hold).visible.trim().length > 0;
|
|
46182
|
+
}
|
|
46183
|
+
#flushHold() {
|
|
46184
|
+
if (!this.#hold)
|
|
46185
|
+
return;
|
|
46186
|
+
const held = this.#hold;
|
|
46187
|
+
this.#hold = "";
|
|
46188
|
+
this.#appendText("agentMessage", held);
|
|
46189
|
+
}
|
|
46190
|
+
#appendText(type, text2) {
|
|
46191
|
+
if (!text2)
|
|
46192
|
+
return;
|
|
46193
|
+
if (type === "agentMessage" && text2.trim())
|
|
46194
|
+
this.#visibleAssistantText = true;
|
|
46195
|
+
if (this.#text?.type !== type) {
|
|
46196
|
+
this.#finishText();
|
|
46197
|
+
const item = {
|
|
46198
|
+
type,
|
|
46199
|
+
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
46200
|
+
text: ""
|
|
46201
|
+
};
|
|
46202
|
+
this.#text = item;
|
|
46203
|
+
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
46204
|
+
}
|
|
46205
|
+
if (!this.#text)
|
|
46206
|
+
return;
|
|
46207
|
+
this.#text.text += text2;
|
|
46208
|
+
this.emit({
|
|
46209
|
+
type: "item.updated",
|
|
46210
|
+
turnId: this.turnId,
|
|
46211
|
+
itemId: this.#text.itemId,
|
|
46212
|
+
update: { type: "text.append", text: text2 }
|
|
46213
|
+
});
|
|
46214
|
+
}
|
|
45639
46215
|
#finishText(outcome = { status: "succeeded" }) {
|
|
45640
46216
|
if (this.#text)
|
|
45641
46217
|
this.emit({
|
|
@@ -45647,6 +46223,7 @@ var CursorTurnOutput = class {
|
|
|
45647
46223
|
}
|
|
45648
46224
|
update(notification) {
|
|
45649
46225
|
if (this.subagents.update(notification)) {
|
|
46226
|
+
this.#flushHold();
|
|
45650
46227
|
this.#finishText();
|
|
45651
46228
|
return;
|
|
45652
46229
|
}
|
|
@@ -45655,26 +46232,17 @@ var CursorTurnOutput = class {
|
|
|
45655
46232
|
if (update.content.type !== "text")
|
|
45656
46233
|
return;
|
|
45657
46234
|
const type = update.sessionUpdate === "agent_message_chunk" ? "agentMessage" : "reasoning";
|
|
45658
|
-
if (
|
|
45659
|
-
this.#
|
|
45660
|
-
|
|
45661
|
-
type,
|
|
45662
|
-
itemId: hostItemIdSchema.parse(`cursor-${this.turnId}-${++this.#index}`),
|
|
45663
|
-
text: ""
|
|
45664
|
-
};
|
|
45665
|
-
this.#text = item;
|
|
45666
|
-
this.emit({ type: "item.started", turnId: this.turnId, item: { ...item } });
|
|
45667
|
-
}
|
|
45668
|
-
if (!this.#text)
|
|
46235
|
+
if (type === "reasoning") {
|
|
46236
|
+
this.#flushHold();
|
|
46237
|
+
this.#appendText(type, update.content.text);
|
|
45669
46238
|
return;
|
|
45670
|
-
|
|
45671
|
-
this.
|
|
45672
|
-
|
|
45673
|
-
|
|
45674
|
-
|
|
45675
|
-
update: { type: "text.append", text: update.content.text }
|
|
45676
|
-
});
|
|
46239
|
+
}
|
|
46240
|
+
const combined = `${this.#hold}${update.content.text}`;
|
|
46241
|
+
const { emit, hold } = holdCursorWritableIterablePrefix(combined, this.#text?.type !== "agentMessage" || this.#text.text.length === 0);
|
|
46242
|
+
this.#hold = hold;
|
|
46243
|
+
this.#appendText(type, emit);
|
|
45677
46244
|
} else if (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") {
|
|
46245
|
+
this.#flushHold();
|
|
45678
46246
|
this.#finishText();
|
|
45679
46247
|
if (this.#finishedTools.has(update.toolCallId))
|
|
45680
46248
|
return;
|
|
@@ -45743,6 +46311,11 @@ ${content.newText}`] : []).join("\n");
|
|
|
45743
46311
|
}
|
|
45744
46312
|
finish(outcome) {
|
|
45745
46313
|
this.subagents.finish(outcome);
|
|
46314
|
+
if (takeCursorWritableIterableClosed(this.#hold).closed) {
|
|
46315
|
+
this.#writableIterableClosed = true;
|
|
46316
|
+
this.#hold = "";
|
|
46317
|
+
}
|
|
46318
|
+
this.#flushHold();
|
|
45746
46319
|
this.#finishText(outcome);
|
|
45747
46320
|
for (const { item } of this.#tools.values())
|
|
45748
46321
|
this.emit({
|
|
@@ -45822,9 +46395,11 @@ function cursorSnapshot(sessionId, native, replay, nativeSubagentId) {
|
|
|
45822
46395
|
import { randomUUID } from "node:crypto";
|
|
45823
46396
|
var CursorInteractions = class {
|
|
45824
46397
|
emit;
|
|
46398
|
+
refuseUnattendedApproval;
|
|
45825
46399
|
#pending = /* @__PURE__ */ new Map();
|
|
45826
|
-
constructor(emit) {
|
|
46400
|
+
constructor(emit, refuseUnattendedApproval) {
|
|
45827
46401
|
this.emit = emit;
|
|
46402
|
+
this.refuseUnattendedApproval = refuseUnattendedApproval;
|
|
45828
46403
|
}
|
|
45829
46404
|
#ask(interaction) {
|
|
45830
46405
|
return new Promise((resolve) => {
|
|
@@ -45833,6 +46408,10 @@ var CursorInteractions = class {
|
|
|
45833
46408
|
});
|
|
45834
46409
|
}
|
|
45835
46410
|
async permission(turnId, request) {
|
|
46411
|
+
if (this.refuseUnattendedApproval) {
|
|
46412
|
+
await this.refuseUnattendedApproval();
|
|
46413
|
+
return { outcome: { outcome: "cancelled" } };
|
|
46414
|
+
}
|
|
45836
46415
|
const response = await this.#ask({
|
|
45837
46416
|
type: "approval",
|
|
45838
46417
|
interactionId: hostInteractionIdSchema.parse(randomUUID()),
|
|
@@ -45850,6 +46429,10 @@ var CursorInteractions = class {
|
|
|
45850
46429
|
async extension(turnId, method, params) {
|
|
45851
46430
|
const interactionId = hostInteractionIdSchema.parse(randomUUID());
|
|
45852
46431
|
if (method === "cursor/create_plan" && typeof params.plan === "string") {
|
|
46432
|
+
if (this.refuseUnattendedApproval) {
|
|
46433
|
+
await this.refuseUnattendedApproval();
|
|
46434
|
+
return { outcome: { outcome: "cancelled" } };
|
|
46435
|
+
}
|
|
45853
46436
|
const response = await this.#ask({
|
|
45854
46437
|
type: "approval",
|
|
45855
46438
|
interactionId,
|
|
@@ -45955,10 +46538,10 @@ var CursorInteractions = class {
|
|
|
45955
46538
|
|
|
45956
46539
|
// dist/fork.js
|
|
45957
46540
|
import { createHash as createHash2 } from "node:crypto";
|
|
45958
|
-
import { copyFile, mkdir, mkdtemp, readdir, readFile, realpath, rm, writeFile } from "node:fs/promises";
|
|
46541
|
+
import { copyFile, mkdir, mkdtemp, readdir, readFile as readFile3, realpath as realpath2, rm, writeFile } from "node:fs/promises";
|
|
45959
46542
|
import { readdirSync as readdirSync2 } from "node:fs";
|
|
45960
46543
|
import os3 from "node:os";
|
|
45961
|
-
import
|
|
46544
|
+
import path9 from "node:path";
|
|
45962
46545
|
import { backup, DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
45963
46546
|
|
|
45964
46547
|
// dist/fork-terminal.js
|
|
@@ -46076,16 +46659,16 @@ async function runCursorForkTerminal(options, sessionId, signal, rewind) {
|
|
|
46076
46659
|
|
|
46077
46660
|
// dist/fork.js
|
|
46078
46661
|
async function copySnapshot(source, target) {
|
|
46079
|
-
const db = new DatabaseSync2(
|
|
46662
|
+
const db = new DatabaseSync2(path9.join(source, "store.db"), { readOnly: true });
|
|
46080
46663
|
try {
|
|
46081
|
-
await backup(db,
|
|
46664
|
+
await backup(db, path9.join(target, "store.db"));
|
|
46082
46665
|
} finally {
|
|
46083
46666
|
db.close();
|
|
46084
46667
|
}
|
|
46085
|
-
await copyFile(
|
|
46668
|
+
await copyFile(path9.join(source, "meta.json"), path9.join(target, "meta.json"));
|
|
46086
46669
|
}
|
|
46087
46670
|
function storeIdentity(directory, hashBlobs = true) {
|
|
46088
|
-
const db = new DatabaseSync2(
|
|
46671
|
+
const db = new DatabaseSync2(path9.join(directory, "store.db"), { readOnly: true });
|
|
46089
46672
|
try {
|
|
46090
46673
|
db.exec("BEGIN");
|
|
46091
46674
|
const value = db.prepare("SELECT value FROM meta WHERE key = '0'").get()?.value;
|
|
@@ -46126,7 +46709,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46126
46709
|
if (rewindTurn && !rewindTurn.rewindRoot)
|
|
46127
46710
|
throw new Error("Cursor target has no native rewind checkpoint");
|
|
46128
46711
|
const original = storeIdentity(sourceDirectory);
|
|
46129
|
-
const temporary = await mkdtemp(
|
|
46712
|
+
const temporary = await mkdtemp(path9.join(os3.tmpdir(), "codexhost-cursor-fork-"));
|
|
46130
46713
|
let target;
|
|
46131
46714
|
let committed = false;
|
|
46132
46715
|
const discard = async () => {
|
|
@@ -46135,12 +46718,12 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46135
46718
|
};
|
|
46136
46719
|
try {
|
|
46137
46720
|
signal.throwIfAborted();
|
|
46138
|
-
const config2 =
|
|
46721
|
+
const config2 = path9.join(temporary, "config");
|
|
46139
46722
|
await mkdir(config2, { mode: 448 });
|
|
46140
|
-
const nativeConfig =
|
|
46723
|
+
const nativeConfig = path9.join(cursorConfigDirectory(options.environment), "cli-config.json");
|
|
46141
46724
|
let settings = {};
|
|
46142
46725
|
try {
|
|
46143
|
-
const data = JSON.parse(await
|
|
46726
|
+
const data = JSON.parse(await readFile3(nativeConfig, "utf8"));
|
|
46144
46727
|
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
46145
46728
|
throw new Error("Invalid Cursor CLI configuration");
|
|
46146
46729
|
settings = data;
|
|
@@ -46148,9 +46731,9 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46148
46731
|
if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT"))
|
|
46149
46732
|
throw error51;
|
|
46150
46733
|
}
|
|
46151
|
-
await writeFile(
|
|
46152
|
-
const chats =
|
|
46153
|
-
const copy =
|
|
46734
|
+
await writeFile(path9.join(config2, "cli-config.json"), JSON.stringify({ ...settings, rewind: true }), { mode: 384 });
|
|
46735
|
+
const chats = path9.join(config2, "chats", createHash2("md5").update(await realpath2(options.cwd)).digest("hex"));
|
|
46736
|
+
const copy = path9.join(chats, source.nativeSessionId);
|
|
46154
46737
|
await mkdir(copy, { recursive: true });
|
|
46155
46738
|
await copySnapshot(sourceDirectory, copy);
|
|
46156
46739
|
if (JSON.stringify(storeIdentity(copy)) !== JSON.stringify(original))
|
|
@@ -46160,14 +46743,14 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46160
46743
|
environment: {
|
|
46161
46744
|
...options.environment,
|
|
46162
46745
|
CURSOR_CONFIG_DIR: config2,
|
|
46163
|
-
CURSOR_DATA_DIR:
|
|
46746
|
+
CURSOR_DATA_DIR: path9.join(temporary, "data")
|
|
46164
46747
|
}
|
|
46165
46748
|
}, source.nativeSessionId, signal, rewindTurn ? {
|
|
46166
46749
|
steps: sourceTurns.slice(retained).filter((turn) => turn.rewindRoot).length,
|
|
46167
46750
|
complete: () => {
|
|
46168
46751
|
const targets = readdirSync2(chats).filter((id) => id !== source.nativeSessionId);
|
|
46169
46752
|
const targetId = targets[0];
|
|
46170
|
-
return targets.length === 1 && !!targetId && storeIdentity(
|
|
46753
|
+
return targets.length === 1 && !!targetId && storeIdentity(path9.join(chats, targetId), false).root === rewindTurn.rewindRoot;
|
|
46171
46754
|
}
|
|
46172
46755
|
} : void 0);
|
|
46173
46756
|
signal.throwIfAborted();
|
|
@@ -46176,7 +46759,7 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46176
46759
|
throw new Error("Cursor fork did not create one independent session");
|
|
46177
46760
|
const sessionId = children[0].name;
|
|
46178
46761
|
const destination = cursorSessionDirectory(sessionId, options.environment);
|
|
46179
|
-
const nativeFork =
|
|
46762
|
+
const nativeFork = path9.join(chats, sessionId);
|
|
46180
46763
|
const forked = storeIdentity(nativeFork);
|
|
46181
46764
|
if (forked.agentId !== sessionId || forked.root !== (rewindTurn?.rewindRoot ?? original.root) || forked.blobs !== original.blobs)
|
|
46182
46765
|
throw new Error("Cursor native fork changed conversation contents or identity");
|
|
@@ -46213,6 +46796,13 @@ async function forkCursorSession(source, checkpoint, options, signal) {
|
|
|
46213
46796
|
// dist/adapter.js
|
|
46214
46797
|
function cursorError(error51) {
|
|
46215
46798
|
const message = sanitizeDiagnosticTail(error51 instanceof Error ? error51.message : "Cursor operation failed");
|
|
46799
|
+
if (isCursorWritableIterableClosed(message)) {
|
|
46800
|
+
return {
|
|
46801
|
+
code: "nativeFailure",
|
|
46802
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
46803
|
+
retryable: true
|
|
46804
|
+
};
|
|
46805
|
+
}
|
|
46216
46806
|
const code = /not installed/iu.test(message) ? "notInstalled" : /auth|not logged in|login/iu.test(message) ? "authenticationRequired" : /exited|closed/iu.test(message) ? "processExited" : "protocolError";
|
|
46217
46807
|
return { code, message, retryable: false };
|
|
46218
46808
|
}
|
|
@@ -46231,14 +46821,19 @@ var CursorAdapter = class {
|
|
|
46231
46821
|
try {
|
|
46232
46822
|
cursorTaskAddress(nativeSubagentId);
|
|
46233
46823
|
const session = [...this.#sessions].find((s) => s.transport.sessionId === parent.nativeSessionId);
|
|
46234
|
-
if (session &&
|
|
46824
|
+
if (session && path10.resolve(session.transport.options.cwd) !== path10.resolve(cwd))
|
|
46235
46825
|
return rejected("invalidRequest", "Cursor parent workspace does not match");
|
|
46236
46826
|
const active = session?.subagentSnapshot(nativeSubagentId);
|
|
46237
46827
|
if (active)
|
|
46238
46828
|
return { ok: true, value: active };
|
|
46239
46829
|
const options = session?.transport.options ?? this.transportOptions(cwd);
|
|
46240
46830
|
const before = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
|
|
46241
|
-
replay = new CursorTransport({
|
|
46831
|
+
replay = new CursorTransport({
|
|
46832
|
+
...options,
|
|
46833
|
+
delegation: false,
|
|
46834
|
+
executionPolicy: "default",
|
|
46835
|
+
loadModelCatalog: false
|
|
46836
|
+
});
|
|
46242
46837
|
await replay.open(parent.nativeSessionId);
|
|
46243
46838
|
const after = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
|
|
46244
46839
|
if (JSON.stringify(before) !== JSON.stringify(after))
|
|
@@ -46259,12 +46854,19 @@ var CursorAdapter = class {
|
|
|
46259
46854
|
#forks = /* @__PURE__ */ new Map();
|
|
46260
46855
|
#inspections = /* @__PURE__ */ new Map();
|
|
46261
46856
|
#closed = false;
|
|
46857
|
+
sessionImport;
|
|
46262
46858
|
constructor(options = {}) {
|
|
46263
46859
|
this.options = options;
|
|
46860
|
+
this.sessionImport = new CursorSessionImport(options.environment ?? process.env);
|
|
46861
|
+
}
|
|
46862
|
+
async inspectAccount() {
|
|
46863
|
+
if (this.#closed)
|
|
46864
|
+
return null;
|
|
46865
|
+
return fetchCursorAccount({ environment: this.options.environment ?? process.env });
|
|
46264
46866
|
}
|
|
46265
46867
|
transportOptions(cwd, environment) {
|
|
46266
46868
|
return {
|
|
46267
|
-
cwd:
|
|
46869
|
+
cwd: path10.resolve(cwd),
|
|
46268
46870
|
environment: { ...this.options.environment ?? process.env, ...environment },
|
|
46269
46871
|
...this.options.command ? { command: this.options.command } : {},
|
|
46270
46872
|
...this.options.timeoutMs ? { timeoutMs: this.options.timeoutMs } : {}
|
|
@@ -46276,7 +46878,7 @@ var CursorAdapter = class {
|
|
|
46276
46878
|
status: "unavailable",
|
|
46277
46879
|
error: { code: "unavailable", message: "Cursor adapter is closed", retryable: false }
|
|
46278
46880
|
};
|
|
46279
|
-
const cwd =
|
|
46881
|
+
const cwd = path10.resolve(input.cwd ?? process.cwd());
|
|
46280
46882
|
const cached2 = this.#inspections.get(cwd);
|
|
46281
46883
|
if (cached2 && (cached2.pending || !input.refresh))
|
|
46282
46884
|
return cached2.result;
|
|
@@ -46323,11 +46925,19 @@ var CursorAdapter = class {
|
|
|
46323
46925
|
return this.#openSession(input);
|
|
46324
46926
|
}
|
|
46325
46927
|
async #openSession(input, prepared) {
|
|
46326
|
-
if (input.kind === "create" && input.executionPolicy === "unattended-full-access")
|
|
46327
|
-
return rejected("unsupported", "Cursor ACP cannot confirm unattended full access under native team policy");
|
|
46328
46928
|
if (input.kind === "resume" && input.nativeRef.harnessId !== this.harnessId)
|
|
46329
46929
|
return rejected("invalidRequest", "Session belongs to another Harness");
|
|
46330
|
-
|
|
46930
|
+
let executionPolicy;
|
|
46931
|
+
try {
|
|
46932
|
+
executionPolicy = input.kind === "create" ? input.executionPolicy ?? "default" : cursorExecutionPolicy(input.nativeRef);
|
|
46933
|
+
} catch {
|
|
46934
|
+
return rejected("invalidRequest", "Invalid Cursor Native Session locator");
|
|
46935
|
+
}
|
|
46936
|
+
const options = {
|
|
46937
|
+
...this.transportOptions(input.cwd, input.environment),
|
|
46938
|
+
delegation: true,
|
|
46939
|
+
executionPolicy
|
|
46940
|
+
};
|
|
46331
46941
|
const transport = prepared ?? new CursorTransport(options);
|
|
46332
46942
|
try {
|
|
46333
46943
|
const before = input.kind === "resume" ? readCursorNativeHistory(input.nativeRef.nativeSessionId, options.cwd, options.environment) : void 0;
|
|
@@ -46380,11 +46990,13 @@ var CursorAdapter = class {
|
|
|
46380
46990
|
const signal = controller.signal;
|
|
46381
46991
|
if (!cursorForkAvailable())
|
|
46382
46992
|
return rejected("unsupported", "Cursor Fork requires macOS/Linux with /usr/bin/script");
|
|
46993
|
+
let executionPolicy;
|
|
46383
46994
|
try {
|
|
46384
46995
|
if (input.kind === "fork")
|
|
46385
46996
|
validateCursorFork(input.sourceRef, input.checkpoint);
|
|
46386
46997
|
else if (input.sourceRef.harnessId !== this.harnessId || input.sourceRef.formatVersion !== 1)
|
|
46387
46998
|
return rejected("invalidRequest", "Invalid Cursor rollback source");
|
|
46999
|
+
executionPolicy = cursorExecutionPolicy(input.sourceRef);
|
|
46388
47000
|
} catch {
|
|
46389
47001
|
return rejected("invalidRequest", "Invalid Cursor fork checkpoint");
|
|
46390
47002
|
}
|
|
@@ -46417,7 +47029,7 @@ var CursorAdapter = class {
|
|
|
46417
47029
|
const sameEnvironment = sourceEnvironment && [
|
|
46418
47030
|
.../* @__PURE__ */ new Set([...Object.keys(sourceEnvironment), ...Object.keys(options.environment)])
|
|
46419
47031
|
].every((key) => sourceEnvironment[key] === options.environment[key]);
|
|
46420
|
-
transport = new CursorTransport({ ...options, delegation: true }, sameEnvironment ? source?.info.nativeModels : void 0);
|
|
47032
|
+
transport = new CursorTransport({ ...options, delegation: true, executionPolicy }, sameEnvironment ? source?.info.nativeModels : void 0);
|
|
46421
47033
|
const abort = (error51) => {
|
|
46422
47034
|
controller.abort(error51);
|
|
46423
47035
|
throw error51;
|
|
@@ -46442,11 +47054,7 @@ var CursorAdapter = class {
|
|
|
46442
47054
|
kind: "resume",
|
|
46443
47055
|
cwd: input.cwd,
|
|
46444
47056
|
environment: options.environment,
|
|
46445
|
-
nativeRef:
|
|
46446
|
-
harnessId: this.harnessId,
|
|
46447
|
-
nativeSessionId: derived.sessionId,
|
|
46448
|
-
formatVersion: 1
|
|
46449
|
-
}),
|
|
47057
|
+
nativeRef: cursorNativeSessionRef(derived.sessionId, executionPolicy),
|
|
46450
47058
|
...model ? { model } : {},
|
|
46451
47059
|
...thinking ? { thinkingOptionId: thinking } : {},
|
|
46452
47060
|
...mode ? { permissionModeId: mode } : {}
|
|
@@ -46472,9 +47080,10 @@ var CursorAdapter = class {
|
|
|
46472
47080
|
}
|
|
46473
47081
|
async close() {
|
|
46474
47082
|
this.#closed = true;
|
|
47083
|
+
const importing = this.sessionImport.close();
|
|
46475
47084
|
for (const controller of this.#forks.keys())
|
|
46476
47085
|
controller.abort();
|
|
46477
|
-
await Promise.allSettled(this.#forks.values());
|
|
47086
|
+
await Promise.allSettled([importing, ...this.#forks.values()]);
|
|
46478
47087
|
await Promise.allSettled([...this.#sessions].map((session) => session.close()));
|
|
46479
47088
|
await Promise.allSettled([...this.#inspections.values()].map((inspection) => inspection.result));
|
|
46480
47089
|
}
|
|
@@ -46506,9 +47115,11 @@ var CursorSession = class {
|
|
|
46506
47115
|
initialState;
|
|
46507
47116
|
#channel = new HarnessOutputChannel();
|
|
46508
47117
|
outputs = this.#channel.outputs;
|
|
46509
|
-
#interactions
|
|
47118
|
+
#interactions;
|
|
47119
|
+
#executionPolicy;
|
|
46510
47120
|
#submitted = /* @__PURE__ */ new Set();
|
|
46511
47121
|
#active;
|
|
47122
|
+
#unattendedApproval = false;
|
|
46512
47123
|
#configuring = false;
|
|
46513
47124
|
#closed = false;
|
|
46514
47125
|
#fresh;
|
|
@@ -46536,12 +47147,10 @@ var CursorSession = class {
|
|
|
46536
47147
|
this.info = structuredClone(info);
|
|
46537
47148
|
this.#fresh = created;
|
|
46538
47149
|
this.#snapshot = loadedSnapshot;
|
|
47150
|
+
this.#executionPolicy = transport.options.executionPolicy ?? "default";
|
|
47151
|
+
this.#interactions = new CursorInteractions((output) => this.#channel.emit(output), this.#executionPolicy === "unattended-full-access" ? () => this.#refuseUnattendedApproval() : void 0);
|
|
46539
47152
|
this.initialState = {
|
|
46540
|
-
nativeRef:
|
|
46541
|
-
harnessId: "cursor-cli",
|
|
46542
|
-
nativeSessionId: transport.sessionId,
|
|
46543
|
-
formatVersion: 1
|
|
46544
|
-
}),
|
|
47153
|
+
nativeRef: cursorNativeSessionRef(transport.sessionId, this.#executionPolicy),
|
|
46545
47154
|
effectiveModel: cursorConfiguredModelRef(cursorModels(info).current, info.configOptions),
|
|
46546
47155
|
...cursorThinkingState(info),
|
|
46547
47156
|
effectivePermissionModeId: harnessPermissionModeIdSchema.parse(info.configOptions?.find((option) => option.id === "mode")?.currentValue ?? info.modes?.currentModeId ?? "agent")
|
|
@@ -46550,6 +47159,11 @@ var CursorSession = class {
|
|
|
46550
47159
|
#native(allowMissing = false) {
|
|
46551
47160
|
return readCursorNativeTurns(this.transport.sessionId, this.transport.options.cwd, this.transport.options.environment, allowMissing);
|
|
46552
47161
|
}
|
|
47162
|
+
/** Bound to unattended full access only; Cursor itself keeps enforcing its team policy. */
|
|
47163
|
+
#refuseUnattendedApproval() {
|
|
47164
|
+
this.#unattendedApproval = true;
|
|
47165
|
+
return this.transport.cancel();
|
|
47166
|
+
}
|
|
46553
47167
|
async readSnapshot() {
|
|
46554
47168
|
if (this.#closed)
|
|
46555
47169
|
return rejected("invalidState", "Cursor session is closed");
|
|
@@ -46566,6 +47180,7 @@ var CursorSession = class {
|
|
|
46566
47180
|
replay = new CursorTransport({
|
|
46567
47181
|
...this.transport.options,
|
|
46568
47182
|
delegation: false,
|
|
47183
|
+
executionPolicy: "default",
|
|
46569
47184
|
loadModelCatalog: false
|
|
46570
47185
|
});
|
|
46571
47186
|
await replay.open(this.transport.sessionId);
|
|
@@ -46680,6 +47295,7 @@ var CursorSession = class {
|
|
|
46680
47295
|
let fault;
|
|
46681
47296
|
const output = new CursorTurnOutput(command.turnId, (event) => this.#channel.emit({ kind: "event", event }), before.length);
|
|
46682
47297
|
this.#subagentOutput = output.subagents;
|
|
47298
|
+
this.#unattendedApproval = false;
|
|
46683
47299
|
this.#channel.emit({ kind: "event", event: { type: "turn.started", turnId: command.turnId } });
|
|
46684
47300
|
let outcome = {
|
|
46685
47301
|
status: "failed",
|
|
@@ -46695,7 +47311,15 @@ var CursorSession = class {
|
|
|
46695
47311
|
output.subagents.extension(method, params);
|
|
46696
47312
|
}
|
|
46697
47313
|
});
|
|
46698
|
-
|
|
47314
|
+
const streamClosed = output.sawWritableIterableClosed() && !output.hasVisibleAssistantText();
|
|
47315
|
+
outcome = this.#active?.cancelled || result.stopReason === "cancelled" ? { status: "cancelled" } : streamClosed ? {
|
|
47316
|
+
status: "failed",
|
|
47317
|
+
error: {
|
|
47318
|
+
code: "nativeFailure",
|
|
47319
|
+
message: "Cursor stream closed (WritableIterable)",
|
|
47320
|
+
retryable: true
|
|
47321
|
+
}
|
|
47322
|
+
} : result.stopReason === "end_turn" ? { status: "succeeded" } : {
|
|
46699
47323
|
status: "failed",
|
|
46700
47324
|
error: {
|
|
46701
47325
|
code: "nativeFailure",
|
|
@@ -46707,6 +47331,15 @@ var CursorSession = class {
|
|
|
46707
47331
|
fault = cursorError(error51);
|
|
46708
47332
|
outcome = this.#active?.cancelled ? { status: "cancelled" } : { status: "failed", error: cursorError(error51) };
|
|
46709
47333
|
}
|
|
47334
|
+
if (!this.#active?.cancelled && this.#unattendedApproval)
|
|
47335
|
+
outcome = {
|
|
47336
|
+
status: "failed",
|
|
47337
|
+
error: {
|
|
47338
|
+
code: "nativeFailure",
|
|
47339
|
+
message: "Cursor requested approval during unattended full access",
|
|
47340
|
+
retryable: false
|
|
47341
|
+
}
|
|
47342
|
+
};
|
|
46710
47343
|
try {
|
|
46711
47344
|
const after = this.#native(this.#fresh);
|
|
46712
47345
|
const added = after.filter((turn) => !before.some((old) => old.id === turn.id));
|
|
@@ -46770,7 +47403,7 @@ var CursorSession = class {
|
|
|
46770
47403
|
|
|
46771
47404
|
// ../../harness-broker/dist/client.js
|
|
46772
47405
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
46773
|
-
import { lstat, readFile as
|
|
47406
|
+
import { lstat as lstat2, readFile as readFile4 } from "node:fs/promises";
|
|
46774
47407
|
import net, {} from "node:net";
|
|
46775
47408
|
|
|
46776
47409
|
// ../../harness-broker/dist/protocol.js
|
|
@@ -46885,24 +47518,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
46885
47518
|
|
|
46886
47519
|
// ../../harness-broker/dist/paths.js
|
|
46887
47520
|
import os4 from "node:os";
|
|
46888
|
-
import
|
|
47521
|
+
import path11 from "node:path";
|
|
46889
47522
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
46890
47523
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
46891
47524
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
46892
47525
|
const home = environment.HOME || os4.homedir();
|
|
46893
|
-
return
|
|
47526
|
+
return path11.join(home, ".codexhost", "harness-broker");
|
|
46894
47527
|
}
|
|
46895
47528
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
46896
47529
|
harnessPluginIdSchema.parse(harnessId);
|
|
46897
47530
|
if (harnessId !== "claude-code")
|
|
46898
|
-
return
|
|
46899
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
47531
|
+
return path11.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
47532
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path11.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
46900
47533
|
}
|
|
46901
47534
|
|
|
46902
47535
|
// ../../harness-broker/dist/validation.js
|
|
46903
47536
|
var cwdSchema = external_exports.string().min(1).max(16384);
|
|
46904
47537
|
var brokerEnvironmentSchema = external_exports.object({
|
|
46905
47538
|
CODEXHOST_CLI_PATH: external_exports.string().max(16384).optional(),
|
|
47539
|
+
CODEXHOST_CLI_NODE_PATH: external_exports.string().max(16384).optional(),
|
|
46906
47540
|
CODEXHOST_RUNTIME_ENDPOINT: external_exports.string().max(16384).optional(),
|
|
46907
47541
|
CODEXHOST_RUNTIME_TOKEN: external_exports.string().max(16384).optional(),
|
|
46908
47542
|
CODEXHOST_THREAD_ID: external_exports.string().max(256).optional()
|
|
@@ -47029,7 +47663,7 @@ var harnessErrorSchema = external_exports.object({
|
|
|
47029
47663
|
var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
47030
47664
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
47031
47665
|
return false;
|
|
47032
|
-
const
|
|
47666
|
+
const record3 = value;
|
|
47033
47667
|
const allowed = /* @__PURE__ */ new Set([
|
|
47034
47668
|
"nativeRef",
|
|
47035
47669
|
"effectiveModel",
|
|
@@ -47038,12 +47672,12 @@ var harnessSessionStateSchema = external_exports.custom((value) => {
|
|
|
47038
47672
|
"availableThinkingOptions",
|
|
47039
47673
|
"effectivePermissionModeId"
|
|
47040
47674
|
]);
|
|
47041
|
-
if (Object.keys(
|
|
47675
|
+
if (Object.keys(record3).some((key) => !allowed.has(key)))
|
|
47042
47676
|
return false;
|
|
47043
|
-
if (
|
|
47677
|
+
if (record3.nativeRef !== void 0 && !nativeSessionRefSchema.safeParse(record3.nativeRef).success) {
|
|
47044
47678
|
return false;
|
|
47045
47679
|
}
|
|
47046
|
-
const { nativeRef: _nativeRef, ...configuration } =
|
|
47680
|
+
const { nativeRef: _nativeRef, ...configuration } = record3;
|
|
47047
47681
|
void _nativeRef;
|
|
47048
47682
|
return harnessConfigurationStateSchema.safeParse(configuration).success;
|
|
47049
47683
|
});
|
|
@@ -47057,6 +47691,7 @@ var eventKeys = /* @__PURE__ */ new Map([
|
|
|
47057
47691
|
["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
|
|
47058
47692
|
["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
|
|
47059
47693
|
["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
|
|
47694
|
+
["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
|
|
47060
47695
|
["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
|
|
47061
47696
|
["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome"])],
|
|
47062
47697
|
["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
|
|
@@ -47173,7 +47808,7 @@ function parseSessionMetadata(value) {
|
|
|
47173
47808
|
};
|
|
47174
47809
|
}
|
|
47175
47810
|
async function readDescriptor(descriptorPath) {
|
|
47176
|
-
const metadata = await
|
|
47811
|
+
const metadata = await lstat2(descriptorPath);
|
|
47177
47812
|
if (metadata.isSymbolicLink())
|
|
47178
47813
|
throw new Error("Aqua Harness broker descriptor must not be a symlink");
|
|
47179
47814
|
if (!metadata.isFile())
|
|
@@ -47185,12 +47820,12 @@ async function readDescriptor(descriptorPath) {
|
|
|
47185
47820
|
throw new Error("Aqua Harness broker descriptor belongs to another user");
|
|
47186
47821
|
}
|
|
47187
47822
|
}
|
|
47188
|
-
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await
|
|
47823
|
+
const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile4(descriptorPath, "utf8")));
|
|
47189
47824
|
if (process.platform === "darwin" && Buffer.byteLength(descriptor.socketPath) > 103) {
|
|
47190
47825
|
throw new Error("Aqua Harness broker socket path is too long for macOS");
|
|
47191
47826
|
}
|
|
47192
47827
|
if (process.platform !== "win32") {
|
|
47193
|
-
const socket = await
|
|
47828
|
+
const socket = await lstat2(descriptor.socketPath);
|
|
47194
47829
|
if (socket.isSymbolicLink() || !socket.isSocket()) {
|
|
47195
47830
|
throw new Error("Aqua Harness broker endpoint is not a Unix socket");
|
|
47196
47831
|
}
|
|
@@ -47625,6 +48260,7 @@ var BrokeredHarnessAdapter = class {
|
|
|
47625
48260
|
if (this.#forwardEnvironment && input.environment) {
|
|
47626
48261
|
const allowed = [
|
|
47627
48262
|
"CODEXHOST_CLI_PATH",
|
|
48263
|
+
"CODEXHOST_CLI_NODE_PATH",
|
|
47628
48264
|
"CODEXHOST_RUNTIME_ENDPOINT",
|
|
47629
48265
|
"CODEXHOST_RUNTIME_TOKEN",
|
|
47630
48266
|
"CODEXHOST_THREAD_ID"
|
|
@@ -47690,7 +48326,10 @@ function createHarnessAdapter(context) {
|
|
|
47690
48326
|
liveCommandCatalog: true,
|
|
47691
48327
|
environment: { ...context.environment }
|
|
47692
48328
|
});
|
|
47693
|
-
|
|
48329
|
+
const environment = { ...context.environment };
|
|
48330
|
+
return Object.assign(new CursorAdapter({ environment }), {
|
|
48331
|
+
installation: createCursorInstallation(environment)
|
|
48332
|
+
});
|
|
47694
48333
|
}
|
|
47695
48334
|
export {
|
|
47696
48335
|
createHarnessAdapter
|