@super-one/cli 0.57.2-alpha → 0.57.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 +671 -614
- package/package.json +1 -1
package/lib/cli.mjs
CHANGED
|
@@ -2990,7 +2990,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
2990
2990
|
},
|
|
2991
2991
|
{
|
|
2992
2992
|
"name": "browser_act",
|
|
2993
|
-
"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.",
|
|
2993
|
+
"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. Set recording=true to save a short video containing only this action transaction. Optional expect keeps the recording open until an explicit page condition is met. Do not use this to navigate (browser_tabs), wait (browser_wait_for), or run JS (browser_evaluate). Fail-fast: stops at the first error.",
|
|
2994
2994
|
"inputSchema": {
|
|
2995
2995
|
"type": "object",
|
|
2996
2996
|
"properties": {
|
|
@@ -3008,7 +3008,19 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3008
3008
|
"required": ["type"],
|
|
3009
3009
|
"additionalProperties": true
|
|
3010
3010
|
}
|
|
3011
|
-
}
|
|
3011
|
+
},
|
|
3012
|
+
"recording": { "type": "boolean", "description": "Save a video of only this action transaction. Default false." },
|
|
3013
|
+
"expect": {
|
|
3014
|
+
"type": "object",
|
|
3015
|
+
"properties": {
|
|
3016
|
+
"selector": { "type": "string" },
|
|
3017
|
+
"selectorGone": { "type": "string" },
|
|
3018
|
+
"text": { "type": "string" },
|
|
3019
|
+
"urlIncludes": { "type": "string" }
|
|
3020
|
+
},
|
|
3021
|
+
"additionalProperties": false
|
|
3022
|
+
},
|
|
3023
|
+
"timeoutMs": { "type": "integer", "minimum": 100, "maximum": 6e4 }
|
|
3012
3024
|
},
|
|
3013
3025
|
"required": ["actions"],
|
|
3014
3026
|
"additionalProperties": false
|
|
@@ -3277,7 +3289,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3277
3289
|
},
|
|
3278
3290
|
{
|
|
3279
3291
|
"name": "computer_act",
|
|
3280
|
-
"description": "Submit 1\u201320 related UI actions as a checked transaction against a stateId. Delivery policy (pick explicitly when possible): (1) Prefer delivery=semantic whenever actions use @eN refs and the action is press/setText/click(ref)/typeText(ref) \u2014 pure AX, most reliable for labeled controls. (2) Use delivery=app-directed (runtime default if omitted) for coordinate click/type/scroll/drag/keypress or when no usable AX ref exists \u2014 posts CGEvent to the target app PID in the background without stealing frontmost. (3) Use delivery=physical only when app-directed fails and global HID is required (requires frontmost; disruptive). Actions: click, typeText, keypress, scroll(dx,dy[,x,y|ref]), drag(path\u22652 points), moveMouse, press/setText (AX). scroll: positive dy scrolls content down; aim with x,y (capture space) or ref center; else window/outline center. drag: path is capture-space points; virtual cursor animates along the path. Returns outcome worked|didnt|unknown based on re-observation (not API success codes): worked when AX readback, expect, typed text, or a meaningful successor outline diff confirms effect; unknown only when applied but unprovable; didnt on hard failure or failed expect. When the successor has pixels, successorImage.path contains the fresh screenshot. Stale stateId (UI changed since snapshot) is rejected before side effects. delivery=semantic never silently upgrades to app-directed/physical input.",
|
|
3292
|
+
"description": "Submit 1\u201320 related UI actions as a checked transaction against a stateId. Delivery policy (pick explicitly when possible): (1) Prefer delivery=semantic whenever actions use @eN refs and the action is press/setText/click(ref)/typeText(ref) \u2014 pure AX, most reliable for labeled controls. (2) Use delivery=app-directed (runtime default if omitted) for coordinate click/type/scroll/drag/keypress or when no usable AX ref exists \u2014 posts CGEvent to the target app PID in the background without stealing frontmost. (3) Use delivery=physical only when app-directed fails and global HID is required (requires frontmost; disruptive). Actions: click, typeText, keypress, scroll(dx,dy[,x,y|ref]), drag(path\u22652 points), moveMouse, press/setText (AX). scroll: positive dy scrolls content down; aim with x,y (capture space) or ref center; else window/outline center. drag: path is capture-space points; virtual cursor animates along the path. Returns outcome worked|didnt|unknown based on re-observation (not API success codes): worked when AX readback, expect, typed text, or a meaningful successor outline diff confirms effect; unknown only when applied but unprovable; didnt on hard failure or failed expect. When the successor has pixels, successorImage.path contains the fresh screenshot. Set recording=true to save a short video containing only this action transaction. Stale stateId (UI changed since snapshot) is rejected before side effects. delivery=semantic never silently upgrades to app-directed/physical input.",
|
|
3281
3293
|
"inputSchema": {
|
|
3282
3294
|
"type": "object",
|
|
3283
3295
|
"properties": {
|
|
@@ -3396,6 +3408,16 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3396
3408
|
],
|
|
3397
3409
|
"additionalProperties": false
|
|
3398
3410
|
},
|
|
3411
|
+
"recording": {
|
|
3412
|
+
"description": "Save a video of only this action transaction. Default false.",
|
|
3413
|
+
"type": "boolean"
|
|
3414
|
+
},
|
|
3415
|
+
"timeoutMs": {
|
|
3416
|
+
"description": "Maximum wait for expect before the action is judged. Default 5000.",
|
|
3417
|
+
"type": "integer",
|
|
3418
|
+
"minimum": 100,
|
|
3419
|
+
"maximum": 6e4
|
|
3420
|
+
},
|
|
3399
3421
|
"delivery": {
|
|
3400
3422
|
"description": "Prefer semantic when actions target @eN refs (press/setText/click/typeText). Omit or app-directed = background postToPid (default). physical = global HID + frontmost only as last resort.",
|
|
3401
3423
|
"type": "string",
|
|
@@ -3800,7 +3822,7 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3800
3822
|
},
|
|
3801
3823
|
{
|
|
3802
3824
|
"name": "device_act",
|
|
3803
|
-
"description": "Run 1-10 touch actions against a snapshot, then re-observe to judge if they worked. Actions: tap, doubleTap, longPress, swipe(direction|toX/toY), pinch(scale), press(ref), type, key, rotate, keyboard. Prefer press
|
|
3825
|
+
"description": "Run 1-10 touch actions against a snapshot, then re-observe to judge if they worked. Actions: tap, doubleTap, longPress, swipe(direction|toX/toY), pinch(scale), press(ref), type, key, rotate, keyboard. Prefer refs; press uses accessibility and is resilient to animation (use tap for source=ocr). Raw x/y is a last resort. The batch and stale stateId are validated before side effects. rotate must be last; re-snapshot afterwards. Set recording=true to save a short video containing only this action transaction. Returns worked|didnt|unknown. Pass expect to define and wait for success.",
|
|
3804
3826
|
"inputSchema": {
|
|
3805
3827
|
"type": "object",
|
|
3806
3828
|
"properties": {
|
|
@@ -3808,7 +3830,9 @@ If the tool returns an error containing "user_locked", the user has manually nam
|
|
|
3808
3830
|
"device": deviceTargetProperty,
|
|
3809
3831
|
"stateId": { "type": "string" },
|
|
3810
3832
|
"actions": { "minItems": 1, "maxItems": 10, "type": "array", "items": deviceActionSchema },
|
|
3811
|
-
"expect": { "description": "Postcondition checked after the actions run.", ...deviceConditionSchema }
|
|
3833
|
+
"expect": { "description": "Postcondition checked after the actions run.", ...deviceConditionSchema },
|
|
3834
|
+
"timeoutMs": { "description": "Maximum wait for expect before the action is judged. Default 5000.", "type": "integer", "minimum": 100, "maximum": 6e4 },
|
|
3835
|
+
"recording": { "description": "Save a video of only this action transaction. Default false.", "type": "boolean" }
|
|
3812
3836
|
},
|
|
3813
3837
|
"required": ["description", "stateId", "actions"],
|
|
3814
3838
|
"additionalProperties": false
|
|
@@ -4548,9 +4572,9 @@ var require_node_gyp_build = __commonJS({
|
|
|
4548
4572
|
var debug = getFirst(path.join(dir, "build/Debug"), matchBuild);
|
|
4549
4573
|
if (debug) return debug;
|
|
4550
4574
|
}
|
|
4551
|
-
var prebuild =
|
|
4575
|
+
var prebuild = resolve15(dir);
|
|
4552
4576
|
if (prebuild) return prebuild;
|
|
4553
|
-
var nearby =
|
|
4577
|
+
var nearby = resolve15(path.dirname(process.execPath));
|
|
4554
4578
|
if (nearby) return nearby;
|
|
4555
4579
|
var target = [
|
|
4556
4580
|
"platform=" + platform2,
|
|
@@ -4566,7 +4590,7 @@ var require_node_gyp_build = __commonJS({
|
|
|
4566
4590
|
// eslint-disable-line
|
|
4567
4591
|
].filter(Boolean).join(" ");
|
|
4568
4592
|
throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n");
|
|
4569
|
-
function
|
|
4593
|
+
function resolve15(dir2) {
|
|
4570
4594
|
var tuples = readdirSync12(path.join(dir2, "prebuilds")).map(parseTuple);
|
|
4571
4595
|
var tuple2 = tuples.filter(matchTuple(platform2, arch2)).sort(compareTuples)[0];
|
|
4572
4596
|
if (!tuple2) return;
|
|
@@ -18701,139 +18725,16 @@ var init_hooks_config = __esm({
|
|
|
18701
18725
|
}
|
|
18702
18726
|
});
|
|
18703
18727
|
|
|
18704
|
-
// ../../packages/runtime/src/fs/
|
|
18705
|
-
import { existsSync as existsSync14,
|
|
18728
|
+
// ../../packages/runtime/src/fs/agents-discover.ts
|
|
18729
|
+
import { existsSync as existsSync14, readdirSync as readdirSync5, readFileSync as readFileSync12 } from "node:fs";
|
|
18730
|
+
import { join as join15 } from "node:path";
|
|
18706
18731
|
import { homedir as osHomedir7 } from "node:os";
|
|
18707
|
-
import { dirname as dirname12, join as join15 } from "node:path";
|
|
18708
18732
|
function homeOf7(opts) {
|
|
18709
18733
|
return opts?.homeDir ?? osHomedir7();
|
|
18710
18734
|
}
|
|
18711
|
-
function codexHomeOf3(opts) {
|
|
18712
|
-
if (opts?.codexHome) return opts.codexHome;
|
|
18713
|
-
return process.env.CODEX_HOME?.trim() || join15(homeOf7(opts), ".codex");
|
|
18714
|
-
}
|
|
18715
|
-
function readJson3(filePath) {
|
|
18716
|
-
if (!existsSync14(filePath)) return null;
|
|
18717
|
-
try {
|
|
18718
|
-
return JSON.parse(readFileSync12(filePath, "utf8"));
|
|
18719
|
-
} catch {
|
|
18720
|
-
return null;
|
|
18721
|
-
}
|
|
18722
|
-
}
|
|
18723
|
-
function readToml(filePath) {
|
|
18724
|
-
if (!existsSync14(filePath)) return null;
|
|
18725
|
-
try {
|
|
18726
|
-
return parse(readFileSync12(filePath, "utf8"));
|
|
18727
|
-
} catch {
|
|
18728
|
-
return null;
|
|
18729
|
-
}
|
|
18730
|
-
}
|
|
18731
|
-
function cleanDirs(value) {
|
|
18732
|
-
if (!Array.isArray(value)) return [];
|
|
18733
|
-
return Array.from(new Set(value.filter((dir) => typeof dir === "string" && dir.trim().length > 0)));
|
|
18734
|
-
}
|
|
18735
|
-
function claudeDirs(data) {
|
|
18736
|
-
if (!data) return [];
|
|
18737
|
-
const permissions = data.permissions;
|
|
18738
|
-
const nested = permissions && typeof permissions === "object" && !Array.isArray(permissions) ? permissions.additionalDirectories : void 0;
|
|
18739
|
-
return Array.from(/* @__PURE__ */ new Set([
|
|
18740
|
-
...cleanDirs(data.additionalDirectories),
|
|
18741
|
-
...cleanDirs(nested)
|
|
18742
|
-
]));
|
|
18743
|
-
}
|
|
18744
|
-
function codexDirs(data) {
|
|
18745
|
-
if (!data) return [];
|
|
18746
|
-
const workspaceWrite = data.sandbox_workspace_write;
|
|
18747
|
-
if (!workspaceWrite || typeof workspaceWrite !== "object" || Array.isArray(workspaceWrite)) return [];
|
|
18748
|
-
return cleanDirs(workspaceWrite.writable_roots);
|
|
18749
|
-
}
|
|
18750
|
-
function readScopedAdditionalDirs(provider, cwd, opts) {
|
|
18751
|
-
if (provider === "codex") {
|
|
18752
|
-
return {
|
|
18753
|
-
user: codexDirs(readToml(join15(codexHomeOf3(opts), "config.toml"))),
|
|
18754
|
-
projectShared: [],
|
|
18755
|
-
projectLocal: codexDirs(readToml(join15(cwd, ".codex", "config.toml")))
|
|
18756
|
-
};
|
|
18757
|
-
}
|
|
18758
|
-
return {
|
|
18759
|
-
user: claudeDirs(readJson3(join15(homeOf7(opts), ".claude", "settings.json"))),
|
|
18760
|
-
projectShared: claudeDirs(readJson3(join15(cwd, ".claude", "settings.json"))),
|
|
18761
|
-
projectLocal: claudeDirs(readJson3(join15(cwd, ".claude", "settings.local.json")))
|
|
18762
|
-
};
|
|
18763
|
-
}
|
|
18764
|
-
function addProjectAdditionalDir(provider, cwd, dir, opts) {
|
|
18765
|
-
if (provider === "codex") {
|
|
18766
|
-
const filePath2 = join15(cwd, ".codex", "config.toml");
|
|
18767
|
-
const data2 = readToml(filePath2) ?? {};
|
|
18768
|
-
const current2 = data2.sandbox_workspace_write;
|
|
18769
|
-
const workspaceWrite = current2 && typeof current2 === "object" && !Array.isArray(current2) ? current2 : {};
|
|
18770
|
-
const existing2 = cleanDirs(workspaceWrite.writable_roots);
|
|
18771
|
-
if (existing2.includes(dir)) return;
|
|
18772
|
-
workspaceWrite.writable_roots = [...existing2, dir];
|
|
18773
|
-
data2.sandbox_workspace_write = workspaceWrite;
|
|
18774
|
-
mkdirSync11(dirname12(filePath2), { recursive: true });
|
|
18775
|
-
writeFileSync9(filePath2, stringify(data2), "utf8");
|
|
18776
|
-
return;
|
|
18777
|
-
}
|
|
18778
|
-
const filePath = join15(cwd, ".claude", "settings.local.json");
|
|
18779
|
-
const data = readJson3(filePath) ?? {};
|
|
18780
|
-
const current = data.permissions;
|
|
18781
|
-
const permissions = current && typeof current === "object" && !Array.isArray(current) ? current : {};
|
|
18782
|
-
const existing = cleanDirs(permissions.additionalDirectories);
|
|
18783
|
-
if (existing.includes(dir)) return;
|
|
18784
|
-
permissions.additionalDirectories = [...existing, dir];
|
|
18785
|
-
data.permissions = permissions;
|
|
18786
|
-
mkdirSync11(dirname12(filePath), { recursive: true });
|
|
18787
|
-
writeFileSync9(filePath, `${JSON.stringify(data, null, 2)}
|
|
18788
|
-
`, "utf8");
|
|
18789
|
-
}
|
|
18790
|
-
function removeProjectAdditionalDir(provider, cwd, dir) {
|
|
18791
|
-
if (provider === "codex") {
|
|
18792
|
-
const filePath2 = join15(cwd, ".codex", "config.toml");
|
|
18793
|
-
const data2 = readToml(filePath2);
|
|
18794
|
-
if (!data2) return;
|
|
18795
|
-
const current2 = data2.sandbox_workspace_write;
|
|
18796
|
-
if (!current2 || typeof current2 !== "object" || Array.isArray(current2)) return;
|
|
18797
|
-
const workspaceWrite = current2;
|
|
18798
|
-
const existing2 = cleanDirs(workspaceWrite.writable_roots);
|
|
18799
|
-
const filtered2 = existing2.filter((root) => root !== dir);
|
|
18800
|
-
if (filtered2.length === existing2.length) return;
|
|
18801
|
-
if (filtered2.length > 0) workspaceWrite.writable_roots = filtered2;
|
|
18802
|
-
else delete workspaceWrite.writable_roots;
|
|
18803
|
-
if (Object.keys(workspaceWrite).length === 0) delete data2.sandbox_workspace_write;
|
|
18804
|
-
writeFileSync9(filePath2, stringify(data2), "utf8");
|
|
18805
|
-
return;
|
|
18806
|
-
}
|
|
18807
|
-
const filePath = join15(cwd, ".claude", "settings.local.json");
|
|
18808
|
-
const data = readJson3(filePath);
|
|
18809
|
-
if (!data) return;
|
|
18810
|
-
const current = data.permissions;
|
|
18811
|
-
if (!current || typeof current !== "object" || Array.isArray(current)) return;
|
|
18812
|
-
const permissions = current;
|
|
18813
|
-
const existing = cleanDirs(permissions.additionalDirectories);
|
|
18814
|
-
const filtered = existing.filter((root) => root !== dir);
|
|
18815
|
-
if (filtered.length === existing.length) return;
|
|
18816
|
-
permissions.additionalDirectories = filtered;
|
|
18817
|
-
writeFileSync9(filePath, `${JSON.stringify(data, null, 2)}
|
|
18818
|
-
`, "utf8");
|
|
18819
|
-
}
|
|
18820
|
-
var init_additional_dirs_config = __esm({
|
|
18821
|
-
"../../packages/runtime/src/fs/additional-dirs-config.ts"() {
|
|
18822
|
-
"use strict";
|
|
18823
|
-
init_dist();
|
|
18824
|
-
}
|
|
18825
|
-
});
|
|
18826
|
-
|
|
18827
|
-
// ../../packages/runtime/src/fs/agents-discover.ts
|
|
18828
|
-
import { existsSync as existsSync15, readdirSync as readdirSync5, readFileSync as readFileSync13 } from "node:fs";
|
|
18829
|
-
import { join as join16 } from "node:path";
|
|
18830
|
-
import { homedir as osHomedir8 } from "node:os";
|
|
18831
|
-
function homeOf8(opts) {
|
|
18832
|
-
return opts?.homeDir ?? osHomedir8();
|
|
18833
|
-
}
|
|
18834
18735
|
function safeRead(path) {
|
|
18835
18736
|
try {
|
|
18836
|
-
return
|
|
18737
|
+
return readFileSync12(path, "utf-8");
|
|
18837
18738
|
} catch {
|
|
18838
18739
|
return "";
|
|
18839
18740
|
}
|
|
@@ -18880,10 +18781,10 @@ function parseFrontmatter(content) {
|
|
|
18880
18781
|
return result;
|
|
18881
18782
|
}
|
|
18882
18783
|
function readPlugins(opts) {
|
|
18883
|
-
const pluginsFile =
|
|
18884
|
-
if (!
|
|
18784
|
+
const pluginsFile = join15(homeOf7(opts), ".claude", "plugins", "installed_plugins.json");
|
|
18785
|
+
if (!existsSync14(pluginsFile)) return {};
|
|
18885
18786
|
try {
|
|
18886
|
-
const data = JSON.parse(
|
|
18787
|
+
const data = JSON.parse(readFileSync12(pluginsFile, "utf-8"));
|
|
18887
18788
|
return data.plugins ?? {};
|
|
18888
18789
|
} catch {
|
|
18889
18790
|
return {};
|
|
@@ -18904,12 +18805,12 @@ function forEachPluginScope(filter, callback, opts) {
|
|
|
18904
18805
|
}
|
|
18905
18806
|
}
|
|
18906
18807
|
function scanAgentDir(dir, source, namePrefix = "") {
|
|
18907
|
-
if (!
|
|
18808
|
+
if (!existsSync14(dir)) return [];
|
|
18908
18809
|
const agents = [];
|
|
18909
18810
|
for (const entry of readdirSync5(dir, { withFileTypes: true })) {
|
|
18910
18811
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
18911
18812
|
const name = namePrefix + entry.name.replace(/\.md$/, "");
|
|
18912
|
-
const content = safeRead(
|
|
18813
|
+
const content = safeRead(join15(dir, entry.name));
|
|
18913
18814
|
const fm = parseFrontmatter(content);
|
|
18914
18815
|
agents.push({
|
|
18915
18816
|
name,
|
|
@@ -18922,23 +18823,23 @@ function scanAgentDir(dir, source, namePrefix = "") {
|
|
|
18922
18823
|
}
|
|
18923
18824
|
function discoverUserAgents(opts) {
|
|
18924
18825
|
const agents = [
|
|
18925
|
-
...scanAgentDir(
|
|
18826
|
+
...scanAgentDir(join15(homeOf7(opts), ".claude", "agents"), "user")
|
|
18926
18827
|
];
|
|
18927
18828
|
forEachPluginScope(
|
|
18928
18829
|
isUserScoped,
|
|
18929
18830
|
(installPath, pluginName) => {
|
|
18930
|
-
agents.push(...scanAgentDir(
|
|
18831
|
+
agents.push(...scanAgentDir(join15(installPath, "agents"), "plugin", `${pluginName}:`));
|
|
18931
18832
|
},
|
|
18932
18833
|
opts
|
|
18933
18834
|
);
|
|
18934
18835
|
return agents;
|
|
18935
18836
|
}
|
|
18936
18837
|
function discoverProjectAgents(cwd, opts) {
|
|
18937
|
-
const agents = [...scanAgentDir(
|
|
18838
|
+
const agents = [...scanAgentDir(join15(cwd, ".claude", "agents"), "project")];
|
|
18938
18839
|
forEachPluginScope(
|
|
18939
18840
|
(e) => isProjectScoped(e, cwd),
|
|
18940
18841
|
(installPath, pluginName) => {
|
|
18941
|
-
agents.push(...scanAgentDir(
|
|
18842
|
+
agents.push(...scanAgentDir(join15(installPath, "agents"), "plugin", `${pluginName}:`));
|
|
18942
18843
|
},
|
|
18943
18844
|
opts
|
|
18944
18845
|
);
|
|
@@ -18961,10 +18862,10 @@ function discoverAllAgents(cwd, opts) {
|
|
|
18961
18862
|
}
|
|
18962
18863
|
function readAgentFile(cwd, name, opts) {
|
|
18963
18864
|
const baseName = name.includes(":") ? name.split(":").pop() : name;
|
|
18964
|
-
const projectPath =
|
|
18965
|
-
if (
|
|
18966
|
-
const userPath =
|
|
18967
|
-
if (
|
|
18865
|
+
const projectPath = join15(cwd, ".claude", "agents", `${baseName}.md`);
|
|
18866
|
+
if (existsSync14(projectPath)) return safeRead(projectPath) || null;
|
|
18867
|
+
const userPath = join15(homeOf7(opts), ".claude", "agents", `${baseName}.md`);
|
|
18868
|
+
if (existsSync14(userPath)) return safeRead(userPath) || null;
|
|
18968
18869
|
const plugins = readPlugins(opts);
|
|
18969
18870
|
for (const [pluginKey, entries] of Object.entries(plugins)) {
|
|
18970
18871
|
const pluginName = pluginKey.split("@")[0] ?? pluginKey;
|
|
@@ -18972,8 +18873,8 @@ function readAgentFile(cwd, name, opts) {
|
|
|
18972
18873
|
if (!entry.installPath) continue;
|
|
18973
18874
|
const prefix = `${pluginName}:`;
|
|
18974
18875
|
const agentBaseName = name.startsWith(prefix) ? name.slice(prefix.length) : baseName;
|
|
18975
|
-
const pluginAgentPath =
|
|
18976
|
-
if (
|
|
18876
|
+
const pluginAgentPath = join15(entry.installPath, "agents", `${agentBaseName}.md`);
|
|
18877
|
+
if (existsSync14(pluginAgentPath)) return safeRead(pluginAgentPath) || null;
|
|
18977
18878
|
}
|
|
18978
18879
|
}
|
|
18979
18880
|
return null;
|
|
@@ -18998,7 +18899,6 @@ var init_fs = __esm({
|
|
|
18998
18899
|
init_fuzzy();
|
|
18999
18900
|
init_plugins_manage();
|
|
19000
18901
|
init_hooks_config();
|
|
19001
|
-
init_additional_dirs_config();
|
|
19002
18902
|
init_agents_discover();
|
|
19003
18903
|
}
|
|
19004
18904
|
});
|
|
@@ -20010,12 +19910,12 @@ var init_agent_event_mapper = __esm({
|
|
|
20010
19910
|
// ../../packages/codex/src/app-server-client.ts
|
|
20011
19911
|
import { spawn } from "node:child_process";
|
|
20012
19912
|
import { createInterface } from "node:readline";
|
|
20013
|
-
import { existsSync as
|
|
19913
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
20014
19914
|
async function openCodexAppServer(opts) {
|
|
20015
19915
|
if (opts.signal?.aborted) {
|
|
20016
19916
|
throw new Error("Codex app-server launch interrupted");
|
|
20017
19917
|
}
|
|
20018
|
-
if (!opts.binaryPath || !
|
|
19918
|
+
if (!opts.binaryPath || !existsSync15(opts.binaryPath)) {
|
|
20019
19919
|
throw new Error(`Codex binary not found: ${opts.binaryPath || "(empty)"}`);
|
|
20020
19920
|
}
|
|
20021
19921
|
const spawnFn = opts.spawnFn ?? defaultSpawn;
|
|
@@ -20079,21 +19979,21 @@ async function openCodexAppServer(opts) {
|
|
|
20079
19979
|
const terminateChild = async () => {
|
|
20080
19980
|
if (processExited) return;
|
|
20081
19981
|
const killTimeoutMs = opts.killTimeoutMs ?? 2e3;
|
|
20082
|
-
await new Promise((
|
|
19982
|
+
await new Promise((resolve15) => {
|
|
20083
19983
|
if (processExited) {
|
|
20084
|
-
|
|
19984
|
+
resolve15();
|
|
20085
19985
|
return;
|
|
20086
19986
|
}
|
|
20087
19987
|
const onExit = () => {
|
|
20088
19988
|
clearTimeout(t);
|
|
20089
|
-
|
|
19989
|
+
resolve15();
|
|
20090
19990
|
};
|
|
20091
19991
|
child.once("exit", onExit);
|
|
20092
19992
|
try {
|
|
20093
19993
|
child.kill("SIGTERM");
|
|
20094
19994
|
} catch {
|
|
20095
19995
|
child.removeListener("exit", onExit);
|
|
20096
|
-
|
|
19996
|
+
resolve15();
|
|
20097
19997
|
return;
|
|
20098
19998
|
}
|
|
20099
19999
|
const t = setTimeout(() => {
|
|
@@ -20105,7 +20005,7 @@ async function openCodexAppServer(opts) {
|
|
|
20105
20005
|
}
|
|
20106
20006
|
setTimeout(() => {
|
|
20107
20007
|
child.removeListener("exit", onExit);
|
|
20108
|
-
|
|
20008
|
+
resolve15();
|
|
20109
20009
|
}, 500);
|
|
20110
20010
|
}, killTimeoutMs);
|
|
20111
20011
|
});
|
|
@@ -20185,7 +20085,7 @@ async function openCodexAppServer(opts) {
|
|
|
20185
20085
|
failAll(safePublicError("Codex app-server read failed", readLoopError));
|
|
20186
20086
|
}
|
|
20187
20087
|
})();
|
|
20188
|
-
const request = (method, params, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) => new Promise((
|
|
20088
|
+
const request = (method, params, timeoutMs = DEFAULT_REQUEST_TIMEOUT_MS) => new Promise((resolve15, reject) => {
|
|
20189
20089
|
if (closed) {
|
|
20190
20090
|
reject(new Error("Codex app-server connection closed"));
|
|
20191
20091
|
return;
|
|
@@ -20203,7 +20103,7 @@ async function openCodexAppServer(opts) {
|
|
|
20203
20103
|
pending.delete(id);
|
|
20204
20104
|
reject(new Error(`Codex app-server ${method} timed out after ${timeoutMs}ms`));
|
|
20205
20105
|
}, timeoutMs);
|
|
20206
|
-
pending.set(id, { resolve:
|
|
20106
|
+
pending.set(id, { resolve: resolve15, reject, timer });
|
|
20207
20107
|
try {
|
|
20208
20108
|
writeLine({ jsonrpc: "2.0", id, method, params: params ?? {} });
|
|
20209
20109
|
} catch (err) {
|
|
@@ -20215,9 +20115,9 @@ async function openCodexAppServer(opts) {
|
|
|
20215
20115
|
const notify = async (method, params) => {
|
|
20216
20116
|
writeLine({ jsonrpc: "2.0", method, params: params ?? {} });
|
|
20217
20117
|
};
|
|
20218
|
-
const nextNotification = (timeoutMs = 3e4) => new Promise((
|
|
20118
|
+
const nextNotification = (timeoutMs = 3e4) => new Promise((resolve15, reject) => {
|
|
20219
20119
|
if (notificationQueue.length) {
|
|
20220
|
-
|
|
20120
|
+
resolve15(notificationQueue.shift());
|
|
20221
20121
|
return;
|
|
20222
20122
|
}
|
|
20223
20123
|
if (readLoopError) {
|
|
@@ -20225,16 +20125,16 @@ async function openCodexAppServer(opts) {
|
|
|
20225
20125
|
return;
|
|
20226
20126
|
}
|
|
20227
20127
|
if (closed) {
|
|
20228
|
-
|
|
20128
|
+
resolve15(null);
|
|
20229
20129
|
return;
|
|
20230
20130
|
}
|
|
20231
20131
|
const timer = setTimeout(() => {
|
|
20232
20132
|
const idx = notificationWaiters.findIndex((w2) => w2.timer === timer);
|
|
20233
20133
|
if (idx >= 0) notificationWaiters.splice(idx, 1);
|
|
20234
20134
|
if (readLoopError) reject(readLoopError);
|
|
20235
|
-
else
|
|
20135
|
+
else resolve15(null);
|
|
20236
20136
|
}, timeoutMs);
|
|
20237
|
-
notificationWaiters.push({ resolve:
|
|
20137
|
+
notificationWaiters.push({ resolve: resolve15, reject, timer });
|
|
20238
20138
|
});
|
|
20239
20139
|
child.stdin.on("error", (err) => {
|
|
20240
20140
|
const publicErr = safePublicError("Codex app-server stdin error", err);
|
|
@@ -21406,6 +21306,52 @@ var init_slash_commands = __esm({
|
|
|
21406
21306
|
}
|
|
21407
21307
|
});
|
|
21408
21308
|
|
|
21309
|
+
// ../../packages/claude/src/result-failure.ts
|
|
21310
|
+
function isClaudeResultError(result, rejectedRateLimit = false) {
|
|
21311
|
+
return result.is_error === true || result.subtype !== "success" || rejectedRateLimit;
|
|
21312
|
+
}
|
|
21313
|
+
function resultErrorText(result, typedCode) {
|
|
21314
|
+
if (Array.isArray(result.errors)) {
|
|
21315
|
+
const errors = result.errors.filter((error51) => typeof error51 === "string" && error51.length > 0);
|
|
21316
|
+
if (errors.length > 0) return errors.join("; ");
|
|
21317
|
+
}
|
|
21318
|
+
if (typeof result.errors === "string" && result.errors) return result.errors;
|
|
21319
|
+
if (typeof result.result === "string" && result.result) return result.result;
|
|
21320
|
+
return typedCode || "Unknown error";
|
|
21321
|
+
}
|
|
21322
|
+
function decorateMessageErrorText(rawError, typedCode, apiStatus) {
|
|
21323
|
+
if (typedCode !== "model_not_found") return rawError;
|
|
21324
|
+
const suffix = apiStatus ? ` (HTTP ${apiStatus})` : "";
|
|
21325
|
+
return `Model not available for this provider${suffix}: ${rawError}`;
|
|
21326
|
+
}
|
|
21327
|
+
function buildClaudeResultFailure(result, context = {}) {
|
|
21328
|
+
const typedCode = context.rejectedRateLimit ? "rate_limit" : context.typedCode;
|
|
21329
|
+
const rawError = resultErrorText(result, typedCode);
|
|
21330
|
+
const httpStatus = typeof result.api_error_status === "number" ? result.api_error_status : void 0;
|
|
21331
|
+
const terminalReason = typeof result.terminal_reason === "string" ? result.terminal_reason : void 0;
|
|
21332
|
+
const subtype = typeof result.subtype === "string" ? result.subtype : void 0;
|
|
21333
|
+
const errorInfo = buildAgentErrorInfo(rawError, {
|
|
21334
|
+
...typedCode ? { code: typedCode } : {},
|
|
21335
|
+
...httpStatus === void 0 ? {} : { httpStatus },
|
|
21336
|
+
...terminalReason ? { terminalReason } : {},
|
|
21337
|
+
...subtype ? { subtype } : {},
|
|
21338
|
+
...context.model ? { model: context.model } : {},
|
|
21339
|
+
...context.requestId ? { requestId: context.requestId } : {},
|
|
21340
|
+
...context.retries ? { retries: context.retries } : {},
|
|
21341
|
+
...context.resetsAt === void 0 ? {} : { resetsAt: context.resetsAt }
|
|
21342
|
+
});
|
|
21343
|
+
return {
|
|
21344
|
+
error: decorateMessageErrorText(rawError, typedCode, httpStatus),
|
|
21345
|
+
errorInfo
|
|
21346
|
+
};
|
|
21347
|
+
}
|
|
21348
|
+
var init_result_failure = __esm({
|
|
21349
|
+
"../../packages/claude/src/result-failure.ts"() {
|
|
21350
|
+
"use strict";
|
|
21351
|
+
init_agent_error();
|
|
21352
|
+
}
|
|
21353
|
+
});
|
|
21354
|
+
|
|
21409
21355
|
// ../../packages/claude/src/agent-event-mapper.ts
|
|
21410
21356
|
function emptyResult(sessionId) {
|
|
21411
21357
|
return {
|
|
@@ -21516,17 +21462,6 @@ function buildClaudeResultMetadata(result, startedAt, pausedMs, lastAssistantUsa
|
|
|
21516
21462
|
}
|
|
21517
21463
|
return metadata;
|
|
21518
21464
|
}
|
|
21519
|
-
function resultErrorText(result) {
|
|
21520
|
-
if (Array.isArray(result.errors)) return result.errors.join("; ") || "Unknown error";
|
|
21521
|
-
if (typeof result.errors === "string" && result.errors) return result.errors;
|
|
21522
|
-
if (typeof result.result === "string" && result.result) return result.result;
|
|
21523
|
-
return "Unknown error";
|
|
21524
|
-
}
|
|
21525
|
-
function decorateMessageErrorText(rawError, typedCode, apiStatus) {
|
|
21526
|
-
if (typedCode !== "model_not_found") return rawError;
|
|
21527
|
-
const suffix = apiStatus ? ` (HTTP ${apiStatus})` : "";
|
|
21528
|
-
return `Model not available for this provider${suffix}: ${rawError}`;
|
|
21529
|
-
}
|
|
21530
21465
|
function createClaudeAgentEventMapper(options) {
|
|
21531
21466
|
const now = options.now ?? Date.now;
|
|
21532
21467
|
const startedAt = options.startedAt ?? now();
|
|
@@ -21543,6 +21478,12 @@ function createClaudeAgentEventMapper(options) {
|
|
|
21543
21478
|
const resolveRetractedMessageIds = (uuids) => [...new Set(uuids.map((uuid3) => wireUuidToMessageId.get(uuid3)).filter((id) => !!id))];
|
|
21544
21479
|
let lastReplayCheckpointId = "";
|
|
21545
21480
|
let lastAssistantTypedError;
|
|
21481
|
+
let lastAssistantRequestId;
|
|
21482
|
+
let lastAssistantModel;
|
|
21483
|
+
const retryDelaysMs = [];
|
|
21484
|
+
let retryMaxRetries;
|
|
21485
|
+
let rejectedRateLimitResetsAt;
|
|
21486
|
+
let hasRejectedRateLimit = false;
|
|
21546
21487
|
let pendingSlashOutput = "";
|
|
21547
21488
|
let messageInputTokens = 0;
|
|
21548
21489
|
let messageOutputTokens = 0;
|
|
@@ -21769,6 +21710,9 @@ function createClaudeAgentEventMapper(options) {
|
|
|
21769
21710
|
});
|
|
21770
21711
|
break;
|
|
21771
21712
|
case "api_retry":
|
|
21713
|
+
retryDelaysMs.push(system.retry_delay_ms ?? 0);
|
|
21714
|
+
retryMaxRetries = system.max_retries ?? 3;
|
|
21715
|
+
if (system.error) lastAssistantTypedError = String(system.error);
|
|
21772
21716
|
emit({
|
|
21773
21717
|
type: "api_retry",
|
|
21774
21718
|
attempt: system.attempt ?? 1,
|
|
@@ -21848,6 +21792,9 @@ function createClaudeAgentEventMapper(options) {
|
|
|
21848
21792
|
const usage2 = raw.message?.usage;
|
|
21849
21793
|
if (usage2) lastAssistantUsage = usage2;
|
|
21850
21794
|
if (raw.error) lastAssistantTypedError = String(raw.error);
|
|
21795
|
+
const requestId = raw.request_id ?? raw.requestId;
|
|
21796
|
+
if (requestId) lastAssistantRequestId = String(requestId);
|
|
21797
|
+
if (raw.message?.model) lastAssistantModel = String(raw.message.model);
|
|
21851
21798
|
if (!assistantParent) {
|
|
21852
21799
|
lastTopLevelAssistantUuid = raw.uuid ?? "";
|
|
21853
21800
|
if (lastTopLevelAssistantUuid) wireUuidToMessageId.set(lastTopLevelAssistantUuid, messageId);
|
|
@@ -22006,9 +21953,15 @@ ${text}` : text;
|
|
|
22006
21953
|
);
|
|
22007
21954
|
if (lastTopLevelAssistantUuid) metadata.forkAnchorId = lastTopLevelAssistantUuid;
|
|
22008
21955
|
const interrupted = options.isInterrupted?.() === true;
|
|
22009
|
-
const resultIsError = raw
|
|
22010
|
-
const
|
|
22011
|
-
|
|
21956
|
+
const resultIsError = isClaudeResultError(raw, hasRejectedRateLimit);
|
|
21957
|
+
const failure = buildClaudeResultFailure(raw, {
|
|
21958
|
+
typedCode: lastAssistantTypedError,
|
|
21959
|
+
model: lastAssistantModel,
|
|
21960
|
+
requestId: lastAssistantRequestId,
|
|
21961
|
+
retries: retryDelaysMs.length > 0 ? { attempts: retryDelaysMs.length, delaysMs: [...retryDelaysMs], ...retryMaxRetries === void 0 ? {} : { max: retryMaxRetries } } : void 0,
|
|
21962
|
+
rejectedRateLimit: hasRejectedRateLimit,
|
|
21963
|
+
resetsAt: rejectedRateLimitResetsAt
|
|
21964
|
+
});
|
|
22012
21965
|
if (interrupted) {
|
|
22013
21966
|
emit({ type: "message_interrupted", messageId, metadata });
|
|
22014
21967
|
activeBackgroundTasks.clear();
|
|
@@ -22016,9 +21969,16 @@ ${text}` : text;
|
|
|
22016
21969
|
if (pendingSlashOutput) emit({ type: "slash_command_output", messageId, content: pendingSlashOutput });
|
|
22017
21970
|
emit({ type: "message_complete", messageId, metadata });
|
|
22018
21971
|
} else {
|
|
22019
|
-
|
|
21972
|
+
metadata.errorInfo = failure.errorInfo;
|
|
21973
|
+
emit({ type: "message_error", messageId, error: failure.error, errorInfo: failure.errorInfo });
|
|
22020
21974
|
}
|
|
22021
21975
|
lastAssistantTypedError = void 0;
|
|
21976
|
+
lastAssistantRequestId = void 0;
|
|
21977
|
+
lastAssistantModel = void 0;
|
|
21978
|
+
retryDelaysMs.length = 0;
|
|
21979
|
+
retryMaxRetries = void 0;
|
|
21980
|
+
hasRejectedRateLimit = false;
|
|
21981
|
+
rejectedRateLimitResetsAt = void 0;
|
|
22022
21982
|
pendingSlashOutput = "";
|
|
22023
21983
|
resultSeen = true;
|
|
22024
21984
|
options.onStepBoundary?.();
|
|
@@ -22029,7 +21989,7 @@ ${text}` : text;
|
|
|
22029
21989
|
isResult: true,
|
|
22030
21990
|
resultIsError,
|
|
22031
21991
|
resultText: typeof raw.result === "string" ? raw.result : null,
|
|
22032
|
-
resultError: resultIsError ?
|
|
21992
|
+
resultError: resultIsError ? failure.error : null
|
|
22033
21993
|
};
|
|
22034
21994
|
}
|
|
22035
21995
|
case "prompt_suggestion":
|
|
@@ -22038,6 +21998,8 @@ ${text}` : text;
|
|
|
22038
21998
|
case "rate_limit_event": {
|
|
22039
21999
|
const info = raw.rate_limit_info;
|
|
22040
22000
|
if (info) {
|
|
22001
|
+
hasRejectedRateLimit = info.status === "rejected";
|
|
22002
|
+
rejectedRateLimitResetsAt = hasRejectedRateLimit && typeof info.resetsAt === "number" ? info.resetsAt : void 0;
|
|
22041
22003
|
emit({
|
|
22042
22004
|
type: "rate_limit",
|
|
22043
22005
|
status: info.status,
|
|
@@ -22066,12 +22028,13 @@ var init_agent_event_mapper2 = __esm({
|
|
|
22066
22028
|
"use strict";
|
|
22067
22029
|
init_model_fallback_wire();
|
|
22068
22030
|
init_slash_commands();
|
|
22031
|
+
init_result_failure();
|
|
22069
22032
|
}
|
|
22070
22033
|
});
|
|
22071
22034
|
|
|
22072
22035
|
// ../../packages/claude/src/resolve-sdk-binary.ts
|
|
22073
22036
|
import { createRequire } from "node:module";
|
|
22074
|
-
import { existsSync as
|
|
22037
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
22075
22038
|
function resolveSdkClaudeBinary() {
|
|
22076
22039
|
if (cached !== void 0) return cached;
|
|
22077
22040
|
try {
|
|
@@ -22086,7 +22049,7 @@ function resolveSdkClaudeBinary() {
|
|
|
22086
22049
|
let p2 = req.resolve(c);
|
|
22087
22050
|
if (p2.includes("/app.asar/")) p2 = p2.replace("/app.asar/", "/app.asar.unpacked/");
|
|
22088
22051
|
if (p2.includes("\\app.asar\\")) p2 = p2.replace("\\app.asar\\", "\\app.asar.unpacked\\");
|
|
22089
|
-
if (
|
|
22052
|
+
if (existsSync16(p2)) {
|
|
22090
22053
|
cached = p2;
|
|
22091
22054
|
return p2;
|
|
22092
22055
|
}
|
|
@@ -22299,8 +22262,8 @@ var init_message_bridge = __esm({
|
|
|
22299
22262
|
if (this.closed) {
|
|
22300
22263
|
return Promise.resolve({ value: void 0, done: true });
|
|
22301
22264
|
}
|
|
22302
|
-
return new Promise((
|
|
22303
|
-
this.waiter = { resolve:
|
|
22265
|
+
return new Promise((resolve15) => {
|
|
22266
|
+
this.waiter = { resolve: resolve15 };
|
|
22304
22267
|
});
|
|
22305
22268
|
}
|
|
22306
22269
|
};
|
|
@@ -22310,7 +22273,7 @@ var init_message_bridge = __esm({
|
|
|
22310
22273
|
});
|
|
22311
22274
|
|
|
22312
22275
|
// ../../packages/claude/src/claude-live-session.ts
|
|
22313
|
-
import { existsSync as
|
|
22276
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
22314
22277
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
22315
22278
|
import { query as sdkQuery2 } from "@anthropic-ai/claude-agent-sdk";
|
|
22316
22279
|
function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing, turn) {
|
|
@@ -22370,7 +22333,7 @@ function buildLiveOptions(opts, onPermission, onQuestion, onPlan, signal, timing
|
|
|
22370
22333
|
if (decision === "allow") return { behavior: "allow" };
|
|
22371
22334
|
return { behavior: "deny", message: "Permission denied by SuperOne node" };
|
|
22372
22335
|
};
|
|
22373
|
-
const binaryPath = (opts.binaryPath &&
|
|
22336
|
+
const binaryPath = (opts.binaryPath && existsSync17(opts.binaryPath) ? opts.binaryPath : null) ?? resolveSdkClaudeBinary() ?? void 0;
|
|
22374
22337
|
const effort = opts.effort === "low" || opts.effort === "medium" || opts.effort === "high" || opts.effort === "xhigh" || opts.effort === "max" ? opts.effort : void 0;
|
|
22375
22338
|
const env = opts.env ? { ...process.env, ...opts.env } : void 0;
|
|
22376
22339
|
const sandbox = opts.sandboxMode === "on" || opts.sandboxMode === "auto" ? {
|
|
@@ -22487,8 +22450,8 @@ var init_claude_live_session = __esm({
|
|
|
22487
22450
|
planHandler;
|
|
22488
22451
|
timing = { pausedMs: 0 };
|
|
22489
22452
|
static open(opts) {
|
|
22490
|
-
const binary = (opts.binaryPath &&
|
|
22491
|
-
if (opts.binaryPath && !
|
|
22453
|
+
const binary = (opts.binaryPath && existsSync17(opts.binaryPath) ? opts.binaryPath : null) ?? resolveSdkClaudeBinary();
|
|
22454
|
+
if (opts.binaryPath && !existsSync17(opts.binaryPath)) {
|
|
22492
22455
|
throw new Error(`Claude binary not found: ${opts.binaryPath}`);
|
|
22493
22456
|
}
|
|
22494
22457
|
if (!binary && !opts.queryFn) {
|
|
@@ -22518,7 +22481,7 @@ var init_claude_live_session = __esm({
|
|
|
22518
22481
|
const sessionId = this.sdkSessionId || "";
|
|
22519
22482
|
const priorityNext = input.priorityNext !== false && this.active != null;
|
|
22520
22483
|
const msg = toUserMessage(input.content, sessionId, priorityNext);
|
|
22521
|
-
return new Promise((
|
|
22484
|
+
return new Promise((resolve15, reject) => {
|
|
22522
22485
|
if (input.signal?.aborted) {
|
|
22523
22486
|
reject(new Error("Claude turn interrupted"));
|
|
22524
22487
|
return;
|
|
@@ -22539,10 +22502,10 @@ var init_claude_live_session = __esm({
|
|
|
22539
22502
|
};
|
|
22540
22503
|
input.signal?.addEventListener("abort", onAbort, { once: true });
|
|
22541
22504
|
if (this.active) {
|
|
22542
|
-
this.pending.push({ tag, msg, input, resolve:
|
|
22505
|
+
this.pending.push({ tag, msg, input, resolve: resolve15, reject });
|
|
22543
22506
|
return;
|
|
22544
22507
|
}
|
|
22545
|
-
this.startTurn({ tag, msg, input, resolve:
|
|
22508
|
+
this.startTurn({ tag, msg, input, resolve: resolve15, reject });
|
|
22546
22509
|
});
|
|
22547
22510
|
}
|
|
22548
22511
|
async dispose() {
|
|
@@ -22742,12 +22705,12 @@ async function fetchClaudeModels(opts) {
|
|
|
22742
22705
|
}
|
|
22743
22706
|
}
|
|
22744
22707
|
function withTimeout(promise2, ms) {
|
|
22745
|
-
return new Promise((
|
|
22708
|
+
return new Promise((resolve15, reject) => {
|
|
22746
22709
|
const timer = setTimeout(() => reject(new Error(`claude model probe timed out after ${ms}ms`)), ms);
|
|
22747
22710
|
promise2.then(
|
|
22748
22711
|
(v2) => {
|
|
22749
22712
|
clearTimeout(timer);
|
|
22750
|
-
|
|
22713
|
+
resolve15(v2);
|
|
22751
22714
|
},
|
|
22752
22715
|
(e) => {
|
|
22753
22716
|
clearTimeout(timer);
|
|
@@ -22768,16 +22731,16 @@ var init_fetch_models = __esm({
|
|
|
22768
22731
|
});
|
|
22769
22732
|
|
|
22770
22733
|
// ../../packages/claude/src/fork-session.ts
|
|
22771
|
-
import { existsSync as
|
|
22734
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync11, readdirSync as readdirSync6, realpathSync as realpathSync2, renameSync } from "node:fs";
|
|
22772
22735
|
import { homedir as homedir3 } from "node:os";
|
|
22773
|
-
import { join as
|
|
22736
|
+
import { join as join16 } from "node:path";
|
|
22774
22737
|
import { forkSession as defaultSdkForkSession } from "@anthropic-ai/claude-agent-sdk";
|
|
22775
22738
|
function claudeProjectSlug(p2) {
|
|
22776
22739
|
return p2.replace(/[^a-zA-Z0-9]/g, "-");
|
|
22777
22740
|
}
|
|
22778
22741
|
function claudeProjectsDir(configDir) {
|
|
22779
|
-
const root = configDir || process.env.CLAUDE_CONFIG_DIR ||
|
|
22780
|
-
return
|
|
22742
|
+
const root = configDir || process.env.CLAUDE_CONFIG_DIR || join16(homedir3(), ".claude");
|
|
22743
|
+
return join16(root, "projects");
|
|
22781
22744
|
}
|
|
22782
22745
|
async function forkClaudeTranscript(input) {
|
|
22783
22746
|
const providerSessionId = input.providerSessionId?.trim();
|
|
@@ -22797,13 +22760,13 @@ async function forkClaudeTranscript(input) {
|
|
|
22797
22760
|
throw new Error("Claude forkSession did not return a session id");
|
|
22798
22761
|
}
|
|
22799
22762
|
const projectsDir = input.projectsDir ?? claudeProjectsDir();
|
|
22800
|
-
if (!
|
|
22763
|
+
if (!existsSync18(projectsDir)) {
|
|
22801
22764
|
throw new Error(`Claude projects dir not found: ${projectsDir}`);
|
|
22802
22765
|
}
|
|
22803
22766
|
let forkedFile = null;
|
|
22804
22767
|
for (const dir of readdirSync6(projectsDir)) {
|
|
22805
|
-
const candidate =
|
|
22806
|
-
if (
|
|
22768
|
+
const candidate = join16(projectsDir, dir, `${newSdkId}.jsonl`);
|
|
22769
|
+
if (existsSync18(candidate)) {
|
|
22807
22770
|
forkedFile = candidate;
|
|
22808
22771
|
break;
|
|
22809
22772
|
}
|
|
@@ -22811,9 +22774,9 @@ async function forkClaudeTranscript(input) {
|
|
|
22811
22774
|
if (!forkedFile) {
|
|
22812
22775
|
throw new Error(`forked transcript ${newSdkId}.jsonl not found under ${projectsDir}`);
|
|
22813
22776
|
}
|
|
22814
|
-
const destDir =
|
|
22815
|
-
|
|
22816
|
-
const dest =
|
|
22777
|
+
const destDir = join16(projectsDir, claudeProjectSlug(realpathSync2(targetCwd)));
|
|
22778
|
+
mkdirSync11(destDir, { recursive: true });
|
|
22779
|
+
const dest = join16(destDir, `${newSdkId}.jsonl`);
|
|
22817
22780
|
if (dest !== forkedFile) {
|
|
22818
22781
|
renameSync(forkedFile, dest);
|
|
22819
22782
|
}
|
|
@@ -22843,6 +22806,7 @@ var init_src2 = __esm({
|
|
|
22843
22806
|
init_message_bridge();
|
|
22844
22807
|
init_claude_live_session();
|
|
22845
22808
|
init_agent_event_mapper2();
|
|
22809
|
+
init_result_failure();
|
|
22846
22810
|
init_resolve_sdk_binary();
|
|
22847
22811
|
init_fetch_models();
|
|
22848
22812
|
init_root_permission_guard();
|
|
@@ -25681,7 +25645,7 @@ var init_session_runtime = __esm({
|
|
|
25681
25645
|
eventType: SESSION_DURABLE_EVENT.hostActionRequested,
|
|
25682
25646
|
payload: { actionId: row.actionId }
|
|
25683
25647
|
});
|
|
25684
|
-
return new Promise((
|
|
25648
|
+
return new Promise((resolve15) => {
|
|
25685
25649
|
const remaining = Math.max(0, row.deadline - Date.now());
|
|
25686
25650
|
const timer = setTimeout(() => {
|
|
25687
25651
|
this.cancelHostActionInternal(row.actionId, "deadline_exceeded");
|
|
@@ -25708,7 +25672,7 @@ var init_session_runtime = __esm({
|
|
|
25708
25672
|
clearTimeout(timer);
|
|
25709
25673
|
for (const c of abortCleanups) c();
|
|
25710
25674
|
this.hostActionWaiters.delete(row.actionId);
|
|
25711
|
-
|
|
25675
|
+
resolve15(result);
|
|
25712
25676
|
},
|
|
25713
25677
|
timer
|
|
25714
25678
|
});
|
|
@@ -25749,14 +25713,14 @@ var init_session_runtime = __esm({
|
|
|
25749
25713
|
cursor: existing.length ? existing[existing.length - 1].sequence : this.hostActions.headSequence()
|
|
25750
25714
|
};
|
|
25751
25715
|
}
|
|
25752
|
-
await new Promise((
|
|
25716
|
+
await new Promise((resolve15) => {
|
|
25753
25717
|
let settled = false;
|
|
25754
25718
|
const done = () => {
|
|
25755
25719
|
if (settled) return;
|
|
25756
25720
|
settled = true;
|
|
25757
25721
|
this.hostActionPollWaiters.delete(done);
|
|
25758
25722
|
clearTimeout(timer);
|
|
25759
|
-
|
|
25723
|
+
resolve15();
|
|
25760
25724
|
};
|
|
25761
25725
|
const timer = setTimeout(done, waitMs);
|
|
25762
25726
|
this.hostActionPollWaiters.add(done);
|
|
@@ -26006,7 +25970,7 @@ var init_session_runtime = __esm({
|
|
|
26006
25970
|
profiles: input.profiles
|
|
26007
25971
|
}
|
|
26008
25972
|
};
|
|
26009
|
-
return new Promise((
|
|
25973
|
+
return new Promise((resolve15) => {
|
|
26010
25974
|
let settled = false;
|
|
26011
25975
|
session.pendingInteraction = interaction;
|
|
26012
25976
|
session.updatedAt = Date.now();
|
|
@@ -26040,14 +26004,14 @@ var init_session_runtime = __esm({
|
|
|
26040
26004
|
action: result.action
|
|
26041
26005
|
}
|
|
26042
26006
|
});
|
|
26043
|
-
|
|
26007
|
+
resolve15({ action: result.action, content: result.content });
|
|
26044
26008
|
} else {
|
|
26045
26009
|
this.events.appendSession({
|
|
26046
26010
|
sessionId: session.sessionId,
|
|
26047
26011
|
eventType: result.reason === "timeout" ? SESSION_DURABLE_EVENT.permissionTimeout : SESSION_DURABLE_EVENT.permissionAborted,
|
|
26048
26012
|
payload: { interactionId: interaction.interactionId, decision: "deny" }
|
|
26049
26013
|
});
|
|
26050
|
-
|
|
26014
|
+
resolve15({ action: "cancel" });
|
|
26051
26015
|
}
|
|
26052
26016
|
};
|
|
26053
26017
|
const timer = setTimeout(() => {
|
|
@@ -26120,7 +26084,7 @@ var init_session_runtime = __esm({
|
|
|
26120
26084
|
if (session.pendingInteraction) {
|
|
26121
26085
|
this.rejectPendingPermission(session, "aborted");
|
|
26122
26086
|
}
|
|
26123
|
-
return new Promise((
|
|
26087
|
+
return new Promise((resolve15) => {
|
|
26124
26088
|
let settled = false;
|
|
26125
26089
|
session.pendingInteraction = interaction;
|
|
26126
26090
|
session.updatedAt = Date.now();
|
|
@@ -26166,7 +26130,7 @@ var init_session_runtime = __esm({
|
|
|
26166
26130
|
payload: { interactionId: interaction.interactionId, decision: "deny" }
|
|
26167
26131
|
});
|
|
26168
26132
|
}
|
|
26169
|
-
|
|
26133
|
+
resolve15(result.decision);
|
|
26170
26134
|
};
|
|
26171
26135
|
const timer = setTimeout(() => {
|
|
26172
26136
|
settle({ decision: "deny", reason: "timeout" });
|
|
@@ -26223,7 +26187,7 @@ var init_session_runtime = __esm({
|
|
|
26223
26187
|
this.rejectPendingPermission(session, "aborted");
|
|
26224
26188
|
}
|
|
26225
26189
|
const pending = { ...interaction, kind: "question" };
|
|
26226
|
-
return new Promise((
|
|
26190
|
+
return new Promise((resolve15) => {
|
|
26227
26191
|
let settled = false;
|
|
26228
26192
|
session.pendingInteraction = pending;
|
|
26229
26193
|
session.updatedAt = Date.now();
|
|
@@ -26266,7 +26230,7 @@ var init_session_runtime = __esm({
|
|
|
26266
26230
|
payload: { interactionId: pending.interactionId }
|
|
26267
26231
|
});
|
|
26268
26232
|
}
|
|
26269
|
-
|
|
26233
|
+
resolve15(result.answers);
|
|
26270
26234
|
};
|
|
26271
26235
|
const timer = setTimeout(() => {
|
|
26272
26236
|
settle({ answers: {}, reason: "timeout" });
|
|
@@ -26294,7 +26258,7 @@ var init_session_runtime = __esm({
|
|
|
26294
26258
|
this.rejectPendingPermission(session, "aborted");
|
|
26295
26259
|
}
|
|
26296
26260
|
const pending = { ...interaction, kind: "plan" };
|
|
26297
|
-
return new Promise((
|
|
26261
|
+
return new Promise((resolve15) => {
|
|
26298
26262
|
let settled = false;
|
|
26299
26263
|
session.pendingInteraction = pending;
|
|
26300
26264
|
session.updatedAt = Date.now();
|
|
@@ -26341,7 +26305,7 @@ var init_session_runtime = __esm({
|
|
|
26341
26305
|
payload: { interactionId: pending.interactionId, decision: "reject" }
|
|
26342
26306
|
});
|
|
26343
26307
|
}
|
|
26344
|
-
|
|
26308
|
+
resolve15({ decision: result.decision, options: result.options });
|
|
26345
26309
|
};
|
|
26346
26310
|
const timer = setTimeout(() => {
|
|
26347
26311
|
settle({ decision: "reject", reason: "timeout" });
|
|
@@ -26427,7 +26391,7 @@ var init_session_runtime = __esm({
|
|
|
26427
26391
|
Promise.allSettled(batch).then(() => {
|
|
26428
26392
|
settled = true;
|
|
26429
26393
|
}),
|
|
26430
|
-
new Promise((
|
|
26394
|
+
new Promise((resolve15) => setTimeout(resolve15, remaining))
|
|
26431
26395
|
]);
|
|
26432
26396
|
if (!settled && Date.now() >= deadline) break;
|
|
26433
26397
|
}
|
|
@@ -26932,9 +26896,9 @@ var init_session_provider_store = __esm({
|
|
|
26932
26896
|
});
|
|
26933
26897
|
|
|
26934
26898
|
// ../../packages/runtime/src/session/harness-resources.ts
|
|
26935
|
-
import { existsSync as
|
|
26936
|
-
import { join as
|
|
26937
|
-
import { homedir as
|
|
26899
|
+
import { existsSync as existsSync19, readdirSync as readdirSync7, readFileSync as readFileSync13 } from "node:fs";
|
|
26900
|
+
import { join as join17 } from "node:path";
|
|
26901
|
+
import { homedir as osHomedir8 } from "node:os";
|
|
26938
26902
|
function emptyClaude() {
|
|
26939
26903
|
return {
|
|
26940
26904
|
models: [],
|
|
@@ -26957,15 +26921,15 @@ function emptyAcp() {
|
|
|
26957
26921
|
}
|
|
26958
26922
|
function safeRead2(path) {
|
|
26959
26923
|
try {
|
|
26960
|
-
return
|
|
26924
|
+
return readFileSync13(path, "utf-8");
|
|
26961
26925
|
} catch {
|
|
26962
26926
|
return "";
|
|
26963
26927
|
}
|
|
26964
26928
|
}
|
|
26965
26929
|
function discoverCodexUserPrompts(opts) {
|
|
26966
|
-
const home = opts?.homeDir ??
|
|
26967
|
-
const dir =
|
|
26968
|
-
if (!
|
|
26930
|
+
const home = opts?.homeDir ?? osHomedir8();
|
|
26931
|
+
const dir = join17(home, ".codex", "prompts");
|
|
26932
|
+
if (!existsSync19(dir)) return [];
|
|
26969
26933
|
let ents;
|
|
26970
26934
|
try {
|
|
26971
26935
|
ents = readdirSync7(dir, { withFileTypes: true });
|
|
@@ -26976,7 +26940,7 @@ function discoverCodexUserPrompts(opts) {
|
|
|
26976
26940
|
for (const ent of ents) {
|
|
26977
26941
|
if (!ent.isFile() || !ent.name.endsWith(".md")) continue;
|
|
26978
26942
|
const name = ent.name.replace(/\.md$/, "");
|
|
26979
|
-
const content = safeRead2(
|
|
26943
|
+
const content = safeRead2(join17(dir, ent.name));
|
|
26980
26944
|
const fm = parseSimpleFrontmatter(content);
|
|
26981
26945
|
out.push({
|
|
26982
26946
|
name,
|
|
@@ -30913,7 +30877,7 @@ function requireInboundAuth(req, res) {
|
|
|
30913
30877
|
return false;
|
|
30914
30878
|
}
|
|
30915
30879
|
function readBody(req) {
|
|
30916
|
-
return new Promise((
|
|
30880
|
+
return new Promise((resolve15, reject) => {
|
|
30917
30881
|
const chunks = [];
|
|
30918
30882
|
let total = 0;
|
|
30919
30883
|
req.on("data", (chunk) => {
|
|
@@ -30925,7 +30889,7 @@ function readBody(req) {
|
|
|
30925
30889
|
}
|
|
30926
30890
|
chunks.push(chunk);
|
|
30927
30891
|
});
|
|
30928
|
-
req.on("end", () =>
|
|
30892
|
+
req.on("end", () => resolve15(Buffer.concat(chunks)));
|
|
30929
30893
|
req.on("error", reject);
|
|
30930
30894
|
});
|
|
30931
30895
|
}
|
|
@@ -30955,7 +30919,7 @@ async function writeWebResponse(res, web) {
|
|
|
30955
30919
|
if (done) break;
|
|
30956
30920
|
if (value) {
|
|
30957
30921
|
if (!res.write(Buffer.from(value))) {
|
|
30958
|
-
await new Promise((
|
|
30922
|
+
await new Promise((resolve15) => res.once("drain", resolve15));
|
|
30959
30923
|
}
|
|
30960
30924
|
}
|
|
30961
30925
|
}
|
|
@@ -31033,15 +30997,15 @@ async function startLlmProxyServer(upstream, port) {
|
|
|
31033
30997
|
}
|
|
31034
30998
|
}
|
|
31035
30999
|
});
|
|
31036
|
-
await new Promise((
|
|
31000
|
+
await new Promise((resolve15, reject) => {
|
|
31037
31001
|
server.once("error", reject);
|
|
31038
|
-
server.listen(port, "127.0.0.1", () =>
|
|
31002
|
+
server.listen(port, "127.0.0.1", () => resolve15());
|
|
31039
31003
|
});
|
|
31040
31004
|
return {
|
|
31041
31005
|
port,
|
|
31042
31006
|
url: `http://127.0.0.1:${port}`,
|
|
31043
|
-
close: () => new Promise((
|
|
31044
|
-
server.close((err) => err ? reject(err) :
|
|
31007
|
+
close: () => new Promise((resolve15, reject) => {
|
|
31008
|
+
server.close((err) => err ? reject(err) : resolve15());
|
|
31045
31009
|
})
|
|
31046
31010
|
};
|
|
31047
31011
|
}
|
|
@@ -31063,7 +31027,7 @@ function upstreamKey(u) {
|
|
|
31063
31027
|
return createHash3("sha256").update(JSON.stringify(u)).digest("hex").slice(0, 16);
|
|
31064
31028
|
}
|
|
31065
31029
|
async function getFreePort() {
|
|
31066
|
-
return new Promise((
|
|
31030
|
+
return new Promise((resolve15, reject) => {
|
|
31067
31031
|
const server = net.createServer();
|
|
31068
31032
|
server.unref();
|
|
31069
31033
|
server.on("error", reject);
|
|
@@ -31071,7 +31035,7 @@ async function getFreePort() {
|
|
|
31071
31035
|
const addr = server.address();
|
|
31072
31036
|
if (typeof addr === "object" && addr) {
|
|
31073
31037
|
const { port } = addr;
|
|
31074
|
-
server.close(() =>
|
|
31038
|
+
server.close(() => resolve15(port));
|
|
31075
31039
|
} else {
|
|
31076
31040
|
server.close(() => reject(new Error("no address")));
|
|
31077
31041
|
}
|
|
@@ -31344,14 +31308,14 @@ var init_resolve_service = __esm({
|
|
|
31344
31308
|
});
|
|
31345
31309
|
|
|
31346
31310
|
// ../../packages/shared/src/attachment-store.ts
|
|
31347
|
-
import { mkdirSync as
|
|
31311
|
+
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync9 } from "node:fs";
|
|
31348
31312
|
import { tmpdir } from "node:os";
|
|
31349
|
-
import { join as
|
|
31313
|
+
import { join as join18 } from "node:path";
|
|
31350
31314
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
31351
31315
|
function resolveAttachmentsDir() {
|
|
31352
31316
|
const override = process.env.SUPERONE_ATTACHMENTS_DIR?.trim();
|
|
31353
31317
|
if (override) return override;
|
|
31354
|
-
return
|
|
31318
|
+
return join18(tmpdir(), SUPERONE_ATTACHMENTS_DIR_NAME);
|
|
31355
31319
|
}
|
|
31356
31320
|
function extForAttachmentMime(mimeType) {
|
|
31357
31321
|
const m2 = mimeType.toLowerCase();
|
|
@@ -31386,10 +31350,10 @@ function persistAttachment(base643, mimeType, opts) {
|
|
|
31386
31350
|
if (!buf) return null;
|
|
31387
31351
|
try {
|
|
31388
31352
|
const dir = resolveAttachmentsDir();
|
|
31389
|
-
|
|
31353
|
+
mkdirSync12(dir, { recursive: true });
|
|
31390
31354
|
const fileName = `${randomUUID7()}-${safeFileBase(opts?.name, mimeType)}`;
|
|
31391
|
-
const filePath =
|
|
31392
|
-
|
|
31355
|
+
const filePath = join18(dir, fileName);
|
|
31356
|
+
writeFileSync9(filePath, buf);
|
|
31393
31357
|
return filePath;
|
|
31394
31358
|
} catch {
|
|
31395
31359
|
return null;
|
|
@@ -31471,11 +31435,11 @@ var init_turn_attachments = __esm({
|
|
|
31471
31435
|
});
|
|
31472
31436
|
|
|
31473
31437
|
// src/session/claude-turn-runner.ts
|
|
31474
|
-
import { existsSync as
|
|
31438
|
+
import { existsSync as existsSync20 } from "node:fs";
|
|
31475
31439
|
function resolveClaudeBinaryPath(opts) {
|
|
31476
|
-
if (opts.binaryPath &&
|
|
31440
|
+
if (opts.binaryPath && existsSync20(opts.binaryPath)) return opts.binaryPath;
|
|
31477
31441
|
const status = opts.harnesses?.get("claude");
|
|
31478
|
-
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command &&
|
|
31442
|
+
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync20(status.command)) {
|
|
31479
31443
|
return status.command;
|
|
31480
31444
|
}
|
|
31481
31445
|
if (!opts.skipSdkBinary) {
|
|
@@ -31483,7 +31447,7 @@ function resolveClaudeBinaryPath(opts) {
|
|
|
31483
31447
|
if (sdk) return sdk;
|
|
31484
31448
|
}
|
|
31485
31449
|
const fromEnv = process.env.SUPERONE_CLAUDE_BINARY?.trim();
|
|
31486
|
-
if (fromEnv &&
|
|
31450
|
+
if (fromEnv && existsSync20(fromEnv)) return fromEnv;
|
|
31487
31451
|
return null;
|
|
31488
31452
|
}
|
|
31489
31453
|
function isClaudeRuntimeRunnable() {
|
|
@@ -31529,6 +31493,7 @@ function createNodeClaudeTurnRunner(opts) {
|
|
|
31529
31493
|
await entry.hostActionDispose?.().catch(() => void 0);
|
|
31530
31494
|
};
|
|
31531
31495
|
const mcpDiskKeyOf = (diskNames) => [...diskNames].sort().join("\0");
|
|
31496
|
+
const additionalDirsKeyOf = (dirs) => [...new Set(dirs ?? [])].sort().join("\0");
|
|
31532
31497
|
const runner = async (input) => {
|
|
31533
31498
|
const harnessId = input.session.harnessId || "claude";
|
|
31534
31499
|
if (harnessId !== "claude") {
|
|
@@ -31582,8 +31547,9 @@ function createNodeClaudeTurnRunner(opts) {
|
|
|
31582
31547
|
homeDir: opts.homeDir
|
|
31583
31548
|
});
|
|
31584
31549
|
const nextMcpDiskKey = mcpDiskKeyOf(mergedProbe.diskNames);
|
|
31550
|
+
const nextAdditionalDirsKey = additionalDirsKeyOf(input.additionalDirectories?.filter(Boolean));
|
|
31585
31551
|
let entry = lives.get(sessionKey);
|
|
31586
|
-
if (entry && (entry.cwd !== cwd || entry.mcpDiskKey !== nextMcpDiskKey)) {
|
|
31552
|
+
if (entry && (entry.cwd !== cwd || entry.mcpDiskKey !== nextMcpDiskKey || entry.additionalDirsKey !== nextAdditionalDirsKey)) {
|
|
31587
31553
|
await entry.live.dispose().catch(() => void 0);
|
|
31588
31554
|
await entry.hostActionDispose?.().catch(() => void 0);
|
|
31589
31555
|
lives.delete(sessionKey);
|
|
@@ -31624,6 +31590,7 @@ function createNodeClaudeTurnRunner(opts) {
|
|
|
31624
31590
|
hostActionDispose: hostActionMcp ? () => hostActionMcp.dispose() : null,
|
|
31625
31591
|
cwd,
|
|
31626
31592
|
mcpDiskKey: mcpDiskKeyOf(merged.diskNames),
|
|
31593
|
+
additionalDirsKey: additionalDirsKeyOf(input.additionalDirectories?.filter(Boolean)),
|
|
31627
31594
|
busyCount: 0,
|
|
31628
31595
|
lastActivityAt: Date.now()
|
|
31629
31596
|
};
|
|
@@ -48969,11 +48936,11 @@ var init_jsonrpc = __esm({
|
|
|
48969
48936
|
const id = this.nextRequestId++;
|
|
48970
48937
|
let cancel = () => {
|
|
48971
48938
|
};
|
|
48972
|
-
const response = new Promise((
|
|
48939
|
+
const response = new Promise((resolve15, reject) => {
|
|
48973
48940
|
const pendingResponse = {
|
|
48974
48941
|
resolve: (value) => {
|
|
48975
48942
|
try {
|
|
48976
|
-
|
|
48943
|
+
resolve15(mapResponse ? mapResponse(value) : value);
|
|
48977
48944
|
} catch (error51) {
|
|
48978
48945
|
reject(error51);
|
|
48979
48946
|
}
|
|
@@ -49030,8 +48997,8 @@ var init_jsonrpc = __esm({
|
|
|
49030
48997
|
this.stream = stream;
|
|
49031
48998
|
this.staticHandlers = handlers;
|
|
49032
48999
|
this.allowBatches = options?.allowBatches ?? true;
|
|
49033
|
-
this.closedPromise = new Promise((
|
|
49034
|
-
this.abortController.signal.addEventListener("abort", () =>
|
|
49000
|
+
this.closedPromise = new Promise((resolve15) => {
|
|
49001
|
+
this.abortController.signal.addEventListener("abort", () => resolve15());
|
|
49035
49002
|
});
|
|
49036
49003
|
void this.receive();
|
|
49037
49004
|
}
|
|
@@ -50035,8 +50002,8 @@ var init_acp = __esm({
|
|
|
50035
50002
|
if (this.failed) {
|
|
50036
50003
|
return Promise.reject(this.failure);
|
|
50037
50004
|
}
|
|
50038
|
-
return new Promise((
|
|
50039
|
-
this.waiters.push({ resolve:
|
|
50005
|
+
return new Promise((resolve15, reject) => {
|
|
50006
|
+
this.waiters.push({ resolve: resolve15, reject });
|
|
50040
50007
|
});
|
|
50041
50008
|
}
|
|
50042
50009
|
};
|
|
@@ -51678,6 +51645,30 @@ var init_session_archive_result_shape = __esm({
|
|
|
51678
51645
|
}
|
|
51679
51646
|
});
|
|
51680
51647
|
|
|
51648
|
+
// ../../packages/shared/src/computer-use-result-shape.ts
|
|
51649
|
+
function isComputerUseToolName(toolName) {
|
|
51650
|
+
if (!toolName) return false;
|
|
51651
|
+
return /(?:^|__)computer_(?:snapshot|observe|query|act|apps|zoom|wait_for)$/.test(toolName);
|
|
51652
|
+
}
|
|
51653
|
+
function isComputerUseRoot(value) {
|
|
51654
|
+
if (typeof value !== "object" || value === null) return false;
|
|
51655
|
+
const root = value;
|
|
51656
|
+
return typeof root.app === "string" && typeof root.bundleId === "string";
|
|
51657
|
+
}
|
|
51658
|
+
function looksLikeComputerUseResult(obj) {
|
|
51659
|
+
const stateId = typeof obj.stateId === "string" ? obj.stateId : obj.successorStateId;
|
|
51660
|
+
if (typeof stateId !== "string") return false;
|
|
51661
|
+
return typeof obj.outline === "string" || typeof obj.subtree === "string" || typeof obj.element === "string" || Array.isArray(obj.matches) || isComputerUseRoot(obj.root) || isComputerUseRoot(obj.successorRoot);
|
|
51662
|
+
}
|
|
51663
|
+
function looksLikeComputerUseOutline(summary) {
|
|
51664
|
+
return /outline\[\d+\]\{ref,depth/.test(summary);
|
|
51665
|
+
}
|
|
51666
|
+
var init_computer_use_result_shape = __esm({
|
|
51667
|
+
"../../packages/shared/src/computer-use-result-shape.ts"() {
|
|
51668
|
+
"use strict";
|
|
51669
|
+
}
|
|
51670
|
+
});
|
|
51671
|
+
|
|
51681
51672
|
// ../../packages/acp/src/tool-result-map.ts
|
|
51682
51673
|
function formatAcpRawOutput(raw) {
|
|
51683
51674
|
return formatAgentToolOutput(raw);
|
|
@@ -51781,11 +51772,13 @@ function shouldKeepFullToolResult(summary, toolName) {
|
|
|
51781
51772
|
if (isCollabToolName(toolName)) return true;
|
|
51782
51773
|
if (isSessionArchiveToolName(toolName)) return true;
|
|
51783
51774
|
if (looksLikeSessionArchiveToon(summary)) return true;
|
|
51775
|
+
if (isComputerUseToolName(toolName)) return true;
|
|
51776
|
+
if (looksLikeComputerUseOutline(summary)) return true;
|
|
51784
51777
|
const trimmed = summary.trim();
|
|
51785
51778
|
if (!trimmed.startsWith("{")) return false;
|
|
51786
51779
|
try {
|
|
51787
51780
|
const obj = JSON.parse(trimmed);
|
|
51788
|
-
return typeof obj.widget_code === "string" && obj.widget_code.length > 0 || looksLikeCollabResult(obj) || looksLikeSessionArchiveJson(obj);
|
|
51781
|
+
return typeof obj.widget_code === "string" && obj.widget_code.length > 0 || looksLikeCollabResult(obj) || looksLikeSessionArchiveJson(obj) || looksLikeComputerUseResult(obj);
|
|
51789
51782
|
} catch {
|
|
51790
51783
|
return false;
|
|
51791
51784
|
}
|
|
@@ -51798,6 +51791,7 @@ var init_tool_result_map = __esm({
|
|
|
51798
51791
|
"use strict";
|
|
51799
51792
|
init_capability_prompt_tags();
|
|
51800
51793
|
init_session_archive_result_shape();
|
|
51794
|
+
init_computer_use_result_shape();
|
|
51801
51795
|
init_tool_ui();
|
|
51802
51796
|
init_tool_normalization();
|
|
51803
51797
|
}
|
|
@@ -51838,7 +51832,7 @@ var init_acp_goal = __esm({
|
|
|
51838
51832
|
|
|
51839
51833
|
// ../../packages/acp/src/xai-state.ts
|
|
51840
51834
|
import { homedir as homedir4 } from "node:os";
|
|
51841
|
-
import { join as
|
|
51835
|
+
import { join as join19 } from "node:path";
|
|
51842
51836
|
function skipEventSeqDedup(kind) {
|
|
51843
51837
|
return kind === "workflow_updated" || !!kind && SUBAGENT_LIFECYCLE.has(kind);
|
|
51844
51838
|
}
|
|
@@ -51874,7 +51868,7 @@ function resetTurnTokens(state) {
|
|
|
51874
51868
|
}
|
|
51875
51869
|
function resolveGrokChildChatHistoryPath(cwd, childSessionId) {
|
|
51876
51870
|
if (!cwd || !childSessionId) return void 0;
|
|
51877
|
-
return
|
|
51871
|
+
return join19(homedir4(), ".grok", "sessions", encodeURIComponent(cwd), childSessionId, "chat_history.jsonl");
|
|
51878
51872
|
}
|
|
51879
51873
|
function noteSubagentOutputFile(state, subagentId, childSessionId) {
|
|
51880
51874
|
const existing = state.subagentOutputById.get(subagentId);
|
|
@@ -53542,7 +53536,7 @@ async function stopProcess(child, closed) {
|
|
|
53542
53536
|
signalProcess(child, "SIGTERM");
|
|
53543
53537
|
const stopped = await Promise.race([
|
|
53544
53538
|
closed.then(() => true),
|
|
53545
|
-
new Promise((
|
|
53539
|
+
new Promise((resolve15) => setTimeout(() => resolve15(false), KILL_ESCALATE_MS))
|
|
53546
53540
|
]);
|
|
53547
53541
|
if (stopped) return;
|
|
53548
53542
|
signalProcess(child, "SIGKILL");
|
|
@@ -53574,9 +53568,9 @@ function spawnAcpProcess(launch2) {
|
|
|
53574
53568
|
const output = Writable.toWeb(stdin);
|
|
53575
53569
|
const input = Readable.toWeb(stdout);
|
|
53576
53570
|
const stream = ndJsonStream2(output, input);
|
|
53577
|
-
const closed = new Promise((
|
|
53571
|
+
const closed = new Promise((resolve15) => {
|
|
53578
53572
|
child.once("exit", (code, signal) => {
|
|
53579
|
-
|
|
53573
|
+
resolve15({ code, signal, stderr: stderrChunks.join("") });
|
|
53580
53574
|
});
|
|
53581
53575
|
});
|
|
53582
53576
|
let killPromise = null;
|
|
@@ -53759,7 +53753,7 @@ var init_run_turn = __esm({
|
|
|
53759
53753
|
});
|
|
53760
53754
|
|
|
53761
53755
|
// ../../packages/acp/src/simulated-runner.ts
|
|
53762
|
-
import { existsSync as
|
|
53756
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
53763
53757
|
function createSimulatedAcpTurnRunner(opts) {
|
|
53764
53758
|
return createSimulatedTurnRunner({
|
|
53765
53759
|
delayMs: opts?.delayMs ?? 15,
|
|
@@ -53773,7 +53767,7 @@ function resolveLaunch(opts) {
|
|
|
53773
53767
|
const fromEnv = process.env.SUPERONE_ACP_BINARY?.trim() || process.env.SUPERONE_ACP_COMMAND?.trim() || opts.binaryPath?.trim();
|
|
53774
53768
|
if (!fromEnv) return null;
|
|
53775
53769
|
if (fromEnv.includes("/") || fromEnv.includes("\\")) {
|
|
53776
|
-
if (!
|
|
53770
|
+
if (!existsSync21(fromEnv)) return null;
|
|
53777
53771
|
}
|
|
53778
53772
|
return {
|
|
53779
53773
|
command: fromEnv,
|
|
@@ -53837,7 +53831,7 @@ var init_serverSentEvents_gen = __esm({
|
|
|
53837
53831
|
"../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js"() {
|
|
53838
53832
|
createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
|
|
53839
53833
|
let lastEventId;
|
|
53840
|
-
const sleep = sseSleepFn ?? ((ms) => new Promise((
|
|
53834
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve15) => setTimeout(resolve15, ms)));
|
|
53841
53835
|
const createStream = async function* () {
|
|
53842
53836
|
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
53843
53837
|
let attempt = 0;
|
|
@@ -59415,12 +59409,12 @@ var require_isexe = __commonJS({
|
|
|
59415
59409
|
if (typeof Promise !== "function") {
|
|
59416
59410
|
throw new TypeError("callback not provided");
|
|
59417
59411
|
}
|
|
59418
|
-
return new Promise(function(
|
|
59412
|
+
return new Promise(function(resolve15, reject) {
|
|
59419
59413
|
isexe(path, options || {}, function(er, is) {
|
|
59420
59414
|
if (er) {
|
|
59421
59415
|
reject(er);
|
|
59422
59416
|
} else {
|
|
59423
|
-
|
|
59417
|
+
resolve15(is);
|
|
59424
59418
|
}
|
|
59425
59419
|
});
|
|
59426
59420
|
});
|
|
@@ -59486,27 +59480,27 @@ var require_which = __commonJS({
|
|
|
59486
59480
|
opt = {};
|
|
59487
59481
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
59488
59482
|
const found = [];
|
|
59489
|
-
const step = (i) => new Promise((
|
|
59483
|
+
const step = (i) => new Promise((resolve15, reject) => {
|
|
59490
59484
|
if (i === pathEnv.length)
|
|
59491
|
-
return opt.all && found.length ?
|
|
59485
|
+
return opt.all && found.length ? resolve15(found) : reject(getNotFoundError(cmd));
|
|
59492
59486
|
const ppRaw = pathEnv[i];
|
|
59493
59487
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
59494
59488
|
const pCmd = path.join(pathPart, cmd);
|
|
59495
59489
|
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
59496
|
-
|
|
59490
|
+
resolve15(subStep(p2, i, 0));
|
|
59497
59491
|
});
|
|
59498
|
-
const subStep = (p2, i, ii) => new Promise((
|
|
59492
|
+
const subStep = (p2, i, ii) => new Promise((resolve15, reject) => {
|
|
59499
59493
|
if (ii === pathExt.length)
|
|
59500
|
-
return
|
|
59494
|
+
return resolve15(step(i + 1));
|
|
59501
59495
|
const ext = pathExt[ii];
|
|
59502
59496
|
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
59503
59497
|
if (!er && is) {
|
|
59504
59498
|
if (opt.all)
|
|
59505
59499
|
found.push(p2 + ext);
|
|
59506
59500
|
else
|
|
59507
|
-
return
|
|
59501
|
+
return resolve15(p2 + ext);
|
|
59508
59502
|
}
|
|
59509
|
-
return
|
|
59503
|
+
return resolve15(subStep(p2, i, ii + 1));
|
|
59510
59504
|
});
|
|
59511
59505
|
});
|
|
59512
59506
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -60215,24 +60209,24 @@ var init_parse4 = __esm({
|
|
|
60215
60209
|
|
|
60216
60210
|
// ../../packages/opencode/src/server.ts
|
|
60217
60211
|
import { spawn as spawn3 } from "node:child_process";
|
|
60218
|
-
import { existsSync as
|
|
60212
|
+
import { existsSync as existsSync22 } from "node:fs";
|
|
60219
60213
|
import { homedir as homedir5 } from "node:os";
|
|
60220
|
-
import { delimiter, join as
|
|
60214
|
+
import { delimiter, join as join20 } from "node:path";
|
|
60221
60215
|
function appendOutput(current, chunk) {
|
|
60222
60216
|
const next = current + chunk.toString();
|
|
60223
60217
|
return next.length <= maxServerOutput ? next : next.slice(-maxServerOutput);
|
|
60224
60218
|
}
|
|
60225
60219
|
function defaultOpenCodeBinaryPath() {
|
|
60226
60220
|
const filename = process.platform === "win32" ? "opencode.exe" : "opencode";
|
|
60227
|
-
const installed =
|
|
60228
|
-
return
|
|
60221
|
+
const installed = join20(homedir5(), ".opencode", "bin", filename);
|
|
60222
|
+
return existsSync22(installed) ? installed : filename;
|
|
60229
60223
|
}
|
|
60230
60224
|
function openCodePath(pathEnv) {
|
|
60231
60225
|
const home = homedir5();
|
|
60232
60226
|
const paths = [
|
|
60233
|
-
|
|
60234
|
-
|
|
60235
|
-
|
|
60227
|
+
join20(home, ".opencode", "bin"),
|
|
60228
|
+
join20(home, ".local", "bin"),
|
|
60229
|
+
join20(home, ".bun", "bin"),
|
|
60236
60230
|
"/opt/homebrew/bin",
|
|
60237
60231
|
"/usr/local/bin",
|
|
60238
60232
|
...(pathEnv ?? "").split(delimiter)
|
|
@@ -60257,7 +60251,7 @@ async function stopChild(child, exited) {
|
|
|
60257
60251
|
signalChild(child, "SIGTERM");
|
|
60258
60252
|
const stopped = await Promise.race([
|
|
60259
60253
|
exited.then(() => true),
|
|
60260
|
-
new Promise((
|
|
60254
|
+
new Promise((resolve15) => setTimeout(() => resolve15(false), 1500))
|
|
60261
60255
|
]);
|
|
60262
60256
|
if (stopped) return;
|
|
60263
60257
|
signalChild(child, "SIGKILL");
|
|
@@ -60265,7 +60259,7 @@ async function stopChild(child, exited) {
|
|
|
60265
60259
|
}
|
|
60266
60260
|
async function waitForServer(child, exited, timeoutMs, signal) {
|
|
60267
60261
|
let output = "";
|
|
60268
|
-
return new Promise((
|
|
60262
|
+
return new Promise((resolve15, reject) => {
|
|
60269
60263
|
let settled = false;
|
|
60270
60264
|
const finish = (error51, url2) => {
|
|
60271
60265
|
if (settled) return;
|
|
@@ -60275,7 +60269,7 @@ async function waitForServer(child, exited, timeoutMs, signal) {
|
|
|
60275
60269
|
child.stderr.off("data", onData);
|
|
60276
60270
|
signal?.removeEventListener("abort", onAbort);
|
|
60277
60271
|
if (error51) reject(error51);
|
|
60278
|
-
else
|
|
60272
|
+
else resolve15(url2);
|
|
60279
60273
|
};
|
|
60280
60274
|
const onData = (chunk) => {
|
|
60281
60275
|
output = appendOutput(output, chunk);
|
|
@@ -60311,12 +60305,12 @@ async function startOpenCodeServer(opts) {
|
|
|
60311
60305
|
env: buildOpenCodeServeEnv(opts.env),
|
|
60312
60306
|
stdio: "pipe"
|
|
60313
60307
|
});
|
|
60314
|
-
const exited = new Promise((
|
|
60308
|
+
const exited = new Promise((resolve15) => {
|
|
60315
60309
|
let settled = false;
|
|
60316
60310
|
const finish = (code, signal) => {
|
|
60317
60311
|
if (settled) return;
|
|
60318
60312
|
settled = true;
|
|
60319
|
-
|
|
60313
|
+
resolve15({ code, signal });
|
|
60320
60314
|
};
|
|
60321
60315
|
child.once("exit", finish);
|
|
60322
60316
|
child.once("close", finish);
|
|
@@ -60341,7 +60335,7 @@ function isOpenCodeBinaryRunnable(binaryPath) {
|
|
|
60341
60335
|
const fromEnv = process.env.SUPERONE_OPENCODE_BINARY?.trim();
|
|
60342
60336
|
const candidate = binaryPath?.trim() || fromEnv;
|
|
60343
60337
|
if (!candidate) return false;
|
|
60344
|
-
return
|
|
60338
|
+
return existsSync22(candidate);
|
|
60345
60339
|
}
|
|
60346
60340
|
var OPENCODE_SERVE_ARGS, maxServerOutput;
|
|
60347
60341
|
var init_server3 = __esm({
|
|
@@ -60692,9 +60686,9 @@ var init_cursor_sdk_available = __esm({
|
|
|
60692
60686
|
});
|
|
60693
60687
|
|
|
60694
60688
|
// ../../packages/cursor/src/cursor-platform-binaries.ts
|
|
60695
|
-
import { existsSync as
|
|
60689
|
+
import { existsSync as existsSync23, statSync as statSync5 } from "node:fs";
|
|
60696
60690
|
import { createRequire as createRequire3 } from "node:module";
|
|
60697
|
-
import { dirname as
|
|
60691
|
+
import { dirname as dirname12, join as join21 } from "node:path";
|
|
60698
60692
|
function cursorPlatformPackageName(platform2 = process.platform, arch2 = process.arch) {
|
|
60699
60693
|
return `@cursor/sdk-${platform2}-${arch2}`;
|
|
60700
60694
|
}
|
|
@@ -60723,7 +60717,7 @@ function resolveCursorPlatformRoot() {
|
|
|
60723
60717
|
const req = cursorSdkRequire();
|
|
60724
60718
|
try {
|
|
60725
60719
|
const pkgJson = toUnpackedAsarPath(req.resolve(`${name}/package.json`));
|
|
60726
|
-
return
|
|
60720
|
+
return existsSync23(pkgJson) ? dirname12(pkgJson) : null;
|
|
60727
60721
|
} catch {
|
|
60728
60722
|
return null;
|
|
60729
60723
|
}
|
|
@@ -60734,20 +60728,20 @@ function platformBinName(base) {
|
|
|
60734
60728
|
function resolveCursorSandboxBinary() {
|
|
60735
60729
|
const root = resolveCursorPlatformRoot();
|
|
60736
60730
|
if (!root) return null;
|
|
60737
|
-
const bin =
|
|
60731
|
+
const bin = join21(root, "bin", platformBinName("cursorsandbox"));
|
|
60738
60732
|
return isExecutableFile(bin) ? bin : null;
|
|
60739
60733
|
}
|
|
60740
60734
|
function resolveCursorRipgrepBinary() {
|
|
60741
60735
|
const root = resolveCursorPlatformRoot();
|
|
60742
60736
|
if (!root) return null;
|
|
60743
|
-
const bin =
|
|
60737
|
+
const bin = join21(root, "bin", platformBinName("rg"));
|
|
60744
60738
|
return isExecutableFile(bin) ? bin : null;
|
|
60745
60739
|
}
|
|
60746
60740
|
function resolveCursorTreeSitterVendorDir() {
|
|
60747
60741
|
const root = resolveCursorPlatformRoot();
|
|
60748
60742
|
if (!root) return null;
|
|
60749
|
-
const vendor =
|
|
60750
|
-
return
|
|
60743
|
+
const vendor = join21(root, "vendor");
|
|
60744
|
+
return existsSync23(join21(vendor, "tree-sitter", "index.js")) ? vendor : null;
|
|
60751
60745
|
}
|
|
60752
60746
|
function sandboxExecAvailable() {
|
|
60753
60747
|
try {
|
|
@@ -60789,7 +60783,7 @@ function beginPlatformLookup() {
|
|
|
60789
60783
|
if (lookupDepth === 0) {
|
|
60790
60784
|
savedArgv1 = process.argv[1];
|
|
60791
60785
|
const root = resolveCursorPlatformRoot();
|
|
60792
|
-
if (root) process.argv[1] =
|
|
60786
|
+
if (root) process.argv[1] = join21(root, "package.json");
|
|
60793
60787
|
primeHelperEnv();
|
|
60794
60788
|
}
|
|
60795
60789
|
lookupDepth += 1;
|
|
@@ -61436,9 +61430,9 @@ var init_cursor_event_map = __esm({
|
|
|
61436
61430
|
|
|
61437
61431
|
// ../../packages/cursor/src/cursor-store.ts
|
|
61438
61432
|
import Database2 from "better-sqlite3";
|
|
61439
|
-
import { mkdirSync as
|
|
61433
|
+
import { mkdirSync as mkdirSync13 } from "node:fs";
|
|
61440
61434
|
import { createHash as createHash4 } from "node:crypto";
|
|
61441
|
-
import { join as
|
|
61435
|
+
import { join as join22 } from "node:path";
|
|
61442
61436
|
function workspaceHash(workspaceRef) {
|
|
61443
61437
|
return createHash4("md5").update(workspaceRef).digest("hex");
|
|
61444
61438
|
}
|
|
@@ -61481,7 +61475,7 @@ var init_cursor_store = __esm({
|
|
|
61481
61475
|
runEvents;
|
|
61482
61476
|
db;
|
|
61483
61477
|
constructor(dbPath) {
|
|
61484
|
-
|
|
61478
|
+
mkdirSync13(join22(dbPath, ".."), { recursive: true });
|
|
61485
61479
|
this.db = new Database2(dbPath);
|
|
61486
61480
|
this.db.pragma("journal_mode = WAL");
|
|
61487
61481
|
this.migrate();
|
|
@@ -61491,9 +61485,9 @@ var init_cursor_store = __esm({
|
|
|
61491
61485
|
this.runEvents = this.createRunEvents();
|
|
61492
61486
|
}
|
|
61493
61487
|
static openForWorkspace(userDataRoot, workspaceRef) {
|
|
61494
|
-
const dir =
|
|
61495
|
-
|
|
61496
|
-
return new _BetterSqliteLocalAgentStore(
|
|
61488
|
+
const dir = join22(userDataRoot, "cursor-sdk", workspaceHash(workspaceRef));
|
|
61489
|
+
mkdirSync13(dir, { recursive: true });
|
|
61490
|
+
return new _BetterSqliteLocalAgentStore(join22(dir, "agent-store.db"));
|
|
61497
61491
|
}
|
|
61498
61492
|
dispose() {
|
|
61499
61493
|
this.db.close();
|
|
@@ -62016,8 +62010,8 @@ function isCursorRetryableNetworkError(error51) {
|
|
|
62016
62010
|
return Boolean(error51.isRetryable);
|
|
62017
62011
|
}
|
|
62018
62012
|
function defaultSleep(ms) {
|
|
62019
|
-
return new Promise((
|
|
62020
|
-
setTimeout(
|
|
62013
|
+
return new Promise((resolve15) => {
|
|
62014
|
+
setTimeout(resolve15, ms);
|
|
62021
62015
|
});
|
|
62022
62016
|
}
|
|
62023
62017
|
async function withCursorNetworkRetries(fn, opts) {
|
|
@@ -62933,7 +62927,7 @@ var init_codex_live_turn = __esm({
|
|
|
62933
62927
|
});
|
|
62934
62928
|
|
|
62935
62929
|
// src/session/codex-turn-runner.ts
|
|
62936
|
-
import { existsSync as
|
|
62930
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
62937
62931
|
function mapCodexReasoningEffort(effort) {
|
|
62938
62932
|
if (!effort) return void 0;
|
|
62939
62933
|
const e = effort.trim().toLowerCase();
|
|
@@ -62943,18 +62937,18 @@ function mapCodexReasoningEffort(effort) {
|
|
|
62943
62937
|
return void 0;
|
|
62944
62938
|
}
|
|
62945
62939
|
function resolveCodexBinaryPath(opts) {
|
|
62946
|
-
if (opts.binaryPath &&
|
|
62940
|
+
if (opts.binaryPath && existsSync24(opts.binaryPath)) return opts.binaryPath;
|
|
62947
62941
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
62948
|
-
if (fromEnv &&
|
|
62942
|
+
if (fromEnv && existsSync24(fromEnv)) return fromEnv;
|
|
62949
62943
|
const status = opts.harnesses?.get("codex");
|
|
62950
|
-
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command &&
|
|
62944
|
+
if (status?.enabled && (status.state === "ready" || status.state === "needs_auth") && status.command && existsSync24(status.command)) {
|
|
62951
62945
|
return status.command;
|
|
62952
62946
|
}
|
|
62953
62947
|
return null;
|
|
62954
62948
|
}
|
|
62955
62949
|
function isCodexBinaryOverrideRunnable() {
|
|
62956
62950
|
const fromEnv = process.env.SUPERONE_CODEX_BINARY?.trim();
|
|
62957
|
-
return Boolean(fromEnv &&
|
|
62951
|
+
return Boolean(fromEnv && existsSync24(fromEnv));
|
|
62958
62952
|
}
|
|
62959
62953
|
function providerEnvKeyOf(env) {
|
|
62960
62954
|
return [
|
|
@@ -66687,7 +66681,7 @@ var require_compile = __commonJS({
|
|
|
66687
66681
|
const schOrFunc = root.refs[ref];
|
|
66688
66682
|
if (schOrFunc)
|
|
66689
66683
|
return schOrFunc;
|
|
66690
|
-
let _sch =
|
|
66684
|
+
let _sch = resolve15.call(this, root, ref);
|
|
66691
66685
|
if (_sch === void 0) {
|
|
66692
66686
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
66693
66687
|
const { schemaId } = this.opts;
|
|
@@ -66714,7 +66708,7 @@ var require_compile = __commonJS({
|
|
|
66714
66708
|
function sameSchemaEnv(s1, s2) {
|
|
66715
66709
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
66716
66710
|
}
|
|
66717
|
-
function
|
|
66711
|
+
function resolve15(root, ref) {
|
|
66718
66712
|
let sch;
|
|
66719
66713
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
66720
66714
|
ref = sch;
|
|
@@ -67345,7 +67339,7 @@ var require_fast_uri = __commonJS({
|
|
|
67345
67339
|
}
|
|
67346
67340
|
return uri;
|
|
67347
67341
|
}
|
|
67348
|
-
function
|
|
67342
|
+
function resolve15(baseURI, relativeURI, options) {
|
|
67349
67343
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
67350
67344
|
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
67351
67345
|
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
@@ -67629,7 +67623,7 @@ var require_fast_uri = __commonJS({
|
|
|
67629
67623
|
var fastUri = {
|
|
67630
67624
|
SCHEMES,
|
|
67631
67625
|
normalize: normalize2,
|
|
67632
|
-
resolve:
|
|
67626
|
+
resolve: resolve15,
|
|
67633
67627
|
resolveComponent,
|
|
67634
67628
|
equal,
|
|
67635
67629
|
serialize,
|
|
@@ -70620,7 +70614,7 @@ var require_dist2 = __commonJS({
|
|
|
70620
70614
|
|
|
70621
70615
|
// src/cli.ts
|
|
70622
70616
|
import { homedir as homedir10 } from "node:os";
|
|
70623
|
-
import { resolve as
|
|
70617
|
+
import { resolve as resolve14 } from "node:path";
|
|
70624
70618
|
|
|
70625
70619
|
// src/config.ts
|
|
70626
70620
|
import { homedir } from "node:os";
|
|
@@ -70661,8 +70655,8 @@ import { fileURLToPath } from "node:url";
|
|
|
70661
70655
|
function resolveCliReleaseVersion() {
|
|
70662
70656
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
70663
70657
|
if (fromEnv) return fromEnv;
|
|
70664
|
-
if ("0.57.
|
|
70665
|
-
return "0.57.
|
|
70658
|
+
if ("0.57.4-alpha".trim()) {
|
|
70659
|
+
return "0.57.4-alpha".trim();
|
|
70666
70660
|
}
|
|
70667
70661
|
const fromDist = readDistManifestVersion();
|
|
70668
70662
|
if (fromDist) return fromDist;
|
|
@@ -71531,9 +71525,9 @@ async function startNodeServer(opts) {
|
|
|
71531
71525
|
}
|
|
71532
71526
|
});
|
|
71533
71527
|
});
|
|
71534
|
-
await new Promise((
|
|
71528
|
+
await new Promise((resolve15, reject) => {
|
|
71535
71529
|
httpServer.once("error", reject);
|
|
71536
|
-
httpServer.listen(opts.bindPort, opts.bindHost, () =>
|
|
71530
|
+
httpServer.listen(opts.bindPort, opts.bindHost, () => resolve15());
|
|
71537
71531
|
});
|
|
71538
71532
|
const address = httpServer.address();
|
|
71539
71533
|
const port = typeof address === "object" && address ? address.port : opts.bindPort;
|
|
@@ -71546,9 +71540,9 @@ async function startNodeServer(opts) {
|
|
|
71546
71540
|
async close() {
|
|
71547
71541
|
for (const ws of activeSockets.keys()) ws.close();
|
|
71548
71542
|
activeSockets.clear();
|
|
71549
|
-
await new Promise((
|
|
71550
|
-
await new Promise((
|
|
71551
|
-
httpServer.close((err) => err ? reject(err) :
|
|
71543
|
+
await new Promise((resolve15) => wss.close(() => resolve15()));
|
|
71544
|
+
await new Promise((resolve15, reject) => {
|
|
71545
|
+
httpServer.close((err) => err ? reject(err) : resolve15());
|
|
71552
71546
|
});
|
|
71553
71547
|
}
|
|
71554
71548
|
};
|
|
@@ -71658,7 +71652,7 @@ async function handleHttp(req, res, opts) {
|
|
|
71658
71652
|
}
|
|
71659
71653
|
|
|
71660
71654
|
// src/runtime.ts
|
|
71661
|
-
import { existsSync as
|
|
71655
|
+
import { existsSync as existsSync41, readFileSync as readFileSync20, writeFileSync as writeFileSync18 } from "node:fs";
|
|
71662
71656
|
|
|
71663
71657
|
// ../../packages/runtime/src/db/database.ts
|
|
71664
71658
|
import Database from "better-sqlite3";
|
|
@@ -71761,7 +71755,8 @@ CREATE TABLE IF NOT EXISTS projects (
|
|
|
71761
71755
|
name TEXT NOT NULL,
|
|
71762
71756
|
repo_identity TEXT,
|
|
71763
71757
|
opened_at INTEGER,
|
|
71764
|
-
last_active_at INTEGER
|
|
71758
|
+
last_active_at INTEGER,
|
|
71759
|
+
extra_dirs_json TEXT NOT NULL DEFAULT '[]'
|
|
71765
71760
|
);
|
|
71766
71761
|
|
|
71767
71762
|
CREATE TABLE IF NOT EXISTS sessions (
|
|
@@ -71954,6 +71949,7 @@ function openNodeDatabase(dbPath) {
|
|
|
71954
71949
|
ensureCollaborationTables(db);
|
|
71955
71950
|
ensureAutomationsSupport(db);
|
|
71956
71951
|
ensureSessionTagsColumn(db);
|
|
71952
|
+
ensureProjectExtraDirsColumn(db);
|
|
71957
71953
|
ensureSessionProvidersSupport(db);
|
|
71958
71954
|
const row = db.prepare("SELECT value FROM meta WHERE key = ?").get("schema_generation");
|
|
71959
71955
|
if (!row) {
|
|
@@ -71984,6 +71980,12 @@ function ensureSessionUiColumns(db) {
|
|
|
71984
71980
|
db.exec(`ALTER TABLE sessions ADD COLUMN is_user_renamed INTEGER NOT NULL DEFAULT 0`);
|
|
71985
71981
|
}
|
|
71986
71982
|
}
|
|
71983
|
+
function ensureProjectExtraDirsColumn(db) {
|
|
71984
|
+
const cols = db.prepare(`PRAGMA table_info(projects)`).all();
|
|
71985
|
+
if (!cols.some((c) => c.name === "extra_dirs_json")) {
|
|
71986
|
+
db.exec(`ALTER TABLE projects ADD COLUMN extra_dirs_json TEXT NOT NULL DEFAULT '[]'`);
|
|
71987
|
+
}
|
|
71988
|
+
}
|
|
71987
71989
|
function ensureHarnessInstallationsTable(db) {
|
|
71988
71990
|
db.exec(`
|
|
71989
71991
|
CREATE TABLE IF NOT EXISTS harness_installations (
|
|
@@ -72689,7 +72691,7 @@ async function cloneRepository(input) {
|
|
|
72689
72691
|
}
|
|
72690
72692
|
|
|
72691
72693
|
// src/rpc/handlers.ts
|
|
72692
|
-
import { existsSync as
|
|
72694
|
+
import { existsSync as existsSync25, mkdirSync as mkdirSync14, readdirSync as readdirSync8, statSync as statSync6 } from "node:fs";
|
|
72693
72695
|
import { join as pathJoin, resolve as pathResolve } from "node:path";
|
|
72694
72696
|
import { arch, cpus, freemem, homedir as homedir6, hostname as hostname4, platform, totalmem, uptime } from "node:os";
|
|
72695
72697
|
|
|
@@ -72896,57 +72898,6 @@ function handleMcpList(payload, ctx) {
|
|
|
72896
72898
|
return mapThrown(err);
|
|
72897
72899
|
}
|
|
72898
72900
|
}
|
|
72899
|
-
function handleAdditionalDirsList(payload, ctx) {
|
|
72900
|
-
const denied = requireScopes(ctx.client, OPERATION_SCOPES.readWorkspace);
|
|
72901
|
-
if (denied) return denied;
|
|
72902
|
-
const p2 = asRecord13(payload);
|
|
72903
|
-
try {
|
|
72904
|
-
const projectId = String(p2.projectId ?? "");
|
|
72905
|
-
const cwd = projectRoot(ctx.projects, projectId);
|
|
72906
|
-
const provider = parseProviderStrict(p2.provider);
|
|
72907
|
-
if (!provider) return { error: { code: "invalid_argument", message: "provider must be claude or codex" } };
|
|
72908
|
-
ctx.projects.touch(projectId);
|
|
72909
|
-
return { result: readScopedAdditionalDirs(provider, cwd, manageOpts(ctx)) };
|
|
72910
|
-
} catch (err) {
|
|
72911
|
-
return mapThrown(err);
|
|
72912
|
-
}
|
|
72913
|
-
}
|
|
72914
|
-
function handleAdditionalDirsAdd(payload, ctx) {
|
|
72915
|
-
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72916
|
-
if (denied) return denied;
|
|
72917
|
-
const p2 = asRecord13(payload);
|
|
72918
|
-
try {
|
|
72919
|
-
const projectId = String(p2.projectId ?? "");
|
|
72920
|
-
const cwd = projectRoot(ctx.projects, projectId);
|
|
72921
|
-
const provider = parseProviderStrict(p2.provider);
|
|
72922
|
-
if (!provider) return { error: { code: "invalid_argument", message: "provider must be claude or codex" } };
|
|
72923
|
-
const dir = typeof p2.dir === "string" ? p2.dir.trim() : "";
|
|
72924
|
-
if (!dir) return { error: { code: "invalid_argument", message: "dir is required" } };
|
|
72925
|
-
addProjectAdditionalDir(provider, cwd, dir, manageOpts(ctx));
|
|
72926
|
-
ctx.projects.touch(projectId);
|
|
72927
|
-
return { result: { ok: true } };
|
|
72928
|
-
} catch (err) {
|
|
72929
|
-
return mapThrown(err);
|
|
72930
|
-
}
|
|
72931
|
-
}
|
|
72932
|
-
function handleAdditionalDirsRemove(payload, ctx) {
|
|
72933
|
-
const denied = requireScopes(ctx.client, OPERATION_SCOPES.writeWorkspace);
|
|
72934
|
-
if (denied) return denied;
|
|
72935
|
-
const p2 = asRecord13(payload);
|
|
72936
|
-
try {
|
|
72937
|
-
const projectId = String(p2.projectId ?? "");
|
|
72938
|
-
const cwd = projectRoot(ctx.projects, projectId);
|
|
72939
|
-
const provider = parseProviderStrict(p2.provider);
|
|
72940
|
-
if (!provider) return { error: { code: "invalid_argument", message: "provider must be claude or codex" } };
|
|
72941
|
-
const dir = typeof p2.dir === "string" ? p2.dir.trim() : "";
|
|
72942
|
-
if (!dir) return { error: { code: "invalid_argument", message: "dir is required" } };
|
|
72943
|
-
removeProjectAdditionalDir(provider, cwd, dir);
|
|
72944
|
-
ctx.projects.touch(projectId);
|
|
72945
|
-
return { result: { ok: true } };
|
|
72946
|
-
} catch (err) {
|
|
72947
|
-
return mapThrown(err);
|
|
72948
|
-
}
|
|
72949
|
-
}
|
|
72950
72901
|
function parseMcpWriteConfig(raw) {
|
|
72951
72902
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
72952
72903
|
return {
|
|
@@ -73558,12 +73509,6 @@ function dispatchResourceRpc(method, payload, ctx) {
|
|
|
73558
73509
|
return handleMcpToggle(payload, ctx);
|
|
73559
73510
|
case "mcp.delete":
|
|
73560
73511
|
return handleMcpDelete(payload, ctx);
|
|
73561
|
-
case "additionalDirs.list":
|
|
73562
|
-
return handleAdditionalDirsList(payload, ctx);
|
|
73563
|
-
case "additionalDirs.add":
|
|
73564
|
-
return handleAdditionalDirsAdd(payload, ctx);
|
|
73565
|
-
case "additionalDirs.remove":
|
|
73566
|
-
return handleAdditionalDirsRemove(payload, ctx);
|
|
73567
73512
|
case "plugins.list":
|
|
73568
73513
|
return handlePluginsList(payload, ctx);
|
|
73569
73514
|
case "plugins.get":
|
|
@@ -74741,12 +74686,14 @@ function clearWatchBuffersForClient(clientSessionId) {
|
|
|
74741
74686
|
watchBuffers.delete(watchId);
|
|
74742
74687
|
}
|
|
74743
74688
|
}
|
|
74689
|
+
var MAX_TURN_ADDITIONAL_DIRS = 64;
|
|
74744
74690
|
var MUTATING_METHODS = /* @__PURE__ */ new Set([
|
|
74745
74691
|
"terminal.create",
|
|
74746
74692
|
"terminal.write",
|
|
74747
74693
|
"terminal.resize",
|
|
74748
74694
|
"terminal.kill",
|
|
74749
74695
|
"project.open",
|
|
74696
|
+
"project.update",
|
|
74750
74697
|
"project.remove",
|
|
74751
74698
|
"workspace.writeFile",
|
|
74752
74699
|
"workspace.rename",
|
|
@@ -74941,6 +74888,8 @@ async function dispatchRpcInner(method, payload, ctx) {
|
|
|
74941
74888
|
return handleProjectGet(payload, ctx);
|
|
74942
74889
|
case "project.open":
|
|
74943
74890
|
return handleProjectOpen(payload, ctx);
|
|
74891
|
+
case "project.update":
|
|
74892
|
+
return handleProjectUpdate(payload, ctx);
|
|
74944
74893
|
case "project.remove":
|
|
74945
74894
|
return handleProjectRemove(payload, ctx);
|
|
74946
74895
|
case "fs.listDir":
|
|
@@ -75625,14 +75574,42 @@ function handleProjectOpen(payload, ctx) {
|
|
|
75625
75574
|
}
|
|
75626
75575
|
const name = typeof p2.name === "string" ? p2.name : void 0;
|
|
75627
75576
|
try {
|
|
75628
|
-
if (p2.createIfMissing === true && !
|
|
75629
|
-
|
|
75577
|
+
if (p2.createIfMissing === true && !existsSync25(path)) {
|
|
75578
|
+
mkdirSync14(path, { recursive: true });
|
|
75630
75579
|
}
|
|
75631
75580
|
return { result: ctx.projects.open(path, name) };
|
|
75632
75581
|
} catch (err) {
|
|
75633
75582
|
return mapThrown7(err);
|
|
75634
75583
|
}
|
|
75635
75584
|
}
|
|
75585
|
+
function handleProjectUpdate(payload, ctx) {
|
|
75586
|
+
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75587
|
+
if (denied) return denied;
|
|
75588
|
+
const p2 = asRecord19(payload);
|
|
75589
|
+
const projectId = typeof p2.projectId === "string" && p2.projectId ? p2.projectId : void 0;
|
|
75590
|
+
const pathRaw = typeof p2.path === "string" && p2.path ? expandHostPath(p2.path) : void 0;
|
|
75591
|
+
if (!projectId && !pathRaw) {
|
|
75592
|
+
return { error: { code: "invalid_argument", message: "projectId or path is required" } };
|
|
75593
|
+
}
|
|
75594
|
+
const name = typeof p2.name === "string" ? p2.name : void 0;
|
|
75595
|
+
const hostDirs = (raw) => Array.isArray(raw) ? raw.filter((d) => typeof d === "string" && d.trim().length > 0).map((d) => expandHostPath(d.trim())) : void 0;
|
|
75596
|
+
try {
|
|
75597
|
+
const updated = ctx.projects.update({
|
|
75598
|
+
projectId,
|
|
75599
|
+
path: pathRaw,
|
|
75600
|
+
name,
|
|
75601
|
+
extraDirs: hostDirs(p2.extraDirs),
|
|
75602
|
+
addExtraDirs: hostDirs(p2.addExtraDirs),
|
|
75603
|
+
removeExtraDirs: hostDirs(p2.removeExtraDirs)
|
|
75604
|
+
});
|
|
75605
|
+
if (!updated) {
|
|
75606
|
+
return { error: { code: "not_found", message: "project not found" } };
|
|
75607
|
+
}
|
|
75608
|
+
return { result: updated };
|
|
75609
|
+
} catch (err) {
|
|
75610
|
+
return mapThrown7(err);
|
|
75611
|
+
}
|
|
75612
|
+
}
|
|
75636
75613
|
function handleProjectRemove(payload, ctx) {
|
|
75637
75614
|
const denied = requireScopes7(ctx.client, OPERATION_SCOPES.manageProject);
|
|
75638
75615
|
if (denied) return denied;
|
|
@@ -75662,7 +75639,7 @@ function handleFsListDir(payload, ctx) {
|
|
|
75662
75639
|
}
|
|
75663
75640
|
try {
|
|
75664
75641
|
const resolved = expandHostPath(raw);
|
|
75665
|
-
if (!
|
|
75642
|
+
if (!existsSync25(resolved)) {
|
|
75666
75643
|
return { error: { code: "not_found", message: "path not found" } };
|
|
75667
75644
|
}
|
|
75668
75645
|
if (!statSync6(resolved).isDirectory()) {
|
|
@@ -76608,7 +76585,7 @@ async function handleSessionSend(payload, ctx) {
|
|
|
76608
76585
|
const permissionModeFromClient = typeof options.permissionMode === "string" && options.permissionMode.trim() ? options.permissionMode.trim() : typeof p2.permissionMode === "string" && p2.permissionMode.trim() ? p2.permissionMode.trim() : null;
|
|
76609
76586
|
const sandboxModeFromClient = typeof options.sandboxMode === "string" && options.sandboxMode.trim() ? options.sandboxMode.trim() : typeof p2.sandboxMode === "string" && p2.sandboxMode.trim() ? p2.sandboxMode.trim() : null;
|
|
76610
76587
|
const rawAdditionalDirs = Array.isArray(options.additionalDirectories) ? options.additionalDirectories : Array.isArray(p2.additionalDirectories) ? p2.additionalDirectories : [];
|
|
76611
|
-
const
|
|
76588
|
+
const clientAdditionalDirectories = rawAdditionalDirs.filter((d) => typeof d === "string" && d.trim().length > 0).map((d) => d.trim());
|
|
76612
76589
|
const rawEnabledSkills = Array.isArray(options.enabledSkills) ? options.enabledSkills : Array.isArray(p2.enabledSkills) ? p2.enabledSkills : [];
|
|
76613
76590
|
const enabledSkills = rawEnabledSkills.filter((s2) => typeof s2 === "string" && s2.trim().length > 0).map((s2) => s2.trim()).slice(0, 200);
|
|
76614
76591
|
const rawDisabledSkills = Array.isArray(options.disabledSkills) ? options.disabledSkills : Array.isArray(p2.disabledSkills) ? p2.disabledSkills : null;
|
|
@@ -76633,6 +76610,10 @@ async function handleSessionSend(payload, ctx) {
|
|
|
76633
76610
|
const reviewTarget = options.reviewTarget !== void 0 ? options.reviewTarget : p2.reviewTarget !== void 0 ? p2.reviewTarget : void 0;
|
|
76634
76611
|
const existing = ctx.sessions.get(String(p2.sessionId ?? ""));
|
|
76635
76612
|
const harnessId = existing?.harnessId || "claude";
|
|
76613
|
+
const projectExtraDirs = existing ? ctx.projects.get(existing.projectId)?.extraDirs ?? [] : [];
|
|
76614
|
+
const additionalDirectories = [
|
|
76615
|
+
.../* @__PURE__ */ new Set([...projectExtraDirs, ...clientAdditionalDirectories])
|
|
76616
|
+
].slice(0, MAX_TURN_ADDITIONAL_DIRS);
|
|
76636
76617
|
const agentDefaults = resolveAgentTurnDefaults(
|
|
76637
76618
|
loadNodeAgentSettings(ctx.settingsConfigPath),
|
|
76638
76619
|
harnessId
|
|
@@ -77243,11 +77224,11 @@ function parseState(raw) {
|
|
|
77243
77224
|
|
|
77244
77225
|
// ../../packages/runtime/src/harness/home-path.ts
|
|
77245
77226
|
import { homedir as homedir7 } from "node:os";
|
|
77246
|
-
import { join as
|
|
77227
|
+
import { join as join23 } from "node:path";
|
|
77247
77228
|
var HARNESS_HOME_DIRNAME = "harness";
|
|
77248
77229
|
var SUPERONE_DIRNAME = ".superone";
|
|
77249
77230
|
function defaultHarnessHomeRoot(userHome = homedir7()) {
|
|
77250
|
-
return
|
|
77231
|
+
return join23(userHome, SUPERONE_DIRNAME, HARNESS_HOME_DIRNAME);
|
|
77251
77232
|
}
|
|
77252
77233
|
function resolveHarnessHomeRoot(opts = {}) {
|
|
77253
77234
|
const explicit = opts.override?.trim();
|
|
@@ -77261,16 +77242,16 @@ function resolveHarnessHomeRoot(opts = {}) {
|
|
|
77261
77242
|
|
|
77262
77243
|
// ../../packages/runtime/src/harness/managed-layout.ts
|
|
77263
77244
|
import {
|
|
77264
|
-
existsSync as
|
|
77265
|
-
mkdirSync as
|
|
77245
|
+
existsSync as existsSync26,
|
|
77246
|
+
mkdirSync as mkdirSync15,
|
|
77266
77247
|
readdirSync as readdirSync9,
|
|
77267
|
-
readFileSync as
|
|
77248
|
+
readFileSync as readFileSync14,
|
|
77268
77249
|
renameSync as renameSync2,
|
|
77269
77250
|
rmSync as rmSync2,
|
|
77270
77251
|
statSync as statSync7,
|
|
77271
|
-
writeFileSync as
|
|
77252
|
+
writeFileSync as writeFileSync10
|
|
77272
77253
|
} from "node:fs";
|
|
77273
|
-
import { join as
|
|
77254
|
+
import { join as join24 } from "node:path";
|
|
77274
77255
|
import { randomBytes as randomBytes3 } from "node:crypto";
|
|
77275
77256
|
var MANAGED_VERSIONS_DIRNAME = "versions";
|
|
77276
77257
|
var MANAGED_CURRENT_BASENAME = "current";
|
|
@@ -77287,19 +77268,19 @@ function sanitizeRuntimeVersionForPath(runtimeVersion) {
|
|
|
77287
77268
|
return v2;
|
|
77288
77269
|
}
|
|
77289
77270
|
function managedVersionsDir(prefix) {
|
|
77290
|
-
return
|
|
77271
|
+
return join24(prefix, MANAGED_VERSIONS_DIRNAME);
|
|
77291
77272
|
}
|
|
77292
77273
|
function managedVersionDir(prefix, runtimeVersion) {
|
|
77293
|
-
return
|
|
77274
|
+
return join24(managedVersionsDir(prefix), sanitizeRuntimeVersionForPath(runtimeVersion));
|
|
77294
77275
|
}
|
|
77295
77276
|
function managedCurrentPath(prefix) {
|
|
77296
|
-
return
|
|
77277
|
+
return join24(prefix, MANAGED_CURRENT_BASENAME);
|
|
77297
77278
|
}
|
|
77298
77279
|
function readCurrentPointer(prefix) {
|
|
77299
77280
|
const path = managedCurrentPath(prefix);
|
|
77300
|
-
if (!
|
|
77281
|
+
if (!existsSync26(path)) return null;
|
|
77301
77282
|
try {
|
|
77302
|
-
const raw = JSON.parse(
|
|
77283
|
+
const raw = JSON.parse(readFileSync14(path, "utf8"));
|
|
77303
77284
|
if (typeof raw.runtimeVersion !== "string" || !raw.runtimeVersion.trim()) return null;
|
|
77304
77285
|
return {
|
|
77305
77286
|
runtimeVersion: raw.runtimeVersion.trim(),
|
|
@@ -77312,7 +77293,7 @@ function readCurrentPointer(prefix) {
|
|
|
77312
77293
|
}
|
|
77313
77294
|
function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
77314
77295
|
const ver = sanitizeRuntimeVersionForPath(runtimeVersion);
|
|
77315
|
-
|
|
77296
|
+
mkdirSync15(prefix, { recursive: true });
|
|
77316
77297
|
const path = managedCurrentPath(prefix);
|
|
77317
77298
|
const body = JSON.stringify(
|
|
77318
77299
|
{
|
|
@@ -77323,19 +77304,19 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
77323
77304
|
null,
|
|
77324
77305
|
2
|
|
77325
77306
|
);
|
|
77326
|
-
const tmp =
|
|
77307
|
+
const tmp = join24(
|
|
77327
77308
|
prefix,
|
|
77328
77309
|
`.${MANAGED_CURRENT_BASENAME}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`
|
|
77329
77310
|
);
|
|
77330
|
-
|
|
77311
|
+
writeFileSync10(tmp, body);
|
|
77331
77312
|
try {
|
|
77332
77313
|
renameSync2(tmp, path);
|
|
77333
77314
|
} catch {
|
|
77334
77315
|
try {
|
|
77335
|
-
if (
|
|
77316
|
+
if (existsSync26(path)) rmSync2(path, { force: true });
|
|
77336
77317
|
renameSync2(tmp, path);
|
|
77337
77318
|
} catch {
|
|
77338
|
-
|
|
77319
|
+
writeFileSync10(path, body);
|
|
77339
77320
|
try {
|
|
77340
77321
|
rmSync2(tmp, { force: true });
|
|
77341
77322
|
} catch {
|
|
@@ -77344,26 +77325,26 @@ function writeCurrentPointer(prefix, runtimeVersion, extras) {
|
|
|
77344
77325
|
}
|
|
77345
77326
|
}
|
|
77346
77327
|
function resolveActiveInstallRoot(prefix) {
|
|
77347
|
-
if (!prefix || !
|
|
77328
|
+
if (!prefix || !existsSync26(prefix)) return null;
|
|
77348
77329
|
const pointer = readCurrentPointer(prefix);
|
|
77349
77330
|
if (pointer) {
|
|
77350
|
-
if (pointer.installRoot &&
|
|
77331
|
+
if (pointer.installRoot && existsSync26(pointer.installRoot) && statSync7(pointer.installRoot).isDirectory()) {
|
|
77351
77332
|
return pointer.installRoot;
|
|
77352
77333
|
}
|
|
77353
77334
|
const dir = managedVersionDir(prefix, pointer.runtimeVersion);
|
|
77354
|
-
if (
|
|
77335
|
+
if (existsSync26(dir) && statSync7(dir).isDirectory()) return dir;
|
|
77355
77336
|
}
|
|
77356
77337
|
const versionsRoot = managedVersionsDir(prefix);
|
|
77357
|
-
if (
|
|
77338
|
+
if (existsSync26(versionsRoot)) {
|
|
77358
77339
|
try {
|
|
77359
77340
|
const kids = readdirSync9(versionsRoot).filter((n) => {
|
|
77360
77341
|
try {
|
|
77361
|
-
return statSync7(
|
|
77342
|
+
return statSync7(join24(versionsRoot, n)).isDirectory();
|
|
77362
77343
|
} catch {
|
|
77363
77344
|
return false;
|
|
77364
77345
|
}
|
|
77365
77346
|
});
|
|
77366
|
-
if (kids.length === 1) return
|
|
77347
|
+
if (kids.length === 1) return join24(versionsRoot, kids[0]);
|
|
77367
77348
|
} catch {
|
|
77368
77349
|
}
|
|
77369
77350
|
}
|
|
@@ -77371,7 +77352,7 @@ function resolveActiveInstallRoot(prefix) {
|
|
|
77371
77352
|
}
|
|
77372
77353
|
function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
77373
77354
|
const versionsRoot = managedVersionsDir(prefix);
|
|
77374
|
-
if (!
|
|
77355
|
+
if (!existsSync26(versionsRoot)) return;
|
|
77375
77356
|
const keepSet = new Set(
|
|
77376
77357
|
keep.filter(Boolean).map((v2) => {
|
|
77377
77358
|
try {
|
|
@@ -77385,7 +77366,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
77385
77366
|
try {
|
|
77386
77367
|
entries = readdirSync9(versionsRoot).map((name) => {
|
|
77387
77368
|
try {
|
|
77388
|
-
const st = statSync7(
|
|
77369
|
+
const st = statSync7(join24(versionsRoot, name));
|
|
77389
77370
|
if (!st.isDirectory()) return null;
|
|
77390
77371
|
return { name, mtime: st.mtimeMs };
|
|
77391
77372
|
} catch {
|
|
@@ -77404,7 +77385,7 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
77404
77385
|
}
|
|
77405
77386
|
for (const e of entries) {
|
|
77406
77387
|
if (retain.has(e.name)) continue;
|
|
77407
|
-
const dir =
|
|
77388
|
+
const dir = join24(versionsRoot, e.name);
|
|
77408
77389
|
try {
|
|
77409
77390
|
rmSync2(dir, { recursive: true, force: true });
|
|
77410
77391
|
} catch {
|
|
@@ -77416,17 +77397,17 @@ function pruneManagedVersions(prefix, keep, maxKeep = MANAGED_VERSION_KEEP) {
|
|
|
77416
77397
|
import {
|
|
77417
77398
|
copyFileSync,
|
|
77418
77399
|
createReadStream,
|
|
77419
|
-
existsSync as
|
|
77420
|
-
mkdirSync as
|
|
77400
|
+
existsSync as existsSync27,
|
|
77401
|
+
mkdirSync as mkdirSync16,
|
|
77421
77402
|
mkdtempSync,
|
|
77422
|
-
readFileSync as
|
|
77403
|
+
readFileSync as readFileSync15,
|
|
77423
77404
|
renameSync as renameSync3,
|
|
77424
77405
|
rmSync as rmSync3,
|
|
77425
77406
|
statSync as statSync8,
|
|
77426
|
-
writeFileSync as
|
|
77407
|
+
writeFileSync as writeFileSync11
|
|
77427
77408
|
} from "node:fs";
|
|
77428
77409
|
import { createHash as createHash5, randomBytes as randomBytes4 } from "node:crypto";
|
|
77429
|
-
import { dirname as
|
|
77410
|
+
import { dirname as dirname13, join as join25, relative, resolve as resolve6, sep as sep3 } from "node:path";
|
|
77430
77411
|
import { arch as osArch, platform as osPlatform } from "node:os";
|
|
77431
77412
|
var releaseVersionProvider = null;
|
|
77432
77413
|
function setHarnessReleaseVersionProvider(fn) {
|
|
@@ -77570,14 +77551,14 @@ function parseManagedHarnessPin(id, raw) {
|
|
|
77570
77551
|
function loadHarnessReleaseManifest(nodeHome) {
|
|
77571
77552
|
const fromEnv = process.env.SUPERONE_HARNESS_MANIFEST;
|
|
77572
77553
|
if (fromEnv) {
|
|
77573
|
-
if (!
|
|
77554
|
+
if (!existsSync27(fromEnv)) {
|
|
77574
77555
|
throw new Error(`SUPERONE_HARNESS_MANIFEST not found: ${fromEnv}`);
|
|
77575
77556
|
}
|
|
77576
|
-
return parseHarnessReleaseManifest(JSON.parse(
|
|
77557
|
+
return parseHarnessReleaseManifest(JSON.parse(readFileSync15(fromEnv, "utf8")));
|
|
77577
77558
|
}
|
|
77578
|
-
const local =
|
|
77579
|
-
if (
|
|
77580
|
-
return parseHarnessReleaseManifest(JSON.parse(
|
|
77559
|
+
const local = join25(nodeHome, "release-manifest.json");
|
|
77560
|
+
if (existsSync27(local)) {
|
|
77561
|
+
return parseHarnessReleaseManifest(JSON.parse(readFileSync15(local, "utf8")));
|
|
77581
77562
|
}
|
|
77582
77563
|
return null;
|
|
77583
77564
|
}
|
|
@@ -77645,7 +77626,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77645
77626
|
throw new Error(`release manifest does not pin managed harness ${opts.harnessId}`);
|
|
77646
77627
|
}
|
|
77647
77628
|
const art = selectArtifactPin(pin);
|
|
77648
|
-
if (!
|
|
77629
|
+
if (!existsSync27(opts.artifactPath)) {
|
|
77649
77630
|
throw new Error(`artifact not found: ${opts.artifactPath}`);
|
|
77650
77631
|
}
|
|
77651
77632
|
if (!statSync8(opts.artifactPath).isFile()) {
|
|
@@ -77663,8 +77644,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77663
77644
|
opts.harnessId,
|
|
77664
77645
|
pin.artifactVersion
|
|
77665
77646
|
);
|
|
77666
|
-
const finalFile =
|
|
77667
|
-
const metaPath =
|
|
77647
|
+
const finalFile = join25(destDir, MANAGED_PAYLOAD_BASENAME);
|
|
77648
|
+
const metaPath = join25(destDir, MANAGED_META_BASENAME);
|
|
77668
77649
|
assertStrictChild(finalFile, destDir, "payload path");
|
|
77669
77650
|
assertStrictChild(metaPath, destDir, "meta path");
|
|
77670
77651
|
const metaBody = JSON.stringify(
|
|
@@ -77683,8 +77664,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77683
77664
|
2
|
|
77684
77665
|
);
|
|
77685
77666
|
let reusedExisting = false;
|
|
77686
|
-
if (
|
|
77687
|
-
const payloadOk =
|
|
77667
|
+
if (existsSync27(destDir)) {
|
|
77668
|
+
const payloadOk = existsSync27(finalFile) && statSync8(finalFile).isFile() && await sha256File(finalFile) === art.digestSha256;
|
|
77688
77669
|
if (payloadOk) {
|
|
77689
77670
|
reusedExisting = true;
|
|
77690
77671
|
} else if (mode === "repair") {
|
|
@@ -77703,26 +77684,26 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77703
77684
|
);
|
|
77704
77685
|
}
|
|
77705
77686
|
} else {
|
|
77706
|
-
const harnessRoot2 =
|
|
77707
|
-
|
|
77687
|
+
const harnessRoot2 = dirname13(destDir);
|
|
77688
|
+
mkdirSync16(harnessRoot2, { recursive: true });
|
|
77708
77689
|
assertPathInside(destDir, harnessRoot2, "version dir");
|
|
77709
77690
|
const stagingDir = mkdtempSync(
|
|
77710
|
-
|
|
77691
|
+
join25(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes4(8).toString("hex")}-`)
|
|
77711
77692
|
);
|
|
77712
77693
|
assertPathInside(stagingDir, harnessRoot2, "staging dir");
|
|
77713
|
-
const stagingFile =
|
|
77714
|
-
const stagingMeta =
|
|
77694
|
+
const stagingFile = join25(stagingDir, MANAGED_PAYLOAD_BASENAME);
|
|
77695
|
+
const stagingMeta = join25(stagingDir, MANAGED_META_BASENAME);
|
|
77715
77696
|
try {
|
|
77716
77697
|
copyFileSync(opts.artifactPath, stagingFile);
|
|
77717
77698
|
const stagedDigest = await sha256File(stagingFile);
|
|
77718
77699
|
if (stagedDigest !== art.digestSha256) {
|
|
77719
77700
|
throw new Error(`staged artifact digest mismatch for ${opts.harnessId}`);
|
|
77720
77701
|
}
|
|
77721
|
-
|
|
77702
|
+
writeFileSync11(stagingMeta, metaBody, "utf8");
|
|
77722
77703
|
renameSync3(stagingDir, destDir);
|
|
77723
77704
|
} catch (err) {
|
|
77724
77705
|
rmSync3(stagingDir, { recursive: true, force: true });
|
|
77725
|
-
if (
|
|
77706
|
+
if (existsSync27(destDir) && existsSync27(finalFile)) {
|
|
77726
77707
|
const existingDigest = await sha256File(finalFile);
|
|
77727
77708
|
if (existingDigest === art.digestSha256) {
|
|
77728
77709
|
reusedExisting = true;
|
|
@@ -77747,22 +77728,22 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77747
77728
|
if (finalDigest !== art.digestSha256) {
|
|
77748
77729
|
throw new Error(`final payload digest mismatch for ${opts.harnessId}`);
|
|
77749
77730
|
}
|
|
77750
|
-
const harnessRoot =
|
|
77731
|
+
const harnessRoot = join25(
|
|
77751
77732
|
releasesRoot(opts.nodeHome),
|
|
77752
77733
|
opts.manifest.cliVersion,
|
|
77753
77734
|
"harnesses",
|
|
77754
77735
|
opts.harnessId
|
|
77755
77736
|
);
|
|
77756
77737
|
assertPathInside(harnessRoot, releasesRoot(opts.nodeHome), "harness root");
|
|
77757
|
-
|
|
77758
|
-
const currentPath =
|
|
77759
|
-
const currentTmp =
|
|
77738
|
+
mkdirSync16(harnessRoot, { recursive: true });
|
|
77739
|
+
const currentPath = join25(harnessRoot, MANAGED_CURRENT_BASENAME2);
|
|
77740
|
+
const currentTmp = join25(
|
|
77760
77741
|
harnessRoot,
|
|
77761
77742
|
`.${MANAGED_CURRENT_BASENAME2}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`
|
|
77762
77743
|
);
|
|
77763
77744
|
assertStrictChild(currentTmp, harnessRoot, "current pointer temp");
|
|
77764
77745
|
try {
|
|
77765
|
-
|
|
77746
|
+
writeFileSync11(
|
|
77766
77747
|
currentTmp,
|
|
77767
77748
|
JSON.stringify(
|
|
77768
77749
|
{
|
|
@@ -77793,10 +77774,10 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
77793
77774
|
};
|
|
77794
77775
|
}
|
|
77795
77776
|
async function replacePayloadAtomically(opts) {
|
|
77796
|
-
|
|
77777
|
+
mkdirSync16(opts.destDir, { recursive: true });
|
|
77797
77778
|
const nonce = randomBytes4(8).toString("hex");
|
|
77798
|
-
const payloadTmp =
|
|
77799
|
-
const metaTmp =
|
|
77779
|
+
const payloadTmp = join25(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
|
|
77780
|
+
const metaTmp = join25(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
|
|
77800
77781
|
assertStrictChild(payloadTmp, opts.destDir, "payload temp");
|
|
77801
77782
|
assertStrictChild(metaTmp, opts.destDir, "meta temp");
|
|
77802
77783
|
try {
|
|
@@ -77805,7 +77786,7 @@ async function replacePayloadAtomically(opts) {
|
|
|
77805
77786
|
if (d !== opts.expectedDigest) {
|
|
77806
77787
|
throw new Error(`repair staged digest mismatch: expected ${opts.expectedDigest}, got ${d}`);
|
|
77807
77788
|
}
|
|
77808
|
-
|
|
77789
|
+
writeFileSync11(metaTmp, opts.metaBody, "utf8");
|
|
77809
77790
|
renameSync3(payloadTmp, opts.finalFile);
|
|
77810
77791
|
renameSync3(metaTmp, opts.metaPath);
|
|
77811
77792
|
} catch (err) {
|
|
@@ -77830,9 +77811,9 @@ function requiredRuntimeVersion(harnessId, manifest) {
|
|
|
77830
77811
|
}
|
|
77831
77812
|
|
|
77832
77813
|
// ../../packages/runtime/src/harness/managed-official.ts
|
|
77833
|
-
import { existsSync as
|
|
77814
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync17, readFileSync as readFileSync16, readdirSync as readdirSync10, statSync as statSync9, writeFileSync as writeFileSync12 } from "node:fs";
|
|
77834
77815
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
77835
|
-
import { join as
|
|
77816
|
+
import { join as join26, resolve as resolve7 } from "node:path";
|
|
77836
77817
|
var OFFICIAL_CLAUDE_SDK_VERSION = "0.3.238";
|
|
77837
77818
|
var OFFICIAL_CODEX_NPM_VERSION = "0.149.0";
|
|
77838
77819
|
var OFFICIAL_CODEX_PACKAGE = "@openai/codex";
|
|
@@ -77876,7 +77857,7 @@ function claudePlatformPackageName() {
|
|
|
77876
77857
|
}
|
|
77877
77858
|
function isMuslLinux() {
|
|
77878
77859
|
try {
|
|
77879
|
-
if (
|
|
77860
|
+
if (existsSync28("/etc/alpine-release")) return true;
|
|
77880
77861
|
const lib = readdirSync10("/lib").some((n) => n.startsWith("ld-musl"));
|
|
77881
77862
|
if (lib) return true;
|
|
77882
77863
|
} catch {
|
|
@@ -77884,44 +77865,44 @@ function isMuslLinux() {
|
|
|
77884
77865
|
return false;
|
|
77885
77866
|
}
|
|
77886
77867
|
function resolveOfficialInstallBinaryInRoot(harnessId, installRoot) {
|
|
77887
|
-
if (!installRoot || !
|
|
77868
|
+
if (!installRoot || !existsSync28(installRoot)) return null;
|
|
77888
77869
|
if (harnessId === "codex") {
|
|
77889
77870
|
const triple = codexTargetTriple();
|
|
77890
77871
|
const nativeName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
77891
77872
|
const candidates = [
|
|
77892
|
-
|
|
77893
|
-
|
|
77894
|
-
|
|
77895
|
-
|
|
77873
|
+
join26(installRoot, "bin", "codex"),
|
|
77874
|
+
join26(installRoot, "bin", "codex.cmd"),
|
|
77875
|
+
join26(installRoot, "lib", "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
77876
|
+
join26(installRoot, "node_modules", "@openai", "codex", "bin", "codex.js"),
|
|
77896
77877
|
...triple ? [
|
|
77897
|
-
|
|
77898
|
-
|
|
77878
|
+
join26(installRoot, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName),
|
|
77879
|
+
join26(installRoot, "node_modules", "@openai", "codex", "vendor", triple, "bin", nativeName)
|
|
77899
77880
|
] : []
|
|
77900
77881
|
];
|
|
77901
77882
|
for (const c of candidates) {
|
|
77902
|
-
if (
|
|
77883
|
+
if (existsSync28(c) && (c.endsWith(".js") || isExecutableFile2(c))) return c;
|
|
77903
77884
|
}
|
|
77904
77885
|
return null;
|
|
77905
77886
|
}
|
|
77906
|
-
const nm =
|
|
77907
|
-
const scoped =
|
|
77887
|
+
const nm = join26(installRoot, "lib", "node_modules");
|
|
77888
|
+
const scoped = join26(nm, "@anthropic-ai");
|
|
77908
77889
|
try {
|
|
77909
|
-
if (
|
|
77890
|
+
if (existsSync28(scoped)) {
|
|
77910
77891
|
const names = readdirSync10(scoped).filter((n) => n.startsWith("claude-agent-sdk-"));
|
|
77911
77892
|
for (const n of names) {
|
|
77912
77893
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
77913
|
-
const bin =
|
|
77914
|
-
if (
|
|
77894
|
+
const bin = join26(scoped, n, `claude${ext}`);
|
|
77895
|
+
if (existsSync28(bin)) return bin;
|
|
77915
77896
|
}
|
|
77916
77897
|
}
|
|
77917
77898
|
} catch {
|
|
77918
77899
|
}
|
|
77919
|
-
const direct =
|
|
77900
|
+
const direct = join26(
|
|
77920
77901
|
nm,
|
|
77921
77902
|
...claudePlatformPackageName().split("/"),
|
|
77922
77903
|
process.platform === "win32" ? "claude.exe" : "claude"
|
|
77923
77904
|
);
|
|
77924
|
-
if (
|
|
77905
|
+
if (existsSync28(direct)) return direct;
|
|
77925
77906
|
return null;
|
|
77926
77907
|
}
|
|
77927
77908
|
function isExecutableFile2(path) {
|
|
@@ -77936,7 +77917,7 @@ function isExecutableFile2(path) {
|
|
|
77936
77917
|
}
|
|
77937
77918
|
|
|
77938
77919
|
// ../../packages/runtime/src/harness/tarball-fetch.ts
|
|
77939
|
-
import { existsSync as
|
|
77920
|
+
import { existsSync as existsSync29, rmSync as rmSync4 } from "node:fs";
|
|
77940
77921
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
77941
77922
|
function assertSha256(actualHex, expectedHex) {
|
|
77942
77923
|
if (actualHex !== expectedHex.toLowerCase()) {
|
|
@@ -77954,7 +77935,7 @@ function assertSha512Integrity(actualBase64, integrity) {
|
|
|
77954
77935
|
}
|
|
77955
77936
|
function discardPartial(destPath) {
|
|
77956
77937
|
try {
|
|
77957
|
-
if (
|
|
77938
|
+
if (existsSync29(destPath)) rmSync4(destPath, { force: true });
|
|
77958
77939
|
} catch {
|
|
77959
77940
|
}
|
|
77960
77941
|
}
|
|
@@ -78035,13 +78016,13 @@ import {
|
|
|
78035
78016
|
appendFileSync,
|
|
78036
78017
|
createReadStream as createReadStream2,
|
|
78037
78018
|
createWriteStream,
|
|
78038
|
-
existsSync as
|
|
78039
|
-
mkdirSync as
|
|
78019
|
+
existsSync as existsSync30,
|
|
78020
|
+
mkdirSync as mkdirSync18,
|
|
78040
78021
|
rmSync as rmSync5,
|
|
78041
78022
|
statSync as statSync10,
|
|
78042
|
-
writeFileSync as
|
|
78023
|
+
writeFileSync as writeFileSync13
|
|
78043
78024
|
} from "node:fs";
|
|
78044
|
-
import { dirname as
|
|
78025
|
+
import { dirname as dirname14 } from "node:path";
|
|
78045
78026
|
import { pipeline } from "node:stream/promises";
|
|
78046
78027
|
import { Readable as Readable2, Transform } from "node:stream";
|
|
78047
78028
|
var HARNESS_PROGRESS_THROTTLE_MS = 200;
|
|
@@ -78072,7 +78053,7 @@ async function seedHashesFromFile(path) {
|
|
|
78072
78053
|
const sha512 = createHash6("sha512");
|
|
78073
78054
|
const size = statSync10(path).size;
|
|
78074
78055
|
if (size === 0) return { sha256, sha512, size };
|
|
78075
|
-
await new Promise((
|
|
78056
|
+
await new Promise((resolve15, reject) => {
|
|
78076
78057
|
const stream = createReadStream2(path);
|
|
78077
78058
|
stream.on("data", (chunk) => {
|
|
78078
78059
|
const buf = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
@@ -78080,7 +78061,7 @@ async function seedHashesFromFile(path) {
|
|
|
78080
78061
|
sha512.update(buf);
|
|
78081
78062
|
});
|
|
78082
78063
|
stream.on("error", reject);
|
|
78083
|
-
stream.on("end", () =>
|
|
78064
|
+
stream.on("end", () => resolve15());
|
|
78084
78065
|
});
|
|
78085
78066
|
return { sha256, sha512, size };
|
|
78086
78067
|
}
|
|
@@ -78102,7 +78083,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
78102
78083
|
const keepPartial = opts.keepPartialOnError !== false;
|
|
78103
78084
|
const contentLen = Number(res.headers.get("content-length") ?? 0);
|
|
78104
78085
|
const total = opts.totalBytes && opts.totalBytes > 0 ? opts.totalBytes : append ? resumeFrom + contentLen : contentLen;
|
|
78105
|
-
|
|
78086
|
+
mkdirSync18(dirname14(destPath), { recursive: true });
|
|
78106
78087
|
const emit = createThrottledProgress(onProgress, opts.progressThrottleMs);
|
|
78107
78088
|
let sha256;
|
|
78108
78089
|
let sha512;
|
|
@@ -78128,7 +78109,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
78128
78109
|
if (append) {
|
|
78129
78110
|
appendFileSync(destPath, buf);
|
|
78130
78111
|
} else {
|
|
78131
|
-
|
|
78112
|
+
writeFileSync13(destPath, buf);
|
|
78132
78113
|
}
|
|
78133
78114
|
sha256.update(buf);
|
|
78134
78115
|
sha512.update(buf);
|
|
@@ -78160,7 +78141,7 @@ async function streamResponseToFile(res, destPath, onProgress, opts = {}) {
|
|
|
78160
78141
|
} catch (err) {
|
|
78161
78142
|
if (!keepPartial) {
|
|
78162
78143
|
try {
|
|
78163
|
-
if (
|
|
78144
|
+
if (existsSync30(destPath)) rmSync5(destPath, { force: true });
|
|
78164
78145
|
} catch {
|
|
78165
78146
|
}
|
|
78166
78147
|
}
|
|
@@ -78177,8 +78158,8 @@ var destPathLocks = /* @__PURE__ */ new Map();
|
|
|
78177
78158
|
async function withDestPathLock(destPath, fn) {
|
|
78178
78159
|
const prev = destPathLocks.get(destPath) ?? Promise.resolve();
|
|
78179
78160
|
let release;
|
|
78180
|
-
const gate = new Promise((
|
|
78181
|
-
release =
|
|
78161
|
+
const gate = new Promise((resolve15) => {
|
|
78162
|
+
release = resolve15;
|
|
78182
78163
|
});
|
|
78183
78164
|
const held = prev.then(() => gate);
|
|
78184
78165
|
destPathLocks.set(
|
|
@@ -78204,14 +78185,14 @@ async function downloadResumableToFile(httpFetch, url2, destPath, onProgress, lo
|
|
|
78204
78185
|
);
|
|
78205
78186
|
}
|
|
78206
78187
|
async function downloadResumableToFileUnlocked(httpFetch, url2, destPath, onProgress, log2) {
|
|
78207
|
-
|
|
78208
|
-
let existing =
|
|
78188
|
+
mkdirSync18(dirname14(destPath), { recursive: true });
|
|
78189
|
+
let existing = existsSync30(destPath) ? statSync10(destPath).size : 0;
|
|
78209
78190
|
if (existing > 0 && existing < 64) {
|
|
78210
78191
|
rmSync5(destPath, { force: true });
|
|
78211
78192
|
existing = 0;
|
|
78212
78193
|
}
|
|
78213
78194
|
const tryOnce = async (from) => {
|
|
78214
|
-
const diskNow =
|
|
78195
|
+
const diskNow = existsSync30(destPath) ? statSync10(destPath).size : 0;
|
|
78215
78196
|
const start = from > 0 ? diskNow : 0;
|
|
78216
78197
|
if (from > 0 && diskNow !== from) {
|
|
78217
78198
|
log2?.warn?.(
|
|
@@ -78293,17 +78274,17 @@ function createResumableDownloadToFile(httpFetch, log2) {
|
|
|
78293
78274
|
|
|
78294
78275
|
// ../../packages/runtime/src/harness/managed-tarball-installer.ts
|
|
78295
78276
|
import {
|
|
78296
|
-
existsSync as
|
|
78297
|
-
mkdirSync as
|
|
78277
|
+
existsSync as existsSync31,
|
|
78278
|
+
mkdirSync as mkdirSync19,
|
|
78298
78279
|
mkdtempSync as mkdtempSync2,
|
|
78299
|
-
readFileSync as
|
|
78280
|
+
readFileSync as readFileSync17,
|
|
78300
78281
|
renameSync as renameSync4,
|
|
78301
78282
|
rmSync as rmSync6,
|
|
78302
78283
|
statSync as statSync11,
|
|
78303
|
-
writeFileSync as
|
|
78284
|
+
writeFileSync as writeFileSync14
|
|
78304
78285
|
} from "node:fs";
|
|
78305
78286
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
78306
|
-
import { dirname as
|
|
78287
|
+
import { dirname as dirname15, join as join27 } from "node:path";
|
|
78307
78288
|
import { spawn as spawn4 } from "node:child_process";
|
|
78308
78289
|
|
|
78309
78290
|
// ../../packages/shared/src/update-channels.ts
|
|
@@ -78383,7 +78364,7 @@ function resolveHarnessManifestChannel(explicit, releaseVersion) {
|
|
|
78383
78364
|
return "alpha";
|
|
78384
78365
|
}
|
|
78385
78366
|
function harnessDownloadDir(homeRoot) {
|
|
78386
|
-
return
|
|
78367
|
+
return join27(homeRoot, ".download");
|
|
78387
78368
|
}
|
|
78388
78369
|
function harnessArtifactDownloadKey(opts) {
|
|
78389
78370
|
const digest = opts.digestSha256?.trim().toLowerCase();
|
|
@@ -78397,11 +78378,11 @@ function harnessPartialPath(homeRoot, key) {
|
|
|
78397
78378
|
if (!key || key.includes("..") || key.includes("/") || key.includes("\\")) {
|
|
78398
78379
|
throw new Error(`unsafe download key: ${key}`);
|
|
78399
78380
|
}
|
|
78400
|
-
return
|
|
78381
|
+
return join27(harnessDownloadDir(homeRoot), `${key}.partial`);
|
|
78401
78382
|
}
|
|
78402
78383
|
function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
78403
|
-
return new Promise((
|
|
78404
|
-
|
|
78384
|
+
return new Promise((resolve15, reject) => {
|
|
78385
|
+
mkdirSync19(destDir, { recursive: true });
|
|
78405
78386
|
const child = spawn4("tar", ["-xzf", tgzPath, "-C", destDir], {
|
|
78406
78387
|
stdio: ["ignore", "ignore", "pipe"]
|
|
78407
78388
|
});
|
|
@@ -78411,19 +78392,19 @@ function extractTgzWithSystemTar(tgzPath, destDir) {
|
|
|
78411
78392
|
});
|
|
78412
78393
|
child.on("error", (err) => reject(new Error(`tar spawn failed: ${err.message}`)));
|
|
78413
78394
|
child.on("close", (code) => {
|
|
78414
|
-
if (code === 0)
|
|
78395
|
+
if (code === 0) resolve15();
|
|
78415
78396
|
else reject(new Error(`tar extract failed (exit ${code}): ${stderr.slice(-500)}`));
|
|
78416
78397
|
});
|
|
78417
78398
|
});
|
|
78418
78399
|
}
|
|
78419
78400
|
function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
78420
|
-
const dest =
|
|
78421
|
-
const parent =
|
|
78422
|
-
|
|
78423
|
-
if (
|
|
78401
|
+
const dest = join27(prefix, "lib", "node_modules", ...nodeModulesRel.split("/"));
|
|
78402
|
+
const parent = dirname15(dest);
|
|
78403
|
+
mkdirSync19(parent, { recursive: true });
|
|
78404
|
+
if (existsSync31(dest)) {
|
|
78424
78405
|
rmSync6(dest, { recursive: true, force: true });
|
|
78425
78406
|
}
|
|
78426
|
-
const staging =
|
|
78407
|
+
const staging = join27(
|
|
78427
78408
|
parent,
|
|
78428
78409
|
`.staging-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`
|
|
78429
78410
|
);
|
|
@@ -78431,7 +78412,7 @@ function installPackageDir(packageDir, prefix, nodeModulesRel) {
|
|
|
78431
78412
|
renameSync4(packageDir, staging);
|
|
78432
78413
|
renameSync4(staging, dest);
|
|
78433
78414
|
} catch (err) {
|
|
78434
|
-
if (
|
|
78415
|
+
if (existsSync31(staging)) rmSync6(staging, { recursive: true, force: true });
|
|
78435
78416
|
throw err instanceof Error ? err : new Error(`failed to place package into ${dest}: ${String(err)}`);
|
|
78436
78417
|
}
|
|
78437
78418
|
return dest;
|
|
@@ -78453,8 +78434,8 @@ function resolveCodexNativeUnderPrefix(prefix) {
|
|
|
78453
78434
|
if (!triple) return null;
|
|
78454
78435
|
const binaryName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
78455
78436
|
const candidates = [
|
|
78456
|
-
|
|
78457
|
-
|
|
78437
|
+
join27(prefix, "lib", "node_modules", "@openai", "codex", "vendor", triple, "bin", binaryName),
|
|
78438
|
+
join27(
|
|
78458
78439
|
prefix,
|
|
78459
78440
|
"lib",
|
|
78460
78441
|
"node_modules",
|
|
@@ -78467,7 +78448,7 @@ function resolveCodexNativeUnderPrefix(prefix) {
|
|
|
78467
78448
|
)
|
|
78468
78449
|
];
|
|
78469
78450
|
for (const c of candidates) {
|
|
78470
|
-
if (
|
|
78451
|
+
if (existsSync31(c) && statSync11(c).isFile()) return c;
|
|
78471
78452
|
}
|
|
78472
78453
|
return null;
|
|
78473
78454
|
}
|
|
@@ -78477,17 +78458,17 @@ function resolveManagedTarballBinary(id, installRoot) {
|
|
|
78477
78458
|
}
|
|
78478
78459
|
function readRuntimeVersionFromRoot(id, installRoot) {
|
|
78479
78460
|
try {
|
|
78480
|
-
const metaPath =
|
|
78481
|
-
if (
|
|
78482
|
-
const raw = JSON.parse(
|
|
78461
|
+
const metaPath = join27(installRoot, "install-meta.json");
|
|
78462
|
+
if (existsSync31(metaPath)) {
|
|
78463
|
+
const raw = JSON.parse(readFileSync17(metaPath, "utf8"));
|
|
78483
78464
|
if (raw.runtimeVersion) return raw.runtimeVersion;
|
|
78484
78465
|
}
|
|
78485
78466
|
} catch {
|
|
78486
78467
|
}
|
|
78487
78468
|
try {
|
|
78488
|
-
const pkgPath = id === "claude" ? null :
|
|
78489
|
-
if (pkgPath &&
|
|
78490
|
-
const raw = JSON.parse(
|
|
78469
|
+
const pkgPath = id === "claude" ? null : join27(installRoot, "lib", "node_modules", "@openai", "codex", "package.json");
|
|
78470
|
+
if (pkgPath && existsSync31(pkgPath)) {
|
|
78471
|
+
const raw = JSON.parse(readFileSync17(pkgPath, "utf8"));
|
|
78491
78472
|
const v2 = raw.version?.trim();
|
|
78492
78473
|
if (!v2) return null;
|
|
78493
78474
|
return v2.replace(/-(darwin|linux|win32)-(arm64|x64)$/, "");
|
|
@@ -78522,7 +78503,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
78522
78503
|
return {
|
|
78523
78504
|
async install(id, home, onProgress) {
|
|
78524
78505
|
const prefix = managedHarnessPrefix(home.root, id);
|
|
78525
|
-
|
|
78506
|
+
mkdirSync19(prefix, { recursive: true });
|
|
78526
78507
|
const pins = managedPackagePins(id);
|
|
78527
78508
|
const versionDir = managedVersionDir(prefix, pins.runtimeVersion);
|
|
78528
78509
|
const previousPointer = readCurrentPointer(prefix)?.runtimeVersion ?? null;
|
|
@@ -78564,7 +78545,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
78564
78545
|
const artifactPin = await resolveArtifactPin(id, channel, opts, fetchJson);
|
|
78565
78546
|
let packageSpec = "";
|
|
78566
78547
|
let source = "npm-tarball";
|
|
78567
|
-
|
|
78548
|
+
mkdirSync19(versionDir, { recursive: true });
|
|
78568
78549
|
for (const pkg of pins.packages) {
|
|
78569
78550
|
const npmName = artifactPin?.npmName ?? pkg.name;
|
|
78570
78551
|
const npmVersion = artifactPin?.npmVersion ?? pkg.version;
|
|
@@ -78576,7 +78557,7 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
78576
78557
|
npmVersion
|
|
78577
78558
|
});
|
|
78578
78559
|
const partialPath = harnessPartialPath(home.root, downloadKey);
|
|
78579
|
-
const work = mkdtempSync2(
|
|
78560
|
+
const work = mkdtempSync2(join27(tmpdir2(), `superone-harness-${id}-`));
|
|
78580
78561
|
try {
|
|
78581
78562
|
const { from } = await fetchTarballWithFallback({
|
|
78582
78563
|
destPath: partialPath,
|
|
@@ -78590,23 +78571,23 @@ function createManagedTarballInstaller(opts = {}) {
|
|
|
78590
78571
|
log: log2
|
|
78591
78572
|
});
|
|
78592
78573
|
source = from;
|
|
78593
|
-
const extractRoot =
|
|
78574
|
+
const extractRoot = join27(work, "out");
|
|
78594
78575
|
await extractTgz(partialPath, extractRoot);
|
|
78595
|
-
const packageDir =
|
|
78596
|
-
if (!
|
|
78576
|
+
const packageDir = join27(extractRoot, "package");
|
|
78577
|
+
if (!existsSync31(packageDir) || !statSync11(packageDir).isDirectory()) {
|
|
78597
78578
|
throw new Error(`tarball for ${packageSpec} has no package/ directory`);
|
|
78598
78579
|
}
|
|
78599
78580
|
installPackageDir(packageDir, versionDir, npmName);
|
|
78600
78581
|
try {
|
|
78601
|
-
if (
|
|
78582
|
+
if (existsSync31(partialPath)) rmSync6(partialPath, { force: true });
|
|
78602
78583
|
} catch {
|
|
78603
78584
|
}
|
|
78604
78585
|
} finally {
|
|
78605
78586
|
rmSync6(work, { recursive: true, force: true });
|
|
78606
78587
|
}
|
|
78607
78588
|
}
|
|
78608
|
-
|
|
78609
|
-
|
|
78589
|
+
writeFileSync14(
|
|
78590
|
+
join27(versionDir, "install-meta.json"),
|
|
78610
78591
|
JSON.stringify(
|
|
78611
78592
|
{
|
|
78612
78593
|
harnessId: id,
|
|
@@ -78838,7 +78819,7 @@ function isAuthSatisfied(id, deps) {
|
|
|
78838
78819
|
|
|
78839
78820
|
// ../../packages/runtime/src/harness/enable.ts
|
|
78840
78821
|
init_environment();
|
|
78841
|
-
import { accessSync, constants, existsSync as
|
|
78822
|
+
import { accessSync, constants, existsSync as existsSync32, realpathSync as realpathSync3, statSync as statSync12 } from "node:fs";
|
|
78842
78823
|
import { isAbsolute as isAbsolute4, resolve as resolve8 } from "node:path";
|
|
78843
78824
|
async function enableHarness(manager, input, deps) {
|
|
78844
78825
|
const id = input.harnessId;
|
|
@@ -79057,7 +79038,7 @@ function requireRegularReadableFile(path) {
|
|
|
79057
79038
|
throw new Error(`path must be absolute: ${path}`);
|
|
79058
79039
|
}
|
|
79059
79040
|
const abs = resolve8(path);
|
|
79060
|
-
if (!
|
|
79041
|
+
if (!existsSync32(abs) || !statSync12(abs).isFile()) {
|
|
79061
79042
|
throw new Error(`not a regular file: ${abs}`);
|
|
79062
79043
|
}
|
|
79063
79044
|
accessSync(abs, constants.R_OK);
|
|
@@ -79066,7 +79047,7 @@ function requireRegularReadableFile(path) {
|
|
|
79066
79047
|
function resolveExternalCommand(explicit, searchNames) {
|
|
79067
79048
|
if (explicit) {
|
|
79068
79049
|
const abs = isAbsolute4(explicit) ? explicit : resolve8(explicit);
|
|
79069
|
-
if (!
|
|
79050
|
+
if (!existsSync32(abs)) return null;
|
|
79070
79051
|
try {
|
|
79071
79052
|
if (!statSync12(abs).isFile()) return null;
|
|
79072
79053
|
accessSync(abs, constants.X_OK);
|
|
@@ -79081,7 +79062,7 @@ function resolveExternalCommand(explicit, searchNames) {
|
|
|
79081
79062
|
for (const dir of dirs) {
|
|
79082
79063
|
if (!dir) continue;
|
|
79083
79064
|
const candidate = resolve8(dir, name);
|
|
79084
|
-
if (!
|
|
79065
|
+
if (!existsSync32(candidate)) continue;
|
|
79085
79066
|
try {
|
|
79086
79067
|
if (!statSync12(candidate).isFile()) continue;
|
|
79087
79068
|
accessSync(candidate, constants.X_OK);
|
|
@@ -79136,7 +79117,7 @@ function looksLikeSecretArg(value) {
|
|
|
79136
79117
|
}
|
|
79137
79118
|
|
|
79138
79119
|
// src/session/harness-host.ts
|
|
79139
|
-
import { existsSync as
|
|
79120
|
+
import { existsSync as existsSync33 } from "node:fs";
|
|
79140
79121
|
init_src2();
|
|
79141
79122
|
init_claude_turn_runner();
|
|
79142
79123
|
init_codex_turn_runner();
|
|
@@ -79144,7 +79125,7 @@ init_resolve_service();
|
|
|
79144
79125
|
setHarnessReleaseVersionProvider(resolveCliReleaseVersion);
|
|
79145
79126
|
function envBinaryExists(envName) {
|
|
79146
79127
|
const v2 = process.env[envName]?.trim();
|
|
79147
|
-
return Boolean(v2 &&
|
|
79128
|
+
return Boolean(v2 && existsSync33(v2));
|
|
79148
79129
|
}
|
|
79149
79130
|
var cliHarnessResolver = {
|
|
79150
79131
|
resolveBinary(id, harnesses) {
|
|
@@ -79154,7 +79135,7 @@ var cliHarnessResolver = {
|
|
|
79154
79135
|
return null;
|
|
79155
79136
|
}
|
|
79156
79137
|
const command = harnesses.get(id).command;
|
|
79157
|
-
return command &&
|
|
79138
|
+
return command && existsSync33(command) ? command : null;
|
|
79158
79139
|
},
|
|
79159
79140
|
isRunnableWithoutCatalog(id) {
|
|
79160
79141
|
if (id === "claude") return isClaudeRuntimeRunnable();
|
|
@@ -79167,7 +79148,7 @@ var cliHarnessResolver = {
|
|
|
79167
79148
|
autoRuntime(id) {
|
|
79168
79149
|
if (id === "claude") {
|
|
79169
79150
|
const sdk = resolveSdkClaudeBinary();
|
|
79170
|
-
if (sdk &&
|
|
79151
|
+
if (sdk && existsSync33(sdk)) return { command: sdk, source: "agent-sdk-optional" };
|
|
79171
79152
|
return null;
|
|
79172
79153
|
}
|
|
79173
79154
|
const fromEnv = resolveCodexBinaryPath({});
|
|
@@ -79309,7 +79290,7 @@ async function startNodeServer2(opts) {
|
|
|
79309
79290
|
|
|
79310
79291
|
// src/terminal/manager.ts
|
|
79311
79292
|
import { createRequire as createRequire5 } from "node:module";
|
|
79312
|
-
import { existsSync as
|
|
79293
|
+
import { existsSync as existsSync34 } from "node:fs";
|
|
79313
79294
|
var nodeRequire = createRequire5(import.meta.url);
|
|
79314
79295
|
var { spawn: spawn5 } = nodeRequire("node-pty");
|
|
79315
79296
|
var SNAPSHOT_SOFT_LIMIT = 64 * 1024;
|
|
@@ -79324,7 +79305,7 @@ var NodeTerminalManager = class {
|
|
|
79324
79305
|
}
|
|
79325
79306
|
byId = /* @__PURE__ */ new Map();
|
|
79326
79307
|
create(opts) {
|
|
79327
|
-
if (!
|
|
79308
|
+
if (!existsSync34(opts.cwd)) {
|
|
79328
79309
|
throw Object.assign(new Error(`cwd does not exist: ${opts.cwd}`), { code: "invalid_argument" });
|
|
79329
79310
|
}
|
|
79330
79311
|
const terminalId = crypto.randomUUID();
|
|
@@ -79464,38 +79445,83 @@ var NodeTerminalManager = class {
|
|
|
79464
79445
|
};
|
|
79465
79446
|
|
|
79466
79447
|
// ../../packages/runtime/src/workspace/project-registry.ts
|
|
79467
|
-
import { basename as basename2, resolve as
|
|
79468
|
-
import { existsSync as
|
|
79448
|
+
import { basename as basename2, resolve as resolve10 } from "node:path";
|
|
79449
|
+
import { existsSync as existsSync35, realpathSync as realpathSync4, statSync as statSync13 } from "node:fs";
|
|
79469
79450
|
import { createHash as createHash7 } from "node:crypto";
|
|
79470
79451
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
79452
|
+
|
|
79453
|
+
// ../../packages/shared/src/project-extra-dirs.ts
|
|
79454
|
+
var MAX_PROJECT_EXTRA_DIRS = 16;
|
|
79455
|
+
function parseProjectExtraDirs(raw) {
|
|
79456
|
+
if (typeof raw !== "string" || !raw.trim()) return [];
|
|
79457
|
+
try {
|
|
79458
|
+
const parsed = JSON.parse(raw);
|
|
79459
|
+
if (!Array.isArray(parsed)) return [];
|
|
79460
|
+
return dedupeDirs(parsed.filter((d) => typeof d === "string" && d.trim().length > 0));
|
|
79461
|
+
} catch {
|
|
79462
|
+
return [];
|
|
79463
|
+
}
|
|
79464
|
+
}
|
|
79465
|
+
function dedupeDirs(dirs) {
|
|
79466
|
+
return [...new Set(dirs)];
|
|
79467
|
+
}
|
|
79468
|
+
function resolveProjectExtraDirs(current, patch) {
|
|
79469
|
+
if (patch.extraDirs !== void 0) return [...patch.extraDirs];
|
|
79470
|
+
if (patch.addExtraDirs === void 0 && patch.removeExtraDirs === void 0) return null;
|
|
79471
|
+
const removed = new Set(patch.removeExtraDirs ?? []);
|
|
79472
|
+
return [...current.filter((d) => !removed.has(d)), ...patch.addExtraDirs ?? []];
|
|
79473
|
+
}
|
|
79474
|
+
|
|
79475
|
+
// ../../packages/shared/src/project-extra-dirs-node.ts
|
|
79476
|
+
import { resolve as resolve9 } from "node:path";
|
|
79477
|
+
function normalizeProjectExtraDirs(dirs, projectPath) {
|
|
79478
|
+
const root = resolve9(projectPath);
|
|
79479
|
+
const normalized = dirs.filter((d) => typeof d === "string" && d.trim().length > 0).map((d) => resolve9(d.trim())).filter((d) => d !== root);
|
|
79480
|
+
return dedupeDirs(normalized).slice(0, MAX_PROJECT_EXTRA_DIRS);
|
|
79481
|
+
}
|
|
79482
|
+
|
|
79483
|
+
// ../../packages/runtime/src/workspace/project-registry.ts
|
|
79471
79484
|
var ProjectRegistry = class {
|
|
79472
79485
|
constructor(db) {
|
|
79473
79486
|
this.db = db;
|
|
79474
79487
|
}
|
|
79475
79488
|
list() {
|
|
79476
79489
|
const rows = this.db.prepare(
|
|
79477
|
-
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at FROM projects ORDER BY last_active_at DESC`
|
|
79490
|
+
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at, extra_dirs_json FROM projects ORDER BY last_active_at DESC`
|
|
79478
79491
|
).all();
|
|
79479
79492
|
return rows.map((r) => this.toSnapshot(r));
|
|
79480
79493
|
}
|
|
79481
79494
|
get(projectId) {
|
|
79482
79495
|
const r = this.db.prepare(
|
|
79483
|
-
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at FROM projects WHERE project_id = ?`
|
|
79496
|
+
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at, extra_dirs_json FROM projects WHERE project_id = ?`
|
|
79484
79497
|
).get(projectId);
|
|
79485
79498
|
if (!r) return null;
|
|
79486
79499
|
return this.toSnapshot(r);
|
|
79487
79500
|
}
|
|
79501
|
+
/**
|
|
79502
|
+
* `open()` stores the realpath, so a caller handing back the path the user
|
|
79503
|
+
* typed must be canonicalized the same way or it misses whenever a parent is
|
|
79504
|
+
* a symlink (`/var` on macOS). Belongs here rather than at each call site:
|
|
79505
|
+
* `update({ path })` and `remove({ path })` both take user-facing spellings.
|
|
79506
|
+
*/
|
|
79488
79507
|
getByPath(path) {
|
|
79489
|
-
const abs =
|
|
79508
|
+
const abs = resolve10(path);
|
|
79490
79509
|
const r = this.db.prepare(
|
|
79491
|
-
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at FROM projects WHERE path = ?`
|
|
79510
|
+
`SELECT project_id, path, name, repo_identity, opened_at, last_active_at, extra_dirs_json FROM projects WHERE path = ?`
|
|
79492
79511
|
).get(abs);
|
|
79493
|
-
if (
|
|
79494
|
-
|
|
79512
|
+
if (r) return this.toSnapshot(r);
|
|
79513
|
+
let real;
|
|
79514
|
+
try {
|
|
79515
|
+
real = realpathSync4(abs);
|
|
79516
|
+
} catch {
|
|
79517
|
+
return null;
|
|
79518
|
+
}
|
|
79519
|
+
if (real === abs) return null;
|
|
79520
|
+
return this.getByPath(real);
|
|
79495
79521
|
}
|
|
79496
79522
|
open(path, name) {
|
|
79497
|
-
let abs =
|
|
79498
|
-
if (!
|
|
79523
|
+
let abs = resolve10(path);
|
|
79524
|
+
if (!existsSync35(abs) || !statSync13(abs).isDirectory()) {
|
|
79499
79525
|
throw Object.assign(new Error(`project path is not a directory: ${abs}`), {
|
|
79500
79526
|
code: "invalid_argument"
|
|
79501
79527
|
});
|
|
@@ -79518,6 +79544,36 @@ var ProjectRegistry = class {
|
|
|
79518
79544
|
).run(projectId, abs, name || basename2(abs), repoIdentity, now, now);
|
|
79519
79545
|
return this.get(projectId);
|
|
79520
79546
|
}
|
|
79547
|
+
/**
|
|
79548
|
+
* Apply an Edit Project submission or an `/add-dir` delta.
|
|
79549
|
+
*
|
|
79550
|
+
* Both fields are optional and independent so one patch covers whatever the
|
|
79551
|
+
* user actually touched. Unlike `open()`, a name given here is authoritative:
|
|
79552
|
+
* it is an explicit rename, not a basename refresh.
|
|
79553
|
+
*/
|
|
79554
|
+
update(input) {
|
|
79555
|
+
const existing = input.projectId ? this.get(input.projectId) : input.path ? this.getByPath(input.path) : null;
|
|
79556
|
+
if (!existing) return null;
|
|
79557
|
+
let nextName = null;
|
|
79558
|
+
if (input.name !== void 0) {
|
|
79559
|
+
const trimmed = input.name.trim();
|
|
79560
|
+
if (!trimmed) {
|
|
79561
|
+
throw Object.assign(new Error("project name cannot be empty"), {
|
|
79562
|
+
code: "invalid_argument"
|
|
79563
|
+
});
|
|
79564
|
+
}
|
|
79565
|
+
nextName = trimmed.slice(0, 200);
|
|
79566
|
+
}
|
|
79567
|
+
const resolved = resolveProjectExtraDirs(existing.extraDirs ?? [], input);
|
|
79568
|
+
const nextExtraDirs = resolved === null ? null : JSON.stringify(normalizeProjectExtraDirs(resolved, existing.path));
|
|
79569
|
+
this.db.prepare(
|
|
79570
|
+
`UPDATE projects
|
|
79571
|
+
SET name = COALESCE(?, name),
|
|
79572
|
+
extra_dirs_json = COALESCE(?, extra_dirs_json)
|
|
79573
|
+
WHERE project_id = ?`
|
|
79574
|
+
).run(nextName, nextExtraDirs, existing.projectId);
|
|
79575
|
+
return this.get(existing.projectId);
|
|
79576
|
+
}
|
|
79521
79577
|
touch(projectId) {
|
|
79522
79578
|
this.db.prepare(`UPDATE projects SET last_active_at = ? WHERE project_id = ?`).run(Date.now(), projectId);
|
|
79523
79579
|
}
|
|
@@ -79548,6 +79604,7 @@ var ProjectRegistry = class {
|
|
|
79548
79604
|
path: r.path,
|
|
79549
79605
|
name: r.name,
|
|
79550
79606
|
...missing ? { missing: true } : {},
|
|
79607
|
+
extraDirs: parseProjectExtraDirs(r.extra_dirs_json),
|
|
79551
79608
|
repoIdentity: r.repo_identity,
|
|
79552
79609
|
openedAt: r.opened_at ?? void 0,
|
|
79553
79610
|
lastActiveAt: r.last_active_at ?? void 0
|
|
@@ -79569,7 +79626,7 @@ function detectRepoIdentity(abs) {
|
|
|
79569
79626
|
if (remote) return `git:${remote}`;
|
|
79570
79627
|
} catch {
|
|
79571
79628
|
}
|
|
79572
|
-
return `gitdir:${
|
|
79629
|
+
return `gitdir:${resolve10(abs, out)}`;
|
|
79573
79630
|
} catch {
|
|
79574
79631
|
return null;
|
|
79575
79632
|
}
|
|
@@ -79579,20 +79636,20 @@ function detectRepoIdentity(abs) {
|
|
|
79579
79636
|
init_fs();
|
|
79580
79637
|
import {
|
|
79581
79638
|
closeSync,
|
|
79582
|
-
existsSync as
|
|
79639
|
+
existsSync as existsSync36,
|
|
79583
79640
|
fstatSync,
|
|
79584
|
-
mkdirSync as
|
|
79641
|
+
mkdirSync as mkdirSync20,
|
|
79585
79642
|
openSync,
|
|
79586
79643
|
readSync,
|
|
79587
79644
|
readdirSync as readdirSync11,
|
|
79588
|
-
readFileSync as
|
|
79645
|
+
readFileSync as readFileSync18,
|
|
79589
79646
|
renameSync as renameSync5,
|
|
79590
79647
|
rmSync as rmSync7,
|
|
79591
79648
|
statSync as statSync14,
|
|
79592
79649
|
unlinkSync,
|
|
79593
|
-
writeFileSync as
|
|
79650
|
+
writeFileSync as writeFileSync15
|
|
79594
79651
|
} from "node:fs";
|
|
79595
|
-
import { dirname as
|
|
79652
|
+
import { dirname as dirname16, join as join28, relative as relative2 } from "node:path";
|
|
79596
79653
|
import { createHash as createHash8 } from "node:crypto";
|
|
79597
79654
|
function normalizeRel(path) {
|
|
79598
79655
|
return path.replace(/\\/g, "/").replace(/\/+$/, "") || ".";
|
|
@@ -79638,7 +79695,7 @@ var WorkspaceFsService = class {
|
|
|
79638
79695
|
if (!resolved.ok) {
|
|
79639
79696
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
79640
79697
|
}
|
|
79641
|
-
if (!
|
|
79698
|
+
if (!existsSync36(resolved.absolutePath)) {
|
|
79642
79699
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
79643
79700
|
}
|
|
79644
79701
|
const st = statSync14(resolved.absolutePath);
|
|
@@ -79648,7 +79705,7 @@ var WorkspaceFsService = class {
|
|
|
79648
79705
|
this.projects.touch(projectId);
|
|
79649
79706
|
const ents = readdirSync11(resolved.absolutePath, { withFileTypes: true });
|
|
79650
79707
|
return ents.map((ent) => {
|
|
79651
|
-
const abs =
|
|
79708
|
+
const abs = join28(resolved.absolutePath, ent.name);
|
|
79652
79709
|
let size;
|
|
79653
79710
|
let mtimeMs;
|
|
79654
79711
|
try {
|
|
@@ -79673,7 +79730,7 @@ var WorkspaceFsService = class {
|
|
|
79673
79730
|
if (!resolved.ok) {
|
|
79674
79731
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
79675
79732
|
}
|
|
79676
|
-
if (!
|
|
79733
|
+
if (!existsSync36(resolved.absolutePath)) {
|
|
79677
79734
|
throw Object.assign(new Error("file not found"), { code: "not_found" });
|
|
79678
79735
|
}
|
|
79679
79736
|
const st = statSync14(resolved.absolutePath);
|
|
@@ -79712,7 +79769,7 @@ var WorkspaceFsService = class {
|
|
|
79712
79769
|
if (!resolved.ok) {
|
|
79713
79770
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
79714
79771
|
}
|
|
79715
|
-
if (
|
|
79772
|
+
if (existsSync36(resolved.absolutePath) && expectedHash) {
|
|
79716
79773
|
const st = statSync14(resolved.absolutePath);
|
|
79717
79774
|
if (st.size > MAX_READ_BYTES) {
|
|
79718
79775
|
throw Object.assign(
|
|
@@ -79725,13 +79782,13 @@ var WorkspaceFsService = class {
|
|
|
79725
79782
|
throw Object.assign(new Error("content hash mismatch"), { code: "conflict" });
|
|
79726
79783
|
}
|
|
79727
79784
|
}
|
|
79728
|
-
|
|
79785
|
+
mkdirSync20(dirname16(resolved.absolutePath), { recursive: true });
|
|
79729
79786
|
const data = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content);
|
|
79730
79787
|
if (data.length > MAX_READ_BYTES) {
|
|
79731
79788
|
throw Object.assign(new Error("write payload too large"), { code: "invalid_argument" });
|
|
79732
79789
|
}
|
|
79733
79790
|
let mode = 384;
|
|
79734
|
-
if (
|
|
79791
|
+
if (existsSync36(resolved.absolutePath)) {
|
|
79735
79792
|
try {
|
|
79736
79793
|
mode = statSync14(resolved.absolutePath).mode & 511;
|
|
79737
79794
|
} catch {
|
|
@@ -79740,7 +79797,7 @@ var WorkspaceFsService = class {
|
|
|
79740
79797
|
const tmp = `${resolved.absolutePath}.tmp-${crypto.randomUUID()}`;
|
|
79741
79798
|
let renamed = false;
|
|
79742
79799
|
try {
|
|
79743
|
-
|
|
79800
|
+
writeFileSync15(tmp, data, { mode });
|
|
79744
79801
|
const again = resolveProjectPath(root, relativePath);
|
|
79745
79802
|
if (!again.ok || again.absolutePath !== resolved.absolutePath) {
|
|
79746
79803
|
throw Object.assign(new Error("path changed during write"), { code: "failed_precondition" });
|
|
@@ -79801,7 +79858,7 @@ var WorkspaceFsService = class {
|
|
|
79801
79858
|
for (const ent of ents) {
|
|
79802
79859
|
if (hits.length >= MAX_SEARCH_HITS) return;
|
|
79803
79860
|
if (ent.name === ".git" || ent.name === "node_modules") continue;
|
|
79804
|
-
const abs =
|
|
79861
|
+
const abs = join28(dir, ent.name);
|
|
79805
79862
|
const rel = relative2(root, abs).split("\\").join("/");
|
|
79806
79863
|
const check2 = resolveProjectPath(root, rel);
|
|
79807
79864
|
if (!check2.ok) continue;
|
|
@@ -79813,7 +79870,7 @@ var WorkspaceFsService = class {
|
|
|
79813
79870
|
try {
|
|
79814
79871
|
const st = statSync14(abs);
|
|
79815
79872
|
if (st.size > MAX_SEARCH_FILE_BYTES) continue;
|
|
79816
|
-
const text =
|
|
79873
|
+
const text = readFileSync18(abs, "utf8");
|
|
79817
79874
|
const lines = text.split(/\r?\n/);
|
|
79818
79875
|
for (let i = 0; i < lines.length; i++) {
|
|
79819
79876
|
if (lines[i].includes(query)) {
|
|
@@ -79875,7 +79932,7 @@ var WorkspaceFsService = class {
|
|
|
79875
79932
|
if (!resolved.ok) {
|
|
79876
79933
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
79877
79934
|
}
|
|
79878
|
-
if (
|
|
79935
|
+
if (existsSync36(resolved.absolutePath)) {
|
|
79879
79936
|
const st = statSync14(resolved.absolutePath);
|
|
79880
79937
|
if (!st.isDirectory()) {
|
|
79881
79938
|
throw Object.assign(new Error("path exists and is not a directory"), { code: "conflict" });
|
|
@@ -79883,7 +79940,7 @@ var WorkspaceFsService = class {
|
|
|
79883
79940
|
this.projects.touch(projectId);
|
|
79884
79941
|
return { path: rel };
|
|
79885
79942
|
}
|
|
79886
|
-
|
|
79943
|
+
mkdirSync20(resolved.absolutePath, { recursive: true });
|
|
79887
79944
|
this.projects.touch(projectId);
|
|
79888
79945
|
return { path: rel };
|
|
79889
79946
|
}
|
|
@@ -79898,7 +79955,7 @@ var WorkspaceFsService = class {
|
|
|
79898
79955
|
if (!resolved.ok) {
|
|
79899
79956
|
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
79900
79957
|
}
|
|
79901
|
-
if (!
|
|
79958
|
+
if (!existsSync36(resolved.absolutePath)) {
|
|
79902
79959
|
throw Object.assign(new Error("path not found"), { code: "not_found" });
|
|
79903
79960
|
}
|
|
79904
79961
|
if (resolved.absolutePath === root) {
|
|
@@ -79922,19 +79979,19 @@ var WorkspaceFsService = class {
|
|
|
79922
79979
|
if (!from.ok) {
|
|
79923
79980
|
throw Object.assign(new Error(from.reason), { code: "invalid_argument" });
|
|
79924
79981
|
}
|
|
79925
|
-
if (!
|
|
79982
|
+
if (!existsSync36(from.absolutePath)) {
|
|
79926
79983
|
throw Object.assign(new Error("source not found"), { code: "not_found" });
|
|
79927
79984
|
}
|
|
79928
79985
|
const to = resolveProjectPath(root, toN);
|
|
79929
79986
|
if (!to.ok) {
|
|
79930
79987
|
throw Object.assign(new Error(to.reason), { code: "invalid_argument" });
|
|
79931
79988
|
}
|
|
79932
|
-
if (
|
|
79989
|
+
if (existsSync36(to.absolutePath)) {
|
|
79933
79990
|
throw Object.assign(new Error(`target already exists: ${baseNameRel(toN)}`), {
|
|
79934
79991
|
code: "conflict"
|
|
79935
79992
|
});
|
|
79936
79993
|
}
|
|
79937
|
-
|
|
79994
|
+
mkdirSync20(dirname16(to.absolutePath), { recursive: true });
|
|
79938
79995
|
renameSync5(from.absolutePath, to.absolutePath);
|
|
79939
79996
|
this.projects.touch(projectId);
|
|
79940
79997
|
return { from: fromN, to: toN };
|
|
@@ -79959,8 +80016,8 @@ function hashFileBounded(absolutePath, size) {
|
|
|
79959
80016
|
}
|
|
79960
80017
|
|
|
79961
80018
|
// src/workspace/git-service.ts
|
|
79962
|
-
import { existsSync as
|
|
79963
|
-
import { join as
|
|
80019
|
+
import { existsSync as existsSync37, mkdirSync as mkdirSync21, realpathSync as realpathSync5, rmSync as rmSync8, writeFileSync as writeFileSync16 } from "node:fs";
|
|
80020
|
+
import { join as join30, resolve as resolve12 } from "node:path";
|
|
79964
80021
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
79965
80022
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
79966
80023
|
|
|
@@ -80037,19 +80094,19 @@ function gitRunSync(folderPath, args, env) {
|
|
|
80037
80094
|
}
|
|
80038
80095
|
|
|
80039
80096
|
// ../../packages/runtime/src/git/worktree-plan.ts
|
|
80040
|
-
import { basename as basename3, dirname as
|
|
80097
|
+
import { basename as basename3, dirname as dirname17, join as join29, resolve as resolve11, sep as sep4 } from "node:path";
|
|
80041
80098
|
import { homedir as homedir8 } from "node:os";
|
|
80042
80099
|
function resolveMainDirFromCommonDir(folderPath, gitCommonDir) {
|
|
80043
|
-
const repoRoot =
|
|
80044
|
-
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ?
|
|
80100
|
+
const repoRoot = resolve11(folderPath, gitCommonDir.trim());
|
|
80101
|
+
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname17(repoRoot) : repoRoot;
|
|
80045
80102
|
}
|
|
80046
80103
|
function planNewWorktreePaths(input) {
|
|
80047
80104
|
const home = input.homeDir ?? homedir8();
|
|
80048
80105
|
const repoName = basename3(input.mainDir);
|
|
80049
80106
|
const epoch = Math.floor((input.nowMs ?? Date.now()) / 1e3).toString(36);
|
|
80050
80107
|
const short = input.shortHash.slice(0, 7);
|
|
80051
|
-
const wtDir =
|
|
80052
|
-
const wtPath =
|
|
80108
|
+
const wtDir = join29(home, ".worktrees", repoName);
|
|
80109
|
+
const wtPath = join29(wtDir, `${epoch}-${short}`);
|
|
80053
80110
|
return { wtDir, wtPath };
|
|
80054
80111
|
}
|
|
80055
80112
|
function worktreeAddArgs(mode, wtPath, baseRef, branchName) {
|
|
@@ -80108,11 +80165,11 @@ function resolveMainWorktreeDir(folderPath) {
|
|
|
80108
80165
|
}
|
|
80109
80166
|
function samePath(a, b2) {
|
|
80110
80167
|
try {
|
|
80111
|
-
const ra =
|
|
80112
|
-
const rb =
|
|
80168
|
+
const ra = existsSync37(a) ? realpathSync5(a) : resolve12(a);
|
|
80169
|
+
const rb = existsSync37(b2) ? realpathSync5(b2) : resolve12(b2);
|
|
80113
80170
|
return ra === rb;
|
|
80114
80171
|
} catch {
|
|
80115
|
-
return
|
|
80172
|
+
return resolve12(a) === resolve12(b2);
|
|
80116
80173
|
}
|
|
80117
80174
|
}
|
|
80118
80175
|
var WorkspaceGitService = class {
|
|
@@ -80141,7 +80198,7 @@ var WorkspaceGitService = class {
|
|
|
80141
80198
|
* --ignored walks the whole tree of ignored paths and dominates remote latency.
|
|
80142
80199
|
*/
|
|
80143
80200
|
statusForCwd(cwd) {
|
|
80144
|
-
if (!
|
|
80201
|
+
if (!existsSync37(join30(cwd, ".git")) && !isGitWorktree(cwd)) {
|
|
80145
80202
|
return { isRepo: false, branch: null, dirty: false, ahead: 0, behind: 0, porcelain: "" };
|
|
80146
80203
|
}
|
|
80147
80204
|
try {
|
|
@@ -80248,19 +80305,19 @@ var WorkspaceGitService = class {
|
|
|
80248
80305
|
if (worktreePath.includes("\0") || worktreePath.includes("..")) {
|
|
80249
80306
|
throw Object.assign(new Error("invalid worktree path"), { code: "invalid_argument" });
|
|
80250
80307
|
}
|
|
80251
|
-
const abs =
|
|
80252
|
-
const main2 =
|
|
80253
|
-
if (samePath(abs, main2)) return
|
|
80308
|
+
const abs = resolve12(worktreePath);
|
|
80309
|
+
const main2 = resolve12(this.root(projectId));
|
|
80310
|
+
if (samePath(abs, main2)) return existsSync37(abs) ? realpathSync5(abs) : abs;
|
|
80254
80311
|
const listed = this.worktrees(projectId);
|
|
80255
80312
|
for (const wt of listed) {
|
|
80256
80313
|
if (samePath(abs, wt.path)) {
|
|
80257
|
-
return
|
|
80314
|
+
return existsSync37(abs) ? realpathSync5(abs) : resolve12(wt.path);
|
|
80258
80315
|
}
|
|
80259
80316
|
}
|
|
80260
80317
|
try {
|
|
80261
|
-
if (
|
|
80262
|
-
const commonA =
|
|
80263
|
-
const commonB =
|
|
80318
|
+
if (existsSync37(abs) && isGitWorktree(abs)) {
|
|
80319
|
+
const commonA = resolve12(abs, git(abs, ["rev-parse", "--git-common-dir"]).trim());
|
|
80320
|
+
const commonB = resolve12(main2, git(main2, ["rev-parse", "--git-common-dir"]).trim());
|
|
80264
80321
|
if (samePath(commonA, commonB)) {
|
|
80265
80322
|
return realpathSync5(abs);
|
|
80266
80323
|
}
|
|
@@ -80300,7 +80357,7 @@ var WorkspaceGitService = class {
|
|
|
80300
80357
|
mainDir,
|
|
80301
80358
|
shortHash: commitHash.slice(0, 7)
|
|
80302
80359
|
});
|
|
80303
|
-
if (!
|
|
80360
|
+
if (!existsSync37(wtDir)) mkdirSync21(wtDir, { recursive: true });
|
|
80304
80361
|
try {
|
|
80305
80362
|
const addArgs = worktreeAddArgs(mode, wtPath, baseBranch, safeBranchName);
|
|
80306
80363
|
git(folderPath, ["worktree", ...addArgs]);
|
|
@@ -80396,8 +80453,8 @@ var WorkspaceGitService = class {
|
|
|
80396
80453
|
const mainStatus = git(diff.mainDir, ["status", "--porcelain"]).trim();
|
|
80397
80454
|
if (mainStatus) return { ok: false, reason: "main-dirty" };
|
|
80398
80455
|
const patch = git(diff.worktreePath, ["diff", "--binary", diff.base, diff.tree]);
|
|
80399
|
-
const patchFile =
|
|
80400
|
-
|
|
80456
|
+
const patchFile = join30(tmpdir3(), `s1-handoff-${randomUUID8()}.patch`);
|
|
80457
|
+
writeFileSync16(patchFile, `${patch}
|
|
80401
80458
|
`);
|
|
80402
80459
|
if (git(diff.mainDir, ["status", "--porcelain"]).trim()) {
|
|
80403
80460
|
rmSync8(patchFile, { force: true });
|
|
@@ -80458,7 +80515,7 @@ var WorkspaceGitService = class {
|
|
|
80458
80515
|
};
|
|
80459
80516
|
}
|
|
80460
80517
|
writeWorkingTree(worktreePath) {
|
|
80461
|
-
const tmpIndex =
|
|
80518
|
+
const tmpIndex = join30(tmpdir3(), `s1-handoff-${randomUUID8()}.index`);
|
|
80462
80519
|
const env = { GIT_INDEX_FILE: tmpIndex };
|
|
80463
80520
|
try {
|
|
80464
80521
|
git(worktreePath, ["read-tree", "HEAD"], env);
|
|
@@ -80654,7 +80711,7 @@ init_codex_turn_runner();
|
|
|
80654
80711
|
init_agent_types();
|
|
80655
80712
|
init_environment();
|
|
80656
80713
|
import { createHash as createHash9, randomBytes as randomBytes5, randomUUID as randomUUID10 } from "node:crypto";
|
|
80657
|
-
import { existsSync as
|
|
80714
|
+
import { existsSync as existsSync38, statSync as statSync15 } from "node:fs";
|
|
80658
80715
|
import { resolve as pathResolve2 } from "node:path";
|
|
80659
80716
|
|
|
80660
80717
|
// ../../packages/shared/src/harness/acp-brand.ts
|
|
@@ -81650,7 +81707,7 @@ var CollaborationService = class {
|
|
|
81650
81707
|
const project = this.deps.projects.get(projectId);
|
|
81651
81708
|
const fallback = parentCwd || project?.path || process.cwd();
|
|
81652
81709
|
const cwd = pathResolve2(config2.cwd || fallback);
|
|
81653
|
-
if (!
|
|
81710
|
+
if (!existsSync38(cwd) || !statSync15(cwd).isDirectory()) {
|
|
81654
81711
|
throw Object.assign(new Error(`Working directory does not exist: ${cwd}`), {
|
|
81655
81712
|
code: "invalid_argument"
|
|
81656
81713
|
});
|
|
@@ -81802,8 +81859,8 @@ var CollaborationService = class {
|
|
|
81802
81859
|
};
|
|
81803
81860
|
|
|
81804
81861
|
// src/provider/secret-crypto.ts
|
|
81805
|
-
import { existsSync as
|
|
81806
|
-
import { dirname as
|
|
81862
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync22, readFileSync as readFileSync19, writeFileSync as writeFileSync17, chmodSync as chmodSync2 } from "node:fs";
|
|
81863
|
+
import { dirname as dirname18 } from "node:path";
|
|
81807
81864
|
import { createCipheriv, createDecipheriv, randomBytes as randomBytes6 } from "node:crypto";
|
|
81808
81865
|
var ENC_PREFIX2 = "enc:v1:";
|
|
81809
81866
|
var KEY_BYTES = 32;
|
|
@@ -81811,13 +81868,13 @@ function isEncryptedSecret(value) {
|
|
|
81811
81868
|
return typeof value === "string" && value.startsWith(ENC_PREFIX2);
|
|
81812
81869
|
}
|
|
81813
81870
|
function ensureKeyFile(keyPath) {
|
|
81814
|
-
if (
|
|
81815
|
-
const raw =
|
|
81871
|
+
if (existsSync39(keyPath)) {
|
|
81872
|
+
const raw = readFileSync19(keyPath);
|
|
81816
81873
|
if (raw.length === KEY_BYTES) return raw;
|
|
81817
81874
|
}
|
|
81818
|
-
|
|
81875
|
+
mkdirSync22(dirname18(keyPath), { recursive: true, mode: 448 });
|
|
81819
81876
|
const key = randomBytes6(KEY_BYTES);
|
|
81820
|
-
|
|
81877
|
+
writeFileSync17(keyPath, key, { mode: 384 });
|
|
81821
81878
|
try {
|
|
81822
81879
|
chmodSync2(keyPath, 384);
|
|
81823
81880
|
} catch {
|
|
@@ -81899,9 +81956,9 @@ var WorkspaceWatchService = class {
|
|
|
81899
81956
|
try {
|
|
81900
81957
|
while (!closed) {
|
|
81901
81958
|
if (queue.length === 0) {
|
|
81902
|
-
await new Promise((
|
|
81903
|
-
wake =
|
|
81904
|
-
setTimeout(() =>
|
|
81959
|
+
await new Promise((resolve15) => {
|
|
81960
|
+
wake = resolve15;
|
|
81961
|
+
setTimeout(() => resolve15(), 100);
|
|
81905
81962
|
});
|
|
81906
81963
|
wake = null;
|
|
81907
81964
|
continue;
|
|
@@ -81959,7 +82016,7 @@ var WorkspaceWatchService = class {
|
|
|
81959
82016
|
|
|
81960
82017
|
// src/workspace/tail-watch-service.ts
|
|
81961
82018
|
init_fs();
|
|
81962
|
-
import { existsSync as
|
|
82019
|
+
import { existsSync as existsSync40, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync16, readSync as readSync2, realpathSync as realpathSync6 } from "node:fs";
|
|
81963
82020
|
var MAX_POLL_BYTES = 10 * 1024 * 1024;
|
|
81964
82021
|
var WorkspaceTailWatchService = class {
|
|
81965
82022
|
constructor(projects, fs) {
|
|
@@ -81981,7 +82038,7 @@ var WorkspaceTailWatchService = class {
|
|
|
81981
82038
|
);
|
|
81982
82039
|
}
|
|
81983
82040
|
try {
|
|
81984
|
-
resolvedAbs =
|
|
82041
|
+
resolvedAbs = existsSync40(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
|
|
81985
82042
|
} catch {
|
|
81986
82043
|
resolvedAbs = absolutePath;
|
|
81987
82044
|
}
|
|
@@ -82012,7 +82069,7 @@ var WorkspaceTailWatchService = class {
|
|
|
82012
82069
|
code: "invalid_argument"
|
|
82013
82070
|
});
|
|
82014
82071
|
}
|
|
82015
|
-
if (
|
|
82072
|
+
if (existsSync40(resolvedAbs)) {
|
|
82016
82073
|
try {
|
|
82017
82074
|
const st = statSync16(resolvedAbs);
|
|
82018
82075
|
if (!st.isFile()) {
|
|
@@ -82063,7 +82120,7 @@ var WorkspaceTailWatchService = class {
|
|
|
82063
82120
|
{ code: "invalid_argument" }
|
|
82064
82121
|
);
|
|
82065
82122
|
}
|
|
82066
|
-
if (!
|
|
82123
|
+
if (!existsSync40(absolutePath)) {
|
|
82067
82124
|
return {
|
|
82068
82125
|
content: "",
|
|
82069
82126
|
encoding: "base64",
|
|
@@ -82909,7 +82966,7 @@ var readBodyDirect = (request) => {
|
|
|
82909
82966
|
request[bodyBufferKey] = buffered;
|
|
82910
82967
|
return Promise.resolve(buffered);
|
|
82911
82968
|
}
|
|
82912
|
-
const promise2 = new Promise((
|
|
82969
|
+
const promise2 = new Promise((resolve15, reject) => {
|
|
82913
82970
|
const chunks = [];
|
|
82914
82971
|
let settled = false;
|
|
82915
82972
|
const finish = (callback) => {
|
|
@@ -82927,7 +82984,7 @@ var readBodyDirect = (request) => {
|
|
|
82927
82984
|
else if (recovered === void 0) reject(error51 ?? normalizeAbortError(request, incoming));
|
|
82928
82985
|
else {
|
|
82929
82986
|
request[bodyBufferKey] = recovered;
|
|
82930
|
-
|
|
82987
|
+
resolve15(recovered);
|
|
82931
82988
|
}
|
|
82932
82989
|
});
|
|
82933
82990
|
return true;
|
|
@@ -82939,7 +82996,7 @@ var readBodyDirect = (request) => {
|
|
|
82939
82996
|
finish(() => {
|
|
82940
82997
|
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
82941
82998
|
request[bodyBufferKey] = buffer;
|
|
82942
|
-
|
|
82999
|
+
resolve15(buffer);
|
|
82943
83000
|
});
|
|
82944
83001
|
};
|
|
82945
83002
|
const onError = (error51) => {
|
|
@@ -83464,7 +83521,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
83464
83521
|
});
|
|
83465
83522
|
if (!chunk) {
|
|
83466
83523
|
if (i === 1) {
|
|
83467
|
-
await new Promise((
|
|
83524
|
+
await new Promise((resolve15) => setTimeout(resolve15));
|
|
83468
83525
|
maxReadCount = 3;
|
|
83469
83526
|
continue;
|
|
83470
83527
|
}
|
|
@@ -85678,9 +85735,9 @@ data:
|
|
|
85678
85735
|
const initRequest = messages.find((m2) => isInitializeRequest(m2));
|
|
85679
85736
|
const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
|
|
85680
85737
|
if (this._enableJsonResponse) {
|
|
85681
|
-
return new Promise((
|
|
85738
|
+
return new Promise((resolve15) => {
|
|
85682
85739
|
this._streamMapping.set(streamId, {
|
|
85683
|
-
resolveJson:
|
|
85740
|
+
resolveJson: resolve15,
|
|
85684
85741
|
cleanup: () => {
|
|
85685
85742
|
this._streamMapping.delete(streamId);
|
|
85686
85743
|
}
|
|
@@ -91997,7 +92054,7 @@ var Protocol = class {
|
|
|
91997
92054
|
return;
|
|
91998
92055
|
}
|
|
91999
92056
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
92000
|
-
await new Promise((
|
|
92057
|
+
await new Promise((resolve15) => setTimeout(resolve15, pollInterval));
|
|
92001
92058
|
options?.signal?.throwIfAborted();
|
|
92002
92059
|
}
|
|
92003
92060
|
} catch (error51) {
|
|
@@ -92014,7 +92071,7 @@ var Protocol = class {
|
|
|
92014
92071
|
*/
|
|
92015
92072
|
request(request, resultSchema, options) {
|
|
92016
92073
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
92017
|
-
return new Promise((
|
|
92074
|
+
return new Promise((resolve15, reject) => {
|
|
92018
92075
|
const earlyReject = (error51) => {
|
|
92019
92076
|
reject(error51);
|
|
92020
92077
|
};
|
|
@@ -92092,7 +92149,7 @@ var Protocol = class {
|
|
|
92092
92149
|
if (!parseResult.success) {
|
|
92093
92150
|
reject(parseResult.error);
|
|
92094
92151
|
} else {
|
|
92095
|
-
|
|
92152
|
+
resolve15(parseResult.data);
|
|
92096
92153
|
}
|
|
92097
92154
|
} catch (error51) {
|
|
92098
92155
|
reject(error51);
|
|
@@ -92353,12 +92410,12 @@ var Protocol = class {
|
|
|
92353
92410
|
}
|
|
92354
92411
|
} catch {
|
|
92355
92412
|
}
|
|
92356
|
-
return new Promise((
|
|
92413
|
+
return new Promise((resolve15, reject) => {
|
|
92357
92414
|
if (signal.aborted) {
|
|
92358
92415
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
92359
92416
|
return;
|
|
92360
92417
|
}
|
|
92361
|
-
const timeoutId = setTimeout(
|
|
92418
|
+
const timeoutId = setTimeout(resolve15, interval);
|
|
92362
92419
|
signal.addEventListener("abort", () => {
|
|
92363
92420
|
clearTimeout(timeoutId);
|
|
92364
92421
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -93453,7 +93510,7 @@ var McpServer = class {
|
|
|
93453
93510
|
let task = createTaskResult.task;
|
|
93454
93511
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
93455
93512
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
93456
|
-
await new Promise((
|
|
93513
|
+
await new Promise((resolve15) => setTimeout(resolve15, pollInterval));
|
|
93457
93514
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
93458
93515
|
if (!updatedTask) {
|
|
93459
93516
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -94469,11 +94526,11 @@ async function startHostActionMcpServer(opts) {
|
|
|
94469
94526
|
writeHttpError(res, 500, err instanceof Error ? err.message : "Internal MCP server error");
|
|
94470
94527
|
}
|
|
94471
94528
|
}
|
|
94472
|
-
await new Promise((
|
|
94529
|
+
await new Promise((resolve15, reject) => {
|
|
94473
94530
|
httpServer.once("error", reject);
|
|
94474
94531
|
httpServer.listen(0, "127.0.0.1", () => {
|
|
94475
94532
|
httpServer.off("error", reject);
|
|
94476
|
-
|
|
94533
|
+
resolve15();
|
|
94477
94534
|
});
|
|
94478
94535
|
});
|
|
94479
94536
|
const address = httpServer.address();
|
|
@@ -94526,8 +94583,8 @@ async function startHostActionMcpServer(opts) {
|
|
|
94526
94583
|
}
|
|
94527
94584
|
httpSessions.clear();
|
|
94528
94585
|
httpSessionsBySuperone.clear();
|
|
94529
|
-
await new Promise((
|
|
94530
|
-
httpServer.close(() =>
|
|
94586
|
+
await new Promise((resolve15) => {
|
|
94587
|
+
httpServer.close(() => resolve15());
|
|
94531
94588
|
});
|
|
94532
94589
|
}
|
|
94533
94590
|
};
|
|
@@ -95858,7 +95915,7 @@ async function startNodeRuntime(partial2 = {}) {
|
|
|
95858
95915
|
startedAt,
|
|
95859
95916
|
simulatedHarness
|
|
95860
95917
|
});
|
|
95861
|
-
|
|
95918
|
+
writeFileSync18(
|
|
95862
95919
|
paths.runtimeJson,
|
|
95863
95920
|
JSON.stringify(
|
|
95864
95921
|
{
|
|
@@ -95933,9 +95990,9 @@ function createLocalPairingToken(nodeHome) {
|
|
|
95933
95990
|
}
|
|
95934
95991
|
function readRuntimeStatus(nodeHome) {
|
|
95935
95992
|
const paths = nodePaths(resolveRuntimeConfig({ nodeHome }).nodeHome);
|
|
95936
|
-
if (!
|
|
95993
|
+
if (!existsSync41(paths.runtimeJson)) return null;
|
|
95937
95994
|
try {
|
|
95938
|
-
return JSON.parse(
|
|
95995
|
+
return JSON.parse(readFileSync20(paths.runtimeJson, "utf8"));
|
|
95939
95996
|
} catch {
|
|
95940
95997
|
return null;
|
|
95941
95998
|
}
|
|
@@ -95943,8 +96000,8 @@ function readRuntimeStatus(nodeHome) {
|
|
|
95943
96000
|
|
|
95944
96001
|
// src/systemd/install.ts
|
|
95945
96002
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
95946
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
95947
|
-
import { dirname as
|
|
96003
|
+
import { chmodSync as chmodSync3, existsSync as existsSync42, mkdirSync as mkdirSync23, unlinkSync as unlinkSync2, writeFileSync as writeFileSync19 } from "node:fs";
|
|
96004
|
+
import { dirname as dirname19 } from "node:path";
|
|
95948
96005
|
|
|
95949
96006
|
// src/systemd/unit.ts
|
|
95950
96007
|
function renderSystemdUserUnit(opts) {
|
|
@@ -96001,8 +96058,8 @@ function checkLinger(user) {
|
|
|
96001
96058
|
return { enabled: null, raw };
|
|
96002
96059
|
}
|
|
96003
96060
|
function writeSystemdUserUnit(opts, unitPath = systemdUserUnitPath()) {
|
|
96004
|
-
|
|
96005
|
-
|
|
96061
|
+
mkdirSync23(dirname19(unitPath), { recursive: true });
|
|
96062
|
+
writeFileSync19(unitPath, renderSystemdUserUnit(opts), { encoding: "utf8", mode: 420 });
|
|
96006
96063
|
try {
|
|
96007
96064
|
chmodSync3(unitPath, 420);
|
|
96008
96065
|
} catch {
|
|
@@ -96055,7 +96112,7 @@ function uninstallSystemdUserService(removeUnitFile = true) {
|
|
|
96055
96112
|
}
|
|
96056
96113
|
if (removeUnitFile) {
|
|
96057
96114
|
const path = systemdUserUnitPath();
|
|
96058
|
-
if (
|
|
96115
|
+
if (existsSync42(path)) {
|
|
96059
96116
|
try {
|
|
96060
96117
|
unlinkSync2(path);
|
|
96061
96118
|
} catch (err) {
|
|
@@ -96078,8 +96135,8 @@ function systemdUserStatus() {
|
|
|
96078
96135
|
|
|
96079
96136
|
// src/session/harness-cli.ts
|
|
96080
96137
|
init_environment();
|
|
96081
|
-
import { accessSync as accessSync2, constants as constants3, existsSync as
|
|
96082
|
-
import { isAbsolute as isAbsolute5, resolve as
|
|
96138
|
+
import { accessSync as accessSync2, constants as constants3, existsSync as existsSync43, realpathSync as realpathSync7, statSync as statSync17 } from "node:fs";
|
|
96139
|
+
import { isAbsolute as isAbsolute5, resolve as resolve13 } from "node:path";
|
|
96083
96140
|
import { homedir as homedir9 } from "node:os";
|
|
96084
96141
|
var DEFERRED_FLAGS = /* @__PURE__ */ new Set([
|
|
96085
96142
|
"--env-file",
|
|
@@ -96619,7 +96676,7 @@ function resolveExternalCommand2(explicit, pathCandidates) {
|
|
|
96619
96676
|
];
|
|
96620
96677
|
for (const name of pathCandidates) {
|
|
96621
96678
|
for (const dir of [...dirs, ...extra]) {
|
|
96622
|
-
const candidate =
|
|
96679
|
+
const candidate = resolve13(dir, name);
|
|
96623
96680
|
const ok = isUsableExecutable(candidate);
|
|
96624
96681
|
if (ok) return ok;
|
|
96625
96682
|
}
|
|
@@ -96627,7 +96684,7 @@ function resolveExternalCommand2(explicit, pathCandidates) {
|
|
|
96627
96684
|
return null;
|
|
96628
96685
|
}
|
|
96629
96686
|
function isUsableExecutable(path) {
|
|
96630
|
-
if (!
|
|
96687
|
+
if (!existsSync43(path)) return null;
|
|
96631
96688
|
let st;
|
|
96632
96689
|
try {
|
|
96633
96690
|
st = statSync17(path);
|
|
@@ -96647,7 +96704,7 @@ function isUsableExecutable(path) {
|
|
|
96647
96704
|
}
|
|
96648
96705
|
}
|
|
96649
96706
|
function probeExecutableIssues(path) {
|
|
96650
|
-
if (!
|
|
96707
|
+
if (!existsSync43(path)) return ["command_missing"];
|
|
96651
96708
|
let st;
|
|
96652
96709
|
try {
|
|
96653
96710
|
st = statSync17(path);
|
|
@@ -96663,7 +96720,7 @@ function probeExecutableIssues(path) {
|
|
|
96663
96720
|
return [];
|
|
96664
96721
|
}
|
|
96665
96722
|
function probeReadableFileIssues(path) {
|
|
96666
|
-
if (!
|
|
96723
|
+
if (!existsSync43(path)) return ["artifact_missing"];
|
|
96667
96724
|
try {
|
|
96668
96725
|
if (!statSync17(path).isFile()) return ["artifact_not_file"];
|
|
96669
96726
|
} catch {
|
|
@@ -97003,7 +97060,7 @@ async function main() {
|
|
|
97003
97060
|
}
|
|
97004
97061
|
if (cmd === "install-systemd") {
|
|
97005
97062
|
const nodeHome = resolveNodeHome(argValue(rest, "--home"));
|
|
97006
|
-
const execStart = argValue(rest, "--exec") ||
|
|
97063
|
+
const execStart = argValue(rest, "--exec") || resolve14(process.argv[1] || "superone");
|
|
97007
97064
|
const host = argValue(rest, "--host") || DEFAULT_BIND_HOST;
|
|
97008
97065
|
const port = Number(argValue(rest, "--port") || DEFAULT_BIND_PORT);
|
|
97009
97066
|
const result = installSystemdUserService({
|