@codexhost/cli-darwin-x64 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/host-runtime.mjs +216 -169
- package/app/plugins/deepseek-harness/plugin.mjs +593 -93
- package/app/plugins/omp/plugin.mjs +163 -103
- package/app/plugins/pi/plugin.mjs +4 -1
- package/app/renderer-extension.js +80 -6
- package/bin/codexhost +0 -0
- package/libexec/codexhost-shim +0 -0
- package/libexec/codexhost-updater +0 -0
- package/package.json +1 -1
package/app/host-runtime.mjs
CHANGED
|
@@ -4283,7 +4283,7 @@ async function runDelegationCli(input) {
|
|
|
4283
4283
|
|
|
4284
4284
|
// packages/host-runtime/src/run-host-runtime.ts
|
|
4285
4285
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
4286
|
-
import
|
|
4286
|
+
import path24 from "node:path";
|
|
4287
4287
|
import { homedir as homedir2 } from "node:os";
|
|
4288
4288
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4289
4289
|
|
|
@@ -5978,10 +5978,10 @@ function mergeDefs(...defs) {
|
|
|
5978
5978
|
function cloneDef(schema) {
|
|
5979
5979
|
return mergeDefs(schema._zod.def);
|
|
5980
5980
|
}
|
|
5981
|
-
function getElementAtPath(obj,
|
|
5982
|
-
if (!
|
|
5981
|
+
function getElementAtPath(obj, path29) {
|
|
5982
|
+
if (!path29)
|
|
5983
5983
|
return obj;
|
|
5984
|
-
return
|
|
5984
|
+
return path29.reduce((acc, key) => acc?.[key], obj);
|
|
5985
5985
|
}
|
|
5986
5986
|
function promiseAllObject(promisesObj) {
|
|
5987
5987
|
const keys = Object.keys(promisesObj);
|
|
@@ -6390,11 +6390,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
6390
6390
|
}
|
|
6391
6391
|
return false;
|
|
6392
6392
|
}
|
|
6393
|
-
function prefixIssues(
|
|
6393
|
+
function prefixIssues(path29, issues) {
|
|
6394
6394
|
return issues.map((iss) => {
|
|
6395
6395
|
var _a3;
|
|
6396
6396
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
6397
|
-
iss.path.unshift(
|
|
6397
|
+
iss.path.unshift(path29);
|
|
6398
6398
|
return iss;
|
|
6399
6399
|
});
|
|
6400
6400
|
}
|
|
@@ -6541,16 +6541,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6541
6541
|
}
|
|
6542
6542
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
6543
6543
|
const fieldErrors = { _errors: [] };
|
|
6544
|
-
const processError = (error52,
|
|
6544
|
+
const processError = (error52, path29 = []) => {
|
|
6545
6545
|
for (const issue2 of error52.issues) {
|
|
6546
6546
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6547
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6547
|
+
issue2.errors.map((issues) => processError({ issues }, [...path29, ...issue2.path]));
|
|
6548
6548
|
} else if (issue2.code === "invalid_key") {
|
|
6549
|
-
processError({ issues: issue2.issues }, [...
|
|
6549
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
6550
6550
|
} else if (issue2.code === "invalid_element") {
|
|
6551
|
-
processError({ issues: issue2.issues }, [...
|
|
6551
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
6552
6552
|
} else {
|
|
6553
|
-
const fullpath = [...
|
|
6553
|
+
const fullpath = [...path29, ...issue2.path];
|
|
6554
6554
|
if (fullpath.length === 0) {
|
|
6555
6555
|
fieldErrors._errors.push(mapper(issue2));
|
|
6556
6556
|
} else {
|
|
@@ -6577,17 +6577,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6577
6577
|
}
|
|
6578
6578
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
6579
6579
|
const result = { errors: [] };
|
|
6580
|
-
const processError = (error52,
|
|
6580
|
+
const processError = (error52, path29 = []) => {
|
|
6581
6581
|
var _a3, _b;
|
|
6582
6582
|
for (const issue2 of error52.issues) {
|
|
6583
6583
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6584
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6584
|
+
issue2.errors.map((issues) => processError({ issues }, [...path29, ...issue2.path]));
|
|
6585
6585
|
} else if (issue2.code === "invalid_key") {
|
|
6586
|
-
processError({ issues: issue2.issues }, [...
|
|
6586
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
6587
6587
|
} else if (issue2.code === "invalid_element") {
|
|
6588
|
-
processError({ issues: issue2.issues }, [...
|
|
6588
|
+
processError({ issues: issue2.issues }, [...path29, ...issue2.path]);
|
|
6589
6589
|
} else {
|
|
6590
|
-
const fullpath = [...
|
|
6590
|
+
const fullpath = [...path29, ...issue2.path];
|
|
6591
6591
|
if (fullpath.length === 0) {
|
|
6592
6592
|
result.errors.push(mapper(issue2));
|
|
6593
6593
|
continue;
|
|
@@ -6619,8 +6619,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6619
6619
|
}
|
|
6620
6620
|
function toDotPath(_path) {
|
|
6621
6621
|
const segs = [];
|
|
6622
|
-
const
|
|
6623
|
-
for (const seg of
|
|
6622
|
+
const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
6623
|
+
for (const seg of path29) {
|
|
6624
6624
|
if (typeof seg === "number")
|
|
6625
6625
|
segs.push(`[${seg}]`);
|
|
6626
6626
|
else if (typeof seg === "symbol")
|
|
@@ -19312,13 +19312,13 @@ function resolveRef(ref, ctx) {
|
|
|
19312
19312
|
if (!ref.startsWith("#")) {
|
|
19313
19313
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19314
19314
|
}
|
|
19315
|
-
const
|
|
19316
|
-
if (
|
|
19315
|
+
const path29 = ref.slice(1).split("/").filter(Boolean);
|
|
19316
|
+
if (path29.length === 0) {
|
|
19317
19317
|
return ctx.rootSchema;
|
|
19318
19318
|
}
|
|
19319
19319
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19320
|
-
if (
|
|
19321
|
-
const key =
|
|
19320
|
+
if (path29[0] === defsKey) {
|
|
19321
|
+
const key = path29[1];
|
|
19322
19322
|
if (!key || !ctx.defs[key]) {
|
|
19323
19323
|
throw new Error(`Reference not found: ${ref}`);
|
|
19324
19324
|
}
|
|
@@ -22814,16 +22814,16 @@ var Diff = class {
|
|
|
22814
22814
|
}
|
|
22815
22815
|
}
|
|
22816
22816
|
}
|
|
22817
|
-
addToPath(
|
|
22818
|
-
const last =
|
|
22817
|
+
addToPath(path29, added, removed, oldPosInc, options2) {
|
|
22818
|
+
const last = path29.lastComponent;
|
|
22819
22819
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
22820
22820
|
return {
|
|
22821
|
-
oldPos:
|
|
22821
|
+
oldPos: path29.oldPos + oldPosInc,
|
|
22822
22822
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
22823
22823
|
};
|
|
22824
22824
|
} else {
|
|
22825
22825
|
return {
|
|
22826
|
-
oldPos:
|
|
22826
|
+
oldPos: path29.oldPos + oldPosInc,
|
|
22827
22827
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
22828
22828
|
};
|
|
22829
22829
|
}
|
|
@@ -23251,6 +23251,9 @@ function splitLines(text) {
|
|
|
23251
23251
|
return result;
|
|
23252
23252
|
}
|
|
23253
23253
|
|
|
23254
|
+
// packages/protocol-core/dist/codex-ui-projector.js
|
|
23255
|
+
import path9 from "node:path";
|
|
23256
|
+
|
|
23254
23257
|
// packages/protocol-core/dist/file-change-summary.js
|
|
23255
23258
|
import path8 from "node:path";
|
|
23256
23259
|
function filePathKey(file2, cwd) {
|
|
@@ -23424,6 +23427,14 @@ function nestedString(value2, keys, preserveText = false) {
|
|
|
23424
23427
|
}
|
|
23425
23428
|
return void 0;
|
|
23426
23429
|
}
|
|
23430
|
+
function toolWorkingDirectory(args, defaultCwd) {
|
|
23431
|
+
const workdir = nestedString(args, ["workdir"]);
|
|
23432
|
+
if (workdir === void 0)
|
|
23433
|
+
return defaultCwd;
|
|
23434
|
+
const windows = /^(?:[a-z]:[/\\]|\\\\)/iu;
|
|
23435
|
+
const paths = windows.test(defaultCwd) || windows.test(workdir) ? path9.win32 : path9.posix;
|
|
23436
|
+
return paths.resolve(defaultCwd, workdir);
|
|
23437
|
+
}
|
|
23427
23438
|
function toolOutputText(item) {
|
|
23428
23439
|
if (!item.output)
|
|
23429
23440
|
return null;
|
|
@@ -23433,7 +23444,7 @@ function toolOutputText(item) {
|
|
|
23433
23444
|
function toolCommandLine(toolName, args) {
|
|
23434
23445
|
const lower = toolName.toLowerCase().replaceAll(/[_-]/g, "");
|
|
23435
23446
|
const command = nestedString(args, ["command", "cmd", "script", "commandLine", "command_line"]);
|
|
23436
|
-
if (command && ["bash", "exec", "terminal", "run", "shell", "powershell", "command"].includes(lower)) {
|
|
23447
|
+
if (command && ["bash", "exec", "terminal", "run", "shell", "powershell", "pwsh", "command"].includes(lower)) {
|
|
23437
23448
|
return command;
|
|
23438
23449
|
}
|
|
23439
23450
|
const filePath = nestedString(args, [
|
|
@@ -23524,8 +23535,8 @@ function projectFileChangeKind(kind) {
|
|
|
23524
23535
|
return { type: kind };
|
|
23525
23536
|
}
|
|
23526
23537
|
function projectFileChanges(changes) {
|
|
23527
|
-
return changes.map(({ path:
|
|
23528
|
-
path:
|
|
23538
|
+
return changes.map(({ path: path29, kind, unifiedDiff }) => ({
|
|
23539
|
+
path: path29,
|
|
23529
23540
|
kind: projectFileChangeKind(kind),
|
|
23530
23541
|
diff: unifiedDiff
|
|
23531
23542
|
}));
|
|
@@ -23690,13 +23701,15 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23690
23701
|
phase: item.phase ?? null,
|
|
23691
23702
|
memoryCitation: null
|
|
23692
23703
|
};
|
|
23693
|
-
case "reasoning":
|
|
23704
|
+
case "reasoning": {
|
|
23705
|
+
const text = reasoningDisplayText(item.text);
|
|
23694
23706
|
return {
|
|
23695
23707
|
id: reasoningPreviewItemId(item.itemId),
|
|
23696
23708
|
type: "reasoning",
|
|
23697
|
-
summary:
|
|
23709
|
+
summary: text ? [text] : [],
|
|
23698
23710
|
content: []
|
|
23699
23711
|
};
|
|
23712
|
+
}
|
|
23700
23713
|
case "contextCompaction":
|
|
23701
23714
|
return { id: item.itemId, type: "contextCompaction" };
|
|
23702
23715
|
case "commandExecution":
|
|
@@ -23720,13 +23733,13 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23720
23733
|
id: item.itemId,
|
|
23721
23734
|
type: "commandExecution",
|
|
23722
23735
|
command,
|
|
23723
|
-
cwd: defaultCwd,
|
|
23736
|
+
cwd: toolWorkingDirectory(item.arguments, defaultCwd),
|
|
23724
23737
|
processId: null,
|
|
23725
23738
|
source: "agent",
|
|
23726
23739
|
status: itemStatus(outcome),
|
|
23727
23740
|
commandActions: [],
|
|
23728
23741
|
aggregatedOutput: includeCommandOutput ? toolOutputText(item) : null,
|
|
23729
|
-
exitCode:
|
|
23742
|
+
exitCode: null,
|
|
23730
23743
|
durationMs: item.durationMs ?? null
|
|
23731
23744
|
};
|
|
23732
23745
|
}
|
|
@@ -23774,6 +23787,9 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23774
23787
|
function reasoningPreviewItemId(itemId) {
|
|
23775
23788
|
return `${itemId}-summary`;
|
|
23776
23789
|
}
|
|
23790
|
+
function reasoningDisplayText(text) {
|
|
23791
|
+
return text.replace(/[\r\n]+$/u, "");
|
|
23792
|
+
}
|
|
23777
23793
|
function projectReasoningTranscriptItem(item, outcome, defaultCwd, durationMs = null) {
|
|
23778
23794
|
return {
|
|
23779
23795
|
id: item.itemId,
|
|
@@ -23784,7 +23800,7 @@ function projectReasoningTranscriptItem(item, outcome, defaultCwd, durationMs =
|
|
|
23784
23800
|
source: "agent",
|
|
23785
23801
|
status: itemStatus(outcome),
|
|
23786
23802
|
commandActions: [],
|
|
23787
|
-
aggregatedOutput: item.text
|
|
23803
|
+
aggregatedOutput: reasoningDisplayText(item.text) || null,
|
|
23788
23804
|
exitCode: outcome ? 0 : null,
|
|
23789
23805
|
durationMs
|
|
23790
23806
|
};
|
|
@@ -23841,6 +23857,8 @@ function projectHistoricalTurn(input) {
|
|
|
23841
23857
|
if (isFileMutatingTool(item.toolName))
|
|
23842
23858
|
return [];
|
|
23843
23859
|
}
|
|
23860
|
+
if (item.type === "reasoning" && !reasoningDisplayText(item.text))
|
|
23861
|
+
return [];
|
|
23844
23862
|
return item.type === "reasoning" ? [
|
|
23845
23863
|
projectItem(item, outcome, cwd, true, input.threadId ?? ""),
|
|
23846
23864
|
projectReasoningTranscriptItem(item, outcome, cwd)
|
|
@@ -24030,7 +24048,7 @@ var CodexTurnProjector = class {
|
|
|
24030
24048
|
startedAtMs
|
|
24031
24049
|
};
|
|
24032
24050
|
this.#items.set(event.item.itemId, projected);
|
|
24033
|
-
if ((event.item.type === "agentMessage" || event.item.type === "reasoning") && event.item.text.length === 0) {
|
|
24051
|
+
if ((event.item.type === "agentMessage" || event.item.type === "reasoning") && (event.item.type === "reasoning" ? reasoningDisplayText(event.item.text).length === 0 : event.item.text.length === 0)) {
|
|
24034
24052
|
return { messages: [] };
|
|
24035
24053
|
}
|
|
24036
24054
|
if (event.item.type === "toolExecution") {
|
|
@@ -24050,7 +24068,8 @@ var CodexTurnProjector = class {
|
|
|
24050
24068
|
const startedItem = event.item.type === "reasoning" ? { ...event.item, text: "" } : event.item;
|
|
24051
24069
|
const messages = [this.#startWireItem(projected, startedItem, startedAtMs)];
|
|
24052
24070
|
if (event.item.type === "reasoning") {
|
|
24053
|
-
|
|
24071
|
+
const text = reasoningDisplayText(event.item.text);
|
|
24072
|
+
messages.push(this.#startReasoningTranscript(event.item, startedAtMs), this.#reasoningOutputDelta(event.item.itemId, text, startedAtMs), ...this.#reasoningDelta(projected, text, startedAtMs));
|
|
24054
24073
|
}
|
|
24055
24074
|
return { messages };
|
|
24056
24075
|
}
|
|
@@ -24078,10 +24097,14 @@ var CodexTurnProjector = class {
|
|
|
24078
24097
|
}
|
|
24079
24098
|
});
|
|
24080
24099
|
} else if (next.type === "reasoning") {
|
|
24100
|
+
const previousText = previous.type === "reasoning" ? reasoningDisplayText(previous.text) : "";
|
|
24101
|
+
const delta = reasoningDisplayText(next.text).slice(previousText.length);
|
|
24102
|
+
if (!delta)
|
|
24103
|
+
return { messages };
|
|
24081
24104
|
if (!projected.wireStarted) {
|
|
24082
24105
|
messages.push(this.#startWireItem(projected, { ...next, text: "" }, emittedAtMs), this.#startReasoningTranscript({ ...next, text: "" }, emittedAtMs));
|
|
24083
24106
|
}
|
|
24084
|
-
messages.push(this.#reasoningOutputDelta(event.itemId,
|
|
24107
|
+
messages.push(this.#reasoningOutputDelta(event.itemId, delta, emittedAtMs), ...this.#reasoningDelta(projected, delta, emittedAtMs));
|
|
24085
24108
|
}
|
|
24086
24109
|
} else if (event.update.type === "output.append") {
|
|
24087
24110
|
projected.streamedCommandOutput = true;
|
|
@@ -24463,13 +24486,13 @@ function decodeThreadForkRequest(request) {
|
|
|
24463
24486
|
if (runtimeWorkspaceRoots !== void 0 && runtimeWorkspaceRoots !== null && (!Array.isArray(runtimeWorkspaceRoots) || runtimeWorkspaceRoots.some((root) => typeof root !== "string" || root.length === 0))) {
|
|
24464
24487
|
throw new Error("thread/fork params.runtimeWorkspaceRoots must be text paths or null");
|
|
24465
24488
|
}
|
|
24466
|
-
const
|
|
24489
|
+
const path29 = optionalText(params, "path", { allowEmpty: true });
|
|
24467
24490
|
const ephemeral = optionalBoolean(params, "ephemeral");
|
|
24468
24491
|
return {
|
|
24469
24492
|
threadId: threadId2,
|
|
24470
24493
|
...lastTurnText ? { lastTurnId: hostTurnIdSchema.parse(lastTurnText) } : {},
|
|
24471
24494
|
...beforeTurnText ? { beforeTurnId: hostTurnIdSchema.parse(beforeTurnText) } : {},
|
|
24472
|
-
...
|
|
24495
|
+
...path29 ? { path: path29 } : {},
|
|
24473
24496
|
...optionalField(params, "model"),
|
|
24474
24497
|
...optionalField(params, "modelProvider"),
|
|
24475
24498
|
...optionalField(params, "cwd"),
|
|
@@ -25647,7 +25670,7 @@ var HarnessAccountInspectionCache = class {
|
|
|
25647
25670
|
// packages/host-runtime/src/app-server-host.ts
|
|
25648
25671
|
import { createHash as createHash8, randomUUID as randomUUID10 } from "node:crypto";
|
|
25649
25672
|
import os5 from "node:os";
|
|
25650
|
-
import
|
|
25673
|
+
import path16 from "node:path";
|
|
25651
25674
|
|
|
25652
25675
|
// packages/host-runtime/src/external-thread-fork.ts
|
|
25653
25676
|
import nodePath from "node:path";
|
|
@@ -25655,7 +25678,7 @@ import nodePath from "node:path";
|
|
|
25655
25678
|
// packages/host-runtime/src/external-thread-repository.ts
|
|
25656
25679
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
25657
25680
|
import os3 from "node:os";
|
|
25658
|
-
import
|
|
25681
|
+
import path10 from "node:path";
|
|
25659
25682
|
|
|
25660
25683
|
// packages/host-runtime/src/external-subagent-threads.ts
|
|
25661
25684
|
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -25795,8 +25818,8 @@ function sameMapping(left, right) {
|
|
|
25795
25818
|
}
|
|
25796
25819
|
function defaultMappingStoreDirectory(environment) {
|
|
25797
25820
|
const dataDirectory = environment.CODEXHOST_DATA_DIR;
|
|
25798
|
-
return
|
|
25799
|
-
dataDirectory ?
|
|
25821
|
+
return path10.join(
|
|
25822
|
+
dataDirectory ? path10.resolve(dataDirectory) : path10.join(os3.homedir(), ".codexhost"),
|
|
25800
25823
|
"mapping-store"
|
|
25801
25824
|
);
|
|
25802
25825
|
}
|
|
@@ -27906,7 +27929,7 @@ async function resolveExternalCommand(commands, text, options2 = {}) {
|
|
|
27906
27929
|
}
|
|
27907
27930
|
|
|
27908
27931
|
// packages/host-runtime/src/live-command-catalog-cache.ts
|
|
27909
|
-
import
|
|
27932
|
+
import path11 from "node:path";
|
|
27910
27933
|
var MAX_ENTRIES = 64;
|
|
27911
27934
|
function isLiveCommandCatalog(catalog, staticCatalog) {
|
|
27912
27935
|
const staticIds = new Set(staticCatalog.commands.map(({ id: id2 }) => id2));
|
|
@@ -27915,7 +27938,7 @@ function isLiveCommandCatalog(catalog, staticCatalog) {
|
|
|
27915
27938
|
var LiveCommandCatalogCache = class {
|
|
27916
27939
|
#entries = /* @__PURE__ */ new Map();
|
|
27917
27940
|
#key(harnessId, cwd) {
|
|
27918
|
-
return `${harnessId}\0${
|
|
27941
|
+
return `${harnessId}\0${path11.resolve(cwd)}`;
|
|
27919
27942
|
}
|
|
27920
27943
|
remember(harnessId, cwd, catalog) {
|
|
27921
27944
|
const key = this.#key(harnessId, cwd);
|
|
@@ -27932,12 +27955,12 @@ var LiveCommandCatalogCache = class {
|
|
|
27932
27955
|
}
|
|
27933
27956
|
};
|
|
27934
27957
|
function sameWorkspace(left, right) {
|
|
27935
|
-
return
|
|
27958
|
+
return path11.resolve(left) === path11.resolve(right);
|
|
27936
27959
|
}
|
|
27937
27960
|
|
|
27938
27961
|
// packages/host-runtime/src/harness-delegation-coordinator.ts
|
|
27939
27962
|
import { createHash as createHash7, randomUUID as randomUUID6 } from "node:crypto";
|
|
27940
|
-
import
|
|
27963
|
+
import path12 from "node:path";
|
|
27941
27964
|
|
|
27942
27965
|
// packages/host-runtime/src/delegation-snapshot.ts
|
|
27943
27966
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -28092,7 +28115,7 @@ function taskDigest(input) {
|
|
|
28092
28115
|
return createHash7("sha256").update(
|
|
28093
28116
|
JSON.stringify({
|
|
28094
28117
|
task: input.task,
|
|
28095
|
-
cwd:
|
|
28118
|
+
cwd: path12.resolve(input.cwd),
|
|
28096
28119
|
modelId: input.model?.id ?? null,
|
|
28097
28120
|
thinkingOptionId: input.thinkingOptionId ?? null
|
|
28098
28121
|
})
|
|
@@ -28163,7 +28186,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28163
28186
|
return {
|
|
28164
28187
|
harnessId: input.harnessId,
|
|
28165
28188
|
inspection: await adapter.inspect({
|
|
28166
|
-
...input.cwd ? { cwd:
|
|
28189
|
+
...input.cwd ? { cwd: path12.resolve(input.cwd) } : {},
|
|
28167
28190
|
...input.refresh !== void 0 ? { refresh: input.refresh } : {}
|
|
28168
28191
|
})
|
|
28169
28192
|
};
|
|
@@ -28177,7 +28200,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28177
28200
|
const result = await this.#startOfficial({ ...input, parentThreadId, cwd: selectedCwd });
|
|
28178
28201
|
return { ...result, parentThreadId, cwd: result.cwd ?? selectedCwd };
|
|
28179
28202
|
}
|
|
28180
|
-
const startInput = { ...input, parentThreadId, cwd:
|
|
28203
|
+
const startInput = { ...input, parentThreadId, cwd: path12.resolve(selectedCwd) };
|
|
28181
28204
|
if (!this.#adapters.has(input.harnessId)) {
|
|
28182
28205
|
throw new DelegationControlError(
|
|
28183
28206
|
"HARNESS_NOT_FOUND",
|
|
@@ -28606,7 +28629,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28606
28629
|
|
|
28607
28630
|
// packages/host-runtime/src/harness-plugin-loader.ts
|
|
28608
28631
|
import { readdir as readdir3, realpath as realpath2 } from "node:fs/promises";
|
|
28609
|
-
import
|
|
28632
|
+
import path14 from "node:path";
|
|
28610
28633
|
import { pathToFileURL } from "node:url";
|
|
28611
28634
|
|
|
28612
28635
|
// packages/host-runtime/src/harness-plugin-registry.ts
|
|
@@ -28644,16 +28667,16 @@ var HarnessPluginRegistry = class {
|
|
|
28644
28667
|
|
|
28645
28668
|
// packages/host-runtime/src/plugin-files.ts
|
|
28646
28669
|
import { open as open5, realpath, stat as stat3 } from "node:fs/promises";
|
|
28647
|
-
import
|
|
28670
|
+
import path13 from "node:path";
|
|
28648
28671
|
function inside(root, candidate) {
|
|
28649
|
-
const relative =
|
|
28650
|
-
return relative !== "" && !
|
|
28672
|
+
const relative = path13.relative(root, candidate);
|
|
28673
|
+
return relative !== "" && !path13.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path13.sep}`);
|
|
28651
28674
|
}
|
|
28652
28675
|
async function pluginResourcePath(root, relative) {
|
|
28653
|
-
if (
|
|
28676
|
+
if (path13.isAbsolute(relative) || !inside(root, path13.resolve(root, relative))) {
|
|
28654
28677
|
throw new Error("Plugin resource escapes its root");
|
|
28655
28678
|
}
|
|
28656
|
-
const resolved = await realpath(
|
|
28679
|
+
const resolved = await realpath(path13.resolve(root, relative));
|
|
28657
28680
|
if (!inside(root, resolved) || !(await stat3(resolved)).isFile()) {
|
|
28658
28681
|
throw new Error("Plugin resource must be a regular file inside its root");
|
|
28659
28682
|
}
|
|
@@ -28815,7 +28838,7 @@ async function loadHarnessPlugins(options2) {
|
|
|
28815
28838
|
const enabledIds = /* @__PURE__ */ new Set();
|
|
28816
28839
|
const roots = /* @__PURE__ */ new Set();
|
|
28817
28840
|
for (const configuredRoot of options2.roots) {
|
|
28818
|
-
if (!
|
|
28841
|
+
if (!path14.isAbsolute(configuredRoot)) {
|
|
28819
28842
|
diagnose({ code: "invalidRoot" });
|
|
28820
28843
|
continue;
|
|
28821
28844
|
}
|
|
@@ -28845,7 +28868,7 @@ async function loadHarnessPlugins(options2) {
|
|
|
28845
28868
|
for (const directory of directories) {
|
|
28846
28869
|
try {
|
|
28847
28870
|
const file2 = await pluginResourcePath(root, `${directory.name}/manifest.json`);
|
|
28848
|
-
const pluginRoot = await realpath2(
|
|
28871
|
+
const pluginRoot = await realpath2(path14.join(root, directory.name));
|
|
28849
28872
|
await pluginResourcePath(pluginRoot, "manifest.json");
|
|
28850
28873
|
const manifest = harnessPluginManifestSchema.parse(
|
|
28851
28874
|
JSON.parse(
|
|
@@ -28943,25 +28966,25 @@ async function loadHarnessPlugins(options2) {
|
|
|
28943
28966
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
28944
28967
|
import { mkdir as mkdir5, readFile as readFile7, rename as rename4, rm as rm5, stat as stat4, writeFile as writeFile3 } from "node:fs/promises";
|
|
28945
28968
|
import os4 from "node:os";
|
|
28946
|
-
import
|
|
28969
|
+
import path15 from "node:path";
|
|
28947
28970
|
var HarnessLaunchSettingsStore = class {
|
|
28948
28971
|
#directory;
|
|
28949
28972
|
#initial = /* @__PURE__ */ new Map();
|
|
28950
28973
|
constructor(environment) {
|
|
28951
|
-
this.#directory =
|
|
28952
|
-
environment.CODEXHOST_DATA_DIR ?
|
|
28974
|
+
this.#directory = path15.join(
|
|
28975
|
+
environment.CODEXHOST_DATA_DIR ? path15.resolve(environment.CODEXHOST_DATA_DIR) : path15.join(os4.homedir(), ".codexhost"),
|
|
28953
28976
|
"harness-launch-settings"
|
|
28954
28977
|
);
|
|
28955
28978
|
}
|
|
28956
28979
|
#file(id2) {
|
|
28957
|
-
return
|
|
28980
|
+
return path15.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
|
|
28958
28981
|
}
|
|
28959
28982
|
async #read(id2) {
|
|
28960
28983
|
try {
|
|
28961
28984
|
const value2 = harnessLaunchPathSchema.parse(
|
|
28962
28985
|
JSON.parse(await readFile7(this.#file(id2), "utf8"))
|
|
28963
28986
|
);
|
|
28964
|
-
if (!
|
|
28987
|
+
if (!path15.isAbsolute(value2)) throw new Error("Expected an absolute entrypoint path");
|
|
28965
28988
|
return value2;
|
|
28966
28989
|
} catch (error51) {
|
|
28967
28990
|
if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
|
|
@@ -28990,7 +29013,7 @@ var HarnessLaunchSettingsStore = class {
|
|
|
28990
29013
|
await rm5(file2, { force: true });
|
|
28991
29014
|
} else {
|
|
28992
29015
|
value2 = harnessLaunchPathSchema.parse(value2);
|
|
28993
|
-
if (!
|
|
29016
|
+
if (!path15.isAbsolute(value2))
|
|
28994
29017
|
throw new Error("Use an absolute entrypoint path without arguments");
|
|
28995
29018
|
const metadata = await stat4(value2).catch(() => void 0);
|
|
28996
29019
|
if (!metadata?.isDirectory() && !metadata?.isFile())
|
|
@@ -30125,25 +30148,25 @@ function resolveExternalSessionTreeIds(records) {
|
|
|
30125
30148
|
const resolve = (start) => {
|
|
30126
30149
|
const cached2 = resolved.get(start.hostThreadId);
|
|
30127
30150
|
if (cached2) return cached2;
|
|
30128
|
-
const
|
|
30151
|
+
const path29 = [];
|
|
30129
30152
|
const visited = /* @__PURE__ */ new Set();
|
|
30130
30153
|
let current = start;
|
|
30131
30154
|
while (true) {
|
|
30132
30155
|
const known = resolved.get(current.hostThreadId);
|
|
30133
30156
|
if (known) {
|
|
30134
|
-
for (const record3 of
|
|
30157
|
+
for (const record3 of path29) resolved.set(record3.hostThreadId, known);
|
|
30135
30158
|
return known;
|
|
30136
30159
|
}
|
|
30137
30160
|
if (visited.has(current.hostThreadId)) {
|
|
30138
30161
|
throw new Error("External Thread Fork tree contains a cycle");
|
|
30139
30162
|
}
|
|
30140
30163
|
visited.add(current.hostThreadId);
|
|
30141
|
-
|
|
30164
|
+
path29.push(current);
|
|
30142
30165
|
const sourceId = current.subagent?.parentHostThreadId ?? current.forkSource?.hostThreadId;
|
|
30143
30166
|
const source = sourceId ? byId.get(sourceId) : void 0;
|
|
30144
30167
|
if (!source) {
|
|
30145
30168
|
const root = current.hostThreadId;
|
|
30146
|
-
for (const record3 of
|
|
30169
|
+
for (const record3 of path29) resolved.set(record3.hostThreadId, root);
|
|
30147
30170
|
return root;
|
|
30148
30171
|
}
|
|
30149
30172
|
current = source;
|
|
@@ -30600,7 +30623,7 @@ var AppServerHost = class {
|
|
|
30600
30623
|
this.#launchSettings = new HarnessLaunchSettingsStore(
|
|
30601
30624
|
this.#options.pluginContext?.environment ?? environment
|
|
30602
30625
|
);
|
|
30603
|
-
const permanentHome =
|
|
30626
|
+
const permanentHome = path16.resolve(environment.CODEX_HOME ?? path16.join(os5.homedir(), ".codex"));
|
|
30604
30627
|
this.#ownsOfficialRuntimeScope = options2.officialRuntimeScope === void 0;
|
|
30605
30628
|
this.#officialRuntimeScope = options2.officialRuntimeScope ?? new OfficialRuntimeScope({
|
|
30606
30629
|
diagnosticOutput: this.#options.diagnosticOutput,
|
|
@@ -33995,7 +34018,7 @@ var AppServerHost = class {
|
|
|
33995
34018
|
// packages/host-runtime/src/native-account-host.ts
|
|
33996
34019
|
import { mkdir as mkdir8, realpath as realpath3 } from "node:fs/promises";
|
|
33997
34020
|
import { homedir } from "node:os";
|
|
33998
|
-
import
|
|
34021
|
+
import path20 from "node:path";
|
|
33999
34022
|
|
|
34000
34023
|
// packages/host-runtime/src/codex-runtime/owned-official-backends.ts
|
|
34001
34024
|
import { createHash as createHash9, randomBytes } from "node:crypto";
|
|
@@ -34005,7 +34028,7 @@ import { Writable as Writable2 } from "node:stream";
|
|
|
34005
34028
|
import { createServer } from "node:http";
|
|
34006
34029
|
import net from "node:net";
|
|
34007
34030
|
import { chmod as chmod3, lstat as lstat6, mkdir as mkdir7, rm as rm7 } from "node:fs/promises";
|
|
34008
|
-
import
|
|
34031
|
+
import path18 from "node:path";
|
|
34009
34032
|
import { PassThrough } from "node:stream";
|
|
34010
34033
|
|
|
34011
34034
|
// node_modules/ws/wrapper.mjs
|
|
@@ -34023,7 +34046,7 @@ var wrapper_default = import_websocket.default;
|
|
|
34023
34046
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
34024
34047
|
import { chmod as chmod2, lstat as lstat5, mkdir as mkdir6, open as open6, readFile as readFile8, readdir as readdir4, rename as rename5, rm as rm6 } from "node:fs/promises";
|
|
34025
34048
|
import { uptime } from "node:os";
|
|
34026
|
-
import
|
|
34049
|
+
import path17 from "node:path";
|
|
34027
34050
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
34028
34051
|
var LOCK_RETRY_COUNT = 200;
|
|
34029
34052
|
var LOCK_RETRY_DELAY_MS = 25;
|
|
@@ -34097,7 +34120,7 @@ async function readLockEntrySnapshot(filePath) {
|
|
|
34097
34120
|
source,
|
|
34098
34121
|
identity: { dev: metadata.dev, ino: metadata.ino },
|
|
34099
34122
|
mtimeMs: metadata.mtimeMs,
|
|
34100
|
-
record: record3 &&
|
|
34123
|
+
record: record3 && path17.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
|
|
34101
34124
|
};
|
|
34102
34125
|
}
|
|
34103
34126
|
function lockEntryIsAbandoned(snapshot) {
|
|
@@ -34118,7 +34141,7 @@ async function readLockEntryCatalog(lockDirectory) {
|
|
|
34118
34141
|
let unsettled = false;
|
|
34119
34142
|
for (const name of names) {
|
|
34120
34143
|
if (!name.startsWith(LOCK_ENTRY_PREFIX) || !name.endsWith(LOCK_ENTRY_SUFFIX)) continue;
|
|
34121
|
-
const snapshot = await readLockEntrySnapshot(
|
|
34144
|
+
const snapshot = await readLockEntrySnapshot(path17.join(lockDirectory, name));
|
|
34122
34145
|
if (snapshot === null) continue;
|
|
34123
34146
|
if (lockEntryIsAbandoned(snapshot)) {
|
|
34124
34147
|
if (!await removeAbandonedLockEntry(snapshot)) unsettled = true;
|
|
@@ -34146,7 +34169,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
|
|
|
34146
34169
|
await chmod2(lockDirectory, 448);
|
|
34147
34170
|
}
|
|
34148
34171
|
async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
|
|
34149
|
-
const temporary =
|
|
34172
|
+
const temporary = path17.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID11()}`);
|
|
34150
34173
|
const handle = await open6(temporary, "wx", 384);
|
|
34151
34174
|
try {
|
|
34152
34175
|
await handle.writeFile(`${JSON.stringify(record3)}
|
|
@@ -34222,7 +34245,7 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
|
|
|
34222
34245
|
const lockDirectory = `${socketPath}.initializers`;
|
|
34223
34246
|
await preparePrivateLockDirectory(lockDirectory);
|
|
34224
34247
|
const ownerToken = randomUUID11();
|
|
34225
|
-
const entryPath =
|
|
34248
|
+
const entryPath = path17.join(lockDirectory, lockEntryName(ownerToken));
|
|
34226
34249
|
const baseRecord = {
|
|
34227
34250
|
version: 2,
|
|
34228
34251
|
ownerToken,
|
|
@@ -34396,14 +34419,14 @@ function remoteAppServerSocketPath(environment, listenUrl = "unix://") {
|
|
|
34396
34419
|
throw new Error("Remote app-server listener must use a Unix URL");
|
|
34397
34420
|
}
|
|
34398
34421
|
const explicit = listenUrl.slice("unix://".length);
|
|
34399
|
-
if (explicit.length > 0) return
|
|
34400
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
34422
|
+
if (explicit.length > 0) return path18.posix.resolve(decodeURIComponent(explicit));
|
|
34423
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path18.posix.join(environment.HOME, ".codex") : void 0);
|
|
34401
34424
|
if (!codexHome)
|
|
34402
34425
|
throw new Error("CODEX_HOME or HOME is required for the remote app-server socket");
|
|
34403
|
-
return
|
|
34426
|
+
return path18.posix.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
34404
34427
|
}
|
|
34405
34428
|
function officialListenerArgumentsForRemoteListener(arguments_2, socketPath) {
|
|
34406
|
-
if (!
|
|
34429
|
+
if (!path18.posix.isAbsolute(socketPath)) {
|
|
34407
34430
|
throw new Error("Shared official app-server socket path must be absolute");
|
|
34408
34431
|
}
|
|
34409
34432
|
if (remoteUnixListenerUrl(arguments_2) === null) {
|
|
@@ -34514,7 +34537,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
34514
34537
|
await rm7(socketPath, { force: true });
|
|
34515
34538
|
}
|
|
34516
34539
|
async function prepareRemoteAppServerSocketDirectory(socketPath) {
|
|
34517
|
-
const socketDirectory =
|
|
34540
|
+
const socketDirectory = path18.dirname(socketPath);
|
|
34518
34541
|
const existing = await lstat6(socketDirectory).catch((error51) => {
|
|
34519
34542
|
if (error51.code === "ENOENT") return null;
|
|
34520
34543
|
throw error51;
|
|
@@ -34720,38 +34743,56 @@ function createRemoteAppServerWebSocketListener(input) {
|
|
|
34720
34743
|
// packages/host-runtime/src/remote-official-app-server.ts
|
|
34721
34744
|
import { spawn as spawn3 } from "node:child_process";
|
|
34722
34745
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
34723
|
-
import { lstat as lstat7, rm as rm8 } from "node:fs/promises";
|
|
34724
|
-
import
|
|
34746
|
+
import { lstat as lstat7, rm as rm8, stat as stat5 } from "node:fs/promises";
|
|
34747
|
+
import path19 from "node:path";
|
|
34725
34748
|
var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
|
|
34726
34749
|
var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
|
|
34727
34750
|
function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID12()) {
|
|
34728
|
-
if (!
|
|
34751
|
+
if (!path19.posix.isAbsolute(desktopControlSocketPath)) {
|
|
34729
34752
|
throw new Error("Desktop control socket path must be absolute");
|
|
34730
34753
|
}
|
|
34731
34754
|
if (!/^[A-Za-z0-9-]+$/u.test(token) || !/[A-Za-z0-9]/u.test(token)) {
|
|
34732
34755
|
throw new Error("Shared official app-server socket token is invalid");
|
|
34733
34756
|
}
|
|
34734
34757
|
const compactToken = token.replaceAll("-", "").slice(0, 15);
|
|
34735
|
-
return
|
|
34758
|
+
return path19.posix.join(path19.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
|
|
34736
34759
|
}
|
|
34737
34760
|
function errorMessage4(error51) {
|
|
34738
34761
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
34739
34762
|
}
|
|
34740
|
-
async function
|
|
34763
|
+
async function inspectSocket(socketPath) {
|
|
34741
34764
|
const metadata = await lstat7(socketPath).catch((error51) => {
|
|
34742
34765
|
if (error51.code === "ENOENT") return null;
|
|
34743
34766
|
throw error51;
|
|
34744
34767
|
});
|
|
34745
34768
|
if (metadata === null) return null;
|
|
34746
|
-
|
|
34769
|
+
const identity = { dev: metadata.dev, ino: metadata.ino };
|
|
34770
|
+
if (metadata.isSymbolicLink()) {
|
|
34771
|
+
const uid = process.getuid?.();
|
|
34772
|
+
if (uid === void 0 || metadata.uid !== uid) {
|
|
34773
|
+
throw new Error(
|
|
34774
|
+
`Shared official app-server link must belong to the current user: ${socketPath}`
|
|
34775
|
+
);
|
|
34776
|
+
}
|
|
34777
|
+
const target = await stat5(socketPath).catch((error51) => {
|
|
34778
|
+
if (error51.code === "ENOENT") return null;
|
|
34779
|
+
throw error51;
|
|
34780
|
+
});
|
|
34781
|
+
if (target === null) return { identity, ready: false };
|
|
34782
|
+
if (target.uid !== uid || !target.isSocket() || (target.mode & 63) !== 0) {
|
|
34783
|
+
throw new Error(
|
|
34784
|
+
`Shared official app-server link must target a current-user private socket: ${socketPath}`
|
|
34785
|
+
);
|
|
34786
|
+
}
|
|
34787
|
+
} else if (!metadata.isSocket()) {
|
|
34747
34788
|
throw new Error(`Shared official app-server path is not a socket: ${socketPath}`);
|
|
34748
34789
|
}
|
|
34749
|
-
return {
|
|
34790
|
+
return { identity, ready: true };
|
|
34750
34791
|
}
|
|
34751
34792
|
function sameUnixFileIdentity3(left, right) {
|
|
34752
34793
|
return left.dev === right.dev && left.ino === right.ino;
|
|
34753
34794
|
}
|
|
34754
|
-
async function waitForOfficialSocket(socketPath, closed) {
|
|
34795
|
+
async function waitForOfficialSocket(socketPath, closed, onIdentity) {
|
|
34755
34796
|
const deadline = Date.now() + 1e4;
|
|
34756
34797
|
const state = { exit: null };
|
|
34757
34798
|
void closed.then((value2) => {
|
|
@@ -34764,14 +34805,20 @@ async function waitForOfficialSocket(socketPath, closed) {
|
|
|
34764
34805
|
exit.error ? `Shared official app-server failed: ${exit.error.message}` : `Shared official app-server exited before its socket was ready (code=${String(exit.code)}, signal=${String(exit.signal)})`
|
|
34765
34806
|
);
|
|
34766
34807
|
}
|
|
34767
|
-
|
|
34808
|
+
const socket = await inspectSocket(socketPath);
|
|
34809
|
+
if (socket !== null) {
|
|
34810
|
+
onIdentity(socket.identity);
|
|
34811
|
+
if (socket.ready) return;
|
|
34812
|
+
}
|
|
34768
34813
|
await new Promise((resolve) => setTimeout(resolve, 25));
|
|
34769
34814
|
}
|
|
34770
34815
|
throw new Error(`Shared official app-server socket was not ready after 10000ms: ${socketPath}`);
|
|
34771
34816
|
}
|
|
34772
34817
|
function createRemoteOfficialAppServerListener(input) {
|
|
34773
34818
|
const spawnOfficial = input.spawnOfficial ?? spawn3;
|
|
34774
|
-
const waitUntilReady = input.waitUntilReady ?? waitForOfficialSocket
|
|
34819
|
+
const waitUntilReady = input.waitUntilReady ?? ((socketPath, closed2) => waitForOfficialSocket(socketPath, closed2, (identity) => {
|
|
34820
|
+
ownedSocketIdentity ??= identity;
|
|
34821
|
+
}));
|
|
34775
34822
|
const closeTimeoutMs = input.closeTimeoutMs ?? DEFAULT_CLOSE_TIMEOUT_MS;
|
|
34776
34823
|
const closed = Promise.withResolvers();
|
|
34777
34824
|
let child = null;
|
|
@@ -34802,7 +34849,7 @@ function createRemoteOfficialAppServerListener(input) {
|
|
|
34802
34849
|
};
|
|
34803
34850
|
const removeOwnedSocket = async () => {
|
|
34804
34851
|
if (ownedSocketIdentity === null) return;
|
|
34805
|
-
const current = await
|
|
34852
|
+
const current = await lstat7(input.socketPath).catch(() => null);
|
|
34806
34853
|
if (current && sameUnixFileIdentity3(current, ownedSocketIdentity)) {
|
|
34807
34854
|
await rm8(input.socketPath, { force: true });
|
|
34808
34855
|
}
|
|
@@ -34828,7 +34875,7 @@ function createRemoteOfficialAppServerListener(input) {
|
|
|
34828
34875
|
spawned.stderr?.pipe(input.diagnosticOutput, { end: false });
|
|
34829
34876
|
try {
|
|
34830
34877
|
await waitUntilReady(input.socketPath, closed.promise);
|
|
34831
|
-
ownedSocketIdentity
|
|
34878
|
+
ownedSocketIdentity ??= (await inspectSocket(input.socketPath).catch(() => null))?.identity ?? null;
|
|
34832
34879
|
} catch (error51) {
|
|
34833
34880
|
let stopFailed = false;
|
|
34834
34881
|
try {
|
|
@@ -34836,7 +34883,7 @@ function createRemoteOfficialAppServerListener(input) {
|
|
|
34836
34883
|
} catch {
|
|
34837
34884
|
stopFailed = true;
|
|
34838
34885
|
}
|
|
34839
|
-
ownedSocketIdentity ??= await
|
|
34886
|
+
ownedSocketIdentity ??= (await inspectSocket(input.socketPath).catch(() => null))?.identity ?? null;
|
|
34840
34887
|
if (!stopFailed) await removeOwnedSocket();
|
|
34841
34888
|
throw new Error(`Shared official app-server startup failed: ${errorMessage4(error51)}`);
|
|
34842
34889
|
}
|
|
@@ -35218,19 +35265,19 @@ function createOwnedUnixBackend(input) {
|
|
|
35218
35265
|
|
|
35219
35266
|
// packages/host-runtime/src/native-account-host.ts
|
|
35220
35267
|
async function canonicalCodexHome(home) {
|
|
35221
|
-
const absolute =
|
|
35268
|
+
const absolute = path20.resolve(home);
|
|
35222
35269
|
try {
|
|
35223
35270
|
return await realpath3(absolute);
|
|
35224
35271
|
} catch (error51) {
|
|
35225
35272
|
if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT")) throw error51;
|
|
35226
|
-
const parent =
|
|
35273
|
+
const parent = path20.dirname(absolute);
|
|
35227
35274
|
if (parent === absolute) throw error51;
|
|
35228
|
-
return
|
|
35275
|
+
return path20.join(await canonicalCodexHome(parent), path20.basename(absolute));
|
|
35229
35276
|
}
|
|
35230
35277
|
}
|
|
35231
35278
|
async function prepareLocalCodex(input) {
|
|
35232
35279
|
const home = await canonicalCodexHome(
|
|
35233
|
-
input.environment.CODEX_HOME ??
|
|
35280
|
+
input.environment.CODEX_HOME ?? path20.join(homedir(), ".codex")
|
|
35234
35281
|
);
|
|
35235
35282
|
await mkdir8(home, { recursive: true });
|
|
35236
35283
|
const scope = new OfficialRuntimeScope({
|
|
@@ -35397,17 +35444,17 @@ var DelegationControlRegistry = class {
|
|
|
35397
35444
|
|
|
35398
35445
|
// packages/host-runtime/src/installed-harness-plugins.ts
|
|
35399
35446
|
import os6 from "node:os";
|
|
35400
|
-
import
|
|
35447
|
+
import path22 from "node:path";
|
|
35401
35448
|
import { fileURLToPath } from "node:url";
|
|
35402
35449
|
|
|
35403
35450
|
// packages/host-runtime/src/launcher-url-opener.ts
|
|
35404
35451
|
import { spawn as spawn4 } from "node:child_process";
|
|
35405
|
-
import
|
|
35452
|
+
import path21 from "node:path";
|
|
35406
35453
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
35407
35454
|
var OPEN_TIMEOUT_MS = 1e4;
|
|
35408
35455
|
function createLauncherUrlOpener(environment, spawnLauncher = (command, arguments_2, options2) => spawn4(command, arguments_2, options2)) {
|
|
35409
35456
|
const launcher = environment.CODEXHOST_LAUNCHER_EXECUTABLE;
|
|
35410
|
-
if (!launcher || !
|
|
35457
|
+
if (!launcher || !path21.isAbsolute(launcher)) return void 0;
|
|
35411
35458
|
const launcherEnvironment = Object.fromEntries(
|
|
35412
35459
|
Object.entries(environment).filter(([name]) => {
|
|
35413
35460
|
const normalized = name.toUpperCase();
|
|
@@ -35465,9 +35512,9 @@ function installedHarnessPluginOptions(environment, managedRemoteHost = false, h
|
|
|
35465
35512
|
const opener = managedRemoteHost ? void 0 : createLauncherUrlOpener(environment);
|
|
35466
35513
|
return {
|
|
35467
35514
|
pluginRoots: [
|
|
35468
|
-
|
|
35469
|
-
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ??
|
|
35470
|
-
environment.CODEXHOST_DATA_DIR ?
|
|
35515
|
+
path22.join(path22.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
|
|
35516
|
+
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path22.join(
|
|
35517
|
+
environment.CODEXHOST_DATA_DIR ? path22.resolve(environment.CODEXHOST_DATA_DIR) : path22.join(os6.homedir(), ".codexhost"),
|
|
35471
35518
|
"plugins"
|
|
35472
35519
|
)
|
|
35473
35520
|
],
|
|
@@ -35594,7 +35641,7 @@ async function startDelegationControlServer(input) {
|
|
|
35594
35641
|
// packages/host-runtime/src/remote-control-app-server.ts
|
|
35595
35642
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
35596
35643
|
import { mkdir as mkdir9, open as open7, rename as rename6, rm as rm9 } from "node:fs/promises";
|
|
35597
|
-
import
|
|
35644
|
+
import path23 from "node:path";
|
|
35598
35645
|
var REMOTE_CONTROL_BRIDGE_PIPE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_PIPE";
|
|
35599
35646
|
var REMOTE_CONTROL_BRIDGE_NODE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_NODE_PATH";
|
|
35600
35647
|
var REMOTE_CONTROL_BRIDGE_RUNTIME_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_RUNTIME_PATH";
|
|
@@ -35605,8 +35652,8 @@ var BRIDGE_READY_METHOD = "codexhost/remote-control-bridge/ready";
|
|
|
35605
35652
|
function absoluteEnvironmentPath2(environment, name, fallback, platform = process.platform) {
|
|
35606
35653
|
const value2 = environment[name] ?? fallback;
|
|
35607
35654
|
if (!value2) return null;
|
|
35608
|
-
if (
|
|
35609
|
-
return platform === "win32" &&
|
|
35655
|
+
if (path23.isAbsolute(value2)) return path23.normalize(value2);
|
|
35656
|
+
return platform === "win32" && path23.win32.isAbsolute(value2) ? path23.win32.normalize(value2) : null;
|
|
35610
35657
|
}
|
|
35611
35658
|
function nodeCompatibleWindowsPath(value2) {
|
|
35612
35659
|
if (value2.startsWith("\\\\?\\UNC\\")) return `\\\\${value2.slice(8)}`;
|
|
@@ -35620,13 +35667,13 @@ function remoteControlBridgePipePath(processId = process.pid, instanceId = rando
|
|
|
35620
35667
|
}
|
|
35621
35668
|
function remoteControlBridgeDescriptorPath(environment) {
|
|
35622
35669
|
const root = environment.LOCALAPPDATA;
|
|
35623
|
-
if (!root || !
|
|
35624
|
-
return
|
|
35670
|
+
if (!root || !path23.isAbsolute(root)) return null;
|
|
35671
|
+
return path23.join(path23.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
|
|
35625
35672
|
}
|
|
35626
35673
|
async function publishRemoteControlAppServerDescriptor(plan) {
|
|
35627
|
-
const directory =
|
|
35674
|
+
const directory = path23.dirname(plan.descriptorPath);
|
|
35628
35675
|
await mkdir9(directory, { recursive: true, mode: 448 });
|
|
35629
|
-
const temporaryPath =
|
|
35676
|
+
const temporaryPath = path23.join(
|
|
35630
35677
|
directory,
|
|
35631
35678
|
`.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID13()}.tmp`
|
|
35632
35679
|
);
|
|
@@ -35927,9 +35974,9 @@ function hasLauncherManagedUpdateRuntime(environment, hostRuntimePath) {
|
|
|
35927
35974
|
if (!environment[UPDATE_RUNTIME_ENV.launcherPid]) return false;
|
|
35928
35975
|
const npmPackageRoot = environment[UPDATE_RUNTIME_ENV.npmPackageRoot];
|
|
35929
35976
|
if (!npmPackageRoot || !hostRuntimePath) return true;
|
|
35930
|
-
if (!
|
|
35931
|
-
const runtimePackageRoot =
|
|
35932
|
-
return
|
|
35977
|
+
if (!path24.isAbsolute(npmPackageRoot) || !path24.isAbsolute(hostRuntimePath)) return false;
|
|
35978
|
+
const runtimePackageRoot = path24.dirname(path24.dirname(path24.normalize(hostRuntimePath)));
|
|
35979
|
+
return path24.relative(path24.normalize(npmPackageRoot), runtimePackageRoot) === "";
|
|
35933
35980
|
}
|
|
35934
35981
|
function requiredRuntimeConfiguration(environment) {
|
|
35935
35982
|
const stockCodexPath = environment[STOCK_CODEX_PATH_ENV];
|
|
@@ -36075,8 +36122,8 @@ async function runHostRuntime(input) {
|
|
|
36075
36122
|
const socketPath = remoteAppServerSocketPath(delegationEnvironment, listenUrl);
|
|
36076
36123
|
const officialPlan = createRemoteOfficialAppServerPlan(input.arguments, socketPath);
|
|
36077
36124
|
const officialRuntimeScope = new OfficialRuntimeScope({
|
|
36078
|
-
permanentHome:
|
|
36079
|
-
delegationEnvironment.CODEX_HOME ??
|
|
36125
|
+
permanentHome: path24.resolve(
|
|
36126
|
+
delegationEnvironment.CODEX_HOME ?? path24.join(homedir2(), ".codex")
|
|
36080
36127
|
),
|
|
36081
36128
|
diagnosticOutput: process.stderr,
|
|
36082
36129
|
createBackend: () => createOwnedUnixBackend({
|
|
@@ -36169,10 +36216,10 @@ import {
|
|
|
36169
36216
|
rename as rename7,
|
|
36170
36217
|
rm as rm10,
|
|
36171
36218
|
rmdir,
|
|
36172
|
-
stat as
|
|
36219
|
+
stat as stat6,
|
|
36173
36220
|
writeFile as writeFile4
|
|
36174
36221
|
} from "node:fs/promises";
|
|
36175
|
-
import
|
|
36222
|
+
import path25 from "node:path";
|
|
36176
36223
|
var MANIFEST_FORMAT = 1;
|
|
36177
36224
|
var WRAPPER_MARKER = "# codexhost remote SSH wrapper v1";
|
|
36178
36225
|
var PROFILE_START = "# >>> codexhost remote SSH >>>";
|
|
@@ -36183,25 +36230,25 @@ function resolvePaths(options2) {
|
|
|
36183
36230
|
if (!configuredHome) {
|
|
36184
36231
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
36185
36232
|
}
|
|
36186
|
-
const home =
|
|
36187
|
-
if (!home || home ===
|
|
36233
|
+
const home = path25.resolve(configuredHome);
|
|
36234
|
+
if (!home || home === path25.parse(home).root) {
|
|
36188
36235
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
36189
36236
|
}
|
|
36190
|
-
const installRoot =
|
|
36191
|
-
const profilePath =
|
|
36192
|
-
options2.profilePath ??
|
|
36237
|
+
const installRoot = path25.resolve(options2.installRoot ?? path25.join(home, ".codexhost", "remote"));
|
|
36238
|
+
const profilePath = path25.resolve(
|
|
36239
|
+
options2.profilePath ?? path25.join(
|
|
36193
36240
|
home,
|
|
36194
|
-
|
|
36241
|
+
path25.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path25.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
|
|
36195
36242
|
)
|
|
36196
36243
|
);
|
|
36197
|
-
const binDirectory =
|
|
36244
|
+
const binDirectory = path25.join(installRoot, "bin");
|
|
36198
36245
|
return {
|
|
36199
36246
|
home,
|
|
36200
36247
|
installRoot,
|
|
36201
36248
|
binDirectory,
|
|
36202
|
-
wrapperPath:
|
|
36203
|
-
manifestPath:
|
|
36204
|
-
dataDirectory:
|
|
36249
|
+
wrapperPath: path25.join(binDirectory, "codex"),
|
|
36250
|
+
manifestPath: path25.join(installRoot, "manifest.json"),
|
|
36251
|
+
dataDirectory: path25.join(installRoot, "data"),
|
|
36205
36252
|
profilePath
|
|
36206
36253
|
};
|
|
36207
36254
|
}
|
|
@@ -36220,9 +36267,9 @@ async function fileSha256(filePath) {
|
|
|
36220
36267
|
return createHash10("sha256").update(await readFile9(filePath)).digest("hex");
|
|
36221
36268
|
}
|
|
36222
36269
|
async function executable(filePath, label) {
|
|
36223
|
-
const absolute =
|
|
36270
|
+
const absolute = path25.resolve(filePath);
|
|
36224
36271
|
try {
|
|
36225
|
-
if (!(await
|
|
36272
|
+
if (!(await stat6(absolute)).isFile()) throw new Error("not a regular file");
|
|
36226
36273
|
await access(absolute, fsConstants.X_OK);
|
|
36227
36274
|
} catch {
|
|
36228
36275
|
throw new Error(`${label} is not an executable file: ${absolute}`);
|
|
@@ -36230,9 +36277,9 @@ async function executable(filePath, label) {
|
|
|
36230
36277
|
return absolute;
|
|
36231
36278
|
}
|
|
36232
36279
|
async function existingFile(filePath, label) {
|
|
36233
|
-
const absolute =
|
|
36280
|
+
const absolute = path25.resolve(filePath);
|
|
36234
36281
|
try {
|
|
36235
|
-
const metadata = await
|
|
36282
|
+
const metadata = await stat6(absolute);
|
|
36236
36283
|
if (!metadata.isFile()) throw new Error("not a regular file");
|
|
36237
36284
|
} catch {
|
|
36238
36285
|
throw new Error(`${label} is not a regular file: ${absolute}`);
|
|
@@ -36240,9 +36287,9 @@ async function existingFile(filePath, label) {
|
|
|
36240
36287
|
return absolute;
|
|
36241
36288
|
}
|
|
36242
36289
|
async function discoverExecutable(name, environment) {
|
|
36243
|
-
for (const directory of (environment.PATH ?? "").split(
|
|
36290
|
+
for (const directory of (environment.PATH ?? "").split(path25.delimiter)) {
|
|
36244
36291
|
if (!directory) continue;
|
|
36245
|
-
const candidate =
|
|
36292
|
+
const candidate = path25.resolve(directory, name);
|
|
36246
36293
|
try {
|
|
36247
36294
|
await access(candidate, fsConstants.X_OK);
|
|
36248
36295
|
return candidate;
|
|
@@ -36253,10 +36300,10 @@ async function discoverExecutable(name, environment) {
|
|
|
36253
36300
|
return null;
|
|
36254
36301
|
}
|
|
36255
36302
|
async function writeAtomic(filePath, contents, mode) {
|
|
36256
|
-
await mkdir10(
|
|
36257
|
-
const temporary =
|
|
36258
|
-
|
|
36259
|
-
`.${
|
|
36303
|
+
await mkdir10(path25.dirname(filePath), { recursive: true, mode: 448 });
|
|
36304
|
+
const temporary = path25.join(
|
|
36305
|
+
path25.dirname(filePath),
|
|
36306
|
+
`.${path25.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
|
|
36260
36307
|
);
|
|
36261
36308
|
try {
|
|
36262
36309
|
if (typeof contents === "string") {
|
|
@@ -36277,10 +36324,10 @@ async function writeAtomic(filePath, contents, mode) {
|
|
|
36277
36324
|
}
|
|
36278
36325
|
}
|
|
36279
36326
|
async function writeAtomicExecutable(filePath, sourcePath) {
|
|
36280
|
-
await mkdir10(
|
|
36281
|
-
const temporary =
|
|
36282
|
-
|
|
36283
|
-
`.${
|
|
36327
|
+
await mkdir10(path25.dirname(filePath), { recursive: true, mode: 448 });
|
|
36328
|
+
const temporary = path25.join(
|
|
36329
|
+
path25.dirname(filePath),
|
|
36330
|
+
`.${path25.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
|
|
36284
36331
|
);
|
|
36285
36332
|
try {
|
|
36286
36333
|
await copyFile3(sourcePath, temporary);
|
|
@@ -36321,8 +36368,8 @@ function removeManagedProfileBlock(contents) {
|
|
|
36321
36368
|
function installManagedProfileBlock(contents, manifest) {
|
|
36322
36369
|
const base = removeManagedProfileBlock(contents);
|
|
36323
36370
|
const environment = [
|
|
36324
|
-
`export CODEX_INSTALL_DIR=${shellQuote(
|
|
36325
|
-
`export PATH=${shellQuote(
|
|
36371
|
+
`export CODEX_INSTALL_DIR=${shellQuote(path25.dirname(manifest.wrapperPath))}`,
|
|
36372
|
+
`export PATH=${shellQuote(path25.dirname(manifest.wrapperPath))}:${shellQuote(path25.dirname(manifest.nodePath))}:${shellQuote(path25.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
|
|
36326
36373
|
`export CODEXHOST_STOCK_CODEX_PATH=${shellQuote(manifest.stockCodexPath)}`,
|
|
36327
36374
|
`export CODEXHOST_HOST_NODE_PATH=${shellQuote(manifest.nodePath)}`,
|
|
36328
36375
|
`export CODEXHOST_HOST_RUNTIME_PATH=${shellQuote(manifest.hostRuntimePath)}`,
|
|
@@ -36338,7 +36385,7 @@ function installManagedProfileBlock(contents, manifest) {
|
|
|
36338
36385
|
PROFILE_END,
|
|
36339
36386
|
""
|
|
36340
36387
|
].join("\n");
|
|
36341
|
-
if (
|
|
36388
|
+
if (path25.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
|
|
36342
36389
|
const separator = base.length > 0 && !base.endsWith("\n") ? "\n" : "";
|
|
36343
36390
|
return `${base}${separator}${block}`;
|
|
36344
36391
|
}
|
|
@@ -36404,9 +36451,9 @@ async function readManifest(filePath) {
|
|
|
36404
36451
|
];
|
|
36405
36452
|
const optionalPaths = ["claudeCommand", "profileBackupPath"];
|
|
36406
36453
|
if (manifest.format !== MANIFEST_FORMAT || Object.keys(manifest).some((key) => !allowed.has(key)) || requiredPaths.some(
|
|
36407
|
-
(key) => typeof manifest[key] !== "string" || !
|
|
36454
|
+
(key) => typeof manifest[key] !== "string" || !path25.isAbsolute(manifest[key])
|
|
36408
36455
|
) || optionalPaths.some(
|
|
36409
|
-
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !
|
|
36456
|
+
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path25.isAbsolute(manifest[key]))
|
|
36410
36457
|
) || manifest.entrypointSha256 !== void 0 && (typeof manifest.entrypointSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(manifest.entrypointSha256))) {
|
|
36411
36458
|
throw new Error("Remote Host manifest has an unsupported format");
|
|
36412
36459
|
}
|
|
@@ -36415,7 +36462,7 @@ async function readManifest(filePath) {
|
|
|
36415
36462
|
async function backupProfile(profilePath, contents, action) {
|
|
36416
36463
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replaceAll(/[-:.TZ]/gu, "");
|
|
36417
36464
|
const backupPath = `${profilePath}.codexhost-${action}-${timestamp}.bak`;
|
|
36418
|
-
const metadata = await
|
|
36465
|
+
const metadata = await stat6(profilePath).catch(() => null);
|
|
36419
36466
|
await writeAtomic(backupPath, contents, metadata?.mode ?? 384);
|
|
36420
36467
|
return backupPath;
|
|
36421
36468
|
}
|
|
@@ -36429,7 +36476,7 @@ async function installRemoteHost(options2) {
|
|
|
36429
36476
|
const previousManifest = await readManifest(paths.manifestPath);
|
|
36430
36477
|
const previousManifestFile = previousManifest ? {
|
|
36431
36478
|
contents: await readFile9(paths.manifestPath),
|
|
36432
|
-
mode: (await
|
|
36479
|
+
mode: (await stat6(paths.manifestPath)).mode & 511
|
|
36433
36480
|
} : null;
|
|
36434
36481
|
const existingEntrypoint = await lstat8(paths.wrapperPath).catch(
|
|
36435
36482
|
(error51) => {
|
|
@@ -36485,7 +36532,7 @@ async function installRemoteHost(options2) {
|
|
|
36485
36532
|
const existingProfile = existingProfileSource ?? "";
|
|
36486
36533
|
const nextProfile = installManagedProfileBlock(existingProfile, manifest);
|
|
36487
36534
|
const profileChanged = nextProfile !== existingProfile;
|
|
36488
|
-
const profileMetadata = await
|
|
36535
|
+
const profileMetadata = await stat6(profilePath).catch(() => null);
|
|
36489
36536
|
try {
|
|
36490
36537
|
if (profileChanged) {
|
|
36491
36538
|
const profileBackupPath = await backupProfile(profilePath, existingProfile, "install");
|
|
@@ -36576,7 +36623,7 @@ async function inspectRemoteHostInstallation(options2) {
|
|
|
36576
36623
|
if (!profileMatches && profileIssue === null)
|
|
36577
36624
|
profileIssue = "shell profile does not configure the managed native entrypoint";
|
|
36578
36625
|
if (profileIssue !== null) issues.push(profileIssue);
|
|
36579
|
-
const dataDirectory = await
|
|
36626
|
+
const dataDirectory = await stat6(manifest.dataDirectory).catch(() => null);
|
|
36580
36627
|
if (!dataDirectory?.isDirectory()) issues.push("remote Host data directory is unavailable");
|
|
36581
36628
|
for (const [label, filePath, requiresExecutable] of [
|
|
36582
36629
|
["stock Codex", manifest.stockCodexPath, true],
|
|
@@ -36586,7 +36633,7 @@ async function inspectRemoteHostInstallation(options2) {
|
|
|
36586
36633
|
]) {
|
|
36587
36634
|
try {
|
|
36588
36635
|
if (requiresExecutable) await executable(filePath, label);
|
|
36589
|
-
else if (!(await
|
|
36636
|
+
else if (!(await stat6(filePath)).isFile()) throw new Error("not a regular file");
|
|
36590
36637
|
} catch {
|
|
36591
36638
|
issues.push(`${label} is unavailable`);
|
|
36592
36639
|
}
|
|
@@ -36615,7 +36662,7 @@ async function uninstallRemoteHost(options2) {
|
|
|
36615
36662
|
const nextProfile = removeManagedProfileBlock(profile);
|
|
36616
36663
|
if (nextProfile !== profile) {
|
|
36617
36664
|
await backupProfile(manifest.profilePath, profile, "uninstall");
|
|
36618
|
-
const metadata = await
|
|
36665
|
+
const metadata = await stat6(manifest.profilePath).catch(() => null);
|
|
36619
36666
|
await writeAtomic(manifest.profilePath, nextProfile, metadata?.mode ?? 384);
|
|
36620
36667
|
}
|
|
36621
36668
|
await rm10(manifest.wrapperPath, { force: true });
|
|
@@ -36630,9 +36677,9 @@ async function uninstallRemoteHost(options2) {
|
|
|
36630
36677
|
|
|
36631
36678
|
// packages/host-runtime/src/remote-host-lifecycle.ts
|
|
36632
36679
|
import { spawn as spawn5 } from "node:child_process";
|
|
36633
|
-
import { stat as
|
|
36680
|
+
import { stat as stat7 } from "node:fs/promises";
|
|
36634
36681
|
import net3 from "node:net";
|
|
36635
|
-
import
|
|
36682
|
+
import path26 from "node:path";
|
|
36636
36683
|
import { Duplex } from "node:stream";
|
|
36637
36684
|
var CODEXHOST_STATUS_METHOD = "codexhost/update/status";
|
|
36638
36685
|
var DIRECT_PROBE_TIMEOUT_MS = 5e3;
|
|
@@ -36651,12 +36698,12 @@ function classifyRemoteHostProbeResponse(response, socketPath) {
|
|
|
36651
36698
|
}
|
|
36652
36699
|
var lifecycleDependencyOverrides = {};
|
|
36653
36700
|
function socketPathFor(environment) {
|
|
36654
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
36701
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path26.join(environment.HOME, ".codex") : void 0);
|
|
36655
36702
|
if (!codexHome) throw new Error("CODEX_HOME or HOME is required for remote Host lifecycle");
|
|
36656
|
-
return
|
|
36703
|
+
return path26.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
36657
36704
|
}
|
|
36658
36705
|
async function defaultSocketExists(socketPath) {
|
|
36659
|
-
const metadata = await
|
|
36706
|
+
const metadata = await stat7(socketPath).catch((error51) => {
|
|
36660
36707
|
if (error51.code === "ENOENT") return null;
|
|
36661
36708
|
throw error51;
|
|
36662
36709
|
});
|
|
@@ -36780,14 +36827,14 @@ function installedManifest(status) {
|
|
|
36780
36827
|
function managedEnvironment(manifest, environment) {
|
|
36781
36828
|
return {
|
|
36782
36829
|
...environment,
|
|
36783
|
-
CODEX_INSTALL_DIR:
|
|
36830
|
+
CODEX_INSTALL_DIR: path26.dirname(manifest.wrapperPath),
|
|
36784
36831
|
CODEXHOST_STOCK_CODEX_PATH: manifest.stockCodexPath,
|
|
36785
36832
|
CODEXHOST_HOST_NODE_PATH: manifest.nodePath,
|
|
36786
36833
|
CODEXHOST_HOST_RUNTIME_PATH: manifest.hostRuntimePath,
|
|
36787
36834
|
CODEXHOST_DATA_DIR: manifest.dataDirectory,
|
|
36788
36835
|
CODEXHOST_DEFAULT_AGENT: "codex",
|
|
36789
36836
|
CODEXHOST_REMOTE_SSH_MANAGED: "1",
|
|
36790
|
-
PATH: `${
|
|
36837
|
+
PATH: `${path26.dirname(manifest.wrapperPath)}${path26.delimiter}${path26.dirname(manifest.stockCodexPath)}${path26.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
|
|
36791
36838
|
};
|
|
36792
36839
|
}
|
|
36793
36840
|
async function defaultRunTerminator(manifest, socketPath, role, environment) {
|
|
@@ -37123,25 +37170,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
37123
37170
|
|
|
37124
37171
|
// packages/harness-broker/dist/paths.js
|
|
37125
37172
|
import os7 from "node:os";
|
|
37126
|
-
import
|
|
37173
|
+
import path27 from "node:path";
|
|
37127
37174
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
37128
37175
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
37129
37176
|
var HARNESS_BROKER_SOCKET_FILE = "claude-code-broker-v1.sock";
|
|
37130
37177
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
37131
37178
|
const home = environment.HOME || os7.homedir();
|
|
37132
|
-
return
|
|
37179
|
+
return path27.join(home, ".codexhost", "harness-broker");
|
|
37133
37180
|
}
|
|
37134
37181
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
37135
37182
|
harnessPluginIdSchema.parse(harnessId);
|
|
37136
37183
|
if (harnessId !== "claude-code")
|
|
37137
|
-
return
|
|
37138
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
37184
|
+
return path27.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
37185
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path27.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
37139
37186
|
}
|
|
37140
37187
|
function defaultHarnessBrokerSocketPath(environment = process.env, harnessId = "claude-code") {
|
|
37141
37188
|
harnessPluginIdSchema.parse(harnessId);
|
|
37142
37189
|
if (harnessId !== "claude-code")
|
|
37143
|
-
return
|
|
37144
|
-
return
|
|
37190
|
+
return path27.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
|
|
37191
|
+
return path27.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
|
|
37145
37192
|
}
|
|
37146
37193
|
|
|
37147
37194
|
// packages/harness-broker/dist/validation.js
|
|
@@ -37357,7 +37404,7 @@ var harnessOutputSchema = external_exports.custom((value2) => {
|
|
|
37357
37404
|
import { randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
|
|
37358
37405
|
import { chmod as chmod5, lstat as lstat9, mkdir as mkdir11, open as open8, readFile as readFile10, rename as rename8, rm as rm11 } from "node:fs/promises";
|
|
37359
37406
|
import net4, {} from "node:net";
|
|
37360
|
-
import
|
|
37407
|
+
import path28 from "node:path";
|
|
37361
37408
|
function harnessError(message, retryable = true) {
|
|
37362
37409
|
return { code: "unavailable", message, retryable, stage: "harnessBroker" };
|
|
37363
37410
|
}
|
|
@@ -37480,13 +37527,13 @@ async function prepareUnixSocketPath(socketPath) {
|
|
|
37480
37527
|
}
|
|
37481
37528
|
async function startHarnessBrokerServer(input) {
|
|
37482
37529
|
harnessPluginIdSchema.parse(input.adapter.harnessId);
|
|
37483
|
-
if (process.platform !== "win32" &&
|
|
37530
|
+
if (process.platform !== "win32" && path28.dirname(input.descriptorPath) !== path28.dirname(input.socketPath)) {
|
|
37484
37531
|
throw new Error("Harness broker descriptor and socket must share one private directory");
|
|
37485
37532
|
}
|
|
37486
37533
|
if (process.platform === "darwin" && Buffer.byteLength(input.socketPath) > 103) {
|
|
37487
37534
|
throw new Error("Harness broker Unix socket path is too long for macOS");
|
|
37488
37535
|
}
|
|
37489
|
-
await privateDirectory(
|
|
37536
|
+
await privateDirectory(path28.dirname(input.descriptorPath));
|
|
37490
37537
|
await assertNoLiveDescriptor(input.descriptorPath);
|
|
37491
37538
|
if (process.platform !== "win32")
|
|
37492
37539
|
await prepareUnixSocketPath(input.socketPath);
|