@super-one/cli 0.53.2-alpha → 0.53.4-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 +763 -252
- package/package.json +10 -10
package/lib/cli.mjs
CHANGED
|
@@ -2878,6 +2878,67 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
2878
2878
|
"additionalProperties": false
|
|
2879
2879
|
}
|
|
2880
2880
|
},
|
|
2881
|
+
{
|
|
2882
|
+
"name": "browser_act",
|
|
2883
|
+
"description": "Submit 1\u201320 page actions as one call: click, hover, type, press, scroll, drag, select, upload. Prefer a CSS selector from snapshot/query; click/hover also accept text or x/y. engine=auto|cdp|synthetic (default auto). description is shown to the user instead of raw selectors. Do not use this to navigate (browser_tabs), wait (browser_wait_for), or run JS (browser_evaluate). Fail-fast: stops at the first error.",
|
|
2884
|
+
"inputSchema": {
|
|
2885
|
+
"type": "object",
|
|
2886
|
+
"properties": {
|
|
2887
|
+
"tab": { "type": "string" },
|
|
2888
|
+
"description": { "type": "string" },
|
|
2889
|
+
"actions": {
|
|
2890
|
+
"type": "array",
|
|
2891
|
+
"minItems": 1,
|
|
2892
|
+
"maxItems": 20,
|
|
2893
|
+
"items": {
|
|
2894
|
+
"type": "object",
|
|
2895
|
+
"properties": {
|
|
2896
|
+
"type": { "type": "string", "enum": ["click", "hover", "type", "press", "scroll", "drag", "select", "upload"] }
|
|
2897
|
+
},
|
|
2898
|
+
"required": ["type"],
|
|
2899
|
+
"additionalProperties": true
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
},
|
|
2903
|
+
"required": ["actions"],
|
|
2904
|
+
"additionalProperties": false
|
|
2905
|
+
}
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
"name": "browser_network",
|
|
2909
|
+
"description": "Network, downloads, and page environment. Recording ladder: action=start \u2192 do an act/navigate \u2192 action=wait or stop (lean manifest) \u2192 action=body({requestId}) for one response. action=download fetches a URL through the session; action=downloads lists page-triggered captures. action=cookies|mock|emulate need CDP experimental settings. emulate with only preset/width/height/reset resizes without CDP. Prefer snapshot/query for page content.",
|
|
2910
|
+
"inputSchema": {
|
|
2911
|
+
"type": "object",
|
|
2912
|
+
"properties": {
|
|
2913
|
+
"action": {
|
|
2914
|
+
"type": "string",
|
|
2915
|
+
"enum": ["start", "stop", "wait", "body", "download", "downloads", "cookies", "mock", "emulate"]
|
|
2916
|
+
},
|
|
2917
|
+
"tab": { "type": "string" },
|
|
2918
|
+
"description": { "type": "string" },
|
|
2919
|
+
"recordingId": { "type": "string" },
|
|
2920
|
+
"requestId": { "type": "string" },
|
|
2921
|
+
"url": { "type": "string" }
|
|
2922
|
+
},
|
|
2923
|
+
"required": ["action"],
|
|
2924
|
+
"additionalProperties": true
|
|
2925
|
+
}
|
|
2926
|
+
},
|
|
2927
|
+
{
|
|
2928
|
+
"name": "browser_action",
|
|
2929
|
+
"description": "Saved semantic browser actions (dynamic catalog \u2014 list then do). action=list (optional domain; includeSteps to see the full definition). action=save creates or replaces a named flow (domain+name). action=do runs one saved action with input. This does not record prior browser calls. Use browser_act for one-off clicks/types.",
|
|
2930
|
+
"inputSchema": {
|
|
2931
|
+
"type": "object",
|
|
2932
|
+
"properties": {
|
|
2933
|
+
"action": { "type": "string", "enum": ["list", "save", "do"] },
|
|
2934
|
+
"domain": { "type": "string" },
|
|
2935
|
+
"name": { "type": "string" },
|
|
2936
|
+
"input": { "type": "object", "additionalProperties": true }
|
|
2937
|
+
},
|
|
2938
|
+
"required": ["action"],
|
|
2939
|
+
"additionalProperties": true
|
|
2940
|
+
}
|
|
2941
|
+
},
|
|
2881
2942
|
{
|
|
2882
2943
|
"name": "miniapp_list",
|
|
2883
2944
|
"description": "List mini-apps authorized for this session and their tools. Omit appId for a compact catalog (tool names + one-line descriptions). Pass appId to inspect one app; includeSchema defaults true for that app's full tool definitions including inputSchema. Call this before miniapp_call when you do not know the tool names or parameters.",
|
|
@@ -9744,7 +9805,7 @@ function isStaticHostOwnedSuperoneToolQualified(qualifiedName) {
|
|
|
9744
9805
|
const bare = qualifiedName.slice(MCP_SUPERONE_TOOL_PREFIX.length);
|
|
9745
9806
|
return isStaticHostOwnedSuperoneBareName(bare);
|
|
9746
9807
|
}
|
|
9747
|
-
var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME;
|
|
9808
|
+
var MCP_SUPERONE_TOOL_PREFIX, BROWSER_PRIMITIVE_TOOL_NAMES, BROWSER_ACTION_TOOL_NAMES, BROWSER_LEGACY_TOOL_NAMES, BROWSER_COMPACT_TOOL_NAMES, BROWSER_TOOL_NAMES, BUILT_IN_SUPERONE_TOOL_NAMES, MOBILE_SHARE_FILE_TOOL_NAME, MINIAPP_LIST_BARE_NAME, MINIAPP_CALL_BARE_NAME;
|
|
9748
9809
|
var init_superone_host_owned_tools = __esm({
|
|
9749
9810
|
"../../packages/shared/src/superone-host-owned-tools.ts"() {
|
|
9750
9811
|
"use strict";
|
|
@@ -9783,10 +9844,26 @@ var init_superone_host_owned_tools = __esm({
|
|
|
9783
9844
|
"browser_action_save",
|
|
9784
9845
|
"browser_action_do"
|
|
9785
9846
|
];
|
|
9786
|
-
|
|
9847
|
+
BROWSER_LEGACY_TOOL_NAMES = [
|
|
9787
9848
|
...BROWSER_PRIMITIVE_TOOL_NAMES,
|
|
9788
9849
|
...BROWSER_ACTION_TOOL_NAMES
|
|
9789
9850
|
];
|
|
9851
|
+
BROWSER_COMPACT_TOOL_NAMES = [
|
|
9852
|
+
"browser_tabs",
|
|
9853
|
+
"browser_snapshot",
|
|
9854
|
+
"browser_query",
|
|
9855
|
+
"browser_act",
|
|
9856
|
+
"browser_wait_for",
|
|
9857
|
+
"browser_evaluate",
|
|
9858
|
+
"browser_network",
|
|
9859
|
+
"browser_action"
|
|
9860
|
+
];
|
|
9861
|
+
BROWSER_TOOL_NAMES = [
|
|
9862
|
+
...BROWSER_LEGACY_TOOL_NAMES,
|
|
9863
|
+
...BROWSER_COMPACT_TOOL_NAMES.filter(
|
|
9864
|
+
(name) => !BROWSER_LEGACY_TOOL_NAMES.includes(name)
|
|
9865
|
+
)
|
|
9866
|
+
];
|
|
9790
9867
|
BUILT_IN_SUPERONE_TOOL_NAMES = [
|
|
9791
9868
|
"read_manual",
|
|
9792
9869
|
"miniapp_dev_setup",
|
|
@@ -10036,6 +10113,18 @@ var init_map_sdk_message = __esm({
|
|
|
10036
10113
|
}
|
|
10037
10114
|
});
|
|
10038
10115
|
|
|
10116
|
+
// ../../packages/shared/src/slash-commands.ts
|
|
10117
|
+
function readTerminalSlashCommands(value) {
|
|
10118
|
+
if (!Array.isArray(value)) return void 0;
|
|
10119
|
+
const names = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
10120
|
+
return names.length > 0 ? names : void 0;
|
|
10121
|
+
}
|
|
10122
|
+
var init_slash_commands = __esm({
|
|
10123
|
+
"../../packages/shared/src/slash-commands.ts"() {
|
|
10124
|
+
"use strict";
|
|
10125
|
+
}
|
|
10126
|
+
});
|
|
10127
|
+
|
|
10039
10128
|
// ../../packages/claude/src/agent-event-mapper.ts
|
|
10040
10129
|
function emptyResult(sessionId) {
|
|
10041
10130
|
return {
|
|
@@ -10208,10 +10297,11 @@ function createClaudeAgentEventMapper(options) {
|
|
|
10208
10297
|
};
|
|
10209
10298
|
const applySystem = (system) => {
|
|
10210
10299
|
switch (system.subtype) {
|
|
10211
|
-
case "init":
|
|
10300
|
+
case "init": {
|
|
10212
10301
|
if (typeof system.session_id === "string" && system.session_id) {
|
|
10213
10302
|
options.onSessionId?.(system.session_id);
|
|
10214
10303
|
}
|
|
10304
|
+
const terminalSlashCommands = readTerminalSlashCommands(system.terminal_slash_commands);
|
|
10215
10305
|
emit({
|
|
10216
10306
|
type: "session_init",
|
|
10217
10307
|
session: {
|
|
@@ -10221,6 +10311,7 @@ function createClaudeAgentEventMapper(options) {
|
|
|
10221
10311
|
mcpServers: system.mcp_servers ?? [],
|
|
10222
10312
|
permissionMode: system.permissionMode ?? "default",
|
|
10223
10313
|
slashCommands: system.slash_commands ?? [],
|
|
10314
|
+
...terminalSlashCommands ? { terminalSlashCommands } : {},
|
|
10224
10315
|
skills: system.skills ?? [],
|
|
10225
10316
|
claudeCodeVersion: system.claude_code_version ?? "",
|
|
10226
10317
|
cwd: system.cwd ?? "",
|
|
@@ -10235,6 +10326,7 @@ function createClaudeAgentEventMapper(options) {
|
|
|
10235
10326
|
}
|
|
10236
10327
|
});
|
|
10237
10328
|
break;
|
|
10329
|
+
}
|
|
10238
10330
|
case "hook_started":
|
|
10239
10331
|
emit({
|
|
10240
10332
|
type: "hook_started",
|
|
@@ -10691,6 +10783,7 @@ ${text}` : text;
|
|
|
10691
10783
|
var init_agent_event_mapper2 = __esm({
|
|
10692
10784
|
"../../packages/claude/src/agent-event-mapper.ts"() {
|
|
10693
10785
|
"use strict";
|
|
10786
|
+
init_slash_commands();
|
|
10694
10787
|
}
|
|
10695
10788
|
});
|
|
10696
10789
|
|
|
@@ -51443,6 +51536,139 @@ var init_cursor_sdk_available = __esm({
|
|
|
51443
51536
|
}
|
|
51444
51537
|
});
|
|
51445
51538
|
|
|
51539
|
+
// ../../packages/cursor/src/cursor-platform-binaries.ts
|
|
51540
|
+
import { existsSync as existsSync21, statSync as statSync5 } from "node:fs";
|
|
51541
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
51542
|
+
import { dirname as dirname11, join as join18 } from "node:path";
|
|
51543
|
+
function cursorPlatformPackageName(platform2 = process.platform, arch2 = process.arch) {
|
|
51544
|
+
return `@cursor/sdk-${platform2}-${arch2}`;
|
|
51545
|
+
}
|
|
51546
|
+
function toUnpackedAsarPath(filePath) {
|
|
51547
|
+
return filePath.replace(/app\.asar([\\/])/, "app.asar.unpacked$1");
|
|
51548
|
+
}
|
|
51549
|
+
function isExecutableFile(candidate) {
|
|
51550
|
+
try {
|
|
51551
|
+
const st = statSync5(candidate);
|
|
51552
|
+
if (!st.isFile()) return false;
|
|
51553
|
+
if (process.platform === "win32") return true;
|
|
51554
|
+
return (st.mode & 73) !== 0;
|
|
51555
|
+
} catch {
|
|
51556
|
+
return false;
|
|
51557
|
+
}
|
|
51558
|
+
}
|
|
51559
|
+
function cursorSdkRequire() {
|
|
51560
|
+
try {
|
|
51561
|
+
return createRequire3(requireFromHere.resolve("@cursor/sdk/package.json"));
|
|
51562
|
+
} catch {
|
|
51563
|
+
return requireFromHere;
|
|
51564
|
+
}
|
|
51565
|
+
}
|
|
51566
|
+
function resolveCursorPlatformRoot() {
|
|
51567
|
+
const name = cursorPlatformPackageName();
|
|
51568
|
+
const req = cursorSdkRequire();
|
|
51569
|
+
try {
|
|
51570
|
+
const pkgJson = toUnpackedAsarPath(req.resolve(`${name}/package.json`));
|
|
51571
|
+
return existsSync21(pkgJson) ? dirname11(pkgJson) : null;
|
|
51572
|
+
} catch {
|
|
51573
|
+
return null;
|
|
51574
|
+
}
|
|
51575
|
+
}
|
|
51576
|
+
function platformBinName(base) {
|
|
51577
|
+
return process.platform === "win32" ? `${base}.exe` : base;
|
|
51578
|
+
}
|
|
51579
|
+
function resolveCursorSandboxBinary() {
|
|
51580
|
+
const root = resolveCursorPlatformRoot();
|
|
51581
|
+
if (!root) return null;
|
|
51582
|
+
const bin = join18(root, "bin", platformBinName("cursorsandbox"));
|
|
51583
|
+
return isExecutableFile(bin) ? bin : null;
|
|
51584
|
+
}
|
|
51585
|
+
function resolveCursorRipgrepBinary() {
|
|
51586
|
+
const root = resolveCursorPlatformRoot();
|
|
51587
|
+
if (!root) return null;
|
|
51588
|
+
const bin = join18(root, "bin", platformBinName("rg"));
|
|
51589
|
+
return isExecutableFile(bin) ? bin : null;
|
|
51590
|
+
}
|
|
51591
|
+
function resolveCursorTreeSitterVendorDir() {
|
|
51592
|
+
const root = resolveCursorPlatformRoot();
|
|
51593
|
+
if (!root) return null;
|
|
51594
|
+
const vendor = join18(root, "vendor");
|
|
51595
|
+
return existsSync21(join18(vendor, "tree-sitter", "index.js")) ? vendor : null;
|
|
51596
|
+
}
|
|
51597
|
+
function sandboxExecAvailable() {
|
|
51598
|
+
try {
|
|
51599
|
+
statSync5("/usr/bin/sandbox-exec");
|
|
51600
|
+
return true;
|
|
51601
|
+
} catch {
|
|
51602
|
+
return false;
|
|
51603
|
+
}
|
|
51604
|
+
}
|
|
51605
|
+
function isCursorLocalSandboxSupported(probe = {}) {
|
|
51606
|
+
const platform2 = probe.platform ?? process.platform;
|
|
51607
|
+
if (platform2 === "win32") return false;
|
|
51608
|
+
const binary = probe.sandboxBinary !== void 0 ? probe.sandboxBinary : resolveCursorSandboxBinary();
|
|
51609
|
+
if (!binary) return false;
|
|
51610
|
+
if (platform2 === "darwin") {
|
|
51611
|
+
const execOk = probe.sandboxExecExists ?? sandboxExecAvailable();
|
|
51612
|
+
return execOk;
|
|
51613
|
+
}
|
|
51614
|
+
return true;
|
|
51615
|
+
}
|
|
51616
|
+
function resolveCursorSandboxEnabled(requested, probe) {
|
|
51617
|
+
return requested && isCursorLocalSandboxSupported(probe);
|
|
51618
|
+
}
|
|
51619
|
+
function isCursorSandboxUnsupportedError(error51) {
|
|
51620
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
51621
|
+
return /sandboxing is not supported/i.test(message);
|
|
51622
|
+
}
|
|
51623
|
+
function primeHelperEnv() {
|
|
51624
|
+
if (!process.env.CURSOR_RIPGREP_PATH) {
|
|
51625
|
+
const rg = resolveCursorRipgrepBinary();
|
|
51626
|
+
if (rg) process.env.CURSOR_RIPGREP_PATH = rg;
|
|
51627
|
+
}
|
|
51628
|
+
if (!process.env.CURSOR_TREE_SITTER_VENDOR_DIR) {
|
|
51629
|
+
const vendor = resolveCursorTreeSitterVendorDir();
|
|
51630
|
+
if (vendor) process.env.CURSOR_TREE_SITTER_VENDOR_DIR = vendor;
|
|
51631
|
+
}
|
|
51632
|
+
}
|
|
51633
|
+
function beginPlatformLookup() {
|
|
51634
|
+
if (lookupDepth === 0) {
|
|
51635
|
+
savedArgv1 = process.argv[1];
|
|
51636
|
+
const root = resolveCursorPlatformRoot();
|
|
51637
|
+
if (root) process.argv[1] = join18(root, "package.json");
|
|
51638
|
+
primeHelperEnv();
|
|
51639
|
+
}
|
|
51640
|
+
lookupDepth += 1;
|
|
51641
|
+
return () => {
|
|
51642
|
+
lookupDepth = Math.max(0, lookupDepth - 1);
|
|
51643
|
+
if (lookupDepth === 0 && savedArgv1 !== void 0) {
|
|
51644
|
+
process.argv[1] = savedArgv1;
|
|
51645
|
+
savedArgv1 = void 0;
|
|
51646
|
+
}
|
|
51647
|
+
};
|
|
51648
|
+
}
|
|
51649
|
+
function withCursorPlatformLookup(fn) {
|
|
51650
|
+
const restore = beginPlatformLookup();
|
|
51651
|
+
try {
|
|
51652
|
+
const result = fn();
|
|
51653
|
+
if (result && typeof result.then === "function") {
|
|
51654
|
+
return result.finally(restore);
|
|
51655
|
+
}
|
|
51656
|
+
restore();
|
|
51657
|
+
return result;
|
|
51658
|
+
} catch (error51) {
|
|
51659
|
+
restore();
|
|
51660
|
+
throw error51;
|
|
51661
|
+
}
|
|
51662
|
+
}
|
|
51663
|
+
var requireFromHere, lookupDepth, savedArgv1;
|
|
51664
|
+
var init_cursor_platform_binaries = __esm({
|
|
51665
|
+
"../../packages/cursor/src/cursor-platform-binaries.ts"() {
|
|
51666
|
+
"use strict";
|
|
51667
|
+
requireFromHere = createRequire3(import.meta.url);
|
|
51668
|
+
lookupDepth = 0;
|
|
51669
|
+
}
|
|
51670
|
+
});
|
|
51671
|
+
|
|
51446
51672
|
// ../../packages/cursor/src/cursor-mcp-map.ts
|
|
51447
51673
|
function mcpServersToStatus(servers) {
|
|
51448
51674
|
return Object.keys(servers).map((name) => ({ name, status: "connected" }));
|
|
@@ -51968,7 +52194,7 @@ var init_cursor_event_map = __esm({
|
|
|
51968
52194
|
import Database2 from "better-sqlite3";
|
|
51969
52195
|
import { mkdirSync as mkdirSync11 } from "node:fs";
|
|
51970
52196
|
import { createHash as createHash4 } from "node:crypto";
|
|
51971
|
-
import { join as
|
|
52197
|
+
import { join as join19 } from "node:path";
|
|
51972
52198
|
function workspaceHash(workspaceRef) {
|
|
51973
52199
|
return createHash4("md5").update(workspaceRef).digest("hex");
|
|
51974
52200
|
}
|
|
@@ -52011,7 +52237,7 @@ var init_cursor_store = __esm({
|
|
|
52011
52237
|
runEvents;
|
|
52012
52238
|
db;
|
|
52013
52239
|
constructor(dbPath) {
|
|
52014
|
-
mkdirSync11(
|
|
52240
|
+
mkdirSync11(join19(dbPath, ".."), { recursive: true });
|
|
52015
52241
|
this.db = new Database2(dbPath);
|
|
52016
52242
|
this.db.pragma("journal_mode = WAL");
|
|
52017
52243
|
this.migrate();
|
|
@@ -52021,9 +52247,9 @@ var init_cursor_store = __esm({
|
|
|
52021
52247
|
this.runEvents = this.createRunEvents();
|
|
52022
52248
|
}
|
|
52023
52249
|
static openForWorkspace(userDataRoot, workspaceRef) {
|
|
52024
|
-
const dir =
|
|
52250
|
+
const dir = join19(userDataRoot, "cursor-sdk", workspaceHash(workspaceRef));
|
|
52025
52251
|
mkdirSync11(dir, { recursive: true });
|
|
52026
|
-
return new _BetterSqliteLocalAgentStore(
|
|
52252
|
+
return new _BetterSqliteLocalAgentStore(join19(dir, "agent-store.db"));
|
|
52027
52253
|
}
|
|
52028
52254
|
dispose() {
|
|
52029
52255
|
this.db.close();
|
|
@@ -52501,6 +52727,126 @@ var init_cursor_sdk_auth = __esm({
|
|
|
52501
52727
|
}
|
|
52502
52728
|
});
|
|
52503
52729
|
|
|
52730
|
+
// ../../packages/cursor/src/cursor-local-options.ts
|
|
52731
|
+
function resolveCursorLocalSessionPlan(input) {
|
|
52732
|
+
const config2 = readCursorConfig(input.config);
|
|
52733
|
+
const resolveApiKey = input.resolveApiKey ?? resolveCursorApiKeyPlain;
|
|
52734
|
+
const buildMcpServers = input.buildMcpServers ?? (() => ({}));
|
|
52735
|
+
const isCloud = config2.runtime === "cloud" || (input.providerSessionId?.startsWith("bc-") ?? false);
|
|
52736
|
+
const perm = mapPermissionToCursorLocal(input.permissionMode);
|
|
52737
|
+
const settingSources = config2.settingSources ?? DEFAULT_CURSOR_SETTING_SOURCES;
|
|
52738
|
+
const sandboxRequested = input.sandboxEnabled ?? config2.sandboxEnabled ?? false;
|
|
52739
|
+
const sandboxEnabled = isCloud ? false : resolveCursorSandboxEnabled(sandboxRequested);
|
|
52740
|
+
const mcpServers = isCloud ? stripStdioCwd(buildMcpServers(input.cwd, input.sessionId)) : buildMcpServers(input.cwd, input.sessionId);
|
|
52741
|
+
return {
|
|
52742
|
+
apiKey: resolveApiKey(input.config),
|
|
52743
|
+
config: config2,
|
|
52744
|
+
isCloud,
|
|
52745
|
+
settingSources,
|
|
52746
|
+
sandboxEnabled,
|
|
52747
|
+
sandboxRequested,
|
|
52748
|
+
perm,
|
|
52749
|
+
enableAgentRetries: config2.enableAgentRetries ?? true,
|
|
52750
|
+
mcpServers
|
|
52751
|
+
};
|
|
52752
|
+
}
|
|
52753
|
+
var DEFAULT_CURSOR_SETTING_SOURCES;
|
|
52754
|
+
var init_cursor_local_options = __esm({
|
|
52755
|
+
"../../packages/cursor/src/cursor-local-options.ts"() {
|
|
52756
|
+
"use strict";
|
|
52757
|
+
init_cursor_config();
|
|
52758
|
+
init_cursor_platform_binaries();
|
|
52759
|
+
init_cursor_mcp_map();
|
|
52760
|
+
DEFAULT_CURSOR_SETTING_SOURCES = ["project", "user"];
|
|
52761
|
+
}
|
|
52762
|
+
});
|
|
52763
|
+
|
|
52764
|
+
// ../../packages/cursor/src/cursor-network-retry.ts
|
|
52765
|
+
import { NetworkError } from "@cursor/sdk";
|
|
52766
|
+
function isCursorRetryableNetworkError(error51) {
|
|
52767
|
+
if (error51 instanceof NetworkError) return error51.isRetryable;
|
|
52768
|
+
if (!error51 || typeof error51 !== "object") return false;
|
|
52769
|
+
const name = "name" in error51 ? String(error51.name) : "";
|
|
52770
|
+
if (name !== "NetworkError") return false;
|
|
52771
|
+
if (!("isRetryable" in error51)) return true;
|
|
52772
|
+
return Boolean(error51.isRetryable);
|
|
52773
|
+
}
|
|
52774
|
+
function defaultSleep(ms) {
|
|
52775
|
+
return new Promise((resolve13) => {
|
|
52776
|
+
setTimeout(resolve13, ms);
|
|
52777
|
+
});
|
|
52778
|
+
}
|
|
52779
|
+
async function withCursorNetworkRetries(fn, opts) {
|
|
52780
|
+
const retries = opts?.retries ?? CURSOR_NETWORK_RETRY_ATTEMPTS;
|
|
52781
|
+
const baseDelayMs = opts?.baseDelayMs ?? CURSOR_NETWORK_RETRY_BASE_DELAY_MS;
|
|
52782
|
+
const maxDelayMs = opts?.maxDelayMs ?? CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
|
|
52783
|
+
const sleep = opts?.sleep ?? defaultSleep;
|
|
52784
|
+
let lastError;
|
|
52785
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
52786
|
+
try {
|
|
52787
|
+
return await fn();
|
|
52788
|
+
} catch (error51) {
|
|
52789
|
+
lastError = error51;
|
|
52790
|
+
if (!isCursorRetryableNetworkError(error51) || attempt === retries) throw error51;
|
|
52791
|
+
const delayMs = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
|
|
52792
|
+
opts?.onRetry?.({ attempt: attempt + 1, retries, delayMs, error: error51 });
|
|
52793
|
+
await sleep(delayMs);
|
|
52794
|
+
}
|
|
52795
|
+
}
|
|
52796
|
+
throw lastError;
|
|
52797
|
+
}
|
|
52798
|
+
var CURSOR_NETWORK_RETRY_ATTEMPTS, CURSOR_NETWORK_RETRY_BASE_DELAY_MS, CURSOR_NETWORK_RETRY_MAX_DELAY_MS;
|
|
52799
|
+
var init_cursor_network_retry = __esm({
|
|
52800
|
+
"../../packages/cursor/src/cursor-network-retry.ts"() {
|
|
52801
|
+
"use strict";
|
|
52802
|
+
CURSOR_NETWORK_RETRY_ATTEMPTS = 5;
|
|
52803
|
+
CURSOR_NETWORK_RETRY_BASE_DELAY_MS = 2e3;
|
|
52804
|
+
CURSOR_NETWORK_RETRY_MAX_DELAY_MS = 8e3;
|
|
52805
|
+
}
|
|
52806
|
+
});
|
|
52807
|
+
|
|
52808
|
+
// ../../packages/cursor/src/cursor-sdk-trace.ts
|
|
52809
|
+
function createCursorSdkTracer(onSdkTrace) {
|
|
52810
|
+
const emit = (source, type, data, tag) => {
|
|
52811
|
+
if (!onSdkTrace) return;
|
|
52812
|
+
try {
|
|
52813
|
+
onSdkTrace(source, type, data, tag);
|
|
52814
|
+
} catch {
|
|
52815
|
+
}
|
|
52816
|
+
};
|
|
52817
|
+
return {
|
|
52818
|
+
sdk(type, data, tag) {
|
|
52819
|
+
emit("agent.sdk", type || "unknown", data, tag);
|
|
52820
|
+
},
|
|
52821
|
+
runtime(type, data, tag) {
|
|
52822
|
+
emit("cursor.runtime", type || "unknown", data, tag);
|
|
52823
|
+
}
|
|
52824
|
+
};
|
|
52825
|
+
}
|
|
52826
|
+
function cursorSdkType(value, fallback) {
|
|
52827
|
+
if (!value || typeof value !== "object") return fallback;
|
|
52828
|
+
const type = value.type;
|
|
52829
|
+
return typeof type === "string" && type ? type : fallback;
|
|
52830
|
+
}
|
|
52831
|
+
function cursorUserSendTracePayload(message) {
|
|
52832
|
+
if (typeof message === "string") return { text: message };
|
|
52833
|
+
if (!message || typeof message !== "object") return message;
|
|
52834
|
+
const rec = message;
|
|
52835
|
+
if (!Array.isArray(rec.images)) return message;
|
|
52836
|
+
return {
|
|
52837
|
+
text: rec.text,
|
|
52838
|
+
images: rec.images.map((img) => ({
|
|
52839
|
+
mimeType: typeof img?.mimeType === "string" ? img.mimeType : "",
|
|
52840
|
+
bytes: typeof img?.data === "string" ? img.data.length : 0
|
|
52841
|
+
}))
|
|
52842
|
+
};
|
|
52843
|
+
}
|
|
52844
|
+
var init_cursor_sdk_trace = __esm({
|
|
52845
|
+
"../../packages/cursor/src/cursor-sdk-trace.ts"() {
|
|
52846
|
+
"use strict";
|
|
52847
|
+
}
|
|
52848
|
+
});
|
|
52849
|
+
|
|
52504
52850
|
// ../../packages/cursor/src/cursor-runtime.ts
|
|
52505
52851
|
import {
|
|
52506
52852
|
Agent as Agent4,
|
|
@@ -52529,41 +52875,63 @@ async function createCursorRuntime(opts) {
|
|
|
52529
52875
|
error: opts.log?.error ?? noopLog.error,
|
|
52530
52876
|
debug: opts.log?.debug ?? noopLog.debug
|
|
52531
52877
|
};
|
|
52532
|
-
const
|
|
52533
|
-
const
|
|
52534
|
-
const
|
|
52535
|
-
const apiKey = resolveApiKey(opts.config);
|
|
52878
|
+
const tracer = createCursorSdkTracer(opts.onSdkTrace);
|
|
52879
|
+
const plan = resolveCursorLocalSessionPlan(opts);
|
|
52880
|
+
const apiKey = plan.apiKey;
|
|
52536
52881
|
if (!apiKey) {
|
|
52537
52882
|
throw new Error(
|
|
52538
52883
|
"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
52884
|
);
|
|
52540
52885
|
}
|
|
52541
|
-
if (
|
|
52886
|
+
if (plan.config.useHttp1ForAgent != null) {
|
|
52542
52887
|
try {
|
|
52543
|
-
Cursor4.configure({ local: { useHttp1ForAgent:
|
|
52888
|
+
Cursor4.configure({ local: { useHttp1ForAgent: plan.config.useHttp1ForAgent } });
|
|
52544
52889
|
} catch (error51) {
|
|
52545
52890
|
log2.debug("[CursorRuntime] Cursor.configure useHttp1ForAgent failed:", error51);
|
|
52546
52891
|
}
|
|
52547
52892
|
}
|
|
52548
|
-
const isCloud =
|
|
52549
|
-
const modelId = opts.modelSelection?.id || opts.model ||
|
|
52893
|
+
const isCloud = plan.isCloud;
|
|
52894
|
+
const modelId = opts.modelSelection?.id || opts.model || plan.config.model;
|
|
52550
52895
|
if (!isCloud && !modelId) {
|
|
52551
52896
|
throw new Error("Cursor model is required for local agents. Connect Cursor to load models, then select one.");
|
|
52552
52897
|
}
|
|
52553
|
-
const perm =
|
|
52898
|
+
const perm = plan.perm;
|
|
52554
52899
|
const model = opts.modelSelection ?? (modelId ? { id: modelId } : void 0);
|
|
52555
|
-
const settingSources =
|
|
52556
|
-
|
|
52557
|
-
|
|
52900
|
+
const settingSources = plan.settingSources;
|
|
52901
|
+
let sandboxEnabled = plan.sandboxEnabled;
|
|
52902
|
+
if (plan.sandboxRequested && !sandboxEnabled) {
|
|
52903
|
+
log2.warn(
|
|
52904
|
+
"[CursorRuntime] sandbox requested but Cursor local sandbox is unavailable; running unsandboxed"
|
|
52905
|
+
);
|
|
52906
|
+
}
|
|
52907
|
+
const mcpServers = plan.mcpServers;
|
|
52908
|
+
const config2 = plan.config;
|
|
52909
|
+
const buildMcpServers = opts.buildMcpServers ?? (() => ({}));
|
|
52558
52910
|
const customTools = isCloud ? void 0 : buildCursorCustomTools({ sessionId: opts.sessionId, cwd: opts.cwd });
|
|
52559
52911
|
const agentName = opts.agentName?.trim() || void 0;
|
|
52560
52912
|
const toolRestrictions = isCloud ? {} : resolveCursorToolRestrictions(config2);
|
|
52561
52913
|
const toolsOpt = toolRestrictions.tools ? { tools: toolRestrictions.tools } : {};
|
|
52562
52914
|
const disallowedOpt = toolRestrictions.disallowedTools ? { disallowedTools: toolRestrictions.disallowedTools } : {};
|
|
52563
|
-
|
|
52564
|
-
|
|
52915
|
+
const createStarted = Date.now();
|
|
52916
|
+
log2.info("[CursorRuntime] opening agent", {
|
|
52917
|
+
sessionId: opts.sessionId,
|
|
52918
|
+
sandboxEnabled,
|
|
52919
|
+
mcpCount: Object.keys(mcpServers).length,
|
|
52920
|
+
settingSources
|
|
52921
|
+
});
|
|
52922
|
+
tracer.runtime("create_session", {
|
|
52923
|
+
sessionId: opts.sessionId,
|
|
52924
|
+
cwd: opts.cwd,
|
|
52925
|
+
sandboxEnabled,
|
|
52926
|
+
mcpCount: Object.keys(mcpServers).length,
|
|
52927
|
+
settingSources,
|
|
52928
|
+
resume: opts.providerSessionId ?? null,
|
|
52929
|
+
model: modelId ?? null,
|
|
52930
|
+
isCloud
|
|
52931
|
+
}, opts.sessionId);
|
|
52932
|
+
const openAgent = (sandbox) => withCursorPlatformLookup(async () => {
|
|
52565
52933
|
if (opts.providerSessionId) {
|
|
52566
|
-
|
|
52934
|
+
return Agent4.resume(opts.providerSessionId, {
|
|
52567
52935
|
apiKey,
|
|
52568
52936
|
...model ? { model } : {},
|
|
52569
52937
|
...agentName ? { name: agentName } : {},
|
|
@@ -52576,16 +52944,17 @@ async function createCursorRuntime(opts) {
|
|
|
52576
52944
|
cwd: opts.cwd,
|
|
52577
52945
|
store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
|
|
52578
52946
|
settingSources,
|
|
52579
|
-
sandboxOptions: { enabled:
|
|
52947
|
+
sandboxOptions: { enabled: sandbox },
|
|
52580
52948
|
// Session permission UI owns autoReview; static config must not override.
|
|
52581
52949
|
autoReview: perm.autoReview,
|
|
52582
|
-
enableAgentRetries:
|
|
52950
|
+
enableAgentRetries: plan.enableAgentRetries,
|
|
52583
52951
|
...customTools ? { customTools } : {}
|
|
52584
52952
|
}
|
|
52585
52953
|
}
|
|
52586
52954
|
});
|
|
52587
|
-
}
|
|
52588
|
-
|
|
52955
|
+
}
|
|
52956
|
+
if (isCloud) {
|
|
52957
|
+
return Agent4.create({
|
|
52589
52958
|
apiKey,
|
|
52590
52959
|
...model ? { model } : {},
|
|
52591
52960
|
...agentName ? { name: agentName } : {},
|
|
@@ -52593,30 +52962,77 @@ async function createCursorRuntime(opts) {
|
|
|
52593
52962
|
mcpServers,
|
|
52594
52963
|
cloud: buildCloudOptions(config2)
|
|
52595
52964
|
});
|
|
52596
|
-
}
|
|
52597
|
-
|
|
52598
|
-
|
|
52599
|
-
|
|
52600
|
-
|
|
52601
|
-
|
|
52602
|
-
|
|
52603
|
-
|
|
52604
|
-
|
|
52605
|
-
|
|
52606
|
-
|
|
52607
|
-
|
|
52608
|
-
|
|
52609
|
-
|
|
52610
|
-
|
|
52611
|
-
|
|
52612
|
-
|
|
52613
|
-
|
|
52614
|
-
|
|
52965
|
+
}
|
|
52966
|
+
return Agent4.create({
|
|
52967
|
+
apiKey,
|
|
52968
|
+
model,
|
|
52969
|
+
...agentName ? { name: agentName } : {},
|
|
52970
|
+
mode: perm.mode,
|
|
52971
|
+
mcpServers,
|
|
52972
|
+
...toolsOpt,
|
|
52973
|
+
...disallowedOpt,
|
|
52974
|
+
local: {
|
|
52975
|
+
cwd: opts.cwd,
|
|
52976
|
+
store: getCursorAgentStore(opts.userDataRoot, opts.cwd),
|
|
52977
|
+
settingSources,
|
|
52978
|
+
sandboxOptions: { enabled: sandbox },
|
|
52979
|
+
// Session permission UI owns autoReview; static config must not override.
|
|
52980
|
+
autoReview: perm.autoReview,
|
|
52981
|
+
enableAgentRetries: plan.enableAgentRetries,
|
|
52982
|
+
...customTools ? { customTools } : {}
|
|
52983
|
+
}
|
|
52984
|
+
});
|
|
52985
|
+
});
|
|
52986
|
+
const openAgentRetrying = (sandbox) => withCursorNetworkRetries(() => openAgent(sandbox), {
|
|
52987
|
+
onRetry: ({ attempt, retries, delayMs, error: error51 }) => {
|
|
52988
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
52989
|
+
log2.warn("[CursorRuntime] retryable network error on Agent.create", {
|
|
52990
|
+
attempt,
|
|
52991
|
+
retries,
|
|
52992
|
+
delayMs,
|
|
52993
|
+
message
|
|
52615
52994
|
});
|
|
52995
|
+
tracer.runtime("create_retry", {
|
|
52996
|
+
attempt,
|
|
52997
|
+
retries,
|
|
52998
|
+
delayMs,
|
|
52999
|
+
message,
|
|
53000
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
53001
|
+
}, opts.sessionId);
|
|
52616
53002
|
}
|
|
53003
|
+
});
|
|
53004
|
+
let agent;
|
|
53005
|
+
try {
|
|
53006
|
+
agent = await openAgentRetrying(sandboxEnabled);
|
|
52617
53007
|
} catch (error51) {
|
|
52618
|
-
|
|
53008
|
+
if (!isCloud && sandboxEnabled && isCursorSandboxUnsupportedError(error51)) {
|
|
53009
|
+
log2.warn(
|
|
53010
|
+
"[CursorRuntime] Cursor SDK rejected local sandbox; retrying with sandbox disabled"
|
|
53011
|
+
);
|
|
53012
|
+
tracer.runtime("sandbox_fallback", {
|
|
53013
|
+
sessionId: opts.sessionId,
|
|
53014
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
53015
|
+
}, opts.sessionId);
|
|
53016
|
+
sandboxEnabled = false;
|
|
53017
|
+
try {
|
|
53018
|
+
agent = await openAgentRetrying(false);
|
|
53019
|
+
} catch (retryError) {
|
|
53020
|
+
throw formatCursorError(retryError);
|
|
53021
|
+
}
|
|
53022
|
+
} else {
|
|
53023
|
+
throw formatCursorError(error51);
|
|
53024
|
+
}
|
|
52619
53025
|
}
|
|
53026
|
+
log2.info("[CursorRuntime] agent ready", {
|
|
53027
|
+
agentId: agent.agentId,
|
|
53028
|
+
ms: Date.now() - createStarted,
|
|
53029
|
+
sandboxEnabled
|
|
53030
|
+
});
|
|
53031
|
+
tracer.runtime("agent_ready", {
|
|
53032
|
+
agentId: agent.agentId,
|
|
53033
|
+
ms: Date.now() - createStarted,
|
|
53034
|
+
sandboxEnabled
|
|
53035
|
+
}, opts.sessionId);
|
|
52620
53036
|
opts.onProviderSessionId?.(agent.agentId);
|
|
52621
53037
|
opts.onEvent({ type: "provider_session_id", providerSessionId: agent.agentId });
|
|
52622
53038
|
let currentRun = null;
|
|
@@ -52674,18 +53090,28 @@ async function createCursorRuntime(opts) {
|
|
|
52674
53090
|
lastMcpServers = servers;
|
|
52675
53091
|
const contextWindow = resolveContextWindow(modelSelection);
|
|
52676
53092
|
const callIdBridge = new CursorTurnCallIdBridge();
|
|
53093
|
+
const sendStarted = Date.now();
|
|
53094
|
+
log2.info("[CursorRuntime] send start", { messageId });
|
|
53095
|
+
tracer.sdk("user_send", cursorUserSendTracePayload(userMessage2), messageId);
|
|
53096
|
+
tracer.runtime("send_start", {
|
|
53097
|
+
messageId,
|
|
53098
|
+
model: modelSelection?.id ?? null,
|
|
53099
|
+
force: Boolean(sendOpts?.force)
|
|
53100
|
+
}, messageId);
|
|
52677
53101
|
const sendOptions = {
|
|
52678
53102
|
...modelSelection ? { model: modelSelection } : {},
|
|
52679
53103
|
mode: permLocal.mode,
|
|
52680
53104
|
mcpServers: Object.keys(servers).length ? servers : void 0,
|
|
52681
53105
|
...sendOpts?.idempotencyKey ? { idempotencyKey: sendOpts.idempotencyKey } : {},
|
|
52682
53106
|
onDelta: ({ update }) => {
|
|
53107
|
+
tracer.sdk(cursorSdkType(update, "delta"), update, messageId);
|
|
52683
53108
|
callIdBridge.observeDelta(update);
|
|
52684
53109
|
for (const event of mapInteractionUpdate(messageId, update, { contextWindow })) {
|
|
52685
53110
|
opts.onEvent(event);
|
|
52686
53111
|
}
|
|
52687
53112
|
},
|
|
52688
53113
|
onStep: ({ step }) => {
|
|
53114
|
+
tracer.sdk(cursorSdkType(step, "step"), step, messageId);
|
|
52689
53115
|
for (const event of mapConversationStep(messageId, step, {
|
|
52690
53116
|
resolveCallId: () => callIdBridge.claimNextCallId()
|
|
52691
53117
|
})) {
|
|
@@ -52706,28 +53132,54 @@ async function createCursorRuntime(opts) {
|
|
|
52706
53132
|
} catch (error51) {
|
|
52707
53133
|
if (error51 instanceof AgentBusyError && !sendOpts?.force && !isCloud) {
|
|
52708
53134
|
log2.warn("[CursorRuntime] AgentBusyError \u2014 retrying with local.force");
|
|
53135
|
+
tracer.runtime("agent_busy_retry", {
|
|
53136
|
+
message: error51 instanceof Error ? error51.message : String(error51)
|
|
53137
|
+
}, messageId);
|
|
52709
53138
|
try {
|
|
52710
53139
|
run = await agent.send(userMessage2, {
|
|
52711
53140
|
...sendOptions,
|
|
52712
53141
|
local: { force: true }
|
|
52713
53142
|
});
|
|
52714
53143
|
} catch (retryError) {
|
|
53144
|
+
tracer.runtime("send_error", {
|
|
53145
|
+
message: retryError instanceof Error ? retryError.message : String(retryError),
|
|
53146
|
+
name: retryError instanceof Error ? retryError.name : "Error",
|
|
53147
|
+
afterForce: true
|
|
53148
|
+
}, messageId);
|
|
52715
53149
|
throw formatCursorError(retryError);
|
|
52716
53150
|
}
|
|
52717
53151
|
} else {
|
|
53152
|
+
tracer.runtime("send_error", {
|
|
53153
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53154
|
+
name: error51 instanceof Error ? error51.name : "Error",
|
|
53155
|
+
ms: Date.now() - sendStarted
|
|
53156
|
+
}, messageId);
|
|
52718
53157
|
throw formatCursorError(error51);
|
|
52719
53158
|
}
|
|
52720
53159
|
}
|
|
52721
53160
|
currentRun = run;
|
|
52722
53161
|
lastRunId = run.id;
|
|
52723
|
-
log2.
|
|
53162
|
+
log2.info("[CursorRuntime] run started", {
|
|
53163
|
+
runId: run.id,
|
|
53164
|
+
agentId: run.agentId,
|
|
53165
|
+
ms: Date.now() - sendStarted
|
|
53166
|
+
});
|
|
53167
|
+
tracer.runtime("run_started", {
|
|
53168
|
+
runId: run.id,
|
|
53169
|
+
agentId: run.agentId,
|
|
53170
|
+
ms: Date.now() - sendStarted
|
|
53171
|
+
}, messageId);
|
|
52724
53172
|
void (async () => {
|
|
52725
53173
|
try {
|
|
52726
53174
|
if (!run.supports("stream")) {
|
|
52727
53175
|
log2.debug("[CursorRuntime] stream unsupported:", run.unsupportedReason("stream"));
|
|
53176
|
+
tracer.runtime("stream_unsupported", {
|
|
53177
|
+
reason: run.unsupportedReason("stream") ?? null
|
|
53178
|
+
}, messageId);
|
|
52728
53179
|
return;
|
|
52729
53180
|
}
|
|
52730
53181
|
for await (const message of run.stream()) {
|
|
53182
|
+
tracer.sdk(cursorSdkType(message, "stream"), message, messageId);
|
|
52731
53183
|
for (const event of mapSdkMessageLifecycle(messageId, message, {
|
|
52732
53184
|
includeContent: false,
|
|
52733
53185
|
contextWindow
|
|
@@ -52737,9 +53189,23 @@ async function createCursorRuntime(opts) {
|
|
|
52737
53189
|
}
|
|
52738
53190
|
} catch (error51) {
|
|
52739
53191
|
log2.debug("[CursorRuntime] stream consumer ended:", error51);
|
|
53192
|
+
tracer.runtime("stream_error", {
|
|
53193
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53194
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
53195
|
+
}, messageId);
|
|
52740
53196
|
}
|
|
52741
53197
|
})();
|
|
52742
|
-
|
|
53198
|
+
let result;
|
|
53199
|
+
try {
|
|
53200
|
+
result = await run.wait();
|
|
53201
|
+
} catch (error51) {
|
|
53202
|
+
tracer.runtime("wait_error", {
|
|
53203
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
53204
|
+
name: error51 instanceof Error ? error51.name : "Error"
|
|
53205
|
+
}, messageId);
|
|
53206
|
+
throw formatCursorError(error51);
|
|
53207
|
+
}
|
|
53208
|
+
tracer.sdk("result", result, messageId);
|
|
52743
53209
|
currentRun = null;
|
|
52744
53210
|
lastRunId = result.id || lastRunId;
|
|
52745
53211
|
if (result.usage) {
|
|
@@ -52816,10 +53282,14 @@ var init_cursor_runtime = __esm({
|
|
|
52816
53282
|
"../../packages/cursor/src/cursor-runtime.ts"() {
|
|
52817
53283
|
"use strict";
|
|
52818
53284
|
init_cursor_config();
|
|
53285
|
+
init_cursor_local_options();
|
|
53286
|
+
init_cursor_network_retry();
|
|
52819
53287
|
init_cursor_custom_tools();
|
|
52820
53288
|
init_cursor_event_map();
|
|
52821
53289
|
init_cursor_mcp_map();
|
|
52822
53290
|
init_cursor_model_selection();
|
|
53291
|
+
init_cursor_platform_binaries();
|
|
53292
|
+
init_cursor_sdk_trace();
|
|
52823
53293
|
init_cursor_store();
|
|
52824
53294
|
noopLog = {
|
|
52825
53295
|
info: () => void 0,
|
|
@@ -52840,6 +53310,25 @@ var init_cursor_runtime = __esm({
|
|
|
52840
53310
|
}
|
|
52841
53311
|
});
|
|
52842
53312
|
|
|
53313
|
+
// ../../packages/cursor/src/cursor-workspace-prewarm.ts
|
|
53314
|
+
import { createAgentPlatform } from "@cursor/sdk";
|
|
53315
|
+
var init_cursor_workspace_prewarm = __esm({
|
|
53316
|
+
"../../packages/cursor/src/cursor-workspace-prewarm.ts"() {
|
|
53317
|
+
"use strict";
|
|
53318
|
+
init_cursor_sdk_trace();
|
|
53319
|
+
init_cursor_local_options();
|
|
53320
|
+
init_cursor_platform_binaries();
|
|
53321
|
+
}
|
|
53322
|
+
});
|
|
53323
|
+
|
|
53324
|
+
// ../../packages/cursor/src/cursor-skills-discover.ts
|
|
53325
|
+
var init_cursor_skills_discover = __esm({
|
|
53326
|
+
"../../packages/cursor/src/cursor-skills-discover.ts"() {
|
|
53327
|
+
"use strict";
|
|
53328
|
+
init_fs();
|
|
53329
|
+
}
|
|
53330
|
+
});
|
|
53331
|
+
|
|
52843
53332
|
// ../../packages/cursor/src/run-sdk-turn.ts
|
|
52844
53333
|
async function runCursorSdkTurn(opts) {
|
|
52845
53334
|
if (opts.signal?.aborted) {
|
|
@@ -52966,6 +53455,7 @@ var init_src5 = __esm({
|
|
|
52966
53455
|
"use strict";
|
|
52967
53456
|
init_cursor_config();
|
|
52968
53457
|
init_cursor_sdk_available();
|
|
53458
|
+
init_cursor_platform_binaries();
|
|
52969
53459
|
init_cursor_mcp_map();
|
|
52970
53460
|
init_cursor_custom_tools();
|
|
52971
53461
|
init_cursor_event_map();
|
|
@@ -52975,6 +53465,10 @@ var init_src5 = __esm({
|
|
|
52975
53465
|
init_cursor_cloud();
|
|
52976
53466
|
init_cursor_sdk_auth();
|
|
52977
53467
|
init_cursor_runtime();
|
|
53468
|
+
init_cursor_sdk_trace();
|
|
53469
|
+
init_cursor_workspace_prewarm();
|
|
53470
|
+
init_cursor_skills_discover();
|
|
53471
|
+
init_cursor_network_retry();
|
|
52978
53472
|
init_run_sdk_turn2();
|
|
52979
53473
|
init_simulated_runner3();
|
|
52980
53474
|
}
|
|
@@ -53188,7 +53682,7 @@ var init_codex_live_turn = __esm({
|
|
|
53188
53682
|
});
|
|
53189
53683
|
|
|
53190
53684
|
// src/session/codex-turn-runner.ts
|
|
53191
|
-
import { existsSync as
|
|
53685
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
53192
53686
|
function mapCodexReasoningEffort(effort) {
|
|
53193
53687
|
if (!effort) return void 0;
|
|
53194
53688
|
const e = effort.trim().toLowerCase();
|
|
@@ -53199,18 +53693,18 @@ function mapCodexReasoningEffort(effort) {
|
|
|
53199
53693
|
return void 0;
|
|
53200
53694
|
}
|
|
53201
53695
|
function resolveCodexBinaryPath(opts) {
|
|
53202
|
-
if (opts.binaryPath &&
|
|
53696
|
+
if (opts.binaryPath && existsSync22(opts.binaryPath)) return opts.binaryPath;
|
|
53203
53697
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
53204
|
-
if (fromEnv &&
|
|
53698
|
+
if (fromEnv && existsSync22(fromEnv)) return fromEnv;
|
|
53205
53699
|
const status = opts.harnesses?.get("codex");
|
|
53206
|
-
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command &&
|
|
53700
|
+
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync22(status.command)) {
|
|
53207
53701
|
return status.command;
|
|
53208
53702
|
}
|
|
53209
53703
|
return null;
|
|
53210
53704
|
}
|
|
53211
53705
|
function isCodexBinaryOverrideRunnable() {
|
|
53212
53706
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
53213
|
-
return Boolean(fromEnv &&
|
|
53707
|
+
return Boolean(fromEnv && existsSync22(fromEnv));
|
|
53214
53708
|
}
|
|
53215
53709
|
function providerEnvKeyOf(env) {
|
|
53216
53710
|
return [
|
|
@@ -60655,8 +61149,8 @@ import { fileURLToPath } from "node:url";
|
|
|
60655
61149
|
function resolveCliReleaseVersion() {
|
|
60656
61150
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
60657
61151
|
if (fromEnv) return fromEnv;
|
|
60658
|
-
if ("0.53.
|
|
60659
|
-
return "0.53.
|
|
61152
|
+
if ("0.53.4-alpha".trim()) {
|
|
61153
|
+
return "0.53.4-alpha".trim();
|
|
60660
61154
|
}
|
|
60661
61155
|
const fromDist = readDistManifestVersion();
|
|
60662
61156
|
if (fromDist) return fromDist;
|
|
@@ -60906,7 +61400,7 @@ function regenerateIdentity(nodeHome, label) {
|
|
|
60906
61400
|
}
|
|
60907
61401
|
|
|
60908
61402
|
// src/runtime.ts
|
|
60909
|
-
import { existsSync as
|
|
61403
|
+
import { existsSync as existsSync40, readFileSync as readFileSync19, writeFileSync as writeFileSync17 } from "node:fs";
|
|
60910
61404
|
|
|
60911
61405
|
// src/auth/auth-service.ts
|
|
60912
61406
|
init_environment();
|
|
@@ -62400,11 +62894,11 @@ function parseState(raw) {
|
|
|
62400
62894
|
|
|
62401
62895
|
// ../../packages/runtime/src/harness/home-path.ts
|
|
62402
62896
|
import { homedir as homedir6 } from "node:os";
|
|
62403
|
-
import { join as
|
|
62897
|
+
import { join as join20 } from "node:path";
|
|
62404
62898
|
var HARNESS_HOME_DIRNAME = "harness";
|
|
62405
62899
|
var SUPERONE_DIRNAME = ".superone";
|
|
62406
62900
|
function defaultHarnessHomeRoot(userHome = homedir6()) {
|
|
62407
|
-
return
|
|
62901
|
+
return join20(userHome, SUPERONE_DIRNAME, HARNESS_HOME_DIRNAME);
|
|
62408
62902
|
}
|
|
62409
62903
|
function resolveHarnessHomeRoot(opts = {}) {
|
|
62410
62904
|
const explicit = opts.override?.trim();
|
|
@@ -62418,16 +62912,16 @@ function resolveHarnessHomeRoot(opts = {}) {
|
|
|
62418
62912
|
|
|
62419
62913
|
// ../../packages/runtime/src/harness/managed-layout.ts
|
|
62420
62914
|
import {
|
|
62421
|
-
existsSync as
|
|
62915
|
+
existsSync as existsSync23,
|
|
62422
62916
|
mkdirSync as mkdirSync12,
|
|
62423
62917
|
readdirSync as readdirSync8,
|
|
62424
62918
|
readFileSync as readFileSync13,
|
|
62425
62919
|
renameSync as renameSync2,
|
|
62426
62920
|
rmSync as rmSync2,
|
|
62427
|
-
statSync as
|
|
62921
|
+
statSync as statSync6,
|
|
62428
62922
|
writeFileSync as writeFileSync9
|
|
62429
62923
|
} from "node:fs";
|
|
62430
|
-
import { join as
|
|
62924
|
+
import { join as join21 } from "node:path";
|
|
62431
62925
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
62432
62926
|
var MANAGED_VERSIONS_DIRNAME = "versions";
|
|
62433
62927
|
var MANAGED_CURRENT_BASENAME = "current";
|
|
@@ -62444,17 +62938,17 @@ function sanitizeRuntimeVersionForPath(runtimeVersion) {
|
|
|
62444
62938
|
return v2;
|
|
62445
62939
|
}
|
|
62446
62940
|
function managedVersionsDir(prefix) {
|
|
62447
|
-
return
|
|
62941
|
+
return join21(prefix, MANAGED_VERSIONS_DIRNAME);
|
|
62448
62942
|
}
|
|
62449
62943
|
function managedVersionDir(prefix, runtimeVersion) {
|
|
62450
|
-
return
|
|
62944
|
+
return join21(managedVersionsDir(prefix), sanitizeRuntimeVersionForPath(runtimeVersion));
|
|
62451
62945
|
}
|
|
62452
62946
|
function managedCurrentPath(prefix) {
|
|
62453
|
-
return
|
|
62947
|
+
return join21(prefix, MANAGED_CURRENT_BASENAME);
|
|
62454
62948
|
}
|
|
62455
62949
|
function readCurrentPointer(prefix) {
|
|
62456
62950
|
const path = managedCurrentPath(prefix);
|
|
62457
|
-
if (!
|
|
62951
|
+
if (!existsSync23(path)) return null;
|
|
62458
62952
|
try {
|
|
62459
62953
|
const raw = JSON.parse(readFileSync13(path, "utf8"));
|
|
62460
62954
|
if (typeof raw.runtimeVersion !== "string" || !raw.runtimeVersion.trim()) return null;
|
|
@@ -62480,7 +62974,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62480
62974
|
null,
|
|
62481
62975
|
2
|
|
62482
62976
|
);
|
|
62483
|
-
const tmp =
|
|
62977
|
+
const tmp = join21(
|
|
62484
62978
|
prefix,
|
|
62485
62979
|
`.${MANAGED_CURRENT_BASENAME}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`
|
|
62486
62980
|
);
|
|
@@ -62489,7 +62983,7 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62489
62983
|
renameSync2(tmp, path);
|
|
62490
62984
|
} catch {
|
|
62491
62985
|
try {
|
|
62492
|
-
if (
|
|
62986
|
+
if (existsSync23(path)) rmSync2(path, { force: true });
|
|
62493
62987
|
renameSync2(tmp, path);
|
|
62494
62988
|
} catch {
|
|
62495
62989
|
writeFileSync9(path, body);
|
|
@@ -62501,26 +62995,26 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
62501
62995
|
}
|
|
62502
62996
|
}
|
|
62503
62997
|
function resolveActiveInstallRoot(prefix) {
|
|
62504
|
-
if (!prefix || !
|
|
62998
|
+
if (!prefix || !existsSync23(prefix)) return null;
|
|
62505
62999
|
const pointer = readCurrentPointer(prefix);
|
|
62506
63000
|
if (pointer) {
|
|
62507
|
-
if (pointer.installRoot &&
|
|
63001
|
+
if (pointer.installRoot && existsSync23(pointer.installRoot) && statSync6(pointer.installRoot).isDirectory()) {
|
|
62508
63002
|
return pointer.installRoot;
|
|
62509
63003
|
}
|
|
62510
63004
|
const dir = managedVersionDir(prefix, pointer.runtimeVersion);
|
|
62511
|
-
if (
|
|
63005
|
+
if (existsSync23(dir) && statSync6(dir).isDirectory()) return dir;
|
|
62512
63006
|
}
|
|
62513
63007
|
const versionsRoot = managedVersionsDir(prefix);
|
|
62514
|
-
if (
|
|
63008
|
+
if (existsSync23(versionsRoot)) {
|
|
62515
63009
|
try {
|
|
62516
63010
|
const kids = readdirSync8(versionsRoot).filter((n) => {
|
|
62517
63011
|
try {
|
|
62518
|
-
return
|
|
63012
|
+
return statSync6(join21(versionsRoot, n)).isDirectory();
|
|
62519
63013
|
} catch {
|
|
62520
63014
|
return false;
|
|
62521
63015
|
}
|
|
62522
63016
|
});
|
|
62523
|
-
if (kids.length === 1) return
|
|
63017
|
+
if (kids.length === 1) return join21(versionsRoot, kids[0]);
|
|
62524
63018
|
} catch {
|
|
62525
63019
|
}
|
|
62526
63020
|
}
|
|
@@ -62528,7 +63022,7 @@ function resolveActiveInstallRoot(prefix) {
|
|
|
62528
63022
|
}
|
|
62529
63023
|
function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
62530
63024
|
const versionsRoot = managedVersionsDir(prefix);
|
|
62531
|
-
if (!
|
|
63025
|
+
if (!existsSync23(versionsRoot)) return;
|
|
62532
63026
|
const keepSet = new Set(
|
|
62533
63027
|
keep.filter(Boolean).map((v2) => {
|
|
62534
63028
|
try {
|
|
@@ -62542,7 +63036,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62542
63036
|
try {
|
|
62543
63037
|
entries = readdirSync8(versionsRoot).map((name) => {
|
|
62544
63038
|
try {
|
|
62545
|
-
const st =
|
|
63039
|
+
const st = statSync6(join21(versionsRoot, name));
|
|
62546
63040
|
if (!st.isDirectory()) return null;
|
|
62547
63041
|
return { name, mtime: st.mtimeMs };
|
|
62548
63042
|
} catch {
|
|
@@ -62561,7 +63055,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62561
63055
|
}
|
|
62562
63056
|
for (const e of entries) {
|
|
62563
63057
|
if (retain.has(e.name)) continue;
|
|
62564
|
-
const dir =
|
|
63058
|
+
const dir = join21(versionsRoot, e.name);
|
|
62565
63059
|
try {
|
|
62566
63060
|
rmSync2(dir, { recursive: true, force: true });
|
|
62567
63061
|
} catch {
|
|
@@ -62573,17 +63067,17 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
62573
63067
|
import {
|
|
62574
63068
|
copyFileSync,
|
|
62575
63069
|
createReadStream,
|
|
62576
|
-
existsSync as
|
|
63070
|
+
existsSync as existsSync24,
|
|
62577
63071
|
mkdirSync as mkdirSync13,
|
|
62578
63072
|
mkdtempSync,
|
|
62579
63073
|
readFileSync as readFileSync14,
|
|
62580
63074
|
renameSync as renameSync3,
|
|
62581
63075
|
rmSync as rmSync3,
|
|
62582
|
-
statSync as
|
|
63076
|
+
statSync as statSync7,
|
|
62583
63077
|
writeFileSync as writeFileSync10
|
|
62584
63078
|
} from "node:fs";
|
|
62585
63079
|
import { createHash as createHash5, randomBytes as randomBytes4 } from "node:crypto";
|
|
62586
|
-
import { dirname as
|
|
63080
|
+
import { dirname as dirname12, join as join22, relative, resolve as resolve4, sep as sep3 } from "node:path";
|
|
62587
63081
|
import { arch as osArch, platform as osPlatform } from "node:os";
|
|
62588
63082
|
var releaseVersionProvider = null;
|
|
62589
63083
|
function setHarnessReleaseVersionProvider(fn) {
|
|
@@ -62727,13 +63221,13 @@ function parseManagedHarnessPin(id, raw) {
|
|
|
62727
63221
|
function loadHarnessReleaseManifest(nodeHome) {
|
|
62728
63222
|
const fromEnv = process.env.SUPERONE_HARNESS_MANIFEST;
|
|
62729
63223
|
if (fromEnv) {
|
|
62730
|
-
if (!
|
|
63224
|
+
if (!existsSync24(fromEnv)) {
|
|
62731
63225
|
throw new Error(`SUPERONE_HARNESS_MANIFEST not found: ${fromEnv}`);
|
|
62732
63226
|
}
|
|
62733
63227
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync14(fromEnv, "utf8")));
|
|
62734
63228
|
}
|
|
62735
|
-
const local =
|
|
62736
|
-
if (
|
|
63229
|
+
const local = join22(nodeHome, "release-manifest.json");
|
|
63230
|
+
if (existsSync24(local)) {
|
|
62737
63231
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync14(local, "utf8")));
|
|
62738
63232
|
}
|
|
62739
63233
|
return null;
|
|
@@ -62802,10 +63296,10 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62802
63296
|
throw new Error(`release manifest does not pin managed harness ${opts.harnessId}`);
|
|
62803
63297
|
}
|
|
62804
63298
|
const art = selectArtifactPin(pin);
|
|
62805
|
-
if (!
|
|
63299
|
+
if (!existsSync24(opts.artifactPath)) {
|
|
62806
63300
|
throw new Error(`artifact not found: ${opts.artifactPath}`);
|
|
62807
63301
|
}
|
|
62808
|
-
if (!
|
|
63302
|
+
if (!statSync7(opts.artifactPath).isFile()) {
|
|
62809
63303
|
throw new Error(`artifact is not a regular file: ${opts.artifactPath}`);
|
|
62810
63304
|
}
|
|
62811
63305
|
const digest = await sha256File(opts.artifactPath);
|
|
@@ -62820,8 +63314,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62820
63314
|
opts.harnessId,
|
|
62821
63315
|
pin.artifactVersion
|
|
62822
63316
|
);
|
|
62823
|
-
const finalFile =
|
|
62824
|
-
const metaPath =
|
|
63317
|
+
const finalFile = join22(destDir, MANAGED_PAYLOAD_BASENAME);
|
|
63318
|
+
const metaPath = join22(destDir, MANAGED_META_BASENAME);
|
|
62825
63319
|
assertStrictChild(finalFile, destDir, "payload path");
|
|
62826
63320
|
assertStrictChild(metaPath, destDir, "meta path");
|
|
62827
63321
|
const metaBody = JSON.stringify(
|
|
@@ -62840,8 +63334,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62840
63334
|
2
|
|
62841
63335
|
);
|
|
62842
63336
|
let reusedExisting = false;
|
|
62843
|
-
if (
|
|
62844
|
-
const payloadOk =
|
|
63337
|
+
if (existsSync24(destDir)) {
|
|
63338
|
+
const payloadOk = existsSync24(finalFile) && statSync7(finalFile).isFile() && await sha256File(finalFile) === art.digestSha256;
|
|
62845
63339
|
if (payloadOk) {
|
|
62846
63340
|
reusedExisting = true;
|
|
62847
63341
|
} else if (mode === "repair") {
|
|
@@ -62860,15 +63354,15 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62860
63354
|
);
|
|
62861
63355
|
}
|
|
62862
63356
|
} else {
|
|
62863
|
-
const harnessRoot2 =
|
|
63357
|
+
const harnessRoot2 = dirname12(destDir);
|
|
62864
63358
|
mkdirSync13(harnessRoot2, { recursive: true });
|
|
62865
63359
|
assertPathInside(destDir, harnessRoot2, "version dir");
|
|
62866
63360
|
const stagingDir = mkdtempSync(
|
|
62867
|
-
|
|
63361
|
+
join22(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes4(8).toString("hex")}-`)
|
|
62868
63362
|
);
|
|
62869
63363
|
assertPathInside(stagingDir, harnessRoot2, "staging dir");
|
|
62870
|
-
const stagingFile =
|
|
62871
|
-
const stagingMeta =
|
|
63364
|
+
const stagingFile = join22(stagingDir, MANAGED_PAYLOAD_BASENAME);
|
|
63365
|
+
const stagingMeta = join22(stagingDir, MANAGED_META_BASENAME);
|
|
62872
63366
|
try {
|
|
62873
63367
|
copyFileSync(opts.artifactPath, stagingFile);
|
|
62874
63368
|
const stagedDigest = await sha256File(stagingFile);
|
|
@@ -62879,7 +63373,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62879
63373
|
renameSync3(stagingDir, destDir);
|
|
62880
63374
|
} catch (err) {
|
|
62881
63375
|
rmSync3(stagingDir, { recursive: true, force: true });
|
|
62882
|
-
if (
|
|
63376
|
+
if (existsSync24(destDir) && existsSync24(finalFile)) {
|
|
62883
63377
|
const existingDigest = await sha256File(finalFile);
|
|
62884
63378
|
if (existingDigest === art.digestSha256) {
|
|
62885
63379
|
reusedExisting = true;
|
|
@@ -62904,7 +63398,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62904
63398
|
if (finalDigest !== art.digestSha256) {
|
|
62905
63399
|
throw new Error(`final payload digest mismatch for ${opts.harnessId}`);
|
|
62906
63400
|
}
|
|
62907
|
-
const harnessRoot =
|
|
63401
|
+
const harnessRoot = join22(
|
|
62908
63402
|
releasesRoot(opts.nodeHome),
|
|
62909
63403
|
opts.manifest.cliVersion,
|
|
62910
63404
|
"harnesses",
|
|
@@ -62912,8 +63406,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62912
63406
|
);
|
|
62913
63407
|
assertPathInside(harnessRoot, releasesRoot(opts.nodeHome), "harness root");
|
|
62914
63408
|
mkdirSync13(harnessRoot, { recursive: true });
|
|
62915
|
-
const currentPath =
|
|
62916
|
-
const currentTmp =
|
|
63409
|
+
const currentPath = join22(harnessRoot, MANAGED_CURRENT_BASENAME2);
|
|
63410
|
+
const currentTmp = join22(
|
|
62917
63411
|
harnessRoot,
|
|
62918
63412
|
`.${MANAGED_CURRENT_BASENAME2}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`
|
|
62919
63413
|
);
|
|
@@ -62952,8 +63446,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
62952
63446
|
async function replacePayloadAtomically(opts) {
|
|
62953
63447
|
mkdirSync13(opts.destDir, { recursive: true });
|
|
62954
63448
|
const nonce = randomBytes4(8).toString("hex");
|
|
62955
|
-
const payloadTmp =
|
|
62956
|
-
const metaTmp =
|
|
63449
|
+
const payloadTmp = join22(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
|
|
63450
|
+
const metaTmp = join22(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
|
|
62957
63451
|
assertStrictChild(payloadTmp, opts.destDir, "payload temp");
|
|
62958
63452
|
assertStrictChild(metaTmp, opts.destDir, "meta temp");
|
|
62959
63453
|
try {
|
|
@@ -62987,12 +63481,33 @@ function requiredRuntimeVersion(harnessId, manifest) {
|
|
|
62987
63481
|
}
|
|
62988
63482
|
|
|
62989
63483
|
// ../../packages/runtime/src/harness/managed-official.ts
|
|
62990
|
-
import { existsSync as
|
|
63484
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync14, readFileSync as readFileSync15, readdirSync as readdirSync9, statSync as statSync8, writeFileSync as writeFileSync11 } from "node:fs";
|
|
62991
63485
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
62992
|
-
import { join as
|
|
62993
|
-
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.
|
|
62994
|
-
var OFFICIAL_CODEX_NPM_VERSION = "0.
|
|
63486
|
+
import { join as join23, resolve as resolve5 } from "node:path";
|
|
63487
|
+
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.232";
|
|
63488
|
+
var OFFICIAL_CODEX_NPM_VERSION = "0.147.0";
|
|
62995
63489
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
63490
|
+
function codexPlatformPackageVersion(baseVersion = OFFICIAL_CODEX_NPM_VERSION) {
|
|
63491
|
+
const platform2 = process.platform;
|
|
63492
|
+
const arch2 = process.arch;
|
|
63493
|
+
if (arch2 !== "arm64" && arch2 !== "x64") {
|
|
63494
|
+
throw new Error(`unsupported arch for Codex: ${arch2}`);
|
|
63495
|
+
}
|
|
63496
|
+
const suffix = platform2 === "darwin" ? `darwin-${arch2}` : platform2 === "linux" ? `linux-${arch2}` : platform2 === "win32" ? `win32-${arch2}` : null;
|
|
63497
|
+
if (!suffix) throw new Error(`unsupported platform for Codex: ${platform2}`);
|
|
63498
|
+
return `${baseVersion}-${suffix}`;
|
|
63499
|
+
}
|
|
63500
|
+
function codexTargetTriple() {
|
|
63501
|
+
const triples = {
|
|
63502
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
63503
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
63504
|
+
"linux-arm64": "aarch64-unknown-linux-musl",
|
|
63505
|
+
"linux-x64": "x86_64-unknown-linux-musl",
|
|
63506
|
+
"win32-arm64": "aarch64-pc-windows-msvc",
|
|
63507
|
+
"win32-x64": "x86_64-pc-windows-msvc"
|
|
63508
|
+
};
|
|
63509
|
+
return triples[`${process.platform}-${process.arch}`] ?? null;
|
|
63510
|
+
}
|
|
62996
63511
|
function managedHarnessPrefix(nodeHome, harnessId) {
|
|
62997
63512
|
return resolve5(nodeHome, harnessId);
|
|
62998
63513
|
}
|
|
@@ -63012,7 +63527,7 @@ function claudePlatformPackageName() {
|
|
|
63012
63527
|
}
|
|
63013
63528
|
function isMuslLinux() {
|
|
63014
63529
|
try {
|
|
63015
|
-
if (
|
|
63530
|
+
if (existsSync25("/etc/alpine-release")) return true;
|
|
63016
63531
|
const lib = readdirSync9("/lib").some((n) => n.startsWith("ld-musl"));
|
|
63017
63532
|
if (lib) return true;
|
|
63018
63533
|
} catch {
|
|
@@ -63020,42 +63535,49 @@ function isMuslLinux() {
|
|
|
63020
63535
|
return false;
|
|
63021
63536
|
}
|
|
63022
63537
|
function resolveOfficialInstallBinaryInRoot(harnessId, installRoot) {
|
|
63023
|
-
if (!installRoot || !
|
|
63538
|
+
if (!installRoot || !existsSync25(installRoot)) return null;
|
|
63024
63539
|
if (harnessId === "codex") {
|
|
63540
|
+
const triple = codexTargetTriple();
|
|
63541
|
+
const nativeName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
63025
63542
|
const candidates = [
|
|
63026
|
-
|
|
63027
|
-
|
|
63028
|
-
|
|
63543
|
+
join23(installRoot, "bin", "codex"),
|
|
63544
|
+
join23(installRoot, "bin", "codex.cmd"),
|
|
63545
|
+
join23(installRoot, "lib", "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
63546
|
+
join23(installRoot, "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
63547
|
+
...triple ? [
|
|
63548
|
+
join23(installRoot, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName),
|
|
63549
|
+
join23(installRoot, "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName)
|
|
63550
|
+
] : []
|
|
63029
63551
|
];
|
|
63030
63552
|
for (const c of candidates) {
|
|
63031
|
-
if (
|
|
63553
|
+
if (existsSync25(c) && (c.endsWith(".js") || isExecutableFile2(c))) return c;
|
|
63032
63554
|
}
|
|
63033
63555
|
return null;
|
|
63034
63556
|
}
|
|
63035
|
-
const nm =
|
|
63036
|
-
const scoped =
|
|
63557
|
+
const nm = join23(installRoot, "lib", "node_modules");
|
|
63558
|
+
const scoped = join23(nm, "@anthropic-ai");
|
|
63037
63559
|
try {
|
|
63038
|
-
if (
|
|
63560
|
+
if (existsSync25(scoped)) {
|
|
63039
63561
|
const names = readdirSync9(scoped).filter((n) => n.startsWith("claude-agent-sdk-"));
|
|
63040
63562
|
for (const n of names) {
|
|
63041
63563
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
63042
|
-
const bin =
|
|
63043
|
-
if (
|
|
63564
|
+
const bin = join23(scoped, n, `claude${ext}`);
|
|
63565
|
+
if (existsSync25(bin)) return bin;
|
|
63044
63566
|
}
|
|
63045
63567
|
}
|
|
63046
63568
|
} catch {
|
|
63047
63569
|
}
|
|
63048
|
-
const direct =
|
|
63570
|
+
const direct = join23(
|
|
63049
63571
|
nm,
|
|
63050
63572
|
...claudePlatformPackageName().split("/"),
|
|
63051
63573
|
process.platform === "win32" ? "claude.exe" : "claude"
|
|
63052
63574
|
);
|
|
63053
|
-
if (
|
|
63575
|
+
if (existsSync25(direct)) return direct;
|
|
63054
63576
|
return null;
|
|
63055
63577
|
}
|
|
63056
|
-
function
|
|
63578
|
+
function isExecutableFile2(path) {
|
|
63057
63579
|
try {
|
|
63058
|
-
const st =
|
|
63580
|
+
const st = statSync8(path);
|
|
63059
63581
|
if (!st.isFile()) return false;
|
|
63060
63582
|
if (process.platform === "win32") return true;
|
|
63061
63583
|
return (st.mode & 73) !== 0;
|
|
@@ -63065,7 +63587,7 @@ function isExecutableFile(path) {
|
|
|
63065
63587
|
}
|
|
63066
63588
|
|
|
63067
63589
|
// ../../packages/runtime/src/harness/tarball-fetch.ts
|
|
63068
|
-
import { existsSync as
|
|
63590
|
+
import { existsSync as existsSync26, rmSync as rmSync4 } from "node:fs";
|
|
63069
63591
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
63070
63592
|
function assertSha256(actualHex, expectedHex) {
|
|
63071
63593
|
if (actualHex !== expectedHex.toLowerCase()) {
|
|
@@ -63083,7 +63605,7 @@ function assertSha512Integrity(actualBase64, integrity) {
|
|
|
63083
63605
|
}
|
|
63084
63606
|
function discardPartial(destPath) {
|
|
63085
63607
|
try {
|
|
63086
|
-
if (
|
|
63608
|
+
if (existsSync26(destPath)) rmSync4(destPath, { force: true });
|
|
63087
63609
|
} catch {
|
|
63088
63610
|
}
|
|
63089
63611
|
}
|
|
@@ -63164,13 +63686,13 @@ import {
|
|
|
63164
63686
|
appendFileSync,
|
|
63165
63687
|
createReadStream as createReadStream2,
|
|
63166
63688
|
createWriteStream,
|
|
63167
|
-
existsSync as
|
|
63689
|
+
existsSync as existsSync27,
|
|
63168
63690
|
mkdirSync as mkdirSync15,
|
|
63169
63691
|
rmSync as rmSync5,
|
|
63170
|
-
statSync as
|
|
63692
|
+
statSync as statSync9,
|
|
63171
63693
|
writeFileSync as writeFileSync12
|
|
63172
63694
|
} from "node:fs";
|
|
63173
|
-
import { dirname as
|
|
63695
|
+
import { dirname as dirname13 } from "node:path";
|
|
63174
63696
|
import { pipeline } from "node:stream/promises";
|
|
63175
63697
|
import { Readable as Readable2, Transform } from "node:stream";
|
|
63176
63698
|
var HARNESS_PROGRESS_THROTTLE_MS = 200;
|
|
@@ -63199,7 +63721,7 @@ function parseContentRange(header) {
|
|
|
63199
63721
|
async function seedHashesFromFile(path) {
|
|
63200
63722
|
const sha256 = createHash6("sha256");
|
|
63201
63723
|
const sha512 = createHash6("sha512");
|
|
63202
|
-
const size =
|
|
63724
|
+
const size = statSync9(path).size;
|
|
63203
63725
|
if (size === 0) return { sha256, sha512, size };
|
|
63204
63726
|
await new Promise((resolve13, reject) => {
|
|
63205
63727
|
const stream = createReadStream2(path);
|
|
@@ -63231,7 +63753,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
63231
63753
|
const keepPartial = opts.keepPartialOnError !== false;
|
|
63232
63754
|
const contentLen = Number(res.headers.get("content-length") ?? 0);
|
|
63233
63755
|
const total = opts.totalBytes && opts.totalBytes > 0 ? opts.totalBytes : append ? resumeFrom + contentLen : contentLen;
|
|
63234
|
-
mkdirSync15(
|
|
63756
|
+
mkdirSync15(dirname13(destPath), { recursive: true });
|
|
63235
63757
|
const emit = createThrottledProgress(onProgress, opts.progressThrottleMs);
|
|
63236
63758
|
let sha256;
|
|
63237
63759
|
let sha512;
|
|
@@ -63289,7 +63811,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
63289
63811
|
} catch (err) {
|
|
63290
63812
|
if (!keepPartial) {
|
|
63291
63813
|
try {
|
|
63292
|
-
if (
|
|
63814
|
+
if (existsSync27(destPath)) rmSync5(destPath, { force: true });
|
|
63293
63815
|
} catch {
|
|
63294
63816
|
}
|
|
63295
63817
|
}
|
|
@@ -63333,14 +63855,14 @@ async function downloadResumableToFile(httpFetch, url2, destPath, onProgress, lo
|
|
|
63333
63855
|
);
|
|
63334
63856
|
}
|
|
63335
63857
|
async function downloadResumableToFileUnlocked(httpFetch, url2, destPath, onProgress, log2) {
|
|
63336
|
-
mkdirSync15(
|
|
63337
|
-
let existing =
|
|
63858
|
+
mkdirSync15(dirname13(destPath), { recursive: true });
|
|
63859
|
+
let existing = existsSync27(destPath) ? statSync9(destPath).size : 0;
|
|
63338
63860
|
if (existing > 0 && existing < 64) {
|
|
63339
63861
|
rmSync5(destPath, { force: true });
|
|
63340
63862
|
existing = 0;
|
|
63341
63863
|
}
|
|
63342
63864
|
const tryOnce = async (from) => {
|
|
63343
|
-
const diskNow =
|
|
63865
|
+
const diskNow = existsSync27(destPath) ? statSync9(destPath).size : 0;
|
|
63344
63866
|
const start = from > 0 ? diskNow : 0;
|
|
63345
63867
|
if (from > 0 && diskNow !== from) {
|
|
63346
63868
|
log2?.warn?.(
|
|
@@ -63422,17 +63944,17 @@ function createResumableDownloadToFile(httpFetch, log2) {
|
|
|
63422
63944
|
|
|
63423
63945
|
// ../../packages/runtime/src/harness/managed-tarball-installer.ts
|
|
63424
63946
|
import {
|
|
63425
|
-
existsSync as
|
|
63947
|
+
existsSync as existsSync28,
|
|
63426
63948
|
mkdirSync as mkdirSync16,
|
|
63427
63949
|
mkdtempSync as mkdtempSync2,
|
|
63428
63950
|
readFileSync as readFileSync16,
|
|
63429
63951
|
renameSync as renameSync4,
|
|
63430
63952
|
rmSync as rmSync6,
|
|
63431
|
-
statSync as
|
|
63953
|
+
statSync as statSync10,
|
|
63432
63954
|
writeFileSync as writeFileSync13
|
|
63433
63955
|
} from "node:fs";
|
|
63434
63956
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
63435
|
-
import { dirname as
|
|
63957
|
+
import { dirname as dirname14, join as join24 } from "node:path";
|
|
63436
63958
|
import { spawn as spawn4 } from "node:child_process";
|
|
63437
63959
|
|
|
63438
63960
|
// ../../packages/shared/src/update-channels.ts
|
|
@@ -63479,17 +64001,6 @@ function selectHarnessArtifact(manifest, harnessId, platform2, arch2) {
|
|
|
63479
64001
|
}
|
|
63480
64002
|
|
|
63481
64003
|
// ../../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
64004
|
function managedPackagePins(id) {
|
|
63494
64005
|
if (id === "claude") {
|
|
63495
64006
|
const ver = process.env.SUPERONE_CLAUDE_SDK_VERSION?.trim() || OFFICIAL_CLAUDE_SDK_VERSION;
|
|
@@ -63505,7 +64016,7 @@ function managedPackagePins(id) {
|
|
|
63505
64016
|
packages: [
|
|
63506
64017
|
{
|
|
63507
64018
|
name: OFFICIAL_CODEX_PACKAGE,
|
|
63508
|
-
version:
|
|
64019
|
+
version: codexPlatformPackageVersion(base),
|
|
63509
64020
|
nodeModulesDir: OFFICIAL_CODEX_PACKAGE
|
|
63510
64021
|
}
|
|
63511
64022
|
]
|
|
@@ -63523,7 +64034,7 @@ function resolveHarnessManifestChannel(explicit, releaseVersion) {
|
|
|
63523
64034
|
return "alpha";
|
|
63524
64035
|
}
|
|
63525
64036
|
function harnessDownloadDir(homeRoot) {
|
|
63526
|
-
return
|
|
64037
|
+
return join24(homeRoot, ".download");
|
|
63527
64038
|
}
|
|
63528
64039
|
function harnessArtifactDownloadKey(opts) {
|
|
63529
64040
|
const digest = opts.digestSha256?.trim().toLowerCase();
|
|
@@ -63537,7 +64048,7 @@ function harnessPartialPath(homeRoot, key) {
|
|
|
63537
64048
|
if (!key || key.includes("..") || key.includes("/") || key.includes("\\")) {
|
|
63538
64049
|
throw new Error(`unsafe download key: ${key}`);
|
|
63539
64050
|
}
|
|
63540
|
-
return
|
|
64051
|
+
return join24(harnessDownloadDir(homeRoot), `${key}.partial`);
|
|
63541
64052
|
}
|
|
63542
64053
|
function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
63543
64054
|
return new Promise((resolve13, reject) => {
|
|
@@ -63557,13 +64068,13 @@ function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
|
63557
64068
|
});
|
|
63558
64069
|
}
|
|
63559
64070
|
function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
63560
|
-
const dest =
|
|
63561
|
-
const parent =
|
|
64071
|
+
const dest = join24(prefix, "lib", "node_modules", ...nodeModulesRel.split("/"));
|
|
64072
|
+
const parent = dirname14(dest);
|
|
63562
64073
|
mkdirSync16(parent, { recursive: true });
|
|
63563
|
-
if (
|
|
64074
|
+
if (existsSync28(dest)) {
|
|
63564
64075
|
rmSync6(dest, { recursive: true, force: true });
|
|
63565
64076
|
}
|
|
63566
|
-
const staging =
|
|
64077
|
+
const staging = join24(
|
|
63567
64078
|
parent,
|
|
63568
64079
|
`.staging-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
63569
64080
|
);
|
|
@@ -63571,12 +64082,12 @@ function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
|
63571
64082
|
renameSync4(packageDir, staging);
|
|
63572
64083
|
renameSync4(staging, dest);
|
|
63573
64084
|
} catch (err) {
|
|
63574
|
-
if (
|
|
64085
|
+
if (existsSync28(staging)) rmSync6(staging, { recursive: true, force: true });
|
|
63575
64086
|
throw err instanceof Error ? err : new Error(`failed to place package into ${dest}: ${String(err)}`);
|
|
63576
64087
|
}
|
|
63577
64088
|
return dest;
|
|
63578
64089
|
}
|
|
63579
|
-
function
|
|
64090
|
+
function codexTargetTriple2() {
|
|
63580
64091
|
const key = `${process.platform}-${process.arch}`;
|
|
63581
64092
|
const map2 = {
|
|
63582
64093
|
"darwin-arm64": "aarch64-apple-darwin",
|
|
@@ -63589,12 +64100,12 @@ function codexTargetTriple() {
|
|
|
63589
64100
|
return map2[key] ?? null;
|
|
63590
64101
|
}
|
|
63591
64102
|
function resolveCodexNativeUnderPrefix(prefix) {
|
|
63592
|
-
const triple =
|
|
64103
|
+
const triple = codexTargetTriple2();
|
|
63593
64104
|
if (!triple) return null;
|
|
63594
64105
|
const binaryName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
63595
64106
|
const candidates = [
|
|
63596
|
-
|
|
63597
|
-
|
|
64107
|
+
join24(prefix, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", binaryName),
|
|
64108
|
+
join24(
|
|
63598
64109
|
prefix,
|
|
63599
64110
|
"lib",
|
|
63600
64111
|
"node_modules",
|
|
@@ -63607,7 +64118,7 @@ function resolveCodexNativeUnderPrefix(prefix) {
|
|
|
63607
64118
|
)
|
|
63608
64119
|
];
|
|
63609
64120
|
for (const c of candidates) {
|
|
63610
|
-
if (
|
|
64121
|
+
if (existsSync28(c) && statSync10(c).isFile()) return c;
|
|
63611
64122
|
}
|
|
63612
64123
|
return null;
|
|
63613
64124
|
}
|
|
@@ -63617,16 +64128,16 @@ function resolveManagedTarballBinary(id, installRoot) {
|
|
|
63617
64128
|
}
|
|
63618
64129
|
function readRuntimeVersionFromRoot(id, installRoot) {
|
|
63619
64130
|
try {
|
|
63620
|
-
const metaPath =
|
|
63621
|
-
if (
|
|
64131
|
+
const metaPath = join24(installRoot, "install-meta.json");
|
|
64132
|
+
if (existsSync28(metaPath)) {
|
|
63622
64133
|
const raw = JSON.parse(readFileSync16(metaPath, "utf8"));
|
|
63623
64134
|
if (raw.runtimeVersion) return raw.runtimeVersion;
|
|
63624
64135
|
}
|
|
63625
64136
|
} catch {
|
|
63626
64137
|
}
|
|
63627
64138
|
try {
|
|
63628
|
-
const pkgPath = id === "claude" ? null :
|
|
63629
|
-
if (pkgPath &&
|
|
64139
|
+
const pkgPath = id === "claude" ? null : join24(installRoot, "lib", "node_modules", "@openai", "codex", "package.json");
|
|
64140
|
+
if (pkgPath && existsSync28(pkgPath)) {
|
|
63630
64141
|
const raw = JSON.parse(readFileSync16(pkgPath, "utf8"));
|
|
63631
64142
|
const v2 = raw.version?.trim();
|
|
63632
64143
|
if (!v2) return null;
|
|
@@ -63716,7 +64227,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63716
64227
|
npmVersion
|
|
63717
64228
|
});
|
|
63718
64229
|
const partialPath = harnessPartialPath(home.root, downloadKey);
|
|
63719
|
-
const work = mkdtempSync2(
|
|
64230
|
+
const work = mkdtempSync2(join24(tmpdir2(), `superone-harness-${id}-`));
|
|
63720
64231
|
try {
|
|
63721
64232
|
const { from } = await fetchTarballWithFallback({
|
|
63722
64233
|
destPath: partialPath,
|
|
@@ -63730,15 +64241,15 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63730
64241
|
log: log2
|
|
63731
64242
|
});
|
|
63732
64243
|
source = from;
|
|
63733
|
-
const extractRoot =
|
|
64244
|
+
const extractRoot = join24(work, "out");
|
|
63734
64245
|
await extractTgz(partialPath, extractRoot);
|
|
63735
|
-
const packageDir =
|
|
63736
|
-
if (!
|
|
64246
|
+
const packageDir = join24(extractRoot, "package");
|
|
64247
|
+
if (!existsSync28(packageDir) || !statSync10(packageDir).isDirectory()) {
|
|
63737
64248
|
throw new Error(`tarball for ${packageSpec} has no package/ directory`);
|
|
63738
64249
|
}
|
|
63739
64250
|
installPackageDir(packageDir, versionDir, npmName);
|
|
63740
64251
|
try {
|
|
63741
|
-
if (
|
|
64252
|
+
if (existsSync28(partialPath)) rmSync6(partialPath, { force: true });
|
|
63742
64253
|
} catch {
|
|
63743
64254
|
}
|
|
63744
64255
|
} finally {
|
|
@@ -63746,7 +64257,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63746
64257
|
}
|
|
63747
64258
|
}
|
|
63748
64259
|
writeFileSync13(
|
|
63749
|
-
|
|
64260
|
+
join24(versionDir, "install-meta.json"),
|
|
63750
64261
|
JSON.stringify(
|
|
63751
64262
|
{
|
|
63752
64263
|
harnessId: id,
|
|
@@ -63790,8 +64301,8 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
63790
64301
|
}
|
|
63791
64302
|
|
|
63792
64303
|
// ../../packages/runtime/src/harness/cursor-availability.ts
|
|
63793
|
-
import { createRequire as
|
|
63794
|
-
var require3 =
|
|
64304
|
+
import { createRequire as createRequire4 } from "node:module";
|
|
64305
|
+
var require3 = createRequire4(import.meta.url);
|
|
63795
64306
|
function isCursorSdkAvailable2() {
|
|
63796
64307
|
try {
|
|
63797
64308
|
require3.resolve("@cursor/sdk");
|
|
@@ -63967,7 +64478,7 @@ function isAuthSatisfied(id, deps) {
|
|
|
63967
64478
|
|
|
63968
64479
|
// ../../packages/runtime/src/harness/enable.ts
|
|
63969
64480
|
init_environment();
|
|
63970
|
-
import { accessSync, constants, existsSync as
|
|
64481
|
+
import { accessSync, constants, existsSync as existsSync29, realpathSync as realpathSync3, statSync as statSync11 } from "node:fs";
|
|
63971
64482
|
import { isAbsolute as isAbsolute2, resolve as resolve6 } from "node:path";
|
|
63972
64483
|
async function enableHarness(manager, input, deps) {
|
|
63973
64484
|
const id = input.harnessId;
|
|
@@ -64174,7 +64685,7 @@ function requireRegularReadableFile(path) {
|
|
|
64174
64685
|
throw new Error(`path must be absolute: ${path}`);
|
|
64175
64686
|
}
|
|
64176
64687
|
const abs = resolve6(path);
|
|
64177
|
-
if (!
|
|
64688
|
+
if (!existsSync29(abs) || !statSync11(abs).isFile()) {
|
|
64178
64689
|
throw new Error(`not a regular file: ${abs}`);
|
|
64179
64690
|
}
|
|
64180
64691
|
accessSync(abs, constants.R_OK);
|
|
@@ -64183,9 +64694,9 @@ function requireRegularReadableFile(path) {
|
|
|
64183
64694
|
function resolveExternalCommand(explicit, searchNames) {
|
|
64184
64695
|
if (explicit) {
|
|
64185
64696
|
const abs = isAbsolute2(explicit) ? explicit : resolve6(explicit);
|
|
64186
|
-
if (!
|
|
64697
|
+
if (!existsSync29(abs)) return null;
|
|
64187
64698
|
try {
|
|
64188
|
-
if (!
|
|
64699
|
+
if (!statSync11(abs).isFile()) return null;
|
|
64189
64700
|
accessSync(abs, constants.X_OK);
|
|
64190
64701
|
} catch {
|
|
64191
64702
|
return null;
|
|
@@ -64198,9 +64709,9 @@ function resolveExternalCommand(explicit, searchNames) {
|
|
|
64198
64709
|
for (const dir of dirs) {
|
|
64199
64710
|
if (!dir) continue;
|
|
64200
64711
|
const candidate = resolve6(dir, name);
|
|
64201
|
-
if (!
|
|
64712
|
+
if (!existsSync29(candidate)) continue;
|
|
64202
64713
|
try {
|
|
64203
|
-
if (!
|
|
64714
|
+
if (!statSync11(candidate).isFile()) continue;
|
|
64204
64715
|
accessSync(candidate, constants.X_OK);
|
|
64205
64716
|
return realpathSync3(candidate);
|
|
64206
64717
|
} catch {
|
|
@@ -64253,7 +64764,7 @@ function looksLikeSecretArg(value) {
|
|
|
64253
64764
|
}
|
|
64254
64765
|
|
|
64255
64766
|
// src/session/harness-host.ts
|
|
64256
|
-
import { existsSync as
|
|
64767
|
+
import { existsSync as existsSync30 } from "node:fs";
|
|
64257
64768
|
init_src2();
|
|
64258
64769
|
init_claude_turn_runner();
|
|
64259
64770
|
init_codex_turn_runner();
|
|
@@ -64261,7 +64772,7 @@ init_resolve_service();
|
|
|
64261
64772
|
setHarnessReleaseVersionProvider(resolveCliReleaseVersion);
|
|
64262
64773
|
function envBinaryExists(envName) {
|
|
64263
64774
|
const v2 = process.env[envName]?.trim();
|
|
64264
|
-
return Boolean(v2 &&
|
|
64775
|
+
return Boolean(v2 && existsSync30(v2));
|
|
64265
64776
|
}
|
|
64266
64777
|
var cliHarnessResolver = {
|
|
64267
64778
|
resolveBinary(id, harnesses) {
|
|
@@ -64271,7 +64782,7 @@ var cliHarnessResolver = {
|
|
|
64271
64782
|
return null;
|
|
64272
64783
|
}
|
|
64273
64784
|
const command = harnesses.get(id).command;
|
|
64274
|
-
return command &&
|
|
64785
|
+
return command && existsSync30(command) ? command : null;
|
|
64275
64786
|
},
|
|
64276
64787
|
isRunnableWithoutCatalog(id) {
|
|
64277
64788
|
if (id === "claude") return isClaudeRuntimeRunnable();
|
|
@@ -64283,7 +64794,7 @@ var cliHarnessResolver = {
|
|
|
64283
64794
|
autoRuntime(id) {
|
|
64284
64795
|
if (id === "claude") {
|
|
64285
64796
|
const sdk = resolveSdkClaudeBinary();
|
|
64286
|
-
if (sdk &&
|
|
64797
|
+
if (sdk && existsSync30(sdk)) return { command: sdk, source: "agent-sdk-optional" };
|
|
64287
64798
|
return null;
|
|
64288
64799
|
}
|
|
64289
64800
|
const fromEnv = resolveCodexBinaryPath({});
|
|
@@ -64366,8 +64877,8 @@ function enableManaged2(manager, id, artifact, mode = "enable") {
|
|
|
64366
64877
|
|
|
64367
64878
|
// ../../packages/shared/src/git-clone.ts
|
|
64368
64879
|
import { execFile as execFile2 } from "node:child_process";
|
|
64369
|
-
import { existsSync as
|
|
64370
|
-
import { isAbsolute as isAbsolute3, join as
|
|
64880
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync17 } from "node:fs";
|
|
64881
|
+
import { isAbsolute as isAbsolute3, join as join25, resolve as resolve7 } from "node:path";
|
|
64371
64882
|
|
|
64372
64883
|
// ../../packages/shared/src/git-remote.ts
|
|
64373
64884
|
function repoNameFromGitUrl(url2) {
|
|
@@ -64432,11 +64943,11 @@ function resolveCloneDestination(input) {
|
|
|
64432
64943
|
if (name.includes("/") || name.includes("\\") || name === "." || name === "..") {
|
|
64433
64944
|
throw invalid(`invalid folder name: ${name}`);
|
|
64434
64945
|
}
|
|
64435
|
-
return { path:
|
|
64946
|
+
return { path: join25(resolve7(parent), name), name };
|
|
64436
64947
|
}
|
|
64437
64948
|
async function cloneRepository(input) {
|
|
64438
64949
|
const destination = resolveCloneDestination(input);
|
|
64439
|
-
if (
|
|
64950
|
+
if (existsSync31(destination.path)) {
|
|
64440
64951
|
throw Object.assign(new Error(`destination already exists: ${destination.path}`), {
|
|
64441
64952
|
code: "conflict"
|
|
64442
64953
|
});
|
|
@@ -64480,7 +64991,7 @@ async function cloneRepository(input) {
|
|
|
64480
64991
|
|
|
64481
64992
|
// src/rpc/handlers.ts
|
|
64482
64993
|
init_resolve_service();
|
|
64483
|
-
import { existsSync as
|
|
64994
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync18, readdirSync as readdirSync10, statSync as statSync12 } from "node:fs";
|
|
64484
64995
|
import { join as pathJoin, resolve as pathResolve } from "node:path";
|
|
64485
64996
|
import { arch, cpus, freemem, homedir as homedir7, hostname as hostname4, platform, totalmem, uptime } from "node:os";
|
|
64486
64997
|
|
|
@@ -67248,7 +67759,7 @@ function handleProjectOpen(payload, ctx) {
|
|
|
67248
67759
|
}
|
|
67249
67760
|
const name = typeof p2.name === "string" ? p2.name : void 0;
|
|
67250
67761
|
try {
|
|
67251
|
-
if (p2.createIfMissing === true && !
|
|
67762
|
+
if (p2.createIfMissing === true && !existsSync32(path)) {
|
|
67252
67763
|
mkdirSync18(path, { recursive: true });
|
|
67253
67764
|
}
|
|
67254
67765
|
return { result: ctx.projects.open(path, name) };
|
|
@@ -67285,10 +67796,10 @@ function handleFsListDir(payload, ctx) {
|
|
|
67285
67796
|
}
|
|
67286
67797
|
try {
|
|
67287
67798
|
const resolved = expandHostPath(raw);
|
|
67288
|
-
if (!
|
|
67799
|
+
if (!existsSync32(resolved)) {
|
|
67289
67800
|
return { error: { code: "not_found", message: "path not found" } };
|
|
67290
67801
|
}
|
|
67291
|
-
if (!
|
|
67802
|
+
if (!statSync12(resolved).isDirectory()) {
|
|
67292
67803
|
return { error: { code: "invalid_argument", message: "not a directory" } };
|
|
67293
67804
|
}
|
|
67294
67805
|
const entries = readdirSync10(resolved, { withFileTypes: true }).filter((ent) => ent.isDirectory() && !ent.name.startsWith(".")).map((ent) => ({
|
|
@@ -69039,9 +69550,9 @@ async function handleHttp(req, res, opts) {
|
|
|
69039
69550
|
}
|
|
69040
69551
|
|
|
69041
69552
|
// src/terminal/manager.ts
|
|
69042
|
-
import { createRequire as
|
|
69043
|
-
import { existsSync as
|
|
69044
|
-
var nodeRequire =
|
|
69553
|
+
import { createRequire as createRequire5 } from "node:module";
|
|
69554
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
69555
|
+
var nodeRequire = createRequire5(import.meta.url);
|
|
69045
69556
|
var { spawn: spawn5 } = nodeRequire("node-pty");
|
|
69046
69557
|
var SNAPSHOT_SOFT_LIMIT = 64 * 1024;
|
|
69047
69558
|
var OUTPUT_BUFFER_SOFT_LIMIT = 256 * 1024;
|
|
@@ -69055,7 +69566,7 @@ var NodeTerminalManager = class {
|
|
|
69055
69566
|
}
|
|
69056
69567
|
byId = /* @__PURE__ */ new Map();
|
|
69057
69568
|
create(opts) {
|
|
69058
|
-
if (!
|
|
69569
|
+
if (!existsSync33(opts.cwd)) {
|
|
69059
69570
|
throw Object.assign(new Error(`cwd does not exist: ${opts.cwd}`), { code: "invalid_argument" });
|
|
69060
69571
|
}
|
|
69061
69572
|
const terminalId = crypto.randomUUID();
|
|
@@ -69196,7 +69707,7 @@ var NodeTerminalManager = class {
|
|
|
69196
69707
|
|
|
69197
69708
|
// src/workspace/project-registry.ts
|
|
69198
69709
|
import { basename as basename2, resolve as resolve8 } from "node:path";
|
|
69199
|
-
import { existsSync as
|
|
69710
|
+
import { existsSync as existsSync34, realpathSync as realpathSync4, statSync as statSync13 } from "node:fs";
|
|
69200
69711
|
import { createHash as createHash7 } from "node:crypto";
|
|
69201
69712
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
69202
69713
|
var ProjectRegistry = class {
|
|
@@ -69226,7 +69737,7 @@ var ProjectRegistry = class {
|
|
|
69226
69737
|
}
|
|
69227
69738
|
open(path, name) {
|
|
69228
69739
|
let abs = resolve8(path);
|
|
69229
|
-
if (!
|
|
69740
|
+
if (!existsSync34(abs) || !statSync13(abs).isDirectory()) {
|
|
69230
69741
|
throw Object.assign(new Error(`project path is not a directory: ${abs}`), {
|
|
69231
69742
|
code: "invalid_argument"
|
|
69232
69743
|
});
|
|
@@ -69270,7 +69781,7 @@ var ProjectRegistry = class {
|
|
|
69270
69781
|
toSnapshot(r) {
|
|
69271
69782
|
let missing = false;
|
|
69272
69783
|
try {
|
|
69273
|
-
missing = !
|
|
69784
|
+
missing = !statSync13(r.path).isDirectory();
|
|
69274
69785
|
} catch {
|
|
69275
69786
|
missing = true;
|
|
69276
69787
|
}
|
|
@@ -69310,7 +69821,7 @@ function detectRepoIdentity(abs) {
|
|
|
69310
69821
|
init_fs();
|
|
69311
69822
|
import {
|
|
69312
69823
|
closeSync,
|
|
69313
|
-
existsSync as
|
|
69824
|
+
existsSync as existsSync35,
|
|
69314
69825
|
fstatSync,
|
|
69315
69826
|
mkdirSync as mkdirSync19,
|
|
69316
69827
|
openSync,
|
|
@@ -69319,11 +69830,11 @@ import {
|
|
|
69319
69830
|
readFileSync as readFileSync17,
|
|
69320
69831
|
renameSync as renameSync5,
|
|
69321
69832
|
rmSync as rmSync7,
|
|
69322
|
-
statSync as
|
|
69833
|
+
statSync as statSync14,
|
|
69323
69834
|
unlinkSync,
|
|
69324
69835
|
writeFileSync as writeFileSync14
|
|
69325
69836
|
} from "node:fs";
|
|
69326
|
-
import { dirname as
|
|
69837
|
+
import { dirname as dirname15, join as join26, relative as relative2 } from "node:path";
|
|
69327
69838
|
import { createHash as createHash8 } from "node:crypto";
|
|
69328
69839
|
function normalizeRel(path) {
|
|
69329
69840
|
return path.replace(/\\/g, "/").replace(/\/+$/, "") || ".";
|
|
@@ -69369,21 +69880,21 @@ var WorkspaceFsService = class {
|
|
|
69369
69880
|
if (!resolved.ok) {
|
|
69370
69881
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69371
69882
|
}
|
|
69372
|
-
if (!
|
|
69883
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69373
69884
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
69374
69885
|
}
|
|
69375
|
-
const st =
|
|
69886
|
+
const st = statSync14(resolved.absolutePath);
|
|
69376
69887
|
if (!st.isDirectory()) {
|
|
69377
69888
|
throw Object.assign(new Error("not a directory"), { code: "invalid_argument" });
|
|
69378
69889
|
}
|
|
69379
69890
|
this.projects.touch(projectId);
|
|
69380
69891
|
const ents = readdirSync11(resolved.absolutePath, { withFileTypes: true });
|
|
69381
69892
|
return ents.map((ent) => {
|
|
69382
|
-
const abs =
|
|
69893
|
+
const abs = join26(resolved.absolutePath, ent.name);
|
|
69383
69894
|
let size;
|
|
69384
69895
|
let mtimeMs;
|
|
69385
69896
|
try {
|
|
69386
|
-
const s2 =
|
|
69897
|
+
const s2 = statSync14(abs);
|
|
69387
69898
|
size = s2.size;
|
|
69388
69899
|
mtimeMs = s2.mtimeMs;
|
|
69389
69900
|
} catch {
|
|
@@ -69404,10 +69915,10 @@ var WorkspaceFsService = class {
|
|
|
69404
69915
|
if (!resolved.ok) {
|
|
69405
69916
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69406
69917
|
}
|
|
69407
|
-
if (!
|
|
69918
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69408
69919
|
throw Object.assign(new Error("file not found"), { code: "not_found" });
|
|
69409
69920
|
}
|
|
69410
|
-
const st =
|
|
69921
|
+
const st = statSync14(resolved.absolutePath);
|
|
69411
69922
|
if (!st.isFile()) {
|
|
69412
69923
|
throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
|
|
69413
69924
|
}
|
|
@@ -69443,8 +69954,8 @@ var WorkspaceFsService = class {
|
|
|
69443
69954
|
if (!resolved.ok) {
|
|
69444
69955
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69445
69956
|
}
|
|
69446
|
-
if (
|
|
69447
|
-
const st =
|
|
69957
|
+
if (existsSync35(resolved.absolutePath) && expectedHash) {
|
|
69958
|
+
const st = statSync14(resolved.absolutePath);
|
|
69448
69959
|
if (st.size > MAX_READ_BYTES) {
|
|
69449
69960
|
throw Object.assign(
|
|
69450
69961
|
new Error(`optimistic-write target too large (${st.size} bytes; max ${MAX_READ_BYTES})`),
|
|
@@ -69456,15 +69967,15 @@ var WorkspaceFsService = class {
|
|
|
69456
69967
|
throw Object.assign(new Error("content hash mismatch"), { code: "conflict" });
|
|
69457
69968
|
}
|
|
69458
69969
|
}
|
|
69459
|
-
mkdirSync19(
|
|
69970
|
+
mkdirSync19(dirname15(resolved.absolutePath), { recursive: true });
|
|
69460
69971
|
const data = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content);
|
|
69461
69972
|
if (data.length > MAX_READ_BYTES) {
|
|
69462
69973
|
throw Object.assign(new Error("write payload too large"), { code: "invalid_argument" });
|
|
69463
69974
|
}
|
|
69464
69975
|
let mode = 384;
|
|
69465
|
-
if (
|
|
69976
|
+
if (existsSync35(resolved.absolutePath)) {
|
|
69466
69977
|
try {
|
|
69467
|
-
mode =
|
|
69978
|
+
mode = statSync14(resolved.absolutePath).mode & 511;
|
|
69468
69979
|
} catch {
|
|
69469
69980
|
}
|
|
69470
69981
|
}
|
|
@@ -69532,7 +70043,7 @@ var WorkspaceFsService = class {
|
|
|
69532
70043
|
for (const ent of ents) {
|
|
69533
70044
|
if (hits.length >= MAX_SEARCH_HITS) return;
|
|
69534
70045
|
if (ent.name === ".git" || ent.name === "node_modules") continue;
|
|
69535
|
-
const abs =
|
|
70046
|
+
const abs = join26(dir, ent.name);
|
|
69536
70047
|
const rel = relative2(root, abs).split("\\").join("/");
|
|
69537
70048
|
const check2 = resolveProjectPath(root, rel);
|
|
69538
70049
|
if (!check2.ok) continue;
|
|
@@ -69542,7 +70053,7 @@ var WorkspaceFsService = class {
|
|
|
69542
70053
|
}
|
|
69543
70054
|
if (!ent.isFile()) continue;
|
|
69544
70055
|
try {
|
|
69545
|
-
const st =
|
|
70056
|
+
const st = statSync14(abs);
|
|
69546
70057
|
if (st.size > MAX_SEARCH_FILE_BYTES) continue;
|
|
69547
70058
|
const text = readFileSync17(abs, "utf8");
|
|
69548
70059
|
const lines = text.split(/\r?\n/);
|
|
@@ -69606,8 +70117,8 @@ var WorkspaceFsService = class {
|
|
|
69606
70117
|
if (!resolved.ok) {
|
|
69607
70118
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69608
70119
|
}
|
|
69609
|
-
if (
|
|
69610
|
-
const st =
|
|
70120
|
+
if (existsSync35(resolved.absolutePath)) {
|
|
70121
|
+
const st = statSync14(resolved.absolutePath);
|
|
69611
70122
|
if (!st.isDirectory()) {
|
|
69612
70123
|
throw Object.assign(new Error("path exists and is not a directory"), { code: "conflict" });
|
|
69613
70124
|
}
|
|
@@ -69629,7 +70140,7 @@ var WorkspaceFsService = class {
|
|
|
69629
70140
|
if (!resolved.ok) {
|
|
69630
70141
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
69631
70142
|
}
|
|
69632
|
-
if (!
|
|
70143
|
+
if (!existsSync35(resolved.absolutePath)) {
|
|
69633
70144
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
69634
70145
|
}
|
|
69635
70146
|
if (resolved.absolutePath === root) {
|
|
@@ -69653,19 +70164,19 @@ var WorkspaceFsService = class {
|
|
|
69653
70164
|
if (!from.ok) {
|
|
69654
70165
|
throw Object.assign(new Error(from.reason), { code: "invalid_argument" });
|
|
69655
70166
|
}
|
|
69656
|
-
if (!
|
|
70167
|
+
if (!existsSync35(from.absolutePath)) {
|
|
69657
70168
|
throw Object.assign(new Error("source not found"), { code: "not_found" });
|
|
69658
70169
|
}
|
|
69659
70170
|
const to = resolveProjectPath(root, toN);
|
|
69660
70171
|
if (!to.ok) {
|
|
69661
70172
|
throw Object.assign(new Error(to.reason), { code: "invalid_argument" });
|
|
69662
70173
|
}
|
|
69663
|
-
if (
|
|
70174
|
+
if (existsSync35(to.absolutePath)) {
|
|
69664
70175
|
throw Object.assign(new Error(`target already exists: ${baseNameRel(toN)}`), {
|
|
69665
70176
|
code: "conflict"
|
|
69666
70177
|
});
|
|
69667
70178
|
}
|
|
69668
|
-
mkdirSync19(
|
|
70179
|
+
mkdirSync19(dirname15(to.absolutePath), { recursive: true });
|
|
69669
70180
|
renameSync5(from.absolutePath, to.absolutePath);
|
|
69670
70181
|
this.projects.touch(projectId);
|
|
69671
70182
|
return { from: fromN, to: toN };
|
|
@@ -69690,8 +70201,8 @@ function hashFileBounded(absolutePath, size) {
|
|
|
69690
70201
|
}
|
|
69691
70202
|
|
|
69692
70203
|
// src/workspace/git-service.ts
|
|
69693
|
-
import { existsSync as
|
|
69694
|
-
import { join as
|
|
70204
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync20, realpathSync as realpathSync5, rmSync as rmSync8, writeFileSync as writeFileSync15 } from "node:fs";
|
|
70205
|
+
import { join as join28, resolve as resolve10 } from "node:path";
|
|
69695
70206
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
69696
70207
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
69697
70208
|
|
|
@@ -69768,19 +70279,19 @@ function gitRunSync(folderPath, args, env) {
|
|
|
69768
70279
|
}
|
|
69769
70280
|
|
|
69770
70281
|
// ../../packages/runtime/src/git/worktree-plan.ts
|
|
69771
|
-
import { basename as basename3, dirname as
|
|
70282
|
+
import { basename as basename3, dirname as dirname16, join as join27, resolve as resolve9, sep as sep4 } from "node:path";
|
|
69772
70283
|
import { homedir as homedir8 } from "node:os";
|
|
69773
70284
|
function resolveMainDirFromCommonDir(folderPath, gitCommonDir) {
|
|
69774
70285
|
const repoRoot = resolve9(folderPath, gitCommonDir.trim());
|
|
69775
|
-
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ?
|
|
70286
|
+
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname16(repoRoot) : repoRoot;
|
|
69776
70287
|
}
|
|
69777
70288
|
function planNewWorktreePaths(input) {
|
|
69778
70289
|
const home = input.homeDir ?? homedir8();
|
|
69779
70290
|
const repoName = basename3(input.mainDir);
|
|
69780
70291
|
const epoch = Math.floor((input.nowMs ?? Date.now()) / 1e3).toString(36);
|
|
69781
70292
|
const short = input.shortHash.slice(0, 7);
|
|
69782
|
-
const wtDir =
|
|
69783
|
-
const wtPath =
|
|
70293
|
+
const wtDir = join27(home, ".worktrees", repoName);
|
|
70294
|
+
const wtPath = join27(wtDir, `${epoch}-${short}`);
|
|
69784
70295
|
return { wtDir, wtPath };
|
|
69785
70296
|
}
|
|
69786
70297
|
function worktreeAddArgs(mode, wtPath, baseRef, branchName) {
|
|
@@ -69839,8 +70350,8 @@ function resolveMainWorktreeDir(folderPath) {
|
|
|
69839
70350
|
}
|
|
69840
70351
|
function samePath(a, b2) {
|
|
69841
70352
|
try {
|
|
69842
|
-
const ra =
|
|
69843
|
-
const rb =
|
|
70353
|
+
const ra = existsSync36(a) ? realpathSync5(a) : resolve10(a);
|
|
70354
|
+
const rb = existsSync36(b2) ? realpathSync5(b2) : resolve10(b2);
|
|
69844
70355
|
return ra === rb;
|
|
69845
70356
|
} catch {
|
|
69846
70357
|
return resolve10(a) === resolve10(b2);
|
|
@@ -69872,7 +70383,7 @@ var WorkspaceGitService = class {
|
|
|
69872
70383
|
* --ignored walks the whole tree of ignored paths and dominates remote latency.
|
|
69873
70384
|
*/
|
|
69874
70385
|
statusForCwd(cwd) {
|
|
69875
|
-
if (!
|
|
70386
|
+
if (!existsSync36(join28(cwd, ".git")) && !isGitWorktree(cwd)) {
|
|
69876
70387
|
return { isRepo: false, branch: null, dirty: false, ahead: 0, behind: 0, porcelain: "" };
|
|
69877
70388
|
}
|
|
69878
70389
|
try {
|
|
@@ -69981,15 +70492,15 @@ var WorkspaceGitService = class {
|
|
|
69981
70492
|
}
|
|
69982
70493
|
const abs = resolve10(worktreePath);
|
|
69983
70494
|
const main2 = resolve10(this.root(projectId));
|
|
69984
|
-
if (samePath(abs, main2)) return
|
|
70495
|
+
if (samePath(abs, main2)) return existsSync36(abs) ? realpathSync5(abs) : abs;
|
|
69985
70496
|
const listed = this.worktrees(projectId);
|
|
69986
70497
|
for (const wt of listed) {
|
|
69987
70498
|
if (samePath(abs, wt.path)) {
|
|
69988
|
-
return
|
|
70499
|
+
return existsSync36(abs) ? realpathSync5(abs) : resolve10(wt.path);
|
|
69989
70500
|
}
|
|
69990
70501
|
}
|
|
69991
70502
|
try {
|
|
69992
|
-
if (
|
|
70503
|
+
if (existsSync36(abs) && isGitWorktree(abs)) {
|
|
69993
70504
|
const commonA = resolve10(abs, git(abs, ["rev-parse", "--git-common-dir"]).trim());
|
|
69994
70505
|
const commonB = resolve10(main2, git(main2, ["rev-parse", "--git-common-dir"]).trim());
|
|
69995
70506
|
if (samePath(commonA, commonB)) {
|
|
@@ -70031,7 +70542,7 @@ var WorkspaceGitService = class {
|
|
|
70031
70542
|
mainDir,
|
|
70032
70543
|
shortHash: commitHash.slice(0, 7)
|
|
70033
70544
|
});
|
|
70034
|
-
if (!
|
|
70545
|
+
if (!existsSync36(wtDir)) mkdirSync20(wtDir, { recursive: true });
|
|
70035
70546
|
try {
|
|
70036
70547
|
const addArgs = worktreeAddArgs(mode, wtPath, baseBranch, safeBranchName);
|
|
70037
70548
|
git(folderPath, ["worktree", ...addArgs]);
|
|
@@ -70127,7 +70638,7 @@ var WorkspaceGitService = class {
|
|
|
70127
70638
|
const mainStatus = git(diff.mainDir, ["status", "--porcelain"]).trim();
|
|
70128
70639
|
if (mainStatus) return { ok: false, reason: "main-dirty" };
|
|
70129
70640
|
const patch = git(diff.worktreePath, ["diff", "--binary", diff.base, diff.tree]);
|
|
70130
|
-
const patchFile =
|
|
70641
|
+
const patchFile = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.patch`);
|
|
70131
70642
|
writeFileSync15(patchFile, `${patch}
|
|
70132
70643
|
`);
|
|
70133
70644
|
if (git(diff.mainDir, ["status", "--porcelain"]).trim()) {
|
|
@@ -70189,7 +70700,7 @@ var WorkspaceGitService = class {
|
|
|
70189
70700
|
};
|
|
70190
70701
|
}
|
|
70191
70702
|
writeWorkingTree(worktreePath) {
|
|
70192
|
-
const tmpIndex =
|
|
70703
|
+
const tmpIndex = join28(tmpdir3(), `s1-handoff-${randomUUID8()}.index`);
|
|
70193
70704
|
const env = { GIT_INDEX_FILE: tmpIndex };
|
|
70194
70705
|
try {
|
|
70195
70706
|
git(worktreePath, ["read-tree", "HEAD"], env);
|
|
@@ -70386,7 +70897,7 @@ init_agent_types();
|
|
|
70386
70897
|
init_environment();
|
|
70387
70898
|
init_resolve_service();
|
|
70388
70899
|
import { createHash as createHash9, randomBytes as randomBytes5, randomUUID as randomUUID10 } from "node:crypto";
|
|
70389
|
-
import { existsSync as
|
|
70900
|
+
import { existsSync as existsSync37, statSync as statSync15 } from "node:fs";
|
|
70390
70901
|
import { resolve as pathResolve2 } from "node:path";
|
|
70391
70902
|
var MAX_MESSAGES_PER_RETRIEVE = 100;
|
|
70392
70903
|
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 +71818,7 @@ var CollaborationService = class {
|
|
|
71307
71818
|
const project = this.deps.projects.get(projectId);
|
|
71308
71819
|
const fallback = parentCwd || project?.path || process.cwd();
|
|
71309
71820
|
const cwd = pathResolve2(config2.cwd || fallback);
|
|
71310
|
-
if (!
|
|
71821
|
+
if (!existsSync37(cwd) || !statSync15(cwd).isDirectory()) {
|
|
71311
71822
|
throw Object.assign(new Error(`Working directory does not exist: ${cwd}`), {
|
|
71312
71823
|
code: "invalid_argument"
|
|
71313
71824
|
});
|
|
@@ -71446,8 +71957,8 @@ var CollaborationService = class {
|
|
|
71446
71957
|
};
|
|
71447
71958
|
|
|
71448
71959
|
// src/provider/secret-crypto.ts
|
|
71449
|
-
import { existsSync as
|
|
71450
|
-
import { dirname as
|
|
71960
|
+
import { existsSync as existsSync38, mkdirSync as mkdirSync21, readFileSync as readFileSync18, writeFileSync as writeFileSync16, chmodSync as chmodSync2 } from "node:fs";
|
|
71961
|
+
import { dirname as dirname17 } from "node:path";
|
|
71451
71962
|
import { createCipheriv, createDecipheriv, randomBytes as randomBytes6 } from "node:crypto";
|
|
71452
71963
|
var ENC_PREFIX2 = "enc:v1:";
|
|
71453
71964
|
var KEY_BYTES = 32;
|
|
@@ -71455,11 +71966,11 @@ function isEncryptedSecret(value) {
|
|
|
71455
71966
|
return typeof value === "string" && value.startsWith(ENC_PREFIX2);
|
|
71456
71967
|
}
|
|
71457
71968
|
function ensureKeyFile(keyPath) {
|
|
71458
|
-
if (
|
|
71969
|
+
if (existsSync38(keyPath)) {
|
|
71459
71970
|
const raw = readFileSync18(keyPath);
|
|
71460
71971
|
if (raw.length === KEY_BYTES) return raw;
|
|
71461
71972
|
}
|
|
71462
|
-
mkdirSync21(
|
|
71973
|
+
mkdirSync21(dirname17(keyPath), { recursive: true, mode: 448 });
|
|
71463
71974
|
const key = randomBytes6(KEY_BYTES);
|
|
71464
71975
|
writeFileSync16(keyPath, key, { mode: 384 });
|
|
71465
71976
|
try {
|
|
@@ -71603,7 +72114,7 @@ var WorkspaceWatchService = class {
|
|
|
71603
72114
|
|
|
71604
72115
|
// src/workspace/tail-watch-service.ts
|
|
71605
72116
|
init_fs();
|
|
71606
|
-
import { existsSync as
|
|
72117
|
+
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
72118
|
var MAX_POLL_BYTES = 10 * 1024 * 1024;
|
|
71608
72119
|
var WorkspaceTailWatchService = class {
|
|
71609
72120
|
constructor(projects, fs) {
|
|
@@ -71625,7 +72136,7 @@ var WorkspaceTailWatchService = class {
|
|
|
71625
72136
|
);
|
|
71626
72137
|
}
|
|
71627
72138
|
try {
|
|
71628
|
-
resolvedAbs =
|
|
72139
|
+
resolvedAbs = existsSync39(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
|
|
71629
72140
|
} catch {
|
|
71630
72141
|
resolvedAbs = absolutePath;
|
|
71631
72142
|
}
|
|
@@ -71656,9 +72167,9 @@ var WorkspaceTailWatchService = class {
|
|
|
71656
72167
|
code: "invalid_argument"
|
|
71657
72168
|
});
|
|
71658
72169
|
}
|
|
71659
|
-
if (
|
|
72170
|
+
if (existsSync39(resolvedAbs)) {
|
|
71660
72171
|
try {
|
|
71661
|
-
const st =
|
|
72172
|
+
const st = statSync16(resolvedAbs);
|
|
71662
72173
|
if (!st.isFile()) {
|
|
71663
72174
|
throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
|
|
71664
72175
|
}
|
|
@@ -71707,7 +72218,7 @@ var WorkspaceTailWatchService = class {
|
|
|
71707
72218
|
{ code: "invalid_argument" }
|
|
71708
72219
|
);
|
|
71709
72220
|
}
|
|
71710
|
-
if (!
|
|
72221
|
+
if (!existsSync39(absolutePath)) {
|
|
71711
72222
|
return {
|
|
71712
72223
|
content: "",
|
|
71713
72224
|
encoding: "base64",
|
|
@@ -84847,7 +85358,7 @@ function createLocalPairingToken(nodeHome) {
|
|
|
84847
85358
|
}
|
|
84848
85359
|
function readRuntimeStatus(nodeHome) {
|
|
84849
85360
|
const paths = nodePaths(resolveRuntimeConfig({ nodeHome }).nodeHome);
|
|
84850
|
-
if (!
|
|
85361
|
+
if (!existsSync40(paths.runtimeJson)) return null;
|
|
84851
85362
|
try {
|
|
84852
85363
|
return JSON.parse(readFileSync19(paths.runtimeJson, "utf8"));
|
|
84853
85364
|
} catch {
|
|
@@ -84857,8 +85368,8 @@ function readRuntimeStatus(nodeHome) {
|
|
|
84857
85368
|
|
|
84858
85369
|
// src/systemd/install.ts
|
|
84859
85370
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
84860
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
84861
|
-
import { dirname as
|
|
85371
|
+
import { chmodSync as chmodSync3, existsSync as existsSync41, mkdirSync as mkdirSync22, unlinkSync as unlinkSync2, writeFileSync as writeFileSync18 } from "node:fs";
|
|
85372
|
+
import { dirname as dirname18 } from "node:path";
|
|
84862
85373
|
|
|
84863
85374
|
// src/systemd/unit.ts
|
|
84864
85375
|
function renderSystemdUserUnit(opts) {
|
|
@@ -84915,7 +85426,7 @@ function checkLinger(user) {
|
|
|
84915
85426
|
return { enabled: null, raw };
|
|
84916
85427
|
}
|
|
84917
85428
|
function writeSystemdUserUnit(opts, unitPath = systemdUserUnitPath()) {
|
|
84918
|
-
mkdirSync22(
|
|
85429
|
+
mkdirSync22(dirname18(unitPath), { recursive: true });
|
|
84919
85430
|
writeFileSync18(unitPath, renderSystemdUserUnit(opts), { encoding: "utf8", mode: 420 });
|
|
84920
85431
|
try {
|
|
84921
85432
|
chmodSync3(unitPath, 420);
|
|
@@ -84969,7 +85480,7 @@ function uninstallSystemdUserService(removeUnitFile = true) {
|
|
|
84969
85480
|
}
|
|
84970
85481
|
if (removeUnitFile) {
|
|
84971
85482
|
const path = systemdUserUnitPath();
|
|
84972
|
-
if (
|
|
85483
|
+
if (existsSync41(path)) {
|
|
84973
85484
|
try {
|
|
84974
85485
|
unlinkSync2(path);
|
|
84975
85486
|
} catch (err) {
|
|
@@ -84992,7 +85503,7 @@ function systemdUserStatus() {
|
|
|
84992
85503
|
|
|
84993
85504
|
// src/session/harness-cli.ts
|
|
84994
85505
|
init_environment();
|
|
84995
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as
|
|
85506
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync42, realpathSync as realpathSync7, statSync as statSync17 } from "node:fs";
|
|
84996
85507
|
import { isAbsolute as isAbsolute4, resolve as resolve11 } from "node:path";
|
|
84997
85508
|
import { homedir as homedir9 } from "node:os";
|
|
84998
85509
|
var DEFERRED_FLAGS = /* @__PURE__ */ new Set([
|
|
@@ -85541,10 +86052,10 @@ function resolveExternalCommand2(explicit, pathCandidates) {
|
|
|
85541
86052
|
return null;
|
|
85542
86053
|
}
|
|
85543
86054
|
function isUsableExecutable(path) {
|
|
85544
|
-
if (!
|
|
86055
|
+
if (!existsSync42(path)) return null;
|
|
85545
86056
|
let st;
|
|
85546
86057
|
try {
|
|
85547
|
-
st =
|
|
86058
|
+
st = statSync17(path);
|
|
85548
86059
|
} catch {
|
|
85549
86060
|
return null;
|
|
85550
86061
|
}
|
|
@@ -85561,10 +86072,10 @@ function isUsableExecutable(path) {
|
|
|
85561
86072
|
}
|
|
85562
86073
|
}
|
|
85563
86074
|
function probeExecutableIssues(path) {
|
|
85564
|
-
if (!
|
|
86075
|
+
if (!existsSync42(path)) return ["command_missing"];
|
|
85565
86076
|
let st;
|
|
85566
86077
|
try {
|
|
85567
|
-
st =
|
|
86078
|
+
st = statSync17(path);
|
|
85568
86079
|
} catch {
|
|
85569
86080
|
return ["command_missing"];
|
|
85570
86081
|
}
|
|
@@ -85577,9 +86088,9 @@ function probeExecutableIssues(path) {
|
|
|
85577
86088
|
return [];
|
|
85578
86089
|
}
|
|
85579
86090
|
function probeReadableFileIssues(path) {
|
|
85580
|
-
if (!
|
|
86091
|
+
if (!existsSync42(path)) return ["artifact_missing"];
|
|
85581
86092
|
try {
|
|
85582
|
-
if (!
|
|
86093
|
+
if (!statSync17(path).isFile()) return ["artifact_not_file"];
|
|
85583
86094
|
} catch {
|
|
85584
86095
|
return ["artifact_missing"];
|
|
85585
86096
|
}
|