@super-one/cli 0.53.2-alpha → 0.53.3-alpha
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/MANIFEST.json +2 -2
- package/lib/cli.mjs +666 -248
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -51443,6 +51443,139 @@ var init_cursor_sdk_available = __esm({
|
|
|
51443
51443
|
}
|
|
51444
51444
|
});
|
|
51445
51445
|
|
|
51446
|
+
// ../../packages/cursor/src/cursor-platform-binaries.ts
|
|
51447
|
+
import { existsSync as existsSync21, statSync as statSync5 } from "node:fs";
|
|
51448
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
51449
|
+
import { dirname as dirname11, join as join18 } from "node:path";
|
|
51450
|
+
function cursorPlatformPackageName(platform2 = process.platform, arch2 = process.arch) {
|
|
51451
|
+
return `@cursor/sdk-${platform2}-${arch2}`;
|
|
51452
|
+
}
|
|
51453
|
+
function toUnpackedAsarPath(filePath) {
|
|
51454
|
+
return filePath.replace(/app\.asar([\\/])/, "app.asar.unpacked$1");
|
|
51455
|
+
}
|
|
51456
|
+
function isExecutableFile(candidate) {
|
|
51457
|
+
try {
|
|
51458
|
+
const st = statSync5(candidate);
|
|
51459
|
+
if (!st.isFile()) return false;
|
|
51460
|
+
if (process.platform === "win32") return true;
|
|
51461
|
+
return (st.mode & 73) !== 0;
|
|
51462
|
+
} catch {
|
|
51463
|
+
return false;
|
|
51464
|
+
}
|
|
51465
|
+
}
|
|
51466
|
+
function cursorSdkRequire() {
|
|
51467
|
+
try {
|
|
51468
|
+
return createRequire3(requireFromHere.resolve("@cursor/sdk/package.json"));
|
|
51469
|
+
} catch {
|
|
51470
|
+
return requireFromHere;
|
|
51471
|
+
}
|
|
51472
|
+
}
|
|
51473
|
+
function resolveCursorPlatformRoot() {
|
|
51474
|
+
const name = cursorPlatformPackageName();
|
|
51475
|
+
const req = cursorSdkRequire();
|
|
51476
|
+
try {
|
|
51477
|
+
const pkgJson = toUnpackedAsarPath(req.resolve(`${name}/package.json`));
|
|
51478
|
+
return existsSync21(pkgJson) ? dirname11(pkgJson) : null;
|
|
51479
|
+
} catch {
|
|
51480
|
+
return null;
|
|
51481
|
+
}
|
|
51482
|
+
}
|
|
51483
|
+
function platformBinName(base) {
|
|
51484
|
+
return process.platform === "win32" ? `${base}.exe` : base;
|
|
51485
|
+
}
|
|
51486
|
+
function resolveCursorSandboxBinary() {
|
|
51487
|
+
const root = resolveCursorPlatformRoot();
|
|
51488
|
+
if (!root) return null;
|
|
51489
|
+
const bin = join18(root, "bin", platformBinName("cursorsandbox"));
|
|
51490
|
+
return isExecutableFile(bin) ? bin : null;
|
|
51491
|
+
}
|
|
51492
|
+
function resolveCursorRipgrepBinary() {
|
|
51493
|
+
const root = resolveCursorPlatformRoot();
|
|
51494
|
+
if (!root) return null;
|
|
51495
|
+
const bin = join18(root, "bin", platformBinName("rg"));
|
|
51496
|
+
return isExecutableFile(bin) ? bin : null;
|
|
51497
|
+
}
|
|
51498
|
+
function resolveCursorTreeSitterVendorDir() {
|
|
51499
|
+
const root = resolveCursorPlatformRoot();
|
|
51500
|
+
if (!root) return null;
|
|
51501
|
+
const vendor = join18(root, "vendor");
|
|
51502
|
+
return existsSync21(join18(vendor, "tree-sitter", "index.js")) ? vendor : null;
|
|
51503
|
+
}
|
|
51504
|
+
function sandboxExecAvailable() {
|
|
51505
|
+
try {
|
|
51506
|
+
statSync5("/usr/bin/sandbox-exec");
|
|
51507
|
+
return true;
|
|
51508
|
+
} catch {
|
|
51509
|
+
return false;
|
|
51510
|
+
}
|
|
51511
|
+
}
|
|
51512
|
+
function isCursorLocalSandboxSupported(probe = {}) {
|
|
51513
|
+
const platform2 = probe.platform ?? process.platform;
|
|
51514
|
+
if (platform2 === "win32") return false;
|
|
51515
|
+
const binary = probe.sandboxBinary !== void 0 ? probe.sandboxBinary : resolveCursorSandboxBinary();
|
|
51516
|
+
if (!binary) return false;
|
|
51517
|
+
if (platform2 === "darwin") {
|
|
51518
|
+
const execOk = probe.sandboxExecExists ?? sandboxExecAvailable();
|
|
51519
|
+
return execOk;
|
|
51520
|
+
}
|
|
51521
|
+
return true;
|
|
51522
|
+
}
|
|
51523
|
+
function resolveCursorSandboxEnabled(requested, probe) {
|
|
51524
|
+
return requested && isCursorLocalSandboxSupported(probe);
|
|
51525
|
+
}
|
|
51526
|
+
function isCursorSandboxUnsupportedError(error51) {
|
|
51527
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
51528
|
+
return /sandboxing is not supported/i.test(message);
|
|
51529
|
+
}
|
|
51530
|
+
function primeHelperEnv() {
|
|
51531
|
+
if (!process.env.CURSOR_RIPGREP_PATH) {
|
|
51532
|
+
const rg = resolveCursorRipgrepBinary();
|
|
51533
|
+
if (rg) process.env.CURSOR_RIPGREP_PATH = rg;
|
|
51534
|
+
}
|
|
51535
|
+
if (!process.env.CURSOR_TREE_SITTER_VENDOR_DIR) {
|
|
51536
|
+
const vendor = resolveCursorTreeSitterVendorDir();
|
|
51537
|
+
if (vendor) process.env.CURSOR_TREE_SITTER_VENDOR_DIR = vendor;
|
|
51538
|
+
}
|
|
51539
|
+
}
|
|
51540
|
+
function beginPlatformLookup() {
|
|
51541
|
+
if (lookupDepth === 0) {
|
|
51542
|
+
savedArgv1 = process.argv[1];
|
|
51543
|
+
const root = resolveCursorPlatformRoot();
|
|
51544
|
+
if (root) process.argv[1] = join18(root, "package.json");
|
|
51545
|
+
primeHelperEnv();
|
|
51546
|
+
}
|
|
51547
|
+
lookupDepth += 1;
|
|
51548
|
+
return () => {
|
|
51549
|
+
lookupDepth = Math.max(0, lookupDepth - 1);
|
|
51550
|
+
if (lookupDepth === 0 && savedArgv1 !== void 0) {
|
|
51551
|
+
process.argv[1] = savedArgv1;
|
|
51552
|
+
savedArgv1 = void 0;
|
|
51553
|
+
}
|
|
51554
|
+
};
|
|
51555
|
+
}
|
|
51556
|
+
function withCursorPlatformLookup(fn) {
|
|
51557
|
+
const restore = beginPlatformLookup();
|
|
51558
|
+
try {
|
|
51559
|
+
const result = fn();
|
|
51560
|
+
if (result && typeof result.then === "function") {
|
|
51561
|
+
return result.finally(restore);
|
|
51562
|
+
}
|
|
51563
|
+
restore();
|
|
51564
|
+
return result;
|
|
51565
|
+
} catch (error51) {
|
|
51566
|
+
restore();
|
|
51567
|
+
throw error51;
|
|
51568
|
+
}
|
|
51569
|
+
}
|
|
51570
|
+
var requireFromHere, lookupDepth, savedArgv1;
|
|
51571
|
+
var init_cursor_platform_binaries = __esm({
|
|
51572
|
+
"../../packages/cursor/src/cursor-platform-binaries.ts"() {
|
|
51573
|
+
"use strict";
|
|
51574
|
+
requireFromHere = createRequire3(import.meta.url);
|
|
51575
|
+
lookupDepth = 0;
|
|
51576
|
+
}
|
|
51577
|
+
});
|
|
51578
|
+
|
|
51446
51579
|
// ../../packages/cursor/src/cursor-mcp-map.ts
|
|
51447
51580
|
function mcpServersToStatus(servers) {
|
|
51448
51581
|
return Object.keys(servers).map((name) => ({ name, status: "connected" }));
|
|
@@ -51968,7 +52101,7 @@ var init_cursor_event_map = __esm({
|
|
|
51968
52101
|
import Database2 from "better-sqlite3";
|
|
51969
52102
|
import { mkdirSync as mkdirSync11 } from "node:fs";
|
|
51970
52103
|
import { createHash as createHash4 } from "node:crypto";
|
|
51971
|
-
import { join as
|
|
52104
|
+
import { join as join19 } from "node:path";
|
|
51972
52105
|
function workspaceHash(workspaceRef) {
|
|
51973
52106
|
return createHash4("md5").update(workspaceRef).digest("hex");
|
|
51974
52107
|
}
|
|
@@ -52011,7 +52144,7 @@ var init_cursor_store = __esm({
|
|
|
52011
52144
|
runEvents;
|
|
52012
52145
|
db;
|
|
52013
52146
|
constructor(dbPath) {
|
|
52014
|
-
mkdirSync11(
|
|
52147
|
+
mkdirSync11(join19(dbPath, ".."), { recursive: true });
|
|
52015
52148
|
this.db = new Database2(dbPath);
|
|
52016
52149
|
this.db.pragma("journal_mode = WAL");
|
|
52017
52150
|
this.migrate();
|
|
@@ -52021,9 +52154,9 @@ var init_cursor_store = __esm({
|
|
|
52021
52154
|
this.runEvents = this.createRunEvents();
|
|
52022
52155
|
}
|
|
52023
52156
|
static openForWorkspace(userDataRoot, workspaceRef) {
|
|
52024
|
-
const dir =
|
|
52157
|
+
const dir = join19(userDataRoot, "cursor-sdk", workspaceHash(workspaceRef));
|
|
52025
52158
|
mkdirSync11(dir, { recursive: true });
|
|
52026
|
-
return new _BetterSqliteLocalAgentStore(
|
|
52159
|
+
return new _BetterSqliteLocalAgentStore(join19(dir, "agent-store.db"));
|
|
52027
52160
|
}
|
|
52028
52161
|
dispose() {
|
|
52029
52162
|
this.db.close();
|
|
@@ -52501,6 +52634,126 @@ var init_cursor_sdk_auth = __esm({
|
|
|
52501
52634
|
}
|
|
52502
52635
|
});
|
|
52503
52636
|
|
|
52637
|
+
// ../../packages/cursor/src/cursor-local-options.ts
|
|
52638
|
+
function resolveCursorLocalSessionPlan(input) {
|
|
52639
|
+
const config2 = readCursorConfig(input.config);
|
|
52640
|
+
const resolveApiKey = input.resolveApiKey ?? resolveCursorApiKeyPlain;
|
|
52641
|
+
const buildMcpServers = input.buildMcpServers ?? (() => ({}));
|
|
52642
|
+
const isCloud = config2.runtime === "cloud" || (input.providerSessionId?.startsWith("bc-") ?? false);
|
|
52643
|
+
const perm = mapPermissionToCursorLocal(input.permissionMode);
|
|
52644
|
+
const settingSources = config2.settingSources ?? DEFAULT_CURSOR_SETTING_SOURCES;
|
|
52645
|
+
const sandboxRequested = input.sandboxEnabled ?? config2.sandboxEnabled ?? false;
|
|
52646
|
+
const sandboxEnabled = isCloud ? false : resolveCursorSandboxEnabled(sandboxRequested);
|
|
52647
|
+
const mcpServers = isCloud ? stripStdioCwd(buildMcpServers(input.cwd, input.sessionId)) : buildMcpServers(input.cwd, input.sessionId);
|
|
52648
|
+
return {
|
|
52649
|
+
apiKey: resolveApiKey(input.config),
|
|
52650
|
+
config: config2,
|
|
52651
|
+
isCloud,
|
|
52652
|
+
settingSources,
|
|
52653
|
+
sandboxEnabled,
|
|
52654
|
+
sandboxRequested,
|
|
52655
|
+
perm,
|
|
52656
|
+
enableAgentRetries: config2.enableAgentRetries ?? true,
|
|
52657
|
+
mcpServers
|
|
52658
|
+
};
|
|
52659
|
+
}
|
|
52660
|
+
var DEFAULT_CURSOR_SETTING_SOURCES;
|
|
52661
|
+
var init_cursor_local_options = __esm({
|
|
52662
|
+
"../../packages/cursor/src/cursor-local-options.ts"() {
|
|
52663
|
+
"use strict";
|
|
52664
|
+
init_cursor_config();
|
|
52665
|
+
init_cursor_platform_binaries();
|
|
52666
|
+
init_cursor_mcp_map();
|
|
52667
|
+
DEFAULT_CURSOR_SETTING_SOURCES = ["project", "user"];
|
|
52668
|
+
}
|
|
52669
|
+
});
|
|
52670
|
+
|
|
52671
|
+
// ../../packages/cursor/src/cursor-network-retry.ts
|
|
52672
|
+
import { NetworkError } from "@cursor/sdk";
|
|
52673
|
+
function isCursorRetryableNetworkError(error51) {
|
|
52674
|
+
if (error51 instanceof NetworkError) return error51.isRetryable;
|
|
52675
|
+
if (!error51 || typeof error51 !== "object") return false;
|
|
52676
|
+
const name = "name" in error51 ? String(error51.name) : "";
|
|
52677
|
+
if (name !== "NetworkError") return false;
|
|
52678
|
+
if (!("isRetryable" in error51)) return true;
|
|
52679
|
+
return Boolean(error51.isRetryable);
|
|
52680
|
+
}
|
|
52681
|
+
function defaultSleep(ms) {
|
|
52682
|
+
return new Promise((resolve13) => {
|
|
52683
|
+
setTimeout(resolve13, ms);
|
|
52684
|
+
});
|
|
52685
|
+
}
|
|
52686
|
+
async function withCursorNetworkRetries(fn, opts) {
|
|
52687
|
+
const retries = opts?.retries ?? CURSOR_NETWORK_RETRY_ATTEMPTS;
|
|
52688
|
+
const baseDelayMs = opts?.baseDelayMs ?? CURSOR_NETWORK_RETRY_BASE_DELAY_MS;
|
|
52689
|
+
const maxDelayMs = opts?.maxDelayMs ?? CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
|
|
52690
|
+
const sleep = opts?.sleep ?? defaultSleep;
|
|
52691
|
+
let lastError;
|
|
52692
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
52693
|
+
try {
|
|
52694
|
+
return await fn();
|
|
52695
|
+
} catch (error51) {
|
|
52696
|
+
lastError = error51;
|
|
52697
|
+
if (!isCursorRetryableNetworkError(error51) || attempt === retries) throw error51;
|
|
52698
|
+
const delayMs = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
|
|
52699
|
+
opts?.onRetry?.({ attempt: attempt + 1, retries, delayMs, error: error51 });
|
|
52700
|
+
await sleep(delayMs);
|
|
52701
|
+
}
|
|
52702
|
+
}
|
|
52703
|
+
throw lastError;
|
|
52704
|
+
}
|
|
52705
|
+
var CURSOR_NETWORK_RETRY_ATTEMPTS, CURSOR_NETWORK_RETRY_BASE_DELAY_MS, CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
|
|
52706
|
+
var init_cursor_network_retry = __esm({
|
|
52707
|
+
"../../packages/cursor/src/cursor-network-retry.ts"() {
|
|
52708
|
+
"use strict";
|
|
52709
|
+
CURSOR_NETWORK_RETRY_ATTEMPTS = 5;
|
|
52710
|
+
CURSOR_NETWORK_RETRY_BASE_DELAY_MS = 2e3;
|
|
52711
|
+
CURSOR_NETWORK_RETRY_MAX_DELAY_MS = 8e3;
|
|
52712
|
+
}
|
|
52713
|
+
});
|
|
52714
|
+
|
|
52715
|
+
// ../../packages/cursor/src/cursor-sdk-trace.ts
|
|
52716
|
+
function createCursorSdkTracer(onSdkTrace) {
|
|
52717
|
+
const emit = (source, type, data, tag) => {
|
|
52718
|
+
if (!onSdkTrace) return;
|
|
52719
|
+
try {
|
|
52720
|
+
onSdkTrace(source, type, data, tag);
|
|
52721
|
+
} catch {
|
|
52722
|
+
}
|
|
52723
|
+
};
|
|
52724
|
+
return {
|
|
52725
|
+
sdk(type, data, tag) {
|
|
52726
|
+
emit("agent.sdk", type || "unknown", data, tag);
|
|
52727
|
+
},
|
|
52728
|
+
runtime(type, data, tag) {
|
|
52729
|
+
emit("cursor.runtime", type || "unknown", data, tag);
|
|
52730
|
+
}
|
|
52731
|
+
};
|
|
52732
|
+
}
|
|
52733
|
+
function cursorSdkType(value, fallback) {
|
|
52734
|
+
if (!value || typeof value !== "object") return fallback;
|
|
52735
|
+
const type = value.type;
|
|
52736
|
+
return typeof type === "string" && type ? type : fallback;
|
|
52737
|
+
}
|
|
52738
|
+
function cursorUserSendTracePayload(message) {
|
|
52739
|
+
if (typeof message === "string") return { text: message };
|
|
52740
|
+
if (!message || typeof message !== "object") return message;
|
|
52741
|
+
const rec = message;
|
|
52742
|
+
if (!Array.isArray(rec.images)) return message;
|
|
52743
|
+
return {
|
|
52744
|
+
text: rec.text,
|
|
52745
|
+
images: rec.images.map((img) => ({
|
|
52746
|
+
mimeType: typeof img?.mimeType === "string" ? img.mimeType : "",
|
|
52747
|
+
bytes: typeof img?.data === "string" ? img.data.length : 0
|
|
52748
|
+
}))
|
|
52749
|
+
};
|
|
52750
|
+
}
|
|
52751
|
+
var init_cursor_sdk_trace = __esm({
|
|
52752
|
+
"../../packages/cursor/src/cursor-sdk-trace.ts"() {
|
|
52753
|
+
"use strict";
|
|
52754
|
+
}
|
|
52755
|
+
});
|
|
52756
|
+
|
|
52504
52757
|
// ../../packages/cursor/src/cursor-runtime.ts
|
|
52505
52758
|
import {
|
|
52506
52759
|
Agent as Agent4,
|
|
@@ -52529,41 +52782,63 @@ async function createCursorRuntime(opts) {
|
|
|
52529
52782
|
error: opts.log?.error ?? noopLog.error,
|
|
52530
52783
|
debug: opts.log?.debug ?? noopLog.debug
|
|
52531
52784
|
};
|
|
52532
|
-
const
|
|
52533
|
-
const
|
|
52534
|
-
const
|
|
52535
|
-
const apiKey = resolveApiKey(opts.config);
|
|
52785
|
+
const tracer = createCursorSdkTracer(opts.onSdkTrace);
|
|
52786
|
+
const plan = resolveCursorLocalSessionPlan(opts);
|
|
52787
|
+
const apiKey = plan.apiKey;
|
|
52536
52788
|
if (!apiKey) {
|
|
52537
52789
|
throw new Error(
|
|
52538
52790
|
"Cursor User API Key missing. Create one at https://cursor.com/dashboard/api, set it on the Cursor provider, or export CURSOR_API_KEY."
|
|
52539
52791
|
);
|
|
52540
52792
|
}
|
|
52541
|
-
if (
|
|
52793
|
+
if (plan.config.useHttp1ForAgent != null) {
|
|
52542
52794
|
try {
|
|
52543
|
-
Cursor4.configure({ local: { useHttp1ForAgent:
|
|
52795
|
+
Cursor4.configure({ local: { useHttp1ForAgent: plan.config.useHttp1ForAgent } });
|
|
52544
52796
|
} catch (error51) {
|
|
52545
52797
|
log2.debug("[CursorRuntime] Cursor.configure useHttp1ForAgent failed:", error51);
|
|
52546
52798
|
}
|
|
52547
52799
|
}
|
|
52548
|
-
const isCloud =
|
|
52549
|
-
const modelId = opts.modelSelection?.id || opts.model ||
|
|
52800
|
+
const isCloud = plan.isCloud;
|
|
52801
|
+
const modelId = opts.modelSelection?.id || opts.model || plan.config.model;
|
|
52550
52802
|
if (!isCloud && !modelId) {
|
|
52551
52803
|
throw new Error("Cursor model is required for local agents. Connect Cursor to load models, then select one.");
|
|
52552
52804
|
}
|
|
52553
|
-
const perm =
|
|
52805
|
+
const perm = plan.perm;
|
|
52554
52806
|
const model = opts.modelSelection ?? (modelId ? { id: modelId } : void 0);
|
|
52555
|
-
const settingSources =
|
|
52556
|
-
|
|
52557
|
-
|
|
52807
|
+
const settingSources = plan.settingSources;
|
|
52808
|
+
let sandboxEnabled = plan.sandboxEnabled;
|
|
52809
|
+
if (plan.sandboxRequested && !sandboxEnabled) {
|
|
52810
|
+
log2.warn(
|
|
52811
|
+
"[CursorRuntime] sandbox requested but Cursor local sandbox is unavailable; running unsandboxed"
|
|
52812
|
+
);
|
|
52813
|
+
}
|
|
52814
|
+
const mcpServers = plan.mcpServers;
|
|
52815
|
+
const config2 = plan.config;
|
|
52816
|
+
const buildMcpServers = opts.buildMcpServers ?? (() => ({}));
|
|
52558
52817
|
const customTools = isCloud ? void 0 : buildCursorCustomTools({ sessionId: opts.sessionId, cwd: opts.cwd });
|
|
52559
52818
|
const agentName = opts.agentName?.trim() || void 0;
|
|
52560
52819
|
const toolRestrictions = isCloud ? {} : resolveCursorToolRestrictions(config2);
|
|
52561
52820
|
const toolsOpt = toolRestrictions.tools ? { tools: toolRestrictions.tools } : {};
|
|
52562
52821
|
const disallowedOpt = toolRestrictions.disallowedTools ? { disallowedTools: toolRestrictions.disallowedTools } : {};
|
|
52563
|
-
|
|
52564
|
-
|
|
52822
|
+
const createStarted = Date.now();
|
|
52823
|
+
log2.info("[CursorRuntime] opening agent", {
|
|
52824
|
+
sessionId: opts.sessionId,
|
|
52825
|
+
sandboxEnabled,
|
|
52826
|
+
mcpCount: Object.keys(mcpServers).length,
|
|
52827
|
+
settingSources
|
|
52828
|
+
});
|
|
52829
|
+
tracer.runtime("create_session", {
|
|
52830
|
+
sessionId: opts.sessionId,
|
|
52831
|
+
cwd: opts.cwd,
|
|
52832
|
+
sandboxEnabled,
|
|
52833
|
+
mcpCount: Object.keys(mcpServers).length,
|
|
52834
|
+
settingSources,
|
|
52835
|
+
resume: opts.providerSessionId ?? null,
|
|
52836
|
+
model: modelId ?? null,
|
|
52837
|
+
isCloud
|
|
52838
|
+
}, opts.sessionId);
|
|
52839
|
+
const openAgent = (sandbox) => withCursorPlatformLookup(async () => {
|
|
52565
52840
|
if (opts.providerSessionId) {
|
|
52566
|
-
|
|
52841
|
+
return Agent4.resume(opts.providerSessionId, {
|
|
52567
52842
|
apiKey,
|
|
52568
52843
|
...model ? { model } : {},
|
|
52569
52844
|
...agentName ? { name: agentName } : {},
|
|
@@ -52576,16 +52851,17 @@ async function createCursorRuntime(opts) {
|
|
|
52576
52851
|
cwd: opts.cwd,
|
|
52577
52852
|
store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
|
|
52578
52853
|
settingSources,
|
|
52579
|
-
sandboxOptions: { enabled:
|
|
52854
|
+
sandboxOptions: { enabled: sandbox },
|
|
52580
52855
|
// Session permission UI owns autoReview; static config must not override.
|
|
52581
52856
|
autoReview: perm.autoReview,
|
|
52582
|
-
enableAgentRetries:
|
|
52857
|
+
enableAgentRetries: plan.enableAgentRetries,
|
|
52583
52858
|
...customTools ? { customTools } : {}
|
|
52584
52859
|
}
|
|
52585
52860
|
}
|
|
52586
52861
|
});
|
|
52587
|
-
}
|
|
52588
|
-
|
|
52862
|
+
}
|
|
52863
|
+
if (isCloud) {
|
|
52864
|
+
return Agent4.create({
|
|
52589
52865
|
apiKey,
|
|
52590
52866
|
...model ? { model } : {},
|
|
52591
52867
|
...agentName ? { name: agentName } : {},
|
|
@@ -52593,30 +52869,77 @@ async function createCursorRuntime(opts) {
|
|
|
52593
52869
|
mcpServers,
|
|
52594
52870
|
cloud: buildCloudOptions(config2)
|
|
52595
52871
|
});
|
|
52596
|
-
}
|
|
52597
|
-
|
|
52598
|
-
|
|
52599
|
-
|
|
52600
|
-
|
|
52601
|
-
|
|
52602
|
-
|
|
52603
|
-
|
|
52604
|
-
|
|
52605
|
-
|
|
52606
|
-
|
|
52607
|
-
|
|
52608
|
-
|
|
52609
|
-
|
|
52610
|
-
|
|
52611
|
-
|
|
52612
|
-
|
|
52613
|
-
|
|
52614
|
-
|
|
52872
|
+
}
|
|
52873
|
+
return Agent4.create({
|
|
52874
|
+
apiKey,
|
|
52875
|
+
model,
|
|
52876
|
+
...agentName ? { name: agentName } : {},
|
|
52877
|
+
mode: perm.mode,
|
|
52878
|
+
mcpServers,
|
|
52879
|
+
...toolsOpt,
|
|
52880
|
+
...disallowedOpt,
|
|
52881
|
+
local: {
|
|
52882
|
+
cwd: opts.cwd,
|
|
52883
|
+
store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
|
|
52884
|
+
settingSources,
|
|
52885
|
+
sandboxOptions: { enabled: sandbox },
|
|
52886
|
+
// Session permission UI owns autoReview; static config must not override.
|
|
52887
|
+
autoReview: perm.autoReview,
|
|
52888
|
+
enableAgentRetries: plan.enableAgentRetries,
|
|
52889
|
+
...customTools ? { customTools } : {}
|
|
52890
|
+
}
|
|
52891
|
+
});
|
|
52892
|
+
});
|
|
52893
|
+
const openAgentRetrying = (sandbox) => withCursorNetworkRetries(() => openAgent(sandbox), {
|
|
52894
|
+
onRetry: ({ attempt, retries, delayMs, error: error51 }) => {
|
|
52895
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
52896
|
+
log2.warn("[CursorRuntime] retryable network error on Agent.create", {
|
|
52897
|
+
attempt,
|
|
52898
|
+
retries,
|
|
52899
|
+
delayMs,
|
|
52900
|
+
message
|
|
52615
52901
|
});
|
|
52902
|
+
tracer.runtime("create_retry", {
|
|
52903
|
+
attempt,
|
|
52904
|
+
retries,
|
|
52905
|
+
delayMs,
|
|
52906
|
+
message,
|
|
52907
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
52908
|
+
}, opts.sessionId);
|
|
52616
52909
|
}
|
|
52910
|
+
});
|
|
52911
|
+
let agent;
|
|
52912
|
+
try {
|
|
52913
|
+
agent = await openAgentRetrying(sandboxEnabled);
|
|
52617
52914
|
} catch (error51) {
|
|
52618
|
-
|
|
52915
|
+
if (!isCloud && sandboxEnabled && isCursorSandboxUnsupportedError(error51)) {
|
|
52916
|
+
log2.warn(
|
|
52917
|
+
"[CursorRuntime] Cursor SDK rejected local sandbox; retrying with sandbox disabled"
|
|
52918
|
+
);
|
|
52919
|
+
tracer.runtime("sandbox_fallback", {
|
|
52920
|
+
sessionId: opts.sessionId,
|
|
52921
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
52922
|
+
}, opts.sessionId);
|
|
52923
|
+
sandboxEnabled = false;
|
|
52924
|
+
try {
|
|
52925
|
+
agent = await openAgentRetrying(false);
|
|
52926
|
+
} catch (retryError) {
|
|
52927
|
+
throw formatCursorError(retryError);
|
|
52928
|
+
}
|
|
52929
|
+
} else {
|
|
52930
|
+
throw formatCursorError(error51);
|
|
52931
|
+
}
|
|
52619
52932
|
}
|
|
52933
|
+
log2.info("[CursorRuntime] agent ready", {
|
|
52934
|
+
agentId: agent.agentId,
|
|
52935
|
+
ms: Date.now() - createStarted,
|
|
52936
|
+
sandboxEnabled
|
|
52937
|
+
});
|
|
52938
|
+
tracer.runtime("agent_ready", {
|
|
52939
|
+
agentId: agent.agentId,
|
|
52940
|
+
ms: Date.now() - createStarted,
|
|
52941
|
+
sandboxEnabled
|
|
52942
|
+
}, opts.sessionId);
|
|
52620
52943
|
opts.onProviderSessionId?.(agent.agentId);
|
|
52621
52944
|
opts.onEvent({ type: "provider_session_id", providerSessionId: agent.agentId });
|
|
52622
52945
|
let currentRun = null;
|
|
@@ -52674,18 +52997,28 @@ async function createCursorRuntime(opts) {
|
|
|
52674
52997
|
lastMcpServers = servers;
|
|
52675
52998
|
const contextWindow = resolveContextWindow(modelSelection);
|
|
52676
52999
|
const callIdBridge = new CursorTurnCallIdBridge();
|
|
53000
|
+
const sendStarted = Date.now();
|
|
53001
|
+
log2.info("[CursorRuntime] send start", { messageId });
|
|
53002
|
+
tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
|
|
53003
|
+
tracer.runtime("send_start", {
|
|
53004
|
+
messageId,
|
|
53005
|
+
model: modelSelection?.id ?? null,
|
|
53006
|
+
force: Boolean(sendOpts?.force)
|
|
53007
|
+
}, messageId);
|
|
52677
53008
|
const sendOptions = {
|
|
52678
53009
|
...modelSelection ? { model: modelSelection } : {},
|
|
52679
53010
|
mode: permLocal.mode,
|
|
52680
53011
|
mcpServers: Object.keys(servers).length ? servers : void 0,
|
|
52681
53012
|
...sendOpts?.idempotencyKey ? { idempotencyKey: sendOpts.idempotencyKey } : {},
|
|
52682
53013
|
onDelta: ({ update }) => {
|
|
53014
|
+
tracer.sdk(cursorSdkType(update, "delta"), update, messageId);
|
|
52683
53015
|
callIdBridge.observeDelta(update);
|
|
52684
53016
|
for (const event of mapInteractionUpdate(messageId, update, { contextWindow })) {
|
|
52685
53017
|
opts.onEvent(event);
|
|
52686
53018
|
}
|
|
52687
53019
|
},
|
|
52688
53020
|
onStep: ({ step }) => {
|
|
53021
|
+
tracer.sdk(cursorSdkType(step, "step"), step, messageId);
|
|
52689
53022
|
for (const event of mapConversationStep(messageId, step, {
|
|
52690
53023
|
resolveCallId: () => callIdBridge.claimNextCallId()
|
|
52691
53024
|
})) {
|
|
@@ -52706,28 +53039,54 @@ async function createCursorRuntime(opts) {
|
|
|
52706
53039
|
} catch (error51) {
|
|
52707
53040
|
if (error51 instanceof AgentBusyError && !sendOpts?.force && !isCloud) {
|
|
52708
53041
|
log2.warn("[CursorRuntime] AgentBusyError \u2014 retrying with local.force");
|
|
53042
|
+
tracer.runtime("agent_busy_retry", {
|
|
53043
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
53044
|
+
}, messageId);
|
|
52709
53045
|
try {
|
|
52710
53046
|
run = await agent.send(userMessage2, {
|
|
52711
53047
|
...sendOptions,
|
|
52712
53048
|
local: { force: true }
|
|
52713
53049
|
});
|
|
52714
53050
|
} catch (retryError) {
|
|
53051
|
+
tracer.runtime("send_error", {
|
|
53052
|
+
message: retryError instanceof Error ? retryError.message : String(retryError),
|
|
53053
|
+
name: retryError instanceof Error ? retryError.name : "Error",
|
|
53054
|
+
afterForce: true
|
|
53055
|
+
}, messageId);
|
|
52715
53056
|
throw formatCursorError(retryError);
|
|
52716
53057
|
}
|
|
52717
53058
|
} else {
|
|
53059
|
+
tracer.runtime("send_error", {
|
|
53060
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53061
|
+
name: error51 instanceof Error ? error51.name : "Error",
|
|
53062
|
+
ms: Date.now() - sendStarted
|
|
53063
|
+
}, messageId);
|
|
52718
53064
|
throw formatCursorError(error51);
|
|
52719
53065
|
}
|
|
52720
53066
|
}
|
|
52721
53067
|
currentRun = run;
|
|
52722
53068
|
lastRunId = run.id;
|
|
52723
|
-
log2.
|
|
53069
|
+
log2.info("[CursorRuntime] run started", {
|
|
53070
|
+
runId: run.id,
|
|
53071
|
+
agentId: run.agentId,
|
|
53072
|
+
ms: Date.now() - sendStarted
|
|
53073
|
+
});
|
|
53074
|
+
tracer.runtime("run_started", {
|
|
53075
|
+
runId: run.id,
|
|
53076
|
+
agentId: run.agentId,
|
|
53077
|
+
ms: Date.now() - sendStarted
|
|
53078
|
+
}, messageId);
|
|
52724
53079
|
void (async () => {
|
|
52725
53080
|
try {
|
|
52726
53081
|
if (!run.supports("stream")) {
|
|
52727
53082
|
log2.debug("[CursorRuntime] stream unsupported:", run.unsupportedReason("stream"));
|
|
53083
|
+
tracer.runtime("stream_unsupported", {
|
|
53084
|
+
reason: run.unsupportedReason("stream") ?? null
|
|
53085
|
+
}, messageId);
|
|
52728
53086
|
return;
|
|
52729
53087
|
}
|
|
52730
53088
|
for await (const message of run.stream()) {
|
|
53089
|
+
tracer.sdk(cursorSdkType(message, "stream"), message, messageId);
|
|
52731
53090
|
for (const event of mapSdkMessageLifecycle(messageId, message, {
|
|
52732
53091
|
includeContent: false,
|
|
52733
53092
|
contextWindow
|
|
@@ -52737,9 +53096,23 @@ async function createCursorRuntime(opts) {
|
|
|
52737
53096
|
}
|
|
52738
53097
|
} catch (error51) {
|
|
52739
53098
|
log2.debug("[CursorRuntime] stream consumer ended:", error51);
|
|
53099
|
+
tracer.runtime("stream_error", {
|
|
53100
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53101
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
53102
|
+
}, messageId);
|
|
52740
53103
|
}
|
|
52741
53104
|
})();
|
|
52742
|
-
|
|
53105
|
+
let result;
|
|
53106
|
+
try {
|
|
53107
|
+
result = await run.wait();
|
|
53108
|
+
} catch (error51) {
|
|
53109
|
+
tracer.runtime("wait_error", {
|
|
53110
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53111
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
53112
|
+
}, messageId);
|
|
53113
|
+
throw formatCursorError(error51);
|
|
53114
|
+
}
|
|
53115
|
+
tracer.sdk("result", result, messageId);
|
|
52743
53116
|
currentRun = null;
|
|
52744
53117
|
lastRunId = result.id || lastRunId;
|
|
52745
53118
|
if (result.usage) {
|
|
@@ -52816,10 +53189,14 @@ var init_cursor_runtime = __esm({
|
|
|
52816
53189
|
"../../packages/cursor/src/cursor-runtime.ts"() {
|
|
52817
53190
|
"use strict";
|
|
52818
53191
|
init_cursor_config();
|
|
53192
|
+
init_cursor_local_options();
|
|
53193
|
+
init_cursor_network_retry();
|
|
52819
53194
|
init_cursor_custom_tools();
|
|
52820
53195
|
init_cursor_event_map();
|
|
52821
53196
|
init_cursor_mcp_map();
|
|
52822
53197
|
init_cursor_model_selection();
|
|
53198
|
+
init_cursor_platform_binaries();
|
|
53199
|
+
init_cursor_sdk_trace();
|
|
52823
53200
|
init_cursor_store();
|
|
52824
53201
|
noopLog = {
|
|
52825
53202
|
info: () => void 0,
|
|
@@ -52840,6 +53217,25 @@ var init_cursor_runtime = __esm({
|
|
|
52840
53217
|
}
|
|
52841
53218
|
});
|
|
52842
53219
|
|
|
53220
|
+
// ../../packages/cursor/src/cursor-workspace-prewarm.ts
|
|
53221
|
+
import { createAgentPlatform } from "@cursor/sdk";
|
|
53222
|
+
var init_cursor_workspace_prewarm = __esm({
|
|
53223
|
+
"../../packages/cursor/src/cursor-workspace-prewarm.ts"() {
|
|
53224
|
+
"use strict";
|
|
53225
|
+
init_cursor_sdk_trace();
|
|
53226
|
+
init_cursor_local_options();
|
|
53227
|
+
init_cursor_platform_binaries();
|
|
53228
|
+
}
|
|
53229
|
+
});
|
|
53230
|
+
|
|
53231
|
+
// ../../packages/cursor/src/cursor-skills-discover.ts
|
|
53232
|
+
var init_cursor_skills_discover = __esm({
|
|
53233
|
+
"../../packages/cursor/src/cursor-skills-discover.ts"() {
|
|
53234
|
+
"use strict";
|
|
53235
|
+
init_fs();
|
|
53236
|
+
}
|
|
53237
|
+
});
|
|
53238
|
+
|
|
52843
53239
|
// ../../packages/cursor/src/run-sdk-turn.ts
|
|
52844
53240
|
async function runCursorSdkTurn(opts) {
|
|
52845
53241
|
if (opts.signal?.aborted) {
|
|
@@ -52966,6 +53362,7 @@ var init_src5 = __esm({
|
|
|
52966
53362
|
"use strict";
|
|
52967
53363
|
init_cursor_config();
|
|
52968
53364
|
init_cursor_sdk_available();
|
|
53365
|
+
init_cursor_platform_binaries();
|
|
52969
53366
|
init_cursor_mcp_map();
|
|
52970
53367
|
init_cursor_custom_tools();
|
|
52971
53368
|
init_cursor_event_map();
|
|
@@ -52975,6 +53372,10 @@ var init_src5 = __esm({
|
|
|
52975
53372
|
init_cursor_cloud();
|
|
52976
53373
|
init_cursor_sdk_auth();
|
|
52977
53374
|
init_cursor_runtime();
|
|
53375
|
+
init_cursor_sdk_trace();
|
|
53376
|
+
init_cursor_workspace_prewarm();
|
|
53377
|
+
init_cursor_skills_discover();
|
|
53378
|
+
init_cursor_network_retry();
|
|
52978
53379
|
init_run_sdk_turn2();
|
|
52979
53380
|
init_simulated_runner3();
|
|
52980
53381
|
}
|
|
@@ -53188,7 +53589,7 @@ var init_codex_live_turn = __esm({
|
|
|
53188
53589
|
});
|
|
53189
53590
|
|
|
53190
53591
|
// src/session/codex-turn-runner.ts
|
|
53191
|
-
import { existsSync as
|
|
53592
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
53192
53593
|
function mapCodexReasoningEffort(effort) {
|
|
53193
53594
|
if (!effort) return void 0;
|
|
53194
53595
|
const e = effort.trim().toLowerCase();
|
|
@@ -53199,18 +53600,18 @@ function mapCodexReasoningEffort(effort) {
|
|
|
53199
53600
|
return void 0;
|
|
53200
53601
|
}
|
|
53201
53602
|
function resolveCodexBinaryPath(opts) {
|
|
53202
|
-
if (opts.binaryPath &&
|
|
53603
|
+
if (opts.binaryPath && existsSync22(opts.binaryPath)) return opts.binaryPath;
|
|
53203
53604
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
53204
|
-
if (fromEnv &&
|
|
53605
|
+
if (fromEnv && existsSync22(fromEnv)) return fromEnv;
|
|
53205
53606
|
const status = opts.harnesses?.get("codex");
|
|
53206
|
-
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command &&
|
|
53607
|
+
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync22(status.command)) {
|
|
53207
53608
|
return status.command;
|
|
53208
53609
|
}
|
|
53209
53610
|
return null;
|
|
53210
53611
|
}
|
|
53211
53612
|
function isCodexBinaryOverrideRunnable() {
|
|
53212
53613
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
53213
|
-
return Boolean(fromEnv &&
|
|
53614
|
+
return Boolean(fromEnv && existsSync22(fromEnv));
|
|
53214
53615
|
}
|
|
53215
53616
|
function providerEnvKeyOf(env) {
|
|
53216
53617
|
return [
|
|
@@ -60655,8 +61056,8 @@ import { fileURLToPath } from "node:url";
|
|
|
60655
61056
|
function resolveCliReleaseVersion() {
|
|
60656
61057
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
60657
61058
|
if (fromEnv) return fromEnv;
|
|
60658
|
-
if ("0.53.
|
|
60659
|
-
return "0.53.
|
|
61059
|
+
if ("0.53.3-alpha".trim()) {
|
|
61060
|
+
return "0.53.3-alpha".trim();
|
|
60660
61061
|
}
|
|
60661
61062
|
const fromDist = readDistManifestVersion();
|
|
60662
61063
|
if (fromDist) return fromDist;
|
|
@@ -60906,7 +61307,7 @@ function regenerateIdentity(nodeHome, label) {
|
|
|
60906
61307
|
}
|
|
60907
61308
|
|
|
60908
61309
|
// src/runtime.ts
|
|
60909
|
-
import { existsSync as
|
|
61310
|
+
import { existsSync as existsSync40, readFileSync as readFileSync19, writeFileSync as writeFileSync17 } from "node:fs";
|
|
60910
61311
|
|
|
60911
61312
|
// src/auth/auth-service.ts
|
|
60912
61313
|
init_environment();
|
|
@@ -62400,11 +62801,11 @@ function parseState(raw) {
|
|
|
62400
62801
|
|
|
62401
62802
|
// ../../packages/runtime/src/harness/home-path.ts
|
|
62402
62803
|
import { homedir as homedir6 } from "node:os";
|
|
62403
|
-
import { join as
|
|
62804
|
+
import { join as join20 } from "node:path";
|
|
62404
62805
|
var HARNESS_HOME_DIRNAME = "harness";
|
|
62405
62806
|
var SUPERONE_DIRNAME = ".superone";
|
|
62406
62807
|
function defaultHarnessHomeRoot(userHome = homedir6()) {
|
|
62407
|
-
return
|
|
62808
|
+
return join20(userHome, SUPERONE_DIRNAME, HARNESS_HOME_DIRNAME);
|
|
62408
62809
|
}
|
|
62409
62810
|
function resolveHarnessHomeRoot(opts = {}) {
|
|
62410
62811
|
const explicit = opts.override?.trim();
|
|
@@ -62418,16 +62819,16 @@ function resolveHarnessHomeRoot(opts = {}) {
|
|
|
62418
62819
|
|
|
62419
62820
|
// ../../packages/runtime/src/harness/managed-layout.ts
|
|
62420
62821
|
import {
|
|
62421
|
-
existsSync as
|
|
62822
|
+
existsSync as existsSync23,
|
|
62422
62823
|
mkdirSync as mkdirSync12,
|
|
62423
62824
|
readdirSync as readdirSync8,
|
|
62424
62825
|
readFileSync as readFileSync13,
|
|
62425
62826
|
renameSync as renameSync2,
|
|
62426
62827
|
rmSync as rmSync2,
|
|
62427
|
-
statSync as
|
|
62828
|
+
statSync as statSync6,
|
|
62428
62829
|
writeFileSync as writeFileSync9
|
|
62429
62830
|
} from "node:fs";
|
|
62430
|
-
import { join as
|
|
62831
|
+
import { join as join21 } from "node:path";
|
|
62431
62832
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
62432
62833
|
var MANAGED_VERSIONS_DIRNAME = "versions";
|
|
62433
62834
|
var MANAGED_CURRENT_BASENAME = "current";
|
|
@@ -62444,17 +62845,17 @@ function sanitizeRuntimeVersionForPath(runtimeVersion) {
|
|
|
62444
62845
|
return v2;
|
|
62445
62846
|
}
|
|
62446
62847
|
function managedVersionsDir(prefix) {
|
|
62447
|
-
return
|
|
62848
|
+
return join21(prefix, MANAGED_VERSIONS_DIRNAME);
|
|
62448
62849
|
}
|
|
62449
62850
|
function managedVersionDir(prefix, runtimeVersion) {
|
|
62450
|
-
return
|
|
62851
|
+
return join21(managedVersionsDir(prefix), sanitizeRuntimeVersionForPath(runtimeVersion));
|
|
62451
62852
|
}
|
|
62452
62853
|
function managedCurrentPath(prefix) {
|
|
62453
|
-
return
|
|
62854
|
+
return join21(prefix, MANAGED_CURRENT_BASENAME);
|
|
62454
62855
|
}
|
|
62455
62856
|
function readCurrentPointer(prefix) {
|
|
62456
62857
|
const path = managedCurrentPath(prefix);
|
|
62457
|
-
if (!
|
|
62858
|
+
if (!existsSync23(path)) return null;
|
|
62458
62859
|
try {
|
|
62459
62860
|
const raw = JSON.parse(readFileSync13(path, "utf8"));
|
|
62460
62861
|
if (typeof raw.runtimeVersion !== "string" || !raw.runtimeVersion.trim()) return null;
|
|
@@ -62480,7 +62881,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62480
62881
|
null,
|
|
62481
62882
|
2
|
|
62482
62883
|
);
|
|
62483
|
-
const tmp =
|
|
62884
|
+
const tmp = join21(
|
|
62484
62885
|
prefix,
|
|
62485
62886
|
`.${MANAGED_CURRENT_BASENAME}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`
|
|
62486
62887
|
);
|
|
@@ -62489,7 +62890,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62489
62890
|
renameSync2(tmp, path);
|
|
62490
62891
|
} catch {
|
|
62491
62892
|
try {
|
|
62492
|
-
if (
|
|
62893
|
+
if (existsSync23(path)) rmSync2(path, { force: true });
|
|
62493
62894
|
renameSync2(tmp, path);
|
|
62494
62895
|
} catch {
|
|
62495
62896
|
writeFileSync9(path, body);
|
|
@@ -62501,26 +62902,26 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62501
62902
|
}
|
|
62502
62903
|
}
|
|
62503
62904
|
function resolveActiveInstallRoot(prefix) {
|
|
62504
|
-
if (!prefix || !
|
|
62905
|
+
if (!prefix || !existsSync23(prefix)) return null;
|
|
62505
62906
|
const pointer = readCurrentPointer(prefix);
|
|
62506
62907
|
if (pointer) {
|
|
62507
|
-
if (pointer.installRoot &&
|
|
62908
|
+
if (pointer.installRoot && existsSync23(pointer.installRoot) && statSync6(pointer.installRoot).isDirectory()) {
|
|
62508
62909
|
return pointer.installRoot;
|
|
62509
62910
|
}
|
|
62510
62911
|
const dir = managedVersionDir(prefix, pointer.runtimeVersion);
|
|
62511
|
-
if (
|
|
62912
|
+
if (existsSync23(dir) && statSync6(dir).isDirectory()) return dir;
|
|
62512
62913
|
}
|
|
62513
62914
|
const versionsRoot = managedVersionsDir(prefix);
|
|
62514
|
-
if (
|
|
62915
|
+
if (existsSync23(versionsRoot)) {
|
|
62515
62916
|
try {
|
|
62516
62917
|
const kids = readdirSync8(versionsRoot).filter((n) => {
|
|
62517
62918
|
try {
|
|
62518
|
-
return
|
|
62919
|
+
return statSync6(join21(versionsRoot, n)).isDirectory();
|
|
62519
62920
|
} catch {
|
|
62520
62921
|
return false;
|
|
62521
62922
|
}
|
|
62522
62923
|
});
|
|
62523
|
-
if (kids.length === 1) return
|
|
62924
|
+
if (kids.length === 1) return join21(versionsRoot, kids[0]);
|
|
62524
62925
|
} catch {
|
|
62525
62926
|
}
|
|
62526
62927
|
}
|
|
@@ -62528,7 +62929,7 @@ function resolveActiveInstallRoot(prefix) {
|
|
|
62528
62929
|
}
|
|
62529
62930
|
function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
62530
62931
|
const versionsRoot = managedVersionsDir(prefix);
|
|
62531
|
-
if (!
|
|
62932
|
+
if (!existsSync23(versionsRoot)) return;
|
|
62532
62933
|
const keepSet = new Set(
|
|
62533
62934
|
keep.filter(Boolean).map((v2) => {
|
|
62534
62935
|
try {
|
|
@@ -62542,7 +62943,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62542
62943
|
try {
|
|
62543
62944
|
entries = readdirSync8(versionsRoot).map((name) => {
|
|
62544
62945
|
try {
|
|
62545
|
-
const st =
|
|
62946
|
+
const st = statSync6(join21(versionsRoot, name));
|
|
62546
62947
|
if (!st.isDirectory()) return null;
|
|
62547
62948
|
return { name, mtime: st.mtimeMs };
|
|
62548
62949
|
} catch {
|
|
@@ -62561,7 +62962,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62561
62962
|
}
|
|
62562
62963
|
for (const e of entries) {
|
|
62563
62964
|
if (retain.has(e.name)) continue;
|
|
62564
|
-
const dir =
|
|
62965
|
+
const dir = join21(versionsRoot, e.name);
|
|
62565
62966
|
try {
|
|
62566
62967
|
rmSync2(dir, { recursive: true, force: true });
|
|
62567
62968
|
} catch {
|
|
@@ -62573,17 +62974,17 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62573
62974
|
import {
|
|
62574
62975
|
copyFileSync,
|
|
62575
62976
|
createReadStream,
|
|
62576
|
-
existsSync as
|
|
62977
|
+
existsSync as existsSync24,
|
|
62577
62978
|
mkdirSync as mkdirSync13,
|
|
62578
62979
|
mkdtempSync,
|
|
62579
62980
|
readFileSync as readFileSync14,
|
|
62580
62981
|
renameSync as renameSync3,
|
|
62581
62982
|
rmSync as rmSync3,
|
|
62582
|
-
statSync as
|
|
62983
|
+
statSync as statSync7,
|
|
62583
62984
|
writeFileSync as writeFileSync10
|
|
62584
62985
|
} from "node:fs";
|
|
62585
62986
|
import { createHash as createHash5, randomBytes as randomBytes4 } from "node:crypto";
|
|
62586
|
-
import { dirname as
|
|
62987
|
+
import { dirname as dirname12, join as join22, relative, resolve as resolve4, sep as sep3 } from "node:path";
|
|
62587
62988
|
import { arch as osArch, platform as osPlatform } from "node:os";
|
|
62588
62989
|
var releaseVersionProvider = null;
|
|
62589
62990
|
function setHarnessReleaseVersionProvider(fn) {
|
|
@@ -62727,13 +63128,13 @@ function parseManagedHarnessPin(id, raw) {
|
|
|
62727
63128
|
function loadHarnessReleaseManifest(nodeHome) {
|
|
62728
63129
|
const fromEnv = process.env.SUPERONE_HARNESS_MANIFEST;
|
|
62729
63130
|
if (fromEnv) {
|
|
62730
|
-
if (!
|
|
63131
|
+
if (!existsSync24(fromEnv)) {
|
|
62731
63132
|
throw new Error(`SUPERONE_HARNESS_MANIFEST not found: ${fromEnv}`);
|
|
62732
63133
|
}
|
|
62733
63134
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync14(fromEnv, "utf8")));
|
|
62734
63135
|
}
|
|
62735
|
-
const local =
|
|
62736
|
-
if (
|
|
63136
|
+
const local = join22(nodeHome, "release-manifest.json");
|
|
63137
|
+
if (existsSync24(local)) {
|
|
62737
63138
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync14(local, "utf8")));
|
|
62738
63139
|
}
|
|
62739
63140
|
return null;
|
|
@@ -62802,10 +63203,10 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62802
63203
|
throw new Error(`release manifest does not pin managed harness ${opts.harnessId}`);
|
|
62803
63204
|
}
|
|
62804
63205
|
const art = selectArtifactPin(pin);
|
|
62805
|
-
if (!
|
|
63206
|
+
if (!existsSync24(opts.artifactPath)) {
|
|
62806
63207
|
throw new Error(`artifact not found: ${opts.artifactPath}`);
|
|
62807
63208
|
}
|
|
62808
|
-
if (!
|
|
63209
|
+
if (!statSync7(opts.artifactPath).isFile()) {
|
|
62809
63210
|
throw new Error(`artifact is not a regular file: ${opts.artifactPath}`);
|
|
62810
63211
|
}
|
|
62811
63212
|
const digest = await sha256File(opts.artifactPath);
|
|
@@ -62820,8 +63221,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62820
63221
|
opts.harnessId,
|
|
62821
63222
|
pin.artifactVersion
|
|
62822
63223
|
);
|
|
62823
|
-
const finalFile =
|
|
62824
|
-
const metaPath =
|
|
63224
|
+
const finalFile = join22(destDir, MANAGED_PAYLOAD_BASENAME);
|
|
63225
|
+
const metaPath = join22(destDir, MANAGED_META_BASENAME);
|
|
62825
63226
|
assertStrictChild(finalFile, destDir, "payload path");
|
|
62826
63227
|
assertStrictChild(metaPath, destDir, "meta path");
|
|
62827
63228
|
const metaBody = JSON.stringify(
|
|
@@ -62840,8 +63241,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62840
63241
|
2
|
|
62841
63242
|
);
|
|
62842
63243
|
let reusedExisting = false;
|
|
62843
|
-
if (
|
|
62844
|
-
const payloadOk =
|
|
63244
|
+
if (existsSync24(destDir)) {
|
|
63245
|
+
const payloadOk = existsSync24(finalFile) && statSync7(finalFile).isFile() && await sha256File(finalFile) === art.digestSha256;
|
|
62845
63246
|
if (payloadOk) {
|
|
62846
63247
|
reusedExisting = true;
|
|
62847
63248
|
} else if (mode === "repair") {
|
|
@@ -62860,15 +63261,15 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62860
63261
|
);
|
|
62861
63262
|
}
|
|
62862
63263
|
} else {
|
|
62863
|
-
const harnessRoot2 =
|
|
63264
|
+
const harnessRoot2 = dirname12(destDir);
|
|
62864
63265
|
mkdirSync13(harnessRoot2, { recursive: true });
|
|
62865
63266
|
assertPathInside(destDir, harnessRoot2, "version dir");
|
|
62866
63267
|
const stagingDir = mkdtempSync(
|
|
62867
|
-
|
|
63268
|
+
join22(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes4(8).toString("hex")}-`)
|
|
62868
63269
|
);
|
|
62869
63270
|
assertPathInside(stagingDir, harnessRoot2, "staging dir");
|
|
62870
|
-
const stagingFile =
|
|
62871
|
-
const stagingMeta =
|
|
63271
|
+
const stagingFile = join22(stagingDir, MANAGED_PAYLOAD_BASENAME);
|
|
63272
|
+
const stagingMeta = join22(stagingDir, MANAGED_META_BASENAME);
|
|
62872
63273
|
try {
|
|
62873
63274
|
copyFileSync(opts.artifactPath, stagingFile);
|
|
62874
63275
|
const stagedDigest = await sha256File(stagingFile);
|
|
@@ -62879,7 +63280,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62879
63280
|
renameSync3(stagingDir, destDir);
|
|
62880
63281
|
} catch (err) {
|
|
62881
63282
|
rmSync3(stagingDir, { recursive: true, force: true });
|
|
62882
|
-
if (
|
|
63283
|
+
if (existsSync24(destDir) && existsSync24(finalFile)) {
|
|
62883
63284
|
const existingDigest = await sha256File(finalFile);
|
|
62884
63285
|
if (existingDigest === art.digestSha256) {
|
|
62885
63286
|
reusedExisting = true;
|
|
@@ -62904,7 +63305,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62904
63305
|
if (finalDigest !== art.digestSha256) {
|
|
62905
63306
|
throw new Error(`final payload digest mismatch for ${opts.harnessId}`);
|
|
62906
63307
|
}
|
|
62907
|
-
const harnessRoot =
|
|
63308
|
+
const harnessRoot = join22(
|
|
62908
63309
|
releasesRoot(opts.nodeHome),
|
|
62909
63310
|
opts.manifest.cliVersion,
|
|
62910
63311
|
"harnesses",
|
|
@@ -62912,8 +63313,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62912
63313
|
);
|
|
62913
63314
|
assertPathInside(harnessRoot, releasesRoot(opts.nodeHome), "harness root");
|
|
62914
63315
|
mkdirSync13(harnessRoot, { recursive: true });
|
|
62915
|
-
const currentPath =
|
|
62916
|
-
const currentTmp =
|
|
63316
|
+
const currentPath = join22(harnessRoot, MANAGED_CURRENT_BASENAME2);
|
|
63317
|
+
const currentTmp = join22(
|
|
62917
63318
|
harnessRoot,
|
|
62918
63319
|
`.${MANAGED_CURRENT_BASENAME2}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`
|
|
62919
63320
|
);
|
|
@@ -62952,8 +63353,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62952
63353
|
async function replacePayloadAtomically(opts) {
|
|
62953
63354
|
mkdirSync13(opts.destDir, { recursive: true });
|
|
62954
63355
|
const nonce = randomBytes4(8).toString("hex");
|
|
62955
|
-
const payloadTmp =
|
|
62956
|
-
const metaTmp =
|
|
63356
|
+
const payloadTmp = join22(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
|
|
63357
|
+
const metaTmp = join22(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
|
|
62957
63358
|
assertStrictChild(payloadTmp, opts.destDir, "payload temp");
|
|
62958
63359
|
assertStrictChild(metaTmp, opts.destDir, "meta temp");
|
|
62959
63360
|
try {
|
|
@@ -62987,12 +63388,33 @@ function requiredRuntimeVersion(harnessId, manifest) {
|
|
|
62987
63388
|
}
|
|
62988
63389
|
|
|
62989
63390
|
// ../../packages/runtime/src/harness/managed-official.ts
|
|
62990
|
-
import { existsSync as
|
|
63391
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync9, statSync as statSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
62991
63392
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
62992
|
-
import { join as
|
|
63393
|
+
import { join as join23, resolve as resolve5 } from "node:path";
|
|
62993
63394
|
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.226";
|
|
62994
|
-
var OFFICIAL_CODEX_NPM_VERSION = "0.
|
|
63395
|
+
var OFFICIAL_CODEX_NPM_VERSION = "0.147.0";
|
|
62995
63396
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
63397
|
+
function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
63398
|
+
const platform2 = process.platform;
|
|
63399
|
+
const arch2 = process.arch;
|
|
63400
|
+
if (arch2 !== "arm64" && arch2 !== "x64") {
|
|
63401
|
+
throw new Error(`unsupported arch for Codex: ${arch2}`);
|
|
63402
|
+
}
|
|
63403
|
+
const suffix = platform2 === "darwin" ? `darwin-${arch2}` : platform2 === "linux" ? `linux-${arch2}` : platform2 === "win32" ? `win32-${arch2}` : null;
|
|
63404
|
+
if (!suffix) throw new Error(`unsupported platform for Codex: ${platform2}`);
|
|
63405
|
+
return `${baseVersion}-${suffix}`;
|
|
63406
|
+
}
|
|
63407
|
+
function codexTargetTriple() {
|
|
63408
|
+
const triples = {
|
|
63409
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
63410
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
63411
|
+
"linux-arm64": "aarch64-unknown-linux-musl",
|
|
63412
|
+
"linux-x64": "x86_64-unknown-linux-musl",
|
|
63413
|
+
"win32-arm64": "aarch64-pc-windows-msvc",
|
|
63414
|
+
"win32-x64": "x86_64-pc-windows-msvc"
|
|
63415
|
+
};
|
|
63416
|
+
return triples[`${process.platform}-${process.arch}`] ?? null;
|
|
63417
|
+
}
|
|
62996
63418
|
function managedHarnessPrefix(nodeHome, harnessId) {
|
|
62997
63419
|
return resolve5(nodeHome, harnessId);
|
|
62998
63420
|
}
|
|
@@ -63012,7 +63434,7 @@ function claudePlatformPackageName() {
|
|
|
63012
63434
|
}
|
|
63013
63435
|
function isMuslLinux() {
|
|
63014
63436
|
try {
|
|
63015
|
-
if (
|
|
63437
|
+
if (existsSync25("/etc/alpine-release")) return true;
|
|
63016
63438
|
const lib = readdirSync9("/lib").some((n) => n.startsWith("ld-musl"));
|
|
63017
63439
|
if (lib) return true;
|
|
63018
63440
|
} catch {
|
|
@@ -63020,42 +63442,49 @@ function isMuslLinux() {
|
|
|
63020
63442
|
return false;
|
|
63021
63443
|
}
|
|
63022
63444
|
function resolveOfficialInstallBinaryInRoot(harnessId, installRoot) {
|
|
63023
|
-
if (!installRoot || !
|
|
63445
|
+
if (!installRoot || !existsSync25(installRoot)) return null;
|
|
63024
63446
|
if (harnessId === "codex") {
|
|
63447
|
+
const triple = codexTargetTriple();
|
|
63448
|
+
const nativeName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
63025
63449
|
const candidates = [
|
|
63026
|
-
|
|
63027
|
-
|
|
63028
|
-
|
|
63450
|
+
join23(installRoot, "bin", "codex"),
|
|
63451
|
+
join23(installRoot, "bin", "codex.cmd"),
|
|
63452
|
+
join23(installRoot, "lib", "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
63453
|
+
join23(installRoot, "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
63454
|
+
...triple ? [
|
|
63455
|
+
join23(installRoot, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName),
|
|
63456
|
+
join23(installRoot, "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName)
|
|
63457
|
+
] : []
|
|
63029
63458
|
];
|
|
63030
63459
|
for (const c of candidates) {
|
|
63031
|
-
if (
|
|
63460
|
+
if (existsSync25(c) && (c.endsWith(".js") || isExecutableFile2(c))) return c;
|
|
63032
63461
|
}
|
|
63033
63462
|
return null;
|
|
63034
63463
|
}
|
|
63035
|
-
const nm =
|
|
63036
|
-
const scoped =
|
|
63464
|
+
const nm = join23(installRoot, "lib", "node_modules");
|
|
63465
|
+
const scoped = join23(nm, "@anthropic-ai");
|
|
63037
63466
|
try {
|
|
63038
|
-
if (
|
|
63467
|
+
if (existsSync25(scoped)) {
|
|
63039
63468
|
const names = readdirSync9(scoped).filter((n) => n.startsWith("claude-agent-sdk-"));
|
|
63040
63469
|
for (const n of names) {
|
|
63041
63470
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
63042
|
-
const bin =
|
|
63043
|
-
if (
|
|
63471
|
+
const bin = join23(scoped, n, `claude${ext}`);
|
|
63472
|
+
if (existsSync25(bin)) return bin;
|
|
63044
63473
|
}
|
|
63045
63474
|
}
|
|
63046
63475
|
} catch {
|
|
63047
63476
|
}
|
|
63048
|
-
const direct =
|
|
63477
|
+
const direct = join23(
|
|
63049
63478
|
nm,
|
|
63050
63479
|
...claudePlatformPackageName().split("/"),
|
|
63051
63480
|
process.platform === "win32" ? "claude.exe" : "claude"
|
|
63052
63481
|
);
|
|
63053
|
-
if (
|
|
63482
|
+
if (existsSync25(direct)) return direct;
|
|
63054
63483
|
return null;
|
|
63055
63484
|
}
|
|
63056
|
-
function
|
|
63485
|
+
function isExecutableFile2(path) {
|
|
63057
63486
|
try {
|
|
63058
|
-
const st =
|
|
63487
|
+
const st = statSync8(path);
|
|
63059
63488
|
if (!st.isFile()) return false;
|
|
63060
63489
|
if (process.platform === "win32") return true;
|
|
63061
63490
|
return (st.mode & 73) !== 0;
|
|
@@ -63065,7 +63494,7 @@ function isExecutableFile(path) {
|
|
|
63065
63494
|
}
|
|
63066
63495
|
|
|
63067
63496
|
// ../../packages/runtime/src/harness/tarball-fetch.ts
|
|
63068
|
-
import { existsSync as
|
|
63497
|
+
import { existsSync as existsSync26, rmSync as rmSync4 } from "node:fs";
|
|
63069
63498
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
63070
63499
|
function assertSha256(actualHex, expectedHex) {
|
|
63071
63500
|
if (actualHex !== expectedHex.toLowerCase()) {
|
|
@@ -63083,7 +63512,7 @@ function assertSha512Integrity(actualBase64, integrity) {
|
|
|
63083
63512
|
}
|
|
63084
63513
|
function discardPartial(destPath) {
|
|
63085
63514
|
try {
|
|
63086
|
-
if (
|
|
63515
|
+
if (existsSync26(destPath)) rmSync4(destPath, { force: true });
|
|
63087
63516
|
} catch {
|
|
63088
63517
|
}
|
|
63089
63518
|
}
|
|
@@ -63164,13 +63593,13 @@ import {
|
|
|
63164
63593
|
appendFileSync,
|
|
63165
63594
|
createReadStream as createReadStream2,
|
|
63166
63595
|
createWriteStream,
|
|
63167
|
-
existsSync as
|
|
63596
|
+
existsSync as existsSync27,
|
|
63168
63597
|
mkdirSync as mkdirSync15,
|
|
63169
63598
|
rmSync as rmSync5,
|
|
63170
|
-
statSync as
|
|
63599
|
+
statSync as statSync9,
|
|
63171
63600
|
writeFileSync as writeFileSync12
|
|
63172
63601
|
} from "node:fs";
|
|
63173
|
-
import { dirname as
|
|
63602
|
+
import { dirname as dirname13 } from "node:path";
|
|
63174
63603
|
import { pipeline } from "node:stream/promises";
|
|
63175
63604
|
import { Readable as Readable2, Transform } from "node:stream";
|
|
63176
63605
|
var HARNESS_PROGRESS_THROTTLE_MS = 200;
|
|
@@ -63199,7 +63628,7 @@ function parseContentRange(header) {
|
|
|
63199
63628
|
async function seedHashesFromFile(path) {
|
|
63200
63629
|
const sha256 = createHash6("sha256");
|
|
63201
63630
|
const sha512 = createHash6("sha512");
|
|
63202
|
-
const size =
|
|
63631
|
+
const size = statSync9(path).size;
|
|
63203
63632
|
if (size === 0) return { sha256, sha512, size };
|
|
63204
63633
|
await new Promise((resolve13, reject) => {
|
|
63205
63634
|
const stream = createReadStream2(path);
|
|
@@ -63231,7 +63660,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
63231
63660
|
const keepPartial = opts.keepPartialOnError !== false;
|
|
63232
63661
|
const contentLen = Number(res.headers.get("content-length") ?? 0);
|
|
63233
63662
|
const total = opts.totalBytes && opts.totalBytes > 0 ? opts.totalBytes : append ? resumeFrom + contentLen : contentLen;
|
|
63234
|
-
mkdirSync15(
|
|
63663
|
+
mkdirSync15(dirname13(destPath), { recursive: true });
|
|
63235
63664
|
const emit = createThrottledProgress(onProgress, opts.progressThrottleMs);
|
|
63236
63665
|
let sha256;
|
|
63237
63666
|
let sha512;
|
|
@@ -63289,7 +63718,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
63289
63718
|
} catch (err) {
|
|
63290
63719
|
if (!keepPartial) {
|
|
63291
63720
|
try {
|
|
63292
|
-
if (
|
|
63721
|
+
if (existsSync27(destPath)) rmSync5(destPath, { force: true });
|
|
63293
63722
|
} catch {
|
|
63294
63723
|
}
|
|
63295
63724
|
}
|
|
@@ -63333,14 +63762,14 @@ async function downloadResumableToFile(httpFetch, url2, destPath, onProgress, lo
|
|
|
63333
63762
|
);
|
|
63334
63763
|
}
|
|
63335
63764
|
async function downloadResumableToFileUnlocked(httpFetch, url2, destPath, onProgress, log2) {
|
|
63336
|
-
mkdirSync15(
|
|
63337
|
-
let existing =
|
|
63765
|
+
mkdirSync15(dirname13(destPath), { recursive: true });
|
|
63766
|
+
let existing = existsSync27(destPath) ? statSync9(destPath).size : 0;
|
|
63338
63767
|
if (existing > 0 && existing < 64) {
|
|
63339
63768
|
rmSync5(destPath, { force: true });
|
|
63340
63769
|
existing = 0;
|
|
63341
63770
|
}
|
|
63342
63771
|
const tryOnce = async (from) => {
|
|
63343
|
-
const diskNow =
|
|
63772
|
+
const diskNow = existsSync27(destPath) ? statSync9(destPath).size : 0;
|
|
63344
63773
|
const start = from > 0 ? diskNow : 0;
|
|
63345
63774
|
if (from > 0 && diskNow !== from) {
|
|
63346
63775
|
log2?.warn?.(
|
|
@@ -63422,17 +63851,17 @@ function createResumableDownloadToFile(httpFetch, log2) {
|
|
|
63422
63851
|
|
|
63423
63852
|
// ../../packages/runtime/src/harness/managed-tarball-installer.ts
|
|
63424
63853
|
import {
|
|
63425
|
-
existsSync as
|
|
63854
|
+
existsSync as existsSync28,
|
|
63426
63855
|
mkdirSync as mkdirSync16,
|
|
63427
63856
|
mkdtempSync as mkdtempSync2,
|
|
63428
63857
|
readFileSync as readFileSync16,
|
|
63429
63858
|
renameSync as renameSync4,
|
|
63430
63859
|
rmSync as rmSync6,
|
|
63431
|
-
statSync as
|
|
63860
|
+
statSync as statSync10,
|
|
63432
63861
|
writeFileSync as writeFileSync13
|
|
63433
63862
|
} from "node:fs";
|
|
63434
63863
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
63435
|
-
import { dirname as
|
|
63864
|
+
import { dirname as dirname14, join as join24 } from "node:path";
|
|
63436
63865
|
import { spawn as spawn4 } from "node:child_process";
|
|
63437
63866
|
|
|
63438
63867
|
// ../../packages/shared/src/update-channels.ts
|
|
@@ -63479,17 +63908,6 @@ function selectHarnessArtifact(manifest, harnessId, platform2, arch2) {
|
|
|
63479
63908
|
}
|
|
63480
63909
|
|
|
63481
63910
|
// ../../packages/runtime/src/harness/managed-tarball-installer.ts
|
|
63482
|
-
function codexPlatformVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
63483
|
-
const p2 = process.platform;
|
|
63484
|
-
const a = process.arch;
|
|
63485
|
-
if (a !== "arm64" && a !== "x64") {
|
|
63486
|
-
throw new Error(`unsupported arch for Codex: ${a}`);
|
|
63487
|
-
}
|
|
63488
|
-
if (p2 === "darwin") return `${baseVersion}-darwin-${a}`;
|
|
63489
|
-
if (p2 === "linux") return `${baseVersion}-linux-${a}`;
|
|
63490
|
-
if (p2 === "win32") return `${baseVersion}-win32-${a}`;
|
|
63491
|
-
throw new Error(`unsupported platform for Codex: ${p2}`);
|
|
63492
|
-
}
|
|
63493
63911
|
function managedPackagePins(id) {
|
|
63494
63912
|
if (id === "claude") {
|
|
63495
63913
|
const ver = process.env.SUPERONE_CLAUDE_SDK_VERSION?.trim() || OFFICIAL_CLAUDE_SDK_VERSION;
|
|
@@ -63505,7 +63923,7 @@ function managedPackagePins(id) {
|
|
|
63505
63923
|
packages: [
|
|
63506
63924
|
{
|
|
63507
63925
|
name: OFFICIAL_CODEX_PACKAGE,
|
|
63508
|
-
version:
|
|
63926
|
+
version: codexPlatformPackageVersion(base),
|
|
63509
63927
|
nodeModulesDir: OFFICIAL_CODEX_PACKAGE
|
|
63510
63928
|
}
|
|
63511
63929
|
]
|
|
@@ -63523,7 +63941,7 @@ function resolveHarnessManifestChannel(explicit, releaseVersion) {
|
|
|
63523
63941
|
return "alpha";
|
|
63524
63942
|
}
|
|
63525
63943
|
function harnessDownloadDir(homeRoot) {
|
|
63526
|
-
return
|
|
63944
|
+
return join24(homeRoot, ".download");
|
|
63527
63945
|
}
|
|
63528
63946
|
function harnessArtifactDownloadKey(opts) {
|
|
63529
63947
|
const digest = opts.digestSha256?.trim().toLowerCase();
|
|
@@ -63537,7 +63955,7 @@ function harnessPartialPath(homeRoot, key) {
|
|
|
63537
63955
|
if (!key || key.includes("..") || key.includes("/") || key.includes("\\")) {
|
|
63538
63956
|
throw new Error(`unsafe download key: ${key}`);
|
|
63539
63957
|
}
|
|
63540
|
-
return
|
|
63958
|
+
return join24(harnessDownloadDir(homeRoot), `${key}.partial`);
|
|
63541
63959
|
}
|
|
63542
63960
|
function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
63543
63961
|
return new Promise((resolve13, reject) => {
|
|
@@ -63557,13 +63975,13 @@ function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
|
63557
63975
|
});
|
|
63558
63976
|
}
|
|
63559
63977
|
function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
63560
|
-
const dest =
|
|
63561
|
-
const parent =
|
|
63978
|
+
const dest = join24(prefix, "lib", "node_modules", ...nodeModulesRel.split("/"));
|
|
63979
|
+
const parent = dirname14(dest);
|
|
63562
63980
|
mkdirSync16(parent, { recursive: true });
|
|
63563
|
-
if (
|
|
63981
|
+
if (existsSync28(dest)) {
|
|
63564
63982
|
rmSync6(dest, { recursive: true, force: true });
|
|
63565
63983
|
}
|
|
63566
|
-
const staging =
|
|
63984
|
+
const staging = join24(
|
|
63567
63985
|
parent,
|
|
63568
63986
|
`.staging-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
63569
63987
|
);
|
|
@@ -63571,12 +63989,12 @@ function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
|
63571
63989
|
renameSync4(packageDir, staging);
|
|
63572
63990
|
renameSync4(staging, dest);
|
|
63573
63991
|
} catch (err) {
|
|
63574
|
-
if (
|
|
63992
|
+
if (existsSync28(staging)) rmSync6(staging, { recursive: true, force: true });
|
|
63575
63993
|
throw err instanceof Error ? err : new Error(`failed to place package into ${dest}: ${String(err)}`);
|
|
63576
63994
|
}
|
|
63577
63995
|
return dest;
|
|
63578
63996
|
}
|
|
63579
|
-
function
|
|
63997
|
+
function codexTargetTriple2() {
|
|
63580
63998
|
const key = `${process.platform}-${process.arch}`;
|
|
63581
63999
|
const map2 = {
|
|
63582
64000
|
"darwin-arm64": "aarch64-apple-darwin",
|
|
@@ -63589,12 +64007,12 @@ function codexTargetTriple() {
|
|
|
63589
64007
|
return map2[key] ?? null;
|
|
63590
64008
|
}
|
|
63591
64009
|
function resolveCodexNativeUnderPrefix(prefix) {
|
|
63592
|
-
const triple =
|
|
64010
|
+
const triple = codexTargetTriple2();
|
|
63593
64011
|
if (!triple) return null;
|
|
63594
64012
|
const binaryName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
63595
64013
|
const candidates = [
|
|
63596
|
-
|
|
63597
|
-
|
|
64014
|
+
join24(prefix, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", binaryName),
|
|
64015
|
+
join24(
|
|
63598
64016
|
prefix,
|
|
63599
64017
|
"lib",
|
|
63600
64018
|
"node_modules",
|
|
@@ -63607,7 +64025,7 @@ function resolveCodexNativeUnderPrefix(prefix) {
|
|
|
63607
64025
|
)
|
|
63608
64026
|
];
|
|
63609
64027
|
for (const c of candidates) {
|
|
63610
|
-
if (
|
|
64028
|
+
if (existsSync28(c) && statSync10(c).isFile()) return c;
|
|
63611
64029
|
}
|
|
63612
64030
|
return null;
|
|
63613
64031
|
}
|
|
@@ -63617,16 +64035,16 @@ function resolveManagedTarballBinary(id, installRoot) {
|
|
|
63617
64035
|
}
|
|
63618
64036
|
function readRuntimeVersionFromRoot(id, installRoot) {
|
|
63619
64037
|
try {
|
|
63620
|
-
const metaPath =
|
|
63621
|
-
if (
|
|
64038
|
+
const metaPath = join24(installRoot, "install-meta.json");
|
|
64039
|
+
if (existsSync28(metaPath)) {
|
|
63622
64040
|
const raw = JSON.parse(readFileSync16(metaPath, "utf8"));
|
|
63623
64041
|
if (raw.runtimeVersion) return raw.runtimeVersion;
|
|
63624
64042
|
}
|
|
63625
64043
|
} catch {
|
|
63626
64044
|
}
|
|
63627
64045
|
try {
|
|
63628
|
-
const pkgPath = id === "claude" ? null :
|
|
63629
|
-
if (pkgPath &&
|
|
64046
|
+
const pkgPath = id === "claude" ? null : join24(installRoot, "lib", "node_modules", "@openai", "codex", "package.json");
|
|
64047
|
+
if (pkgPath && existsSync28(pkgPath)) {
|
|
63630
64048
|
const raw = JSON.parse(readFileSync16(pkgPath, "utf8"));
|
|
63631
64049
|
const v2 = raw.version?.trim();
|
|
63632
64050
|
if (!v2) return null;
|
|
@@ -63716,7 +64134,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63716
64134
|
npmVersion
|
|
63717
64135
|
});
|
|
63718
64136
|
const partialPath = harnessPartialPath(home.root, downloadKey);
|
|
63719
|
-
const work = mkdtempSync2(
|
|
64137
|
+
const work = mkdtempSync2(join24(tmpdir2(), `superone-harness-${id}-`));
|
|
63720
64138
|
try {
|
|
63721
64139
|
const { from } = await fetchTarballWithFallback({
|
|
63722
64140
|
destPath: partialPath,
|
|
@@ -63730,15 +64148,15 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63730
64148
|
log: log2
|
|
63731
64149
|
});
|
|
63732
64150
|
source = from;
|
|
63733
|
-
const extractRoot =
|
|
64151
|
+
const extractRoot = join24(work, "out");
|
|
63734
64152
|
await extractTgz(partialPath, extractRoot);
|
|
63735
|
-
const packageDir =
|
|
63736
|
-
if (!
|
|
64153
|
+
const packageDir = join24(extractRoot, "package");
|
|
64154
|
+
if (!existsSync28(packageDir) || !statSync10(packageDir).isDirectory()) {
|
|
63737
64155
|
throw new Error(`tarball for ${packageSpec} has no package/ directory`);
|
|
63738
64156
|
}
|
|
63739
64157
|
installPackageDir(packageDir, versionDir, npmName);
|
|
63740
64158
|
try {
|
|
63741
|
-
if (
|
|
64159
|
+
if (existsSync28(partialPath)) rmSync6(partialPath, { force: true });
|
|
63742
64160
|
} catch {
|
|
63743
64161
|
}
|
|
63744
64162
|
} finally {
|
|
@@ -63746,7 +64164,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63746
64164
|
}
|
|
63747
64165
|
}
|
|
63748
64166
|
writeFileSync13(
|
|
63749
|
-
|
|
64167
|
+
join24(versionDir, "install-meta.json"),
|
|
63750
64168
|
JSON.stringify(
|
|
63751
64169
|
{
|
|
63752
64170
|
harnessId: id,
|
|
@@ -63790,8 +64208,8 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63790
64208
|
}
|
|
63791
64209
|
|
|
63792
64210
|
// ../../packages/runtime/src/harness/cursor-availability.ts
|
|
63793
|
-
import { createRequire as
|
|
63794
|
-
var require3 =
|
|
64211
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
64212
|
+
var require3 = createRequire4(import.meta.url);
|
|
63795
64213
|
function isCursorSdkAvailable2() {
|
|
63796
64214
|
try {
|
|
63797
64215
|
require3.resolve("@cursor/sdk");
|
|
@@ -63967,7 +64385,7 @@ function isAuthSatisfied(id, deps) {
|
|
|
63967
64385
|
|
|
63968
64386
|
// ../../packages/runtime/src/harness/enable.ts
|
|
63969
64387
|
init_environment();
|
|
63970
|
-
import { accessSync, constants, existsSync as
|
|
64388
|
+
import { accessSync, constants, existsSync as existsSync29, realpathSync as realpathSync3, statSync as statSync11 } from "node:fs";
|
|
63971
64389
|
import { isAbsolute as isAbsolute2, resolve as resolve6 } from "node:path";
|
|
63972
64390
|
async function enableHarness(manager, input, deps) {
|
|
63973
64391
|
const id = input.harnessId;
|
|
@@ -64174,7 +64592,7 @@ function requireRegularReadableFile(path) {
|
|
|
64174
64592
|
throw new Error(`path must be absolute: ${path}`);
|
|
64175
64593
|
}
|
|
64176
64594
|
const abs = resolve6(path);
|
|
64177
|
-
if (!
|
|
64595
|
+
if (!existsSync29(abs) || !statSync11(abs).isFile()) {
|
|
64178
64596
|
throw new Error(`not a regular file: ${abs}`);
|
|
64179
64597
|
}
|
|
64180
64598
|
accessSync(abs, constants.R_OK);
|
|
@@ -64183,9 +64601,9 @@ function requireRegularReadableFile(path) {
|
|
|
64183
64601
|
function resolveExternalCommand(explicit, searchNames) {
|
|
64184
64602
|
if (explicit) {
|
|
64185
64603
|
const abs = isAbsolute2(explicit) ? explicit : resolve6(explicit);
|
|
64186
|
-
if (!
|
|
64604
|
+
if (!existsSync29(abs)) return null;
|
|
64187
64605
|
try {
|
|
64188
|
-
if (!
|
|
64606
|
+
if (!statSync11(abs).isFile()) return null;
|
|
64189
64607
|
accessSync(abs, constants.X_OK);
|
|
64190
64608
|
} catch {
|
|
64191
64609
|
return null;
|
|
@@ -64198,9 +64616,9 @@ function resolveExternalCommand(explicit, searchNames) {
|
|
|
64198
64616
|
for (const dir of dirs) {
|
|
64199
64617
|
if (!dir) continue;
|
|
64200
64618
|
const candidate = resolve6(dir, name);
|
|
64201
|
-
if (!
|
|
64619
|
+
if (!existsSync29(candidate)) continue;
|
|
64202
64620
|
try {
|
|
64203
|
-
if (!
|
|
64621
|
+
if (!statSync11(candidate).isFile()) continue;
|
|
64204
64622
|
accessSync(candidate, constants.X_OK);
|
|
64205
64623
|
return realpathSync3(candidate);
|
|
64206
64624
|
} catch {
|
|
@@ -64253,7 +64671,7 @@ function looksLikeSecretArg(value) {
|
|
|
64253
64671
|
}
|
|
64254
64672
|
|
|
64255
64673
|
// src/session/harness-host.ts
|
|
64256
|
-
import { existsSync as
|
|
64674
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
64257
64675
|
init_src2();
|
|
64258
64676
|
init_claude_turn_runner();
|
|
64259
64677
|
init_codex_turn_runner();
|
|
@@ -64261,7 +64679,7 @@ init_resolve_service();
|
|
|
64261
64679
|
setHarnessReleaseVersionProvider(resolveCliReleaseVersion);
|
|
64262
64680
|
function envBinaryExists(envName) {
|
|
64263
64681
|
const v2 = process.env[envName]?.trim();
|
|
64264
|
-
return Boolean(v2 &&
|
|
64682
|
+
return Boolean(v2 && existsSync30(v2));
|
|
64265
64683
|
}
|
|
64266
64684
|
var cliHarnessResolver = {
|
|
64267
64685
|
resolveBinary(id, harnesses) {
|
|
@@ -64271,7 +64689,7 @@ var cliHarnessResolver = {
|
|
|
64271
64689
|
return null;
|
|
64272
64690
|
}
|
|
64273
64691
|
const command = harnesses.get(id).command;
|
|
64274
|
-
return command &&
|
|
64692
|
+
return command && existsSync30(command) ? command : null;
|
|
64275
64693
|
},
|
|
64276
64694
|
isRunnableWithoutCatalog(id) {
|
|
64277
64695
|
if (id === "claude") return isClaudeRuntimeRunnable();
|
|
@@ -64283,7 +64701,7 @@ var cliHarnessResolver = {
|
|
|
64283
64701
|
autoRuntime(id) {
|
|
64284
64702
|
if (id === "claude") {
|
|
64285
64703
|
const sdk = resolveSdkClaudeBinary();
|
|
64286
|
-
if (sdk &&
|
|
64704
|
+
if (sdk && existsSync30(sdk)) return { command: sdk, source: "agent-sdk-optional" };
|
|
64287
64705
|
return null;
|
|
64288
64706
|
}
|
|
64289
64707
|
const fromEnv = resolveCodexBinaryPath({});
|
|
@@ -64366,8 +64784,8 @@ function enableManaged2(manager, id, artifact, mode = "enable") {
|
|
|
64366
64784
|
|
|
64367
64785
|
// ../../packages/shared/src/git-clone.ts
|
|
64368
64786
|
import { execFile as execFile2 } from "node:child_process";
|
|
64369
|
-
import { existsSync as
|
|
64370
|
-
import { isAbsolute as isAbsolute3, join as
|
|
64787
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync17 } from "node:fs";
|
|
64788
|
+
import { isAbsolute as isAbsolute3, join as join25, resolve as resolve7 } from "node:path";
|
|
64371
64789
|
|
|
64372
64790
|
// ../../packages/shared/src/git-remote.ts
|
|
64373
64791
|
function repoNameFromGitUrl(url2) {
|
|
@@ -64432,11 +64850,11 @@ function resolveCloneDestination(input) {
|
|
|
64432
64850
|
if (name.includes("/") || name.includes("\\") || name === "." || name === "..") {
|
|
64433
64851
|
throw invalid(`invalid folder name: ${name}`);
|
|
64434
64852
|
}
|
|
64435
|
-
return { path:
|
|
64853
|
+
return { path: join25(resolve7(parent), name), name };
|
|
64436
64854
|
}
|
|
64437
64855
|
async function cloneRepository(input) {
|
|
64438
64856
|
const destination = resolveCloneDestination(input);
|
|
64439
|
-
if (
|
|
64857
|
+
if (existsSync31(destination.path)) {
|
|
64440
64858
|
throw Object.assign(new Error(`destination already exists: ${destination.path}`), {
|
|
64441
64859
|
code: "conflict"
|
|
64442
64860
|
});
|
|
@@ -64480,7 +64898,7 @@ async function cloneRepository(input) {
|
|
|
64480
64898
|
|
|
64481
64899
|
// src/rpc/handlers.ts
|
|
64482
64900
|
init_resolve_service();
|
|
64483
|
-
import { existsSync as
|
|
64901
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync18, readdirSync as readdirSync10, statSync as statSync12 } from "node:fs";
|
|
64484
64902
|
import { join as pathJoin, resolve as pathResolve } from "node:path";
|
|
64485
64903
|
import { arch, cpus, freemem, homedir as homedir7, hostname as hostname4, platform, totalmem, uptime } from "node:os";
|
|
64486
64904
|
|
|
@@ -67248,7 +67666,7 @@ function handleProjectOpen(payload, ctx) {
|
|
|
67248
67666
|
}
|
|
67249
67667
|
const name = typeof p2.name === "string" ? p2.name : void 0;
|
|
67250
67668
|
try {
|
|
67251
|
-
if (p2.createIfMissing === true && !
|
|
67669
|
+
if (p2.createIfMissing === true && !existsSync32(path)) {
|
|
67252
67670
|
mkdirSync18(path, { recursive: true });
|
|
67253
67671
|
}
|
|
67254
67672
|
return { result: ctx.projects.open(path, name) };
|
|
@@ -67285,10 +67703,10 @@ function handleFsListDir(payload, ctx) {
|
|
|
67285
67703
|
}
|
|
67286
67704
|
try {
|
|
67287
67705
|
const resolved = expandHostPath(raw);
|
|
67288
|
-
if (!
|
|
67706
|
+
if (!existsSync32(resolved)) {
|
|
67289
67707
|
return { error: { code: "not_found", message: "path not found" } };
|
|
67290
67708
|
}
|
|
67291
|
-
if (!
|
|
67709
|
+
if (!statSync12(resolved).isDirectory()) {
|
|
67292
67710
|
return { error: { code: "invalid_argument", message: "not a directory" } };
|
|
67293
67711
|
}
|
|
67294
67712
|
const entries = readdirSync10(resolved, { withFileTypes: true }).filter((ent) => ent.isDirectory() && !ent.name.startsWith(".")).map((ent) => ({
|
|
@@ -69039,9 +69457,9 @@ async function handleHttp(req, res, opts) {
|
|
|
69039
69457
|
}
|
|
69040
69458
|
|
|
69041
69459
|
// src/terminal/manager.ts
|
|
69042
|
-
import { createRequire as
|
|
69043
|
-
import { existsSync as
|
|
69044
|
-
var nodeRequire =
|
|
69460
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
69461
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
69462
|
+
var nodeRequire = createRequire5(import.meta.url);
|
|
69045
69463
|
var { spawn: spawn5 } = nodeRequire("node-pty");
|
|
69046
69464
|
var SNAPSHOT_SOFT_LIMIT = 64 * 1024;
|
|
69047
69465
|
var OUTPUT_BUFFER_SOFT_LIMIT = 256 * 1024;
|
|
@@ -69055,7 +69473,7 @@ var NodeTerminalManager = class {
|
|
|
69055
69473
|
}
|
|
69056
69474
|
byId = /* @__PURE__ */ new Map();
|
|
69057
69475
|
create(opts) {
|
|
69058
|
-
if (!
|
|
69476
|
+
if (!existsSync33(opts.cwd)) {
|
|
69059
69477
|
throw Object.assign(new Error(`cwd does not exist: ${opts.cwd}`), { code: "invalid_argument" });
|
|
69060
69478
|
}
|
|
69061
69479
|
const terminalId = crypto.randomUUID();
|
|
@@ -69196,7 +69614,7 @@ var NodeTerminalManager = class {
|
|
|
69196
69614
|
|
|
69197
69615
|
// src/workspace/project-registry.ts
|
|
69198
69616
|
import { basename as basename2, resolve as resolve8 } from "node:path";
|
|
69199
|
-
import { existsSync as
|
|
69617
|
+
import { existsSync as existsSync34, realpathSync as realpathSync4, statSync as statSync13 } from "node:fs";
|
|
69200
69618
|
import { createHash as createHash7 } from "node:crypto";
|
|
69201
69619
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
69202
69620
|
var ProjectRegistry = class {
|
|
@@ -69226,7 +69644,7 @@ var ProjectRegistry = class {
|
|
|
69226
69644
|
}
|
|
69227
69645
|
open(path, name) {
|
|
69228
69646
|
let abs = resolve8(path);
|
|
69229
|
-
if (!
|
|
69647
|
+
if (!existsSync34(abs) || !statSync13(abs).isDirectory()) {
|
|
69230
69648
|
throw Object.assign(new Error(`project path is not a directory: ${abs}`), {
|
|
69231
69649
|
code: "invalid_argument"
|
|
69232
69650
|
});
|
|
@@ -69270,7 +69688,7 @@ var ProjectRegistry = class {
|
|
|
69270
69688
|
toSnapshot(r) {
|
|
69271
69689
|
let missing = false;
|
|
69272
69690
|
try {
|
|
69273
|
-
missing = !
|
|
69691
|
+
missing = !statSync13(r.path).isDirectory();
|
|
69274
69692
|
} catch {
|
|
69275
69693
|
missing = true;
|
|
69276
69694
|
}
|
|
@@ -69310,7 +69728,7 @@ function detectRepoIdentity(abs) {
|
|
|
69310
69728
|
init_fs();
|
|
69311
69729
|
import {
|
|
69312
69730
|
closeSync,
|
|
69313
|
-
existsSync as
|
|
69731
|
+
existsSync as existsSync35,
|
|
69314
69732
|
fstatSync,
|
|
69315
69733
|
mkdirSync as mkdirSync19,
|
|
69316
69734
|
openSync,
|
|
@@ -69319,11 +69737,11 @@ import {
|
|
|
69319
69737
|
readFileSync as readFileSync17,
|
|
69320
69738
|
renameSync as renameSync5,
|
|
69321
69739
|
rmSync as rmSync7,
|
|
69322
|
-
statSync as
|
|
69740
|
+
statSync as statSync14,
|
|
69323
69741
|
unlinkSync,
|
|
69324
69742
|
writeFileSync as writeFileSync14
|
|
69325
69743
|
} from "node:fs";
|
|
69326
|
-
import { dirname as
|
|
69744
|
+
import { dirname as dirname15, join as join26, relative as relative2 } from "node:path";
|
|
69327
69745
|
import { createHash as createHash8 } from "node:crypto";
|
|
69328
69746
|
function normalizeRel(path) {
|
|
69329
69747
|
return path.replace(/\\/g, "/").replace(/\/+$/, "") || ".";
|
|
@@ -69369,21 +69787,21 @@ var WorkspaceFsService = class {
|
|
|
69369
69787
|
if (!resolved.ok) {
|
|
69370
69788
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69371
69789
|
}
|
|
69372
|
-
if (!
|
|
69790
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69373
69791
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
69374
69792
|
}
|
|
69375
|
-
const st =
|
|
69793
|
+
const st = statSync14(resolved.absolutePath);
|
|
69376
69794
|
if (!st.isDirectory()) {
|
|
69377
69795
|
throw Object.assign(new Error("not a directory"), { code: "invalid_argument" });
|
|
69378
69796
|
}
|
|
69379
69797
|
this.projects.touch(projectId);
|
|
69380
69798
|
const ents = readdirSync11(resolved.absolutePath, { withFileTypes: true });
|
|
69381
69799
|
return ents.map((ent) => {
|
|
69382
|
-
const abs =
|
|
69800
|
+
const abs = join26(resolved.absolutePath, ent.name);
|
|
69383
69801
|
let size;
|
|
69384
69802
|
let mtimeMs;
|
|
69385
69803
|
try {
|
|
69386
|
-
const s2 =
|
|
69804
|
+
const s2 = statSync14(abs);
|
|
69387
69805
|
size = s2.size;
|
|
69388
69806
|
mtimeMs = s2.mtimeMs;
|
|
69389
69807
|
} catch {
|
|
@@ -69404,10 +69822,10 @@ var WorkspaceFsService = class {
|
|
|
69404
69822
|
if (!resolved.ok) {
|
|
69405
69823
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69406
69824
|
}
|
|
69407
|
-
if (!
|
|
69825
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69408
69826
|
throw Object.assign(new Error("file not found"), { code: "not_found" });
|
|
69409
69827
|
}
|
|
69410
|
-
const st =
|
|
69828
|
+
const st = statSync14(resolved.absolutePath);
|
|
69411
69829
|
if (!st.isFile()) {
|
|
69412
69830
|
throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
|
|
69413
69831
|
}
|
|
@@ -69443,8 +69861,8 @@ var WorkspaceFsService = class {
|
|
|
69443
69861
|
if (!resolved.ok) {
|
|
69444
69862
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69445
69863
|
}
|
|
69446
|
-
if (
|
|
69447
|
-
const st =
|
|
69864
|
+
if (existsSync35(resolved.absolutePath) && expectedHash) {
|
|
69865
|
+
const st = statSync14(resolved.absolutePath);
|
|
69448
69866
|
if (st.size > MAX_READ_BYTES) {
|
|
69449
69867
|
throw Object.assign(
|
|
69450
69868
|
new Error(`optimistic-write target too large (${st.size} bytes; max ${MAX_READ_BYTES})`),
|
|
@@ -69456,15 +69874,15 @@ var WorkspaceFsService = class {
|
|
|
69456
69874
|
throw Object.assign(new Error("content hash mismatch"), { code: "conflict" });
|
|
69457
69875
|
}
|
|
69458
69876
|
}
|
|
69459
|
-
mkdirSync19(
|
|
69877
|
+
mkdirSync19(dirname15(resolved.absolutePath), { recursive: true });
|
|
69460
69878
|
const data = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content);
|
|
69461
69879
|
if (data.length > MAX_READ_BYTES) {
|
|
69462
69880
|
throw Object.assign(new Error("write payload too large"), { code: "invalid_argument" });
|
|
69463
69881
|
}
|
|
69464
69882
|
let mode = 384;
|
|
69465
|
-
if (
|
|
69883
|
+
if (existsSync35(resolved.absolutePath)) {
|
|
69466
69884
|
try {
|
|
69467
|
-
mode =
|
|
69885
|
+
mode = statSync14(resolved.absolutePath).mode & 511;
|
|
69468
69886
|
} catch {
|
|
69469
69887
|
}
|
|
69470
69888
|
}
|
|
@@ -69532,7 +69950,7 @@ var WorkspaceFsService = class {
|
|
|
69532
69950
|
for (const ent of ents) {
|
|
69533
69951
|
if (hits.length >= MAX_SEARCH_HITS) return;
|
|
69534
69952
|
if (ent.name === ".git" || ent.name === "node_modules") continue;
|
|
69535
|
-
const abs =
|
|
69953
|
+
const abs = join26(dir, ent.name);
|
|
69536
69954
|
const rel = relative2(root, abs).split("\\").join("/");
|
|
69537
69955
|
const check2 = resolveProjectPath(root, rel);
|
|
69538
69956
|
if (!check2.ok) continue;
|
|
@@ -69542,7 +69960,7 @@ var WorkspaceFsService = class {
|
|
|
69542
69960
|
}
|
|
69543
69961
|
if (!ent.isFile()) continue;
|
|
69544
69962
|
try {
|
|
69545
|
-
const st =
|
|
69963
|
+
const st = statSync14(abs);
|
|
69546
69964
|
if (st.size > MAX_SEARCH_FILE_BYTES) continue;
|
|
69547
69965
|
const text = readFileSync17(abs, "utf8");
|
|
69548
69966
|
const lines = text.split(/\r?\n/);
|
|
@@ -69606,8 +70024,8 @@ var WorkspaceFsService = class {
|
|
|
69606
70024
|
if (!resolved.ok) {
|
|
69607
70025
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69608
70026
|
}
|
|
69609
|
-
if (
|
|
69610
|
-
const st =
|
|
70027
|
+
if (existsSync35(resolved.absolutePath)) {
|
|
70028
|
+
const st = statSync14(resolved.absolutePath);
|
|
69611
70029
|
if (!st.isDirectory()) {
|
|
69612
70030
|
throw Object.assign(new Error("path exists and is not a directory"), { code: "conflict" });
|
|
69613
70031
|
}
|
|
@@ -69629,7 +70047,7 @@ var WorkspaceFsService = class {
|
|
|
69629
70047
|
if (!resolved.ok) {
|
|
69630
70048
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69631
70049
|
}
|
|
69632
|
-
if (!
|
|
70050
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69633
70051
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
69634
70052
|
}
|
|
69635
70053
|
if (resolved.absolutePath === root) {
|
|
@@ -69653,19 +70071,19 @@ var WorkspaceFsService = class {
|
|
|
69653
70071
|
if (!from.ok) {
|
|
69654
70072
|
throw Object.assign(new Error(from.reason), { code: "invalid_argument" });
|
|
69655
70073
|
}
|
|
69656
|
-
if (!
|
|
70074
|
+
if (!existsSync35(from.absolutePath)) {
|
|
69657
70075
|
throw Object.assign(new Error("source not found"), { code: "not_found" });
|
|
69658
70076
|
}
|
|
69659
70077
|
const to = resolveProjectPath(root, toN);
|
|
69660
70078
|
if (!to.ok) {
|
|
69661
70079
|
throw Object.assign(new Error(to.reason), { code: "invalid_argument" });
|
|
69662
70080
|
}
|
|
69663
|
-
if (
|
|
70081
|
+
if (existsSync35(to.absolutePath)) {
|
|
69664
70082
|
throw Object.assign(new Error(`target already exists: ${baseNameRel(toN)}`), {
|
|
69665
70083
|
code: "conflict"
|
|
69666
70084
|
});
|
|
69667
70085
|
}
|
|
69668
|
-
mkdirSync19(
|
|
70086
|
+
mkdirSync19(dirname15(to.absolutePath), { recursive: true });
|
|
69669
70087
|
renameSync5(from.absolutePath, to.absolutePath);
|
|
69670
70088
|
this.projects.touch(projectId);
|
|
69671
70089
|
return { from: fromN, to: toN };
|
|
@@ -69690,8 +70108,8 @@ function hashFileBounded(absolutePath, size) {
|
|
|
69690
70108
|
}
|
|
69691
70109
|
|
|
69692
70110
|
// src/workspace/git-service.ts
|
|
69693
|
-
import { existsSync as
|
|
69694
|
-
import { join as
|
|
70111
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync20, realpathSync as realpathSync5, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
|
|
70112
|
+
import { join as join28, resolve as resolve10 } from "node:path";
|
|
69695
70113
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
69696
70114
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
69697
70115
|
|
|
@@ -69768,19 +70186,19 @@ function gitRunSync(folderPath, args, env) {
|
|
|
69768
70186
|
}
|
|
69769
70187
|
|
|
69770
70188
|
// ../../packages/runtime/src/git/worktree-plan.ts
|
|
69771
|
-
import { basename as basename3, dirname as
|
|
70189
|
+
import { basename as basename3, dirname as dirname16, join as join27, resolve as resolve9, sep as sep4 } from "node:path";
|
|
69772
70190
|
import { homedir as homedir8 } from "node:os";
|
|
69773
70191
|
function resolveMainDirFromCommonDir(folderPath, gitCommonDir) {
|
|
69774
70192
|
const repoRoot = resolve9(folderPath, gitCommonDir.trim());
|
|
69775
|
-
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ?
|
|
70193
|
+
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname16(repoRoot) : repoRoot;
|
|
69776
70194
|
}
|
|
69777
70195
|
function planNewWorktreePaths(input) {
|
|
69778
70196
|
const home = input.homeDir ?? homedir8();
|
|
69779
70197
|
const repoName = basename3(input.mainDir);
|
|
69780
70198
|
const epoch = Math.floor((input.nowMs ?? Date.now()) / 1e3).toString(36);
|
|
69781
70199
|
const short = input.shortHash.slice(0, 7);
|
|
69782
|
-
const wtDir =
|
|
69783
|
-
const wtPath =
|
|
70200
|
+
const wtDir = join27(home, ".worktrees", repoName);
|
|
70201
|
+
const wtPath = join27(wtDir, `${epoch}-${short}`);
|
|
69784
70202
|
return { wtDir, wtPath };
|
|
69785
70203
|
}
|
|
69786
70204
|
function worktreeAddArgs(mode, wtPath, baseRef, branchName) {
|
|
@@ -69839,8 +70257,8 @@ function resolveMainWorktreeDir(folderPath) {
|
|
|
69839
70257
|
}
|
|
69840
70258
|
function samePath(a, b2) {
|
|
69841
70259
|
try {
|
|
69842
|
-
const ra =
|
|
69843
|
-
const rb =
|
|
70260
|
+
const ra = existsSync36(a) ? realpathSync5(a) : resolve10(a);
|
|
70261
|
+
const rb = existsSync36(b2) ? realpathSync5(b2) : resolve10(b2);
|
|
69844
70262
|
return ra === rb;
|
|
69845
70263
|
} catch {
|
|
69846
70264
|
return resolve10(a) === resolve10(b2);
|
|
@@ -69872,7 +70290,7 @@ var WorkspaceGitService = class {
|
|
|
69872
70290
|
* --ignored walks the whole tree of ignored paths and dominates remote latency.
|
|
69873
70291
|
*/
|
|
69874
70292
|
statusForCwd(cwd) {
|
|
69875
|
-
if (!
|
|
70293
|
+
if (!existsSync36(join28(cwd, ".git")) && !isGitWorktree(cwd)) {
|
|
69876
70294
|
return { isRepo: false, branch: null, dirty: false, ahead: 0, behind: 0, porcelain: "" };
|
|
69877
70295
|
}
|
|
69878
70296
|
try {
|
|
@@ -69981,15 +70399,15 @@ var WorkspaceGitService = class {
|
|
|
69981
70399
|
}
|
|
69982
70400
|
const abs = resolve10(worktreePath);
|
|
69983
70401
|
const main2 = resolve10(this.root(projectId));
|
|
69984
|
-
if (samePath(abs, main2)) return
|
|
70402
|
+
if (samePath(abs, main2)) return existsSync36(abs) ? realpathSync5(abs) : abs;
|
|
69985
70403
|
const listed = this.worktrees(projectId);
|
|
69986
70404
|
for (const wt of listed) {
|
|
69987
70405
|
if (samePath(abs, wt.path)) {
|
|
69988
|
-
return
|
|
70406
|
+
return existsSync36(abs) ? realpathSync5(abs) : resolve10(wt.path);
|
|
69989
70407
|
}
|
|
69990
70408
|
}
|
|
69991
70409
|
try {
|
|
69992
|
-
if (
|
|
70410
|
+
if (existsSync36(abs) && isGitWorktree(abs)) {
|
|
69993
70411
|
const commonA = resolve10(abs, git(abs, ["rev-parse", "--git-common-dir"]).trim());
|
|
69994
70412
|
const commonB = resolve10(main2, git(main2, ["rev-parse", "--git-common-dir"]).trim());
|
|
69995
70413
|
if (samePath(commonA, commonB)) {
|
|
@@ -70031,7 +70449,7 @@ var WorkspaceGitService = class {
|
|
|
70031
70449
|
mainDir,
|
|
70032
70450
|
shortHash: commitHash.slice(0, 7)
|
|
70033
70451
|
});
|
|
70034
|
-
if (!
|
|
70452
|
+
if (!existsSync36(wtDir)) mkdirSync20(wtDir, { recursive: true });
|
|
70035
70453
|
try {
|
|
70036
70454
|
const addArgs = worktreeAddArgs(mode, wtPath, baseBranch, safeBranchName);
|
|
70037
70455
|
git(folderPath, ["worktree", ...addArgs]);
|
|
@@ -70127,7 +70545,7 @@ var WorkspaceGitService = class {
|
|
|
70127
70545
|
const mainStatus = git(diff.mainDir, ["status", "--porcelain"]).trim();
|
|
70128
70546
|
if (mainStatus) return { ok: false, reason: "main-dirty" };
|
|
70129
70547
|
const patch = git(diff.worktreePath, ["diff", "--binary", diff.base, diff.tree]);
|
|
70130
|
-
const patchFile =
|
|
70548
|
+
const patchFile = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.patch`);
|
|
70131
70549
|
writeFileSync15(patchFile, `${patch}
|
|
70132
70550
|
`);
|
|
70133
70551
|
if (git(diff.mainDir, ["status", "--porcelain"]).trim()) {
|
|
@@ -70189,7 +70607,7 @@ var WorkspaceGitService = class {
|
|
|
70189
70607
|
};
|
|
70190
70608
|
}
|
|
70191
70609
|
writeWorkingTree(worktreePath) {
|
|
70192
|
-
const tmpIndex =
|
|
70610
|
+
const tmpIndex = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.index`);
|
|
70193
70611
|
const env = { GIT_INDEX_FILE: tmpIndex };
|
|
70194
70612
|
try {
|
|
70195
70613
|
git(worktreePath, ["read-tree", "HEAD"], env);
|
|
@@ -70386,7 +70804,7 @@ init_agent_types();
|
|
|
70386
70804
|
init_environment();
|
|
70387
70805
|
init_resolve_service();
|
|
70388
70806
|
import { createHash as createHash9, randomBytes as randomBytes5, randomUUID as randomUUID10 } from "node:crypto";
|
|
70389
|
-
import { existsSync as
|
|
70807
|
+
import { existsSync as existsSync37, statSync as statSync15 } from "node:fs";
|
|
70390
70808
|
import { resolve as pathResolve2 } from "node:path";
|
|
70391
70809
|
var MAX_MESSAGES_PER_RETRIEVE = 100;
|
|
70392
70810
|
var EMPTY_MAILBOX_HINT = "No peer has replied yet. Do not retrieve again, do not sleep, do not wait in place \u2014 end your turn or do unrelated work. A task notification will start a new turn for you as soon as a message arrives.";
|
|
@@ -71307,7 +71725,7 @@ var CollaborationService = class {
|
|
|
71307
71725
|
const project = this.deps.projects.get(projectId);
|
|
71308
71726
|
const fallback = parentCwd || project?.path || process.cwd();
|
|
71309
71727
|
const cwd = pathResolve2(config2.cwd || fallback);
|
|
71310
|
-
if (!
|
|
71728
|
+
if (!existsSync37(cwd) || !statSync15(cwd).isDirectory()) {
|
|
71311
71729
|
throw Object.assign(new Error(`Working directory does not exist: ${cwd}`), {
|
|
71312
71730
|
code: "invalid_argument"
|
|
71313
71731
|
});
|
|
@@ -71446,8 +71864,8 @@ var CollaborationService = class {
|
|
|
71446
71864
|
};
|
|
71447
71865
|
|
|
71448
71866
|
// src/provider/secret-crypto.ts
|
|
71449
|
-
import { existsSync as
|
|
71450
|
-
import { dirname as
|
|
71867
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync16, chmodSync as chmodSync2 } from "node:fs";
|
|
71868
|
+
import { dirname as dirname17 } from "node:path";
|
|
71451
71869
|
import { createCipheriv, createDecipheriv, randomBytes as randomBytes6 } from "node:crypto";
|
|
71452
71870
|
var ENC_PREFIX2 = "enc:v1:";
|
|
71453
71871
|
var KEY_BYTES = 32;
|
|
@@ -71455,11 +71873,11 @@ function isEncryptedSecret(value) {
|
|
|
71455
71873
|
return typeof value === "string" && value.startsWith(ENC_PREFIX2);
|
|
71456
71874
|
}
|
|
71457
71875
|
function ensureKeyFile(keyPath) {
|
|
71458
|
-
if (
|
|
71876
|
+
if (existsSync38(keyPath)) {
|
|
71459
71877
|
const raw = readFileSync18(keyPath);
|
|
71460
71878
|
if (raw.length === KEY_BYTES) return raw;
|
|
71461
71879
|
}
|
|
71462
|
-
mkdirSync21(
|
|
71880
|
+
mkdirSync21(dirname17(keyPath), { recursive: true, mode: 448 });
|
|
71463
71881
|
const key = randomBytes6(KEY_BYTES);
|
|
71464
71882
|
writeFileSync16(keyPath, key, { mode: 384 });
|
|
71465
71883
|
try {
|
|
@@ -71603,7 +72021,7 @@ var WorkspaceWatchService = class {
|
|
|
71603
72021
|
|
|
71604
72022
|
// src/workspace/tail-watch-service.ts
|
|
71605
72023
|
init_fs();
|
|
71606
|
-
import { existsSync as
|
|
72024
|
+
import { existsSync as existsSync39, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync16, readSync as readSync2, realpathSync as realpathSync6 } from "node:fs";
|
|
71607
72025
|
var MAX_POLL_BYTES = 10 * 1024 * 1024;
|
|
71608
72026
|
var WorkspaceTailWatchService = class {
|
|
71609
72027
|
constructor(projects, fs) {
|
|
@@ -71625,7 +72043,7 @@ var WorkspaceTailWatchService = class {
|
|
|
71625
72043
|
);
|
|
71626
72044
|
}
|
|
71627
72045
|
try {
|
|
71628
|
-
resolvedAbs =
|
|
72046
|
+
resolvedAbs = existsSync39(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
|
|
71629
72047
|
} catch {
|
|
71630
72048
|
resolvedAbs = absolutePath;
|
|
71631
72049
|
}
|
|
@@ -71656,9 +72074,9 @@ var WorkspaceTailWatchService = class {
|
|
|
71656
72074
|
code: "invalid_argument"
|
|
71657
72075
|
});
|
|
71658
72076
|
}
|
|
71659
|
-
if (
|
|
72077
|
+
if (existsSync39(resolvedAbs)) {
|
|
71660
72078
|
try {
|
|
71661
|
-
const st =
|
|
72079
|
+
const st = statSync16(resolvedAbs);
|
|
71662
72080
|
if (!st.isFile()) {
|
|
71663
72081
|
throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
|
|
71664
72082
|
}
|
|
@@ -71707,7 +72125,7 @@ var WorkspaceTailWatchService = class {
|
|
|
71707
72125
|
{ code: "invalid_argument" }
|
|
71708
72126
|
);
|
|
71709
72127
|
}
|
|
71710
|
-
if (!
|
|
72128
|
+
if (!existsSync39(absolutePath)) {
|
|
71711
72129
|
return {
|
|
71712
72130
|
content: "",
|
|
71713
72131
|
encoding: "base64",
|
|
@@ -84847,7 +85265,7 @@ function createLocalPairingToken(nodeHome) {
|
|
|
84847
85265
|
}
|
|
84848
85266
|
function readRuntimeStatus(nodeHome) {
|
|
84849
85267
|
const paths = nodePaths(resolveRuntimeConfig({ nodeHome }).nodeHome);
|
|
84850
|
-
if (!
|
|
85268
|
+
if (!existsSync40(paths.runtimeJson)) return null;
|
|
84851
85269
|
try {
|
|
84852
85270
|
return JSON.parse(readFileSync19(paths.runtimeJson, "utf8"));
|
|
84853
85271
|
} catch {
|
|
@@ -84857,8 +85275,8 @@ function readRuntimeStatus(nodeHome) {
|
|
|
84857
85275
|
|
|
84858
85276
|
// src/systemd/install.ts
|
|
84859
85277
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
84860
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
84861
|
-
import { dirname as
|
|
85278
|
+
import { chmodSync as chmodSync3, existsSync as existsSync41, mkdirSync as mkdirSync22, unlinkSync as unlinkSync2, writeFileSync as writeFileSync18 } from "node:fs";
|
|
85279
|
+
import { dirname as dirname18 } from "node:path";
|
|
84862
85280
|
|
|
84863
85281
|
// src/systemd/unit.ts
|
|
84864
85282
|
function renderSystemdUserUnit(opts) {
|
|
@@ -84915,7 +85333,7 @@ function checkLinger(user) {
|
|
|
84915
85333
|
return { enabled: null, raw };
|
|
84916
85334
|
}
|
|
84917
85335
|
function writeSystemdUserUnit(opts, unitPath = systemdUserUnitPath()) {
|
|
84918
|
-
mkdirSync22(
|
|
85336
|
+
mkdirSync22(dirname18(unitPath), { recursive: true });
|
|
84919
85337
|
writeFileSync18(unitPath, renderSystemdUserUnit(opts), { encoding: "utf8", mode: 420 });
|
|
84920
85338
|
try {
|
|
84921
85339
|
chmodSync3(unitPath, 420);
|
|
@@ -84969,7 +85387,7 @@ function uninstallSystemdUserService(removeUnitFile = true) {
|
|
|
84969
85387
|
}
|
|
84970
85388
|
if (removeUnitFile) {
|
|
84971
85389
|
const path = systemdUserUnitPath();
|
|
84972
|
-
if (
|
|
85390
|
+
if (existsSync41(path)) {
|
|
84973
85391
|
try {
|
|
84974
85392
|
unlinkSync2(path);
|
|
84975
85393
|
} catch (err) {
|
|
@@ -84992,7 +85410,7 @@ function systemdUserStatus() {
|
|
|
84992
85410
|
|
|
84993
85411
|
// src/session/harness-cli.ts
|
|
84994
85412
|
init_environment();
|
|
84995
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as
|
|
85413
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync42, realpathSync as realpathSync7, statSync as statSync17 } from "node:fs";
|
|
84996
85414
|
import { isAbsolute as isAbsolute4, resolve as resolve11 } from "node:path";
|
|
84997
85415
|
import { homedir as homedir9 } from "node:os";
|
|
84998
85416
|
var DEFERRED_FLAGS = /* @__PURE__ */ new Set([
|
|
@@ -85541,10 +85959,10 @@ function resolveExternalCommand2(explicit, pathCandidates) {
|
|
|
85541
85959
|
return null;
|
|
85542
85960
|
}
|
|
85543
85961
|
function isUsableExecutable(path) {
|
|
85544
|
-
if (!
|
|
85962
|
+
if (!existsSync42(path)) return null;
|
|
85545
85963
|
let st;
|
|
85546
85964
|
try {
|
|
85547
|
-
st =
|
|
85965
|
+
st = statSync17(path);
|
|
85548
85966
|
} catch {
|
|
85549
85967
|
return null;
|
|
85550
85968
|
}
|
|
@@ -85561,10 +85979,10 @@ function isUsableExecutable(path) {
|
|
|
85561
85979
|
}
|
|
85562
85980
|
}
|
|
85563
85981
|
function probeExecutableIssues(path) {
|
|
85564
|
-
if (!
|
|
85982
|
+
if (!existsSync42(path)) return ["command_missing"];
|
|
85565
85983
|
let st;
|
|
85566
85984
|
try {
|
|
85567
|
-
st =
|
|
85985
|
+
st = statSync17(path);
|
|
85568
85986
|
} catch {
|
|
85569
85987
|
return ["command_missing"];
|
|
85570
85988
|
}
|
|
@@ -85577,9 +85995,9 @@ function probeExecutableIssues(path) {
|
|
|
85577
85995
|
return [];
|
|
85578
85996
|
}
|
|
85579
85997
|
function probeReadableFileIssues(path) {
|
|
85580
|
-
if (!
|
|
85998
|
+
if (!existsSync42(path)) return ["artifact_missing"];
|
|
85581
85999
|
try {
|
|
85582
|
-
if (!
|
|
86000
|
+
if (!statSync17(path).isFile()) return ["artifact_not_file"];
|
|
85583
86001
|
} catch {
|
|
85584
86002
|
return ["artifact_missing"];
|
|
85585
86003
|
}
|