@liberseek/boft-cli-win32-arm64 0.7.3 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +4 -0
- package/app/codexhost-distribution.json +1 -1
- package/app/host-runtime.mjs +458 -171
- package/app/plugins/claude-code/plugin.mjs +3 -6
- package/app/plugins/cursor-cli/plugin.mjs +80 -19
- package/app/plugins/deepseek-harness/plugin.mjs +598 -125
- package/app/plugins/omp/plugin.mjs +163 -103
- package/app/plugins/opencode/plugin.mjs +3175 -169
- package/app/plugins/pi/plugin.mjs +4 -1
- package/app/renderer-extension.js +149 -156
- package/bin/boft.exe +0 -0
- package/libexec/boft-node-repl.exe +0 -0
- package/libexec/boft-shim.exe +0 -0
- package/libexec/boft-updater.exe +0 -0
- package/licenses/OpenCode-v2-Client-LICENSE.txt +21 -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 path25 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, path31) {
|
|
5982
|
+
if (!path31)
|
|
5983
5983
|
return obj;
|
|
5984
|
-
return
|
|
5984
|
+
return path31.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(path31, 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(path31);
|
|
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, path31 = []) => {
|
|
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 }, [...path31, ...issue2.path]));
|
|
6548
6548
|
} else if (issue2.code === "invalid_key") {
|
|
6549
|
-
processError({ issues: issue2.issues }, [...
|
|
6549
|
+
processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
|
|
6550
6550
|
} else if (issue2.code === "invalid_element") {
|
|
6551
|
-
processError({ issues: issue2.issues }, [...
|
|
6551
|
+
processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
|
|
6552
6552
|
} else {
|
|
6553
|
-
const fullpath = [...
|
|
6553
|
+
const fullpath = [...path31, ...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, path31 = []) => {
|
|
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 }, [...path31, ...issue2.path]));
|
|
6585
6585
|
} else if (issue2.code === "invalid_key") {
|
|
6586
|
-
processError({ issues: issue2.issues }, [...
|
|
6586
|
+
processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
|
|
6587
6587
|
} else if (issue2.code === "invalid_element") {
|
|
6588
|
-
processError({ issues: issue2.issues }, [...
|
|
6588
|
+
processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
|
|
6589
6589
|
} else {
|
|
6590
|
-
const fullpath = [...
|
|
6590
|
+
const fullpath = [...path31, ...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 path31 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
6623
|
+
for (const seg of path31) {
|
|
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 path31 = ref.slice(1).split("/").filter(Boolean);
|
|
19316
|
+
if (path31.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 (path31[0] === defsKey) {
|
|
19321
|
+
const key = path31[1];
|
|
19322
19322
|
if (!key || !ctx.defs[key]) {
|
|
19323
19323
|
throw new Error(`Reference not found: ${ref}`);
|
|
19324
19324
|
}
|
|
@@ -22864,16 +22864,16 @@ var Diff = class {
|
|
|
22864
22864
|
}
|
|
22865
22865
|
}
|
|
22866
22866
|
}
|
|
22867
|
-
addToPath(
|
|
22868
|
-
const last =
|
|
22867
|
+
addToPath(path31, added, removed, oldPosInc, options2) {
|
|
22868
|
+
const last = path31.lastComponent;
|
|
22869
22869
|
if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
22870
22870
|
return {
|
|
22871
|
-
oldPos:
|
|
22871
|
+
oldPos: path31.oldPos + oldPosInc,
|
|
22872
22872
|
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
22873
22873
|
};
|
|
22874
22874
|
} else {
|
|
22875
22875
|
return {
|
|
22876
|
-
oldPos:
|
|
22876
|
+
oldPos: path31.oldPos + oldPosInc,
|
|
22877
22877
|
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
22878
22878
|
};
|
|
22879
22879
|
}
|
|
@@ -23301,6 +23301,9 @@ function splitLines(text2) {
|
|
|
23301
23301
|
return result;
|
|
23302
23302
|
}
|
|
23303
23303
|
|
|
23304
|
+
// packages/protocol-core/dist/codex-ui-projector.js
|
|
23305
|
+
import path9 from "node:path";
|
|
23306
|
+
|
|
23304
23307
|
// packages/protocol-core/dist/file-change-summary.js
|
|
23305
23308
|
import path8 from "node:path";
|
|
23306
23309
|
function filePathKey(file2, cwd) {
|
|
@@ -23475,6 +23478,14 @@ function nestedString(value2, keys, preserveText = false) {
|
|
|
23475
23478
|
}
|
|
23476
23479
|
return void 0;
|
|
23477
23480
|
}
|
|
23481
|
+
function toolWorkingDirectory(args, defaultCwd) {
|
|
23482
|
+
const workdir = nestedString(args, ["workdir"]);
|
|
23483
|
+
if (workdir === void 0)
|
|
23484
|
+
return defaultCwd;
|
|
23485
|
+
const windows = /^(?:[a-z]:[/\\]|\\\\)/iu;
|
|
23486
|
+
const paths = windows.test(defaultCwd) || windows.test(workdir) ? path9.win32 : path9.posix;
|
|
23487
|
+
return paths.resolve(defaultCwd, workdir);
|
|
23488
|
+
}
|
|
23478
23489
|
function toolOutputText(item) {
|
|
23479
23490
|
if (!item.output)
|
|
23480
23491
|
return null;
|
|
@@ -23484,7 +23495,7 @@ function toolOutputText(item) {
|
|
|
23484
23495
|
function toolCommandLine(toolName, args) {
|
|
23485
23496
|
const lower = toolName.toLowerCase().replaceAll(/[_-]/g, "");
|
|
23486
23497
|
const command = nestedString(args, ["command", "cmd", "script", "commandLine", "command_line"]);
|
|
23487
|
-
if (command && ["bash", "exec", "terminal", "run", "shell", "powershell", "command"].includes(lower)) {
|
|
23498
|
+
if (command && ["bash", "exec", "terminal", "run", "shell", "powershell", "pwsh", "command"].includes(lower)) {
|
|
23488
23499
|
return command;
|
|
23489
23500
|
}
|
|
23490
23501
|
const filePath = nestedString(args, [
|
|
@@ -23575,8 +23586,8 @@ function projectFileChangeKind(kind) {
|
|
|
23575
23586
|
return { type: kind };
|
|
23576
23587
|
}
|
|
23577
23588
|
function projectFileChanges(changes) {
|
|
23578
|
-
return changes.map(({ path:
|
|
23579
|
-
path:
|
|
23589
|
+
return changes.map(({ path: path31, kind, unifiedDiff }) => ({
|
|
23590
|
+
path: path31,
|
|
23580
23591
|
kind: projectFileChangeKind(kind),
|
|
23581
23592
|
diff: unifiedDiff
|
|
23582
23593
|
}));
|
|
@@ -23748,14 +23759,16 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23748
23759
|
memoryCitation: null,
|
|
23749
23760
|
durationMs: item.durationMs ?? null
|
|
23750
23761
|
};
|
|
23751
|
-
case "reasoning":
|
|
23762
|
+
case "reasoning": {
|
|
23763
|
+
const text2 = reasoningDisplayText(item.text);
|
|
23752
23764
|
return {
|
|
23753
23765
|
id: reasoningPreviewItemId(item.itemId),
|
|
23754
23766
|
type: "reasoning",
|
|
23755
|
-
summary:
|
|
23767
|
+
summary: text2 ? [text2] : [],
|
|
23756
23768
|
content: [],
|
|
23757
23769
|
durationMs: item.durationMs ?? null
|
|
23758
23770
|
};
|
|
23771
|
+
}
|
|
23759
23772
|
case "contextCompaction":
|
|
23760
23773
|
return { id: item.itemId, type: "contextCompaction" };
|
|
23761
23774
|
case "commandExecution":
|
|
@@ -23779,13 +23792,13 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23779
23792
|
id: item.itemId,
|
|
23780
23793
|
type: "commandExecution",
|
|
23781
23794
|
command,
|
|
23782
|
-
cwd: defaultCwd,
|
|
23795
|
+
cwd: toolWorkingDirectory(item.arguments, defaultCwd),
|
|
23783
23796
|
processId: null,
|
|
23784
23797
|
source: "agent",
|
|
23785
23798
|
status: itemStatus(outcome),
|
|
23786
23799
|
commandActions: [],
|
|
23787
23800
|
aggregatedOutput: includeCommandOutput ? toolOutputText(item) : null,
|
|
23788
|
-
exitCode:
|
|
23801
|
+
exitCode: null,
|
|
23789
23802
|
durationMs: item.durationMs ?? null
|
|
23790
23803
|
};
|
|
23791
23804
|
}
|
|
@@ -23833,6 +23846,9 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
23833
23846
|
function reasoningPreviewItemId(itemId) {
|
|
23834
23847
|
return `${itemId}-summary`;
|
|
23835
23848
|
}
|
|
23849
|
+
function reasoningDisplayText(text2) {
|
|
23850
|
+
return text2.replace(/[\r\n]+$/u, "");
|
|
23851
|
+
}
|
|
23836
23852
|
function projectReasoningTranscriptItem(item, outcome, defaultCwd, durationMs = null) {
|
|
23837
23853
|
return {
|
|
23838
23854
|
id: item.itemId,
|
|
@@ -23843,7 +23859,7 @@ function projectReasoningTranscriptItem(item, outcome, defaultCwd, durationMs =
|
|
|
23843
23859
|
source: "agent",
|
|
23844
23860
|
status: itemStatus(outcome),
|
|
23845
23861
|
commandActions: [],
|
|
23846
|
-
aggregatedOutput: item.text
|
|
23862
|
+
aggregatedOutput: reasoningDisplayText(item.text) || null,
|
|
23847
23863
|
exitCode: outcome ? 0 : null,
|
|
23848
23864
|
durationMs
|
|
23849
23865
|
};
|
|
@@ -23900,6 +23916,8 @@ function projectHistoricalTurn(input) {
|
|
|
23900
23916
|
if (isFileMutatingTool(item.toolName))
|
|
23901
23917
|
return [];
|
|
23902
23918
|
}
|
|
23919
|
+
if (item.type === "reasoning" && !reasoningDisplayText(item.text))
|
|
23920
|
+
return [];
|
|
23903
23921
|
return item.type === "reasoning" ? [
|
|
23904
23922
|
projectItem(item, outcome, cwd, true, input.threadId ?? ""),
|
|
23905
23923
|
projectReasoningTranscriptItem(item, outcome, cwd, item.durationMs ?? null)
|
|
@@ -24089,7 +24107,7 @@ var CodexTurnProjector = class {
|
|
|
24089
24107
|
startedAtMs
|
|
24090
24108
|
};
|
|
24091
24109
|
this.#items.set(event.item.itemId, projected);
|
|
24092
|
-
if ((event.item.type === "agentMessage" || event.item.type === "reasoning") && event.item.text.length === 0) {
|
|
24110
|
+
if ((event.item.type === "agentMessage" || event.item.type === "reasoning") && (event.item.type === "reasoning" ? reasoningDisplayText(event.item.text).length === 0 : event.item.text.length === 0)) {
|
|
24093
24111
|
return { messages: [] };
|
|
24094
24112
|
}
|
|
24095
24113
|
if (event.item.type === "toolExecution") {
|
|
@@ -24109,7 +24127,8 @@ var CodexTurnProjector = class {
|
|
|
24109
24127
|
const startedItem = event.item.type === "reasoning" ? { ...event.item, text: "" } : event.item;
|
|
24110
24128
|
const messages = [this.#startWireItem(projected, startedItem, startedAtMs)];
|
|
24111
24129
|
if (event.item.type === "reasoning") {
|
|
24112
|
-
|
|
24130
|
+
const text2 = reasoningDisplayText(event.item.text);
|
|
24131
|
+
messages.push(this.#startReasoningTranscript(event.item, startedAtMs), this.#reasoningOutputDelta(event.item.itemId, text2, startedAtMs), ...this.#reasoningDelta(projected, text2, startedAtMs));
|
|
24113
24132
|
}
|
|
24114
24133
|
return { messages };
|
|
24115
24134
|
}
|
|
@@ -24137,10 +24156,14 @@ var CodexTurnProjector = class {
|
|
|
24137
24156
|
}
|
|
24138
24157
|
});
|
|
24139
24158
|
} else if (next.type === "reasoning") {
|
|
24159
|
+
const previousText = previous.type === "reasoning" ? reasoningDisplayText(previous.text) : "";
|
|
24160
|
+
const delta = reasoningDisplayText(next.text).slice(previousText.length);
|
|
24161
|
+
if (!delta)
|
|
24162
|
+
return { messages };
|
|
24140
24163
|
if (!projected.wireStarted) {
|
|
24141
24164
|
messages.push(this.#startWireItem(projected, { ...next, text: "" }, emittedAtMs), this.#startReasoningTranscript({ ...next, text: "" }, emittedAtMs));
|
|
24142
24165
|
}
|
|
24143
|
-
messages.push(this.#reasoningOutputDelta(event.itemId,
|
|
24166
|
+
messages.push(this.#reasoningOutputDelta(event.itemId, delta, emittedAtMs), ...this.#reasoningDelta(projected, delta, emittedAtMs));
|
|
24144
24167
|
}
|
|
24145
24168
|
} else if (event.update.type === "output.append") {
|
|
24146
24169
|
projected.streamedCommandOutput = true;
|
|
@@ -24523,13 +24546,13 @@ function decodeThreadForkRequest(request) {
|
|
|
24523
24546
|
if (runtimeWorkspaceRoots !== void 0 && runtimeWorkspaceRoots !== null && (!Array.isArray(runtimeWorkspaceRoots) || runtimeWorkspaceRoots.some((root) => typeof root !== "string" || root.length === 0))) {
|
|
24524
24547
|
throw new Error("thread/fork params.runtimeWorkspaceRoots must be text paths or null");
|
|
24525
24548
|
}
|
|
24526
|
-
const
|
|
24549
|
+
const path31 = optionalText(params, "path", { allowEmpty: true });
|
|
24527
24550
|
const ephemeral = optionalBoolean(params, "ephemeral");
|
|
24528
24551
|
return {
|
|
24529
24552
|
threadId: threadId2,
|
|
24530
24553
|
...lastTurnText ? { lastTurnId: hostTurnIdSchema.parse(lastTurnText) } : {},
|
|
24531
24554
|
...beforeTurnText ? { beforeTurnId: hostTurnIdSchema.parse(beforeTurnText) } : {},
|
|
24532
|
-
...
|
|
24555
|
+
...path31 ? { path: path31 } : {},
|
|
24533
24556
|
...optionalField(params, "model"),
|
|
24534
24557
|
...optionalField(params, "modelProvider"),
|
|
24535
24558
|
...optionalField(params, "cwd"),
|
|
@@ -25707,7 +25730,7 @@ var HarnessAccountInspectionCache = class {
|
|
|
25707
25730
|
// packages/host-runtime/src/app-server-host.ts
|
|
25708
25731
|
import { createHash as createHash8, randomUUID as randomUUID10 } from "node:crypto";
|
|
25709
25732
|
import os5 from "node:os";
|
|
25710
|
-
import
|
|
25733
|
+
import path17 from "node:path";
|
|
25711
25734
|
|
|
25712
25735
|
// packages/host-runtime/src/external-thread-fork.ts
|
|
25713
25736
|
import nodePath from "node:path";
|
|
@@ -25715,7 +25738,7 @@ import nodePath from "node:path";
|
|
|
25715
25738
|
// packages/host-runtime/src/external-thread-repository.ts
|
|
25716
25739
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
25717
25740
|
import os3 from "node:os";
|
|
25718
|
-
import
|
|
25741
|
+
import path10 from "node:path";
|
|
25719
25742
|
|
|
25720
25743
|
// packages/host-runtime/src/external-subagent-threads.ts
|
|
25721
25744
|
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
@@ -25855,8 +25878,8 @@ function sameMapping(left, right) {
|
|
|
25855
25878
|
}
|
|
25856
25879
|
function defaultMappingStoreDirectory(environment) {
|
|
25857
25880
|
const dataDirectory = environment.CODEXHOST_DATA_DIR;
|
|
25858
|
-
return
|
|
25859
|
-
dataDirectory ?
|
|
25881
|
+
return path10.join(
|
|
25882
|
+
dataDirectory ? path10.resolve(dataDirectory) : path10.join(os3.homedir(), ".codexhost"),
|
|
25860
25883
|
"mapping-store"
|
|
25861
25884
|
);
|
|
25862
25885
|
}
|
|
@@ -27496,6 +27519,7 @@ var ExternalThreadRuntime = class {
|
|
|
27496
27519
|
responseGates: /* @__PURE__ */ new Map(),
|
|
27497
27520
|
ephemeralTurnIds: /* @__PURE__ */ new Set(),
|
|
27498
27521
|
persistenceError: null,
|
|
27522
|
+
projectedTerminalTurnId: null,
|
|
27499
27523
|
ignoredInteractionIds: /* @__PURE__ */ new Set()
|
|
27500
27524
|
};
|
|
27501
27525
|
this.idleRelease.touch(externalThread);
|
|
@@ -28004,7 +28028,7 @@ async function resolveExternalCommand(commands, text2, options2 = {}) {
|
|
|
28004
28028
|
}
|
|
28005
28029
|
|
|
28006
28030
|
// packages/host-runtime/src/live-command-catalog-cache.ts
|
|
28007
|
-
import
|
|
28031
|
+
import path11 from "node:path";
|
|
28008
28032
|
var MAX_ENTRIES = 64;
|
|
28009
28033
|
function isLiveCommandCatalog(catalog, staticCatalog) {
|
|
28010
28034
|
const staticIds = new Set(staticCatalog.commands.map(({ id: id2 }) => id2));
|
|
@@ -28013,7 +28037,7 @@ function isLiveCommandCatalog(catalog, staticCatalog) {
|
|
|
28013
28037
|
var LiveCommandCatalogCache = class {
|
|
28014
28038
|
#entries = /* @__PURE__ */ new Map();
|
|
28015
28039
|
#key(harnessId, cwd) {
|
|
28016
|
-
return `${harnessId}\0${
|
|
28040
|
+
return `${harnessId}\0${path11.resolve(cwd)}`;
|
|
28017
28041
|
}
|
|
28018
28042
|
remember(harnessId, cwd, catalog) {
|
|
28019
28043
|
const key = this.#key(harnessId, cwd);
|
|
@@ -28030,12 +28054,12 @@ var LiveCommandCatalogCache = class {
|
|
|
28030
28054
|
}
|
|
28031
28055
|
};
|
|
28032
28056
|
function sameWorkspace(left, right) {
|
|
28033
|
-
return
|
|
28057
|
+
return path11.resolve(left) === path11.resolve(right);
|
|
28034
28058
|
}
|
|
28035
28059
|
|
|
28036
28060
|
// packages/host-runtime/src/harness-delegation-coordinator.ts
|
|
28037
28061
|
import { createHash as createHash7, randomUUID as randomUUID6 } from "node:crypto";
|
|
28038
|
-
import
|
|
28062
|
+
import path12 from "node:path";
|
|
28039
28063
|
|
|
28040
28064
|
// packages/host-runtime/src/delegation-snapshot.ts
|
|
28041
28065
|
import { createHash as createHash6 } from "node:crypto";
|
|
@@ -28206,7 +28230,7 @@ function taskDigest(input) {
|
|
|
28206
28230
|
return createHash7("sha256").update(
|
|
28207
28231
|
JSON.stringify({
|
|
28208
28232
|
task: input.task,
|
|
28209
|
-
cwd:
|
|
28233
|
+
cwd: path12.resolve(input.cwd),
|
|
28210
28234
|
modelId: input.model?.id ?? null,
|
|
28211
28235
|
thinkingOptionId: input.thinkingOptionId ?? null
|
|
28212
28236
|
})
|
|
@@ -28277,7 +28301,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28277
28301
|
return {
|
|
28278
28302
|
harnessId: input.harnessId,
|
|
28279
28303
|
inspection: await adapter.inspect({
|
|
28280
|
-
...input.cwd ? { cwd:
|
|
28304
|
+
...input.cwd ? { cwd: path12.resolve(input.cwd) } : {},
|
|
28281
28305
|
...input.refresh !== void 0 ? { refresh: input.refresh } : {}
|
|
28282
28306
|
})
|
|
28283
28307
|
};
|
|
@@ -28291,7 +28315,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28291
28315
|
const result = await this.#startOfficial({ ...input, parentThreadId, cwd: selectedCwd });
|
|
28292
28316
|
return { ...result, parentThreadId, cwd: result.cwd ?? selectedCwd };
|
|
28293
28317
|
}
|
|
28294
|
-
const startInput = { ...input, parentThreadId, cwd:
|
|
28318
|
+
const startInput = { ...input, parentThreadId, cwd: path12.resolve(selectedCwd) };
|
|
28295
28319
|
if (!this.#adapters.has(input.harnessId)) {
|
|
28296
28320
|
throw new DelegationControlError(
|
|
28297
28321
|
"HARNESS_NOT_FOUND",
|
|
@@ -28410,6 +28434,26 @@ var HarnessDelegationCoordinator = class {
|
|
|
28410
28434
|
revision = thread.stateObserver.revision;
|
|
28411
28435
|
}
|
|
28412
28436
|
}
|
|
28437
|
+
const state = thread.stateObserver.state;
|
|
28438
|
+
if (state.effectiveModel && state.effectivePermissionModeId) {
|
|
28439
|
+
const transportModelId = encodeExternalTransportSelection(targetHarnessId, {
|
|
28440
|
+
model: state.effectiveModel,
|
|
28441
|
+
permissionModeId: state.effectivePermissionModeId,
|
|
28442
|
+
...state.effectiveThinkingOptionId ? { thinkingOptionId: state.effectiveThinkingOptionId } : {}
|
|
28443
|
+
});
|
|
28444
|
+
thread.record = await this.#repository.setTransportModelId(
|
|
28445
|
+
childThreadId,
|
|
28446
|
+
transportModelId
|
|
28447
|
+
);
|
|
28448
|
+
thread.transportModelId = transportModelId;
|
|
28449
|
+
thread.requestedPermissionModeId = state.effectivePermissionModeId;
|
|
28450
|
+
thread.thread = externalThreadValue({
|
|
28451
|
+
record: thread.record,
|
|
28452
|
+
turns: thread.turns,
|
|
28453
|
+
sessionId: thread.sessionId,
|
|
28454
|
+
running: thread.running
|
|
28455
|
+
});
|
|
28456
|
+
}
|
|
28413
28457
|
await this.#repository.setDelegationStatus(delegationId, "running");
|
|
28414
28458
|
await this.#notifyThreadStarted(thread.thread);
|
|
28415
28459
|
return {
|
|
@@ -28523,7 +28567,10 @@ var HarnessDelegationCoordinator = class {
|
|
|
28523
28567
|
const thread = resolution.thread;
|
|
28524
28568
|
if (!thread.running && !resolution.historyFresh) {
|
|
28525
28569
|
const error51 = await this.#externalRuntime.refresh(thread);
|
|
28526
|
-
|
|
28570
|
+
const last = thread.turns.at(-1);
|
|
28571
|
+
const projectedTerminal = thread.projectedTerminalTurnId !== null && last?.id === thread.projectedTerminalTurnId && (last.status === "completed" || last.status === "failed" || last.status === "interrupted");
|
|
28572
|
+
if (error51 && !projectedTerminal)
|
|
28573
|
+
throw new DelegationControlError("INTERNAL_ERROR", error51.message);
|
|
28527
28574
|
}
|
|
28528
28575
|
const turns = thread.activeTurnId ? [
|
|
28529
28576
|
...thread.turns,
|
|
@@ -28720,7 +28767,7 @@ var HarnessDelegationCoordinator = class {
|
|
|
28720
28767
|
|
|
28721
28768
|
// packages/host-runtime/src/harness-plugin-loader.ts
|
|
28722
28769
|
import { readdir as readdir3, realpath as realpath2 } from "node:fs/promises";
|
|
28723
|
-
import
|
|
28770
|
+
import path14 from "node:path";
|
|
28724
28771
|
import { pathToFileURL } from "node:url";
|
|
28725
28772
|
|
|
28726
28773
|
// packages/host-runtime/src/harness-plugin-registry.ts
|
|
@@ -28758,16 +28805,16 @@ var HarnessPluginRegistry = class {
|
|
|
28758
28805
|
|
|
28759
28806
|
// packages/host-runtime/src/plugin-files.ts
|
|
28760
28807
|
import { open as open5, realpath, stat as stat3 } from "node:fs/promises";
|
|
28761
|
-
import
|
|
28808
|
+
import path13 from "node:path";
|
|
28762
28809
|
function inside(root, candidate) {
|
|
28763
|
-
const relative =
|
|
28764
|
-
return relative !== "" && !
|
|
28810
|
+
const relative = path13.relative(root, candidate);
|
|
28811
|
+
return relative !== "" && !path13.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path13.sep}`);
|
|
28765
28812
|
}
|
|
28766
28813
|
async function pluginResourcePath(root, relative) {
|
|
28767
|
-
if (
|
|
28814
|
+
if (path13.isAbsolute(relative) || !inside(root, path13.resolve(root, relative))) {
|
|
28768
28815
|
throw new Error("Plugin resource escapes its root");
|
|
28769
28816
|
}
|
|
28770
|
-
const resolved = await realpath(
|
|
28817
|
+
const resolved = await realpath(path13.resolve(root, relative));
|
|
28771
28818
|
if (!inside(root, resolved) || !(await stat3(resolved)).isFile()) {
|
|
28772
28819
|
throw new Error("Plugin resource must be a regular file inside its root");
|
|
28773
28820
|
}
|
|
@@ -28929,7 +28976,7 @@ async function loadHarnessPlugins(options2) {
|
|
|
28929
28976
|
const enabledIds = /* @__PURE__ */ new Set();
|
|
28930
28977
|
const roots = /* @__PURE__ */ new Set();
|
|
28931
28978
|
for (const configuredRoot of options2.roots) {
|
|
28932
|
-
if (!
|
|
28979
|
+
if (!path14.isAbsolute(configuredRoot)) {
|
|
28933
28980
|
diagnose({ code: "invalidRoot" });
|
|
28934
28981
|
continue;
|
|
28935
28982
|
}
|
|
@@ -28959,7 +29006,7 @@ async function loadHarnessPlugins(options2) {
|
|
|
28959
29006
|
for (const directory of directories) {
|
|
28960
29007
|
try {
|
|
28961
29008
|
const file2 = await pluginResourcePath(root, `${directory.name}/manifest.json`);
|
|
28962
|
-
const pluginRoot = await realpath2(
|
|
29009
|
+
const pluginRoot = await realpath2(path14.join(root, directory.name));
|
|
28963
29010
|
await pluginResourcePath(pluginRoot, "manifest.json");
|
|
28964
29011
|
const manifest = harnessPluginManifestSchema.parse(
|
|
28965
29012
|
JSON.parse(
|
|
@@ -29057,25 +29104,25 @@ async function loadHarnessPlugins(options2) {
|
|
|
29057
29104
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
29058
29105
|
import { mkdir as mkdir5, readFile as readFile7, rename as rename4, rm as rm5, stat as stat4, writeFile as writeFile3 } from "node:fs/promises";
|
|
29059
29106
|
import os4 from "node:os";
|
|
29060
|
-
import
|
|
29107
|
+
import path15 from "node:path";
|
|
29061
29108
|
var HarnessLaunchSettingsStore = class {
|
|
29062
29109
|
#directory;
|
|
29063
29110
|
#initial = /* @__PURE__ */ new Map();
|
|
29064
29111
|
constructor(environment) {
|
|
29065
|
-
this.#directory =
|
|
29066
|
-
environment.CODEXHOST_DATA_DIR ?
|
|
29112
|
+
this.#directory = path15.join(
|
|
29113
|
+
environment.CODEXHOST_DATA_DIR ? path15.resolve(environment.CODEXHOST_DATA_DIR) : path15.join(os4.homedir(), ".codexhost"),
|
|
29067
29114
|
"harness-launch-settings"
|
|
29068
29115
|
);
|
|
29069
29116
|
}
|
|
29070
29117
|
#file(id2) {
|
|
29071
|
-
return
|
|
29118
|
+
return path15.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
|
|
29072
29119
|
}
|
|
29073
29120
|
async #read(id2) {
|
|
29074
29121
|
try {
|
|
29075
29122
|
const value2 = harnessLaunchPathSchema.parse(
|
|
29076
29123
|
JSON.parse(await readFile7(this.#file(id2), "utf8"))
|
|
29077
29124
|
);
|
|
29078
|
-
if (!
|
|
29125
|
+
if (!path15.isAbsolute(value2)) throw new Error("Expected an absolute entrypoint path");
|
|
29079
29126
|
return value2;
|
|
29080
29127
|
} catch (error51) {
|
|
29081
29128
|
if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
|
|
@@ -29104,7 +29151,7 @@ var HarnessLaunchSettingsStore = class {
|
|
|
29104
29151
|
await rm5(file2, { force: true });
|
|
29105
29152
|
} else {
|
|
29106
29153
|
value2 = harnessLaunchPathSchema.parse(value2);
|
|
29107
|
-
if (!
|
|
29154
|
+
if (!path15.isAbsolute(value2))
|
|
29108
29155
|
throw new Error("Use an absolute entrypoint path without arguments");
|
|
29109
29156
|
const metadata = await stat4(value2).catch(() => void 0);
|
|
29110
29157
|
if (!metadata?.isDirectory() && !metadata?.isFile())
|
|
@@ -29314,7 +29361,7 @@ var SingleNativeCodexAccount = class {
|
|
|
29314
29361
|
|
|
29315
29362
|
// packages/host-runtime/src/account/codex-home-auth.ts
|
|
29316
29363
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
29317
|
-
import
|
|
29364
|
+
import path16 from "node:path";
|
|
29318
29365
|
var CODEX_API_AUTH_IDENTITY_FALLBACK = "BANK OF TOKEN";
|
|
29319
29366
|
function tomlUnquote(value2) {
|
|
29320
29367
|
const trimmed = value2.trim();
|
|
@@ -29460,10 +29507,10 @@ function inspectCodexApiUsageSource(input) {
|
|
|
29460
29507
|
return { baseUrl, apiKey };
|
|
29461
29508
|
}
|
|
29462
29509
|
async function inspectCodexHomeAuth(codexHome) {
|
|
29463
|
-
const root =
|
|
29510
|
+
const root = path16.resolve(codexHome);
|
|
29464
29511
|
const [configToml, authJson] = await Promise.all([
|
|
29465
|
-
readOptionalUtf8(
|
|
29466
|
-
readOptionalUtf8(
|
|
29512
|
+
readOptionalUtf8(path16.join(root, "config.toml")),
|
|
29513
|
+
readOptionalUtf8(path16.join(root, "auth.json"))
|
|
29467
29514
|
]);
|
|
29468
29515
|
return inspectCodexAuthDocuments({
|
|
29469
29516
|
...configToml ? { configToml } : {},
|
|
@@ -29471,10 +29518,10 @@ async function inspectCodexHomeAuth(codexHome) {
|
|
|
29471
29518
|
});
|
|
29472
29519
|
}
|
|
29473
29520
|
async function inspectCodexHomeApiUsageSource(codexHome, env = process.env) {
|
|
29474
|
-
const root =
|
|
29521
|
+
const root = path16.resolve(codexHome);
|
|
29475
29522
|
const [configToml, authJson] = await Promise.all([
|
|
29476
|
-
readOptionalUtf8(
|
|
29477
|
-
readOptionalUtf8(
|
|
29523
|
+
readOptionalUtf8(path16.join(root, "config.toml")),
|
|
29524
|
+
readOptionalUtf8(path16.join(root, "auth.json"))
|
|
29478
29525
|
]);
|
|
29479
29526
|
return inspectCodexApiUsageSource({
|
|
29480
29527
|
...configToml ? { configToml } : {},
|
|
@@ -30516,25 +30563,25 @@ function resolveExternalSessionTreeIds(records) {
|
|
|
30516
30563
|
const resolve = (start) => {
|
|
30517
30564
|
const cached2 = resolved.get(start.hostThreadId);
|
|
30518
30565
|
if (cached2) return cached2;
|
|
30519
|
-
const
|
|
30566
|
+
const path31 = [];
|
|
30520
30567
|
const visited = /* @__PURE__ */ new Set();
|
|
30521
30568
|
let current = start;
|
|
30522
30569
|
while (true) {
|
|
30523
30570
|
const known = resolved.get(current.hostThreadId);
|
|
30524
30571
|
if (known) {
|
|
30525
|
-
for (const record3 of
|
|
30572
|
+
for (const record3 of path31) resolved.set(record3.hostThreadId, known);
|
|
30526
30573
|
return known;
|
|
30527
30574
|
}
|
|
30528
30575
|
if (visited.has(current.hostThreadId)) {
|
|
30529
30576
|
throw new Error("External Thread Fork tree contains a cycle");
|
|
30530
30577
|
}
|
|
30531
30578
|
visited.add(current.hostThreadId);
|
|
30532
|
-
|
|
30579
|
+
path31.push(current);
|
|
30533
30580
|
const sourceId = current.subagent?.parentHostThreadId ?? current.forkSource?.hostThreadId;
|
|
30534
30581
|
const source = sourceId ? byId.get(sourceId) : void 0;
|
|
30535
30582
|
if (!source) {
|
|
30536
30583
|
const root = current.hostThreadId;
|
|
30537
|
-
for (const record3 of
|
|
30584
|
+
for (const record3 of path31) resolved.set(record3.hostThreadId, root);
|
|
30538
30585
|
return root;
|
|
30539
30586
|
}
|
|
30540
30587
|
current = source;
|
|
@@ -30767,6 +30814,12 @@ function delay3(milliseconds) {
|
|
|
30767
30814
|
function isRecord15(value2) {
|
|
30768
30815
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
30769
30816
|
}
|
|
30817
|
+
function officialThreadBusy(thread) {
|
|
30818
|
+
if (thread && isRecord15(thread.status) && thread.status.type === "active") return true;
|
|
30819
|
+
const turns = thread && Array.isArray(thread.turns) ? thread.turns : [];
|
|
30820
|
+
const latestTurn = turns.at(-1);
|
|
30821
|
+
return isRecord15(latestTurn) && (latestTurn.status === "inProgress" || latestTurn.status === "running");
|
|
30822
|
+
}
|
|
30770
30823
|
function isCreditsAdapter(adapter) {
|
|
30771
30824
|
return typeof adapter.credits === "function";
|
|
30772
30825
|
}
|
|
@@ -30999,7 +31052,7 @@ var AppServerHost = class {
|
|
|
30999
31052
|
this.#launchSettings = new HarnessLaunchSettingsStore(
|
|
31000
31053
|
this.#options.pluginContext?.environment ?? environment
|
|
31001
31054
|
);
|
|
31002
|
-
const permanentHome =
|
|
31055
|
+
const permanentHome = path17.resolve(environment.CODEX_HOME ?? path17.join(os5.homedir(), ".codex"));
|
|
31003
31056
|
this.#ownsOfficialRuntimeScope = options2.officialRuntimeScope === void 0;
|
|
31004
31057
|
this.#officialRuntimeScope = options2.officialRuntimeScope ?? new OfficialRuntimeScope({
|
|
31005
31058
|
diagnosticOutput: this.#options.diagnosticOutput,
|
|
@@ -32294,11 +32347,35 @@ var AppServerHost = class {
|
|
|
32294
32347
|
throw new DelegationControlError("THREAD_NOT_FOUND", "Official Thread was not found");
|
|
32295
32348
|
}
|
|
32296
32349
|
const currentThread = isRecord15(current.result.thread) ? current.result.thread : null;
|
|
32297
|
-
|
|
32298
|
-
|
|
32299
|
-
|
|
32350
|
+
if (officialThreadBusy(currentThread)) {
|
|
32351
|
+
throw new DelegationControlError("THREAD_BUSY", "Thread already has an active Turn");
|
|
32352
|
+
}
|
|
32353
|
+
const resumed = await this.#requestOfficial("thread/resume", {
|
|
32354
|
+
threadId: input.threadId,
|
|
32355
|
+
excludeTurns: true
|
|
32356
|
+
});
|
|
32357
|
+
if (isRecord15(resumed.error) || !isRecord15(resumed.result)) {
|
|
32358
|
+
throw new DelegationControlError(
|
|
32359
|
+
"DELEGATION_FAILED",
|
|
32360
|
+
isRecord15(resumed.error) && typeof resumed.error.message === "string" ? resumed.error.message : "Official Thread resume failed"
|
|
32361
|
+
);
|
|
32362
|
+
}
|
|
32363
|
+
const resumedThread = isRecord15(resumed.result.thread) ? resumed.result.thread : null;
|
|
32364
|
+
if (!resumedThread || resumedThread.id !== input.threadId) {
|
|
32365
|
+
throw new DelegationControlError(
|
|
32366
|
+
"DELEGATION_FAILED",
|
|
32367
|
+
"Official Thread resume did not return the requested Thread"
|
|
32368
|
+
);
|
|
32369
|
+
}
|
|
32370
|
+
if (officialThreadBusy(resumedThread)) {
|
|
32300
32371
|
throw new DelegationControlError("THREAD_BUSY", "Thread already has an active Turn");
|
|
32301
32372
|
}
|
|
32373
|
+
if (!isRecord15(resumedThread.status) || resumedThread.status.type !== "idle") {
|
|
32374
|
+
throw new DelegationControlError(
|
|
32375
|
+
"DELEGATION_FAILED",
|
|
32376
|
+
"Official Thread is not idle after resume"
|
|
32377
|
+
);
|
|
32378
|
+
}
|
|
32302
32379
|
const response = await this.#requestOfficial("turn/start", {
|
|
32303
32380
|
threadId: input.threadId,
|
|
32304
32381
|
input: [{ type: "text", text: input.message }]
|
|
@@ -32555,7 +32632,9 @@ var AppServerHost = class {
|
|
|
32555
32632
|
}
|
|
32556
32633
|
const coordinator = this.#options.updateCoordinator;
|
|
32557
32634
|
if (!coordinator) {
|
|
32558
|
-
await this.#writer.json(
|
|
32635
|
+
await this.#writer.json(
|
|
32636
|
+
request.method === "codexhost/update/check" ? rpcEnvelope(request, { result: null }) : rpcError(request, -32090, "Application updates are unavailable")
|
|
32637
|
+
);
|
|
32559
32638
|
return;
|
|
32560
32639
|
}
|
|
32561
32640
|
try {
|
|
@@ -32941,6 +33020,7 @@ var AppServerHost = class {
|
|
|
32941
33020
|
const gate = turnProjectionGate();
|
|
32942
33021
|
thread.running = true;
|
|
32943
33022
|
thread.activeTurnId = turnId;
|
|
33023
|
+
thread.projectedTerminalTurnId = null;
|
|
32944
33024
|
thread.projectedTurns.set(turnId, projection);
|
|
32945
33025
|
thread.responseGates.set(turnId, gate);
|
|
32946
33026
|
thread.ephemeralTurnIds.add(turnId);
|
|
@@ -33169,6 +33249,12 @@ var AppServerHost = class {
|
|
|
33169
33249
|
});
|
|
33170
33250
|
thread.transportModelId = transportModelId;
|
|
33171
33251
|
thread.requestedModel = effectiveModel;
|
|
33252
|
+
thread.thread = externalThreadValue({
|
|
33253
|
+
record: { ...thread.record, transportModelId },
|
|
33254
|
+
turns: thread.turns,
|
|
33255
|
+
sessionId: thread.sessionId,
|
|
33256
|
+
running: thread.running
|
|
33257
|
+
});
|
|
33172
33258
|
try {
|
|
33173
33259
|
thread.record = await this.#repository.setTransportModelId(
|
|
33174
33260
|
thread.record.hostThreadId,
|
|
@@ -33176,13 +33262,15 @@ var AppServerHost = class {
|
|
|
33176
33262
|
);
|
|
33177
33263
|
} catch (error51) {
|
|
33178
33264
|
this.#diagnose(error51);
|
|
33265
|
+
await this.#writer.json(
|
|
33266
|
+
rpcError(
|
|
33267
|
+
request,
|
|
33268
|
+
-32078,
|
|
33269
|
+
`Permission Mode was applied but could not be saved: ${errorMessage3(error51)}`
|
|
33270
|
+
)
|
|
33271
|
+
);
|
|
33272
|
+
return;
|
|
33179
33273
|
}
|
|
33180
|
-
thread.thread = externalThreadValue({
|
|
33181
|
-
record: { ...thread.record, transportModelId },
|
|
33182
|
-
turns: thread.turns,
|
|
33183
|
-
sessionId: thread.sessionId,
|
|
33184
|
-
running: thread.running
|
|
33185
|
-
});
|
|
33186
33274
|
}
|
|
33187
33275
|
await this.#writer.json(rpcEnvelope(request, { result: jsonValueSchema.parse(projected) }));
|
|
33188
33276
|
} catch (error51) {
|
|
@@ -33633,6 +33721,7 @@ var AppServerHost = class {
|
|
|
33633
33721
|
};
|
|
33634
33722
|
thread.running = true;
|
|
33635
33723
|
thread.activeTurnId = turnId;
|
|
33724
|
+
thread.projectedTerminalTurnId = null;
|
|
33636
33725
|
thread.projectedTurns.set(turnId, projection);
|
|
33637
33726
|
thread.responseGates.set(turnId, {
|
|
33638
33727
|
promise: Promise.resolve(),
|
|
@@ -33774,6 +33863,7 @@ var AppServerHost = class {
|
|
|
33774
33863
|
const gate = turnProjectionGate();
|
|
33775
33864
|
thread.running = true;
|
|
33776
33865
|
thread.activeTurnId = turnId;
|
|
33866
|
+
thread.projectedTerminalTurnId = null;
|
|
33777
33867
|
thread.projectedTurns.set(turnId, projection);
|
|
33778
33868
|
thread.responseGates.set(turnId, gate);
|
|
33779
33869
|
try {
|
|
@@ -34061,6 +34151,7 @@ var AppServerHost = class {
|
|
|
34061
34151
|
};
|
|
34062
34152
|
thread.running = true;
|
|
34063
34153
|
thread.activeTurnId = event.turnId;
|
|
34154
|
+
thread.projectedTerminalTurnId = null;
|
|
34064
34155
|
thread.projectedTurns.set(event.turnId, projection2);
|
|
34065
34156
|
thread.responseGates.set(event.turnId, {
|
|
34066
34157
|
promise: Promise.resolve(),
|
|
@@ -34107,6 +34198,7 @@ var AppServerHost = class {
|
|
|
34107
34198
|
thread.ephemeralTurnIds.delete(event.turnId);
|
|
34108
34199
|
} else {
|
|
34109
34200
|
thread.turns.push(result.completedTurn);
|
|
34201
|
+
thread.projectedTerminalTurnId = event.turnId;
|
|
34110
34202
|
thread.thread.updatedAt = completedAt;
|
|
34111
34203
|
thread.thread.recencyAt = completedAt;
|
|
34112
34204
|
}
|
|
@@ -34557,7 +34649,7 @@ var AppServerHost = class {
|
|
|
34557
34649
|
// packages/host-runtime/src/native-account-host.ts
|
|
34558
34650
|
import { mkdir as mkdir8, realpath as realpath3 } from "node:fs/promises";
|
|
34559
34651
|
import { homedir } from "node:os";
|
|
34560
|
-
import
|
|
34652
|
+
import path21 from "node:path";
|
|
34561
34653
|
|
|
34562
34654
|
// packages/host-runtime/src/codex-runtime/owned-official-backends.ts
|
|
34563
34655
|
import { createHash as createHash9, randomBytes } from "node:crypto";
|
|
@@ -34567,7 +34659,7 @@ import { Writable as Writable2 } from "node:stream";
|
|
|
34567
34659
|
import { createServer } from "node:http";
|
|
34568
34660
|
import net from "node:net";
|
|
34569
34661
|
import { chmod as chmod3, lstat as lstat6, mkdir as mkdir7, rm as rm7 } from "node:fs/promises";
|
|
34570
|
-
import
|
|
34662
|
+
import path19 from "node:path";
|
|
34571
34663
|
import { PassThrough } from "node:stream";
|
|
34572
34664
|
|
|
34573
34665
|
// node_modules/ws/wrapper.mjs
|
|
@@ -34585,7 +34677,7 @@ var wrapper_default = import_websocket.default;
|
|
|
34585
34677
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
34586
34678
|
import { chmod as chmod2, lstat as lstat5, mkdir as mkdir6, open as open6, readFile as readFile9, readdir as readdir4, rename as rename5, rm as rm6 } from "node:fs/promises";
|
|
34587
34679
|
import { uptime } from "node:os";
|
|
34588
|
-
import
|
|
34680
|
+
import path18 from "node:path";
|
|
34589
34681
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
34590
34682
|
var LOCK_RETRY_COUNT = 200;
|
|
34591
34683
|
var LOCK_RETRY_DELAY_MS = 25;
|
|
@@ -34659,7 +34751,7 @@ async function readLockEntrySnapshot(filePath) {
|
|
|
34659
34751
|
source,
|
|
34660
34752
|
identity: { dev: metadata.dev, ino: metadata.ino },
|
|
34661
34753
|
mtimeMs: metadata.mtimeMs,
|
|
34662
|
-
record: record3 &&
|
|
34754
|
+
record: record3 && path18.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
|
|
34663
34755
|
};
|
|
34664
34756
|
}
|
|
34665
34757
|
function lockEntryIsAbandoned(snapshot) {
|
|
@@ -34680,7 +34772,7 @@ async function readLockEntryCatalog(lockDirectory) {
|
|
|
34680
34772
|
let unsettled = false;
|
|
34681
34773
|
for (const name of names) {
|
|
34682
34774
|
if (!name.startsWith(LOCK_ENTRY_PREFIX) || !name.endsWith(LOCK_ENTRY_SUFFIX)) continue;
|
|
34683
|
-
const snapshot = await readLockEntrySnapshot(
|
|
34775
|
+
const snapshot = await readLockEntrySnapshot(path18.join(lockDirectory, name));
|
|
34684
34776
|
if (snapshot === null) continue;
|
|
34685
34777
|
if (lockEntryIsAbandoned(snapshot)) {
|
|
34686
34778
|
if (!await removeAbandonedLockEntry(snapshot)) unsettled = true;
|
|
@@ -34708,7 +34800,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
|
|
|
34708
34800
|
await chmod2(lockDirectory, 448);
|
|
34709
34801
|
}
|
|
34710
34802
|
async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
|
|
34711
|
-
const temporary =
|
|
34803
|
+
const temporary = path18.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID11()}`);
|
|
34712
34804
|
const handle = await open6(temporary, "wx", 384);
|
|
34713
34805
|
try {
|
|
34714
34806
|
await handle.writeFile(`${JSON.stringify(record3)}
|
|
@@ -34784,7 +34876,7 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
|
|
|
34784
34876
|
const lockDirectory = `${socketPath}.initializers`;
|
|
34785
34877
|
await preparePrivateLockDirectory(lockDirectory);
|
|
34786
34878
|
const ownerToken = randomUUID11();
|
|
34787
|
-
const entryPath =
|
|
34879
|
+
const entryPath = path18.join(lockDirectory, lockEntryName(ownerToken));
|
|
34788
34880
|
const baseRecord = {
|
|
34789
34881
|
version: 2,
|
|
34790
34882
|
ownerToken,
|
|
@@ -34958,14 +35050,14 @@ function remoteAppServerSocketPath(environment, listenUrl = "unix://") {
|
|
|
34958
35050
|
throw new Error("Remote app-server listener must use a Unix URL");
|
|
34959
35051
|
}
|
|
34960
35052
|
const explicit = listenUrl.slice("unix://".length);
|
|
34961
|
-
if (explicit.length > 0) return
|
|
34962
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
35053
|
+
if (explicit.length > 0) return path19.posix.resolve(decodeURIComponent(explicit));
|
|
35054
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path19.posix.join(environment.HOME, ".codex") : void 0);
|
|
34963
35055
|
if (!codexHome)
|
|
34964
35056
|
throw new Error("CODEX_HOME or HOME is required for the remote app-server socket");
|
|
34965
|
-
return
|
|
35057
|
+
return path19.posix.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
34966
35058
|
}
|
|
34967
35059
|
function officialListenerArgumentsForRemoteListener(arguments_2, socketPath) {
|
|
34968
|
-
if (!
|
|
35060
|
+
if (!path19.posix.isAbsolute(socketPath)) {
|
|
34969
35061
|
throw new Error("Shared official app-server socket path must be absolute");
|
|
34970
35062
|
}
|
|
34971
35063
|
if (remoteUnixListenerUrl(arguments_2) === null) {
|
|
@@ -35076,7 +35168,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
35076
35168
|
await rm7(socketPath, { force: true });
|
|
35077
35169
|
}
|
|
35078
35170
|
async function prepareRemoteAppServerSocketDirectory(socketPath) {
|
|
35079
|
-
const socketDirectory =
|
|
35171
|
+
const socketDirectory = path19.dirname(socketPath);
|
|
35080
35172
|
const existing = await lstat6(socketDirectory).catch((error51) => {
|
|
35081
35173
|
if (error51.code === "ENOENT") return null;
|
|
35082
35174
|
throw error51;
|
|
@@ -35283,18 +35375,18 @@ function createRemoteAppServerWebSocketListener(input) {
|
|
|
35283
35375
|
import { spawn as spawn3 } from "node:child_process";
|
|
35284
35376
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
35285
35377
|
import { lstat as lstat7, rm as rm8, stat as stat5 } from "node:fs/promises";
|
|
35286
|
-
import
|
|
35378
|
+
import path20 from "node:path";
|
|
35287
35379
|
var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
|
|
35288
35380
|
var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
|
|
35289
35381
|
function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID12()) {
|
|
35290
|
-
if (!
|
|
35382
|
+
if (!path20.posix.isAbsolute(desktopControlSocketPath)) {
|
|
35291
35383
|
throw new Error("Desktop control socket path must be absolute");
|
|
35292
35384
|
}
|
|
35293
35385
|
if (!/^[A-Za-z0-9-]+$/u.test(token) || !/[A-Za-z0-9]/u.test(token)) {
|
|
35294
35386
|
throw new Error("Shared official app-server socket token is invalid");
|
|
35295
35387
|
}
|
|
35296
35388
|
const compactToken = token.replaceAll("-", "").slice(0, 15);
|
|
35297
|
-
return
|
|
35389
|
+
return path20.posix.join(path20.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
|
|
35298
35390
|
}
|
|
35299
35391
|
function errorMessage4(error51) {
|
|
35300
35392
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -35804,19 +35896,19 @@ function createOwnedUnixBackend(input) {
|
|
|
35804
35896
|
|
|
35805
35897
|
// packages/host-runtime/src/native-account-host.ts
|
|
35806
35898
|
async function canonicalCodexHome(home) {
|
|
35807
|
-
const absolute =
|
|
35899
|
+
const absolute = path21.resolve(home);
|
|
35808
35900
|
try {
|
|
35809
35901
|
return await realpath3(absolute);
|
|
35810
35902
|
} catch (error51) {
|
|
35811
35903
|
if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT")) throw error51;
|
|
35812
|
-
const parent =
|
|
35904
|
+
const parent = path21.dirname(absolute);
|
|
35813
35905
|
if (parent === absolute) throw error51;
|
|
35814
|
-
return
|
|
35906
|
+
return path21.join(await canonicalCodexHome(parent), path21.basename(absolute));
|
|
35815
35907
|
}
|
|
35816
35908
|
}
|
|
35817
35909
|
async function prepareLocalCodex(input) {
|
|
35818
35910
|
const home = await canonicalCodexHome(
|
|
35819
|
-
input.environment.CODEX_HOME ??
|
|
35911
|
+
input.environment.CODEX_HOME ?? path21.join(homedir(), ".codex")
|
|
35820
35912
|
);
|
|
35821
35913
|
await mkdir8(home, { recursive: true });
|
|
35822
35914
|
const scope = new OfficialRuntimeScope({
|
|
@@ -35983,17 +36075,17 @@ var DelegationControlRegistry = class {
|
|
|
35983
36075
|
|
|
35984
36076
|
// packages/host-runtime/src/installed-harness-plugins.ts
|
|
35985
36077
|
import os6 from "node:os";
|
|
35986
|
-
import
|
|
36078
|
+
import path23 from "node:path";
|
|
35987
36079
|
import { fileURLToPath } from "node:url";
|
|
35988
36080
|
|
|
35989
36081
|
// packages/host-runtime/src/launcher-url-opener.ts
|
|
35990
36082
|
import { spawn as spawn4 } from "node:child_process";
|
|
35991
|
-
import
|
|
36083
|
+
import path22 from "node:path";
|
|
35992
36084
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
35993
36085
|
var OPEN_TIMEOUT_MS = 1e4;
|
|
35994
36086
|
function createLauncherUrlOpener(environment, spawnLauncher = (command, arguments_2, options2) => spawn4(command, arguments_2, options2)) {
|
|
35995
36087
|
const launcher = environment.CODEXHOST_LAUNCHER_EXECUTABLE;
|
|
35996
|
-
if (!launcher || !
|
|
36088
|
+
if (!launcher || !path22.isAbsolute(launcher)) return void 0;
|
|
35997
36089
|
const launcherEnvironment = Object.fromEntries(
|
|
35998
36090
|
Object.entries(environment).filter(([name]) => {
|
|
35999
36091
|
const normalized = name.toUpperCase();
|
|
@@ -36051,9 +36143,9 @@ function installedHarnessPluginOptions(environment, managedRemoteHost = false, h
|
|
|
36051
36143
|
const opener = managedRemoteHost ? void 0 : createLauncherUrlOpener(environment);
|
|
36052
36144
|
return {
|
|
36053
36145
|
pluginRoots: [
|
|
36054
|
-
|
|
36055
|
-
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ??
|
|
36056
|
-
environment.CODEXHOST_DATA_DIR ?
|
|
36146
|
+
path23.join(path23.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
|
|
36147
|
+
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path23.join(
|
|
36148
|
+
environment.CODEXHOST_DATA_DIR ? path23.resolve(environment.CODEXHOST_DATA_DIR) : path23.join(os6.homedir(), ".codexhost"),
|
|
36057
36149
|
"plugins"
|
|
36058
36150
|
)
|
|
36059
36151
|
],
|
|
@@ -36180,7 +36272,7 @@ async function startDelegationControlServer(input) {
|
|
|
36180
36272
|
// packages/host-runtime/src/remote-control-app-server.ts
|
|
36181
36273
|
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
36182
36274
|
import { mkdir as mkdir9, open as open7, rename as rename6, rm as rm9 } from "node:fs/promises";
|
|
36183
|
-
import
|
|
36275
|
+
import path24 from "node:path";
|
|
36184
36276
|
var REMOTE_CONTROL_BRIDGE_PIPE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_PIPE";
|
|
36185
36277
|
var REMOTE_CONTROL_BRIDGE_NODE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_NODE_PATH";
|
|
36186
36278
|
var REMOTE_CONTROL_BRIDGE_RUNTIME_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_RUNTIME_PATH";
|
|
@@ -36191,8 +36283,8 @@ var BRIDGE_READY_METHOD = "codexhost/remote-control-bridge/ready";
|
|
|
36191
36283
|
function absoluteEnvironmentPath2(environment, name, fallback, platform = process.platform) {
|
|
36192
36284
|
const value2 = environment[name] ?? fallback;
|
|
36193
36285
|
if (!value2) return null;
|
|
36194
|
-
if (
|
|
36195
|
-
return platform === "win32" &&
|
|
36286
|
+
if (path24.isAbsolute(value2)) return path24.normalize(value2);
|
|
36287
|
+
return platform === "win32" && path24.win32.isAbsolute(value2) ? path24.win32.normalize(value2) : null;
|
|
36196
36288
|
}
|
|
36197
36289
|
function nodeCompatibleWindowsPath(value2) {
|
|
36198
36290
|
if (value2.startsWith("\\\\?\\UNC\\")) return `\\\\${value2.slice(8)}`;
|
|
@@ -36206,13 +36298,13 @@ function remoteControlBridgePipePath(processId = process.pid, instanceId = rando
|
|
|
36206
36298
|
}
|
|
36207
36299
|
function remoteControlBridgeDescriptorPath(environment) {
|
|
36208
36300
|
const root = environment.LOCALAPPDATA;
|
|
36209
|
-
if (!root || !
|
|
36210
|
-
return
|
|
36301
|
+
if (!root || !path24.isAbsolute(root)) return null;
|
|
36302
|
+
return path24.join(path24.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
|
|
36211
36303
|
}
|
|
36212
36304
|
async function publishRemoteControlAppServerDescriptor(plan) {
|
|
36213
|
-
const directory =
|
|
36305
|
+
const directory = path24.dirname(plan.descriptorPath);
|
|
36214
36306
|
await mkdir9(directory, { recursive: true, mode: 448 });
|
|
36215
|
-
const temporaryPath =
|
|
36307
|
+
const temporaryPath = path24.join(
|
|
36216
36308
|
directory,
|
|
36217
36309
|
`.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID13()}.tmp`
|
|
36218
36310
|
);
|
|
@@ -36513,9 +36605,9 @@ function hasLauncherManagedUpdateRuntime(environment, hostRuntimePath) {
|
|
|
36513
36605
|
if (!environment[UPDATE_RUNTIME_ENV.launcherPid]) return false;
|
|
36514
36606
|
const npmPackageRoot = environment[UPDATE_RUNTIME_ENV.npmPackageRoot];
|
|
36515
36607
|
if (!npmPackageRoot || !hostRuntimePath) return true;
|
|
36516
|
-
if (!
|
|
36517
|
-
const runtimePackageRoot =
|
|
36518
|
-
return
|
|
36608
|
+
if (!path25.isAbsolute(npmPackageRoot) || !path25.isAbsolute(hostRuntimePath)) return false;
|
|
36609
|
+
const runtimePackageRoot = path25.dirname(path25.dirname(path25.normalize(hostRuntimePath)));
|
|
36610
|
+
return path25.relative(path25.normalize(npmPackageRoot), runtimePackageRoot) === "";
|
|
36519
36611
|
}
|
|
36520
36612
|
function requiredRuntimeConfiguration(environment) {
|
|
36521
36613
|
const stockCodexPath = environment[STOCK_CODEX_PATH_ENV];
|
|
@@ -36661,8 +36753,8 @@ async function runHostRuntime(input) {
|
|
|
36661
36753
|
const socketPath = remoteAppServerSocketPath(delegationEnvironment, listenUrl);
|
|
36662
36754
|
const officialPlan = createRemoteOfficialAppServerPlan(input.arguments, socketPath);
|
|
36663
36755
|
const officialRuntimeScope = new OfficialRuntimeScope({
|
|
36664
|
-
permanentHome:
|
|
36665
|
-
delegationEnvironment.CODEX_HOME ??
|
|
36756
|
+
permanentHome: path25.resolve(
|
|
36757
|
+
delegationEnvironment.CODEX_HOME ?? path25.join(homedir2(), ".codex")
|
|
36666
36758
|
),
|
|
36667
36759
|
diagnosticOutput: process.stderr,
|
|
36668
36760
|
createBackend: () => createOwnedUnixBackend({
|
|
@@ -36758,7 +36850,7 @@ import {
|
|
|
36758
36850
|
stat as stat6,
|
|
36759
36851
|
writeFile as writeFile4
|
|
36760
36852
|
} from "node:fs/promises";
|
|
36761
|
-
import
|
|
36853
|
+
import path26 from "node:path";
|
|
36762
36854
|
var MANIFEST_FORMAT = 1;
|
|
36763
36855
|
var WRAPPER_MARKER = "# codexhost remote SSH wrapper v1";
|
|
36764
36856
|
var PROFILE_START = "# >>> codexhost remote SSH >>>";
|
|
@@ -36769,25 +36861,25 @@ function resolvePaths(options2) {
|
|
|
36769
36861
|
if (!configuredHome) {
|
|
36770
36862
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
36771
36863
|
}
|
|
36772
|
-
const home =
|
|
36773
|
-
if (!home || home ===
|
|
36864
|
+
const home = path26.resolve(configuredHome);
|
|
36865
|
+
if (!home || home === path26.parse(home).root) {
|
|
36774
36866
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
36775
36867
|
}
|
|
36776
|
-
const installRoot =
|
|
36777
|
-
const profilePath =
|
|
36778
|
-
options2.profilePath ??
|
|
36868
|
+
const installRoot = path26.resolve(options2.installRoot ?? path26.join(home, ".codexhost", "remote"));
|
|
36869
|
+
const profilePath = path26.resolve(
|
|
36870
|
+
options2.profilePath ?? path26.join(
|
|
36779
36871
|
home,
|
|
36780
|
-
|
|
36872
|
+
path26.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path26.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
|
|
36781
36873
|
)
|
|
36782
36874
|
);
|
|
36783
|
-
const binDirectory =
|
|
36875
|
+
const binDirectory = path26.join(installRoot, "bin");
|
|
36784
36876
|
return {
|
|
36785
36877
|
home,
|
|
36786
36878
|
installRoot,
|
|
36787
36879
|
binDirectory,
|
|
36788
|
-
wrapperPath:
|
|
36789
|
-
manifestPath:
|
|
36790
|
-
dataDirectory:
|
|
36880
|
+
wrapperPath: path26.join(binDirectory, "codex"),
|
|
36881
|
+
manifestPath: path26.join(installRoot, "manifest.json"),
|
|
36882
|
+
dataDirectory: path26.join(installRoot, "data"),
|
|
36791
36883
|
profilePath
|
|
36792
36884
|
};
|
|
36793
36885
|
}
|
|
@@ -36806,7 +36898,7 @@ async function fileSha256(filePath) {
|
|
|
36806
36898
|
return createHash10("sha256").update(await readFile10(filePath)).digest("hex");
|
|
36807
36899
|
}
|
|
36808
36900
|
async function executable(filePath, label) {
|
|
36809
|
-
const absolute =
|
|
36901
|
+
const absolute = path26.resolve(filePath);
|
|
36810
36902
|
try {
|
|
36811
36903
|
if (!(await stat6(absolute)).isFile()) throw new Error("not a regular file");
|
|
36812
36904
|
await access(absolute, fsConstants.X_OK);
|
|
@@ -36816,7 +36908,7 @@ async function executable(filePath, label) {
|
|
|
36816
36908
|
return absolute;
|
|
36817
36909
|
}
|
|
36818
36910
|
async function existingFile(filePath, label) {
|
|
36819
|
-
const absolute =
|
|
36911
|
+
const absolute = path26.resolve(filePath);
|
|
36820
36912
|
try {
|
|
36821
36913
|
const metadata = await stat6(absolute);
|
|
36822
36914
|
if (!metadata.isFile()) throw new Error("not a regular file");
|
|
@@ -36826,9 +36918,9 @@ async function existingFile(filePath, label) {
|
|
|
36826
36918
|
return absolute;
|
|
36827
36919
|
}
|
|
36828
36920
|
async function discoverExecutable(name, environment) {
|
|
36829
|
-
for (const directory of (environment.PATH ?? "").split(
|
|
36921
|
+
for (const directory of (environment.PATH ?? "").split(path26.delimiter)) {
|
|
36830
36922
|
if (!directory) continue;
|
|
36831
|
-
const candidate =
|
|
36923
|
+
const candidate = path26.resolve(directory, name);
|
|
36832
36924
|
try {
|
|
36833
36925
|
await access(candidate, fsConstants.X_OK);
|
|
36834
36926
|
return candidate;
|
|
@@ -36839,10 +36931,10 @@ async function discoverExecutable(name, environment) {
|
|
|
36839
36931
|
return null;
|
|
36840
36932
|
}
|
|
36841
36933
|
async function writeAtomic(filePath, contents, mode) {
|
|
36842
|
-
await mkdir10(
|
|
36843
|
-
const temporary =
|
|
36844
|
-
|
|
36845
|
-
`.${
|
|
36934
|
+
await mkdir10(path26.dirname(filePath), { recursive: true, mode: 448 });
|
|
36935
|
+
const temporary = path26.join(
|
|
36936
|
+
path26.dirname(filePath),
|
|
36937
|
+
`.${path26.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
|
|
36846
36938
|
);
|
|
36847
36939
|
try {
|
|
36848
36940
|
if (typeof contents === "string") {
|
|
@@ -36863,10 +36955,10 @@ async function writeAtomic(filePath, contents, mode) {
|
|
|
36863
36955
|
}
|
|
36864
36956
|
}
|
|
36865
36957
|
async function writeAtomicExecutable(filePath, sourcePath) {
|
|
36866
|
-
await mkdir10(
|
|
36867
|
-
const temporary =
|
|
36868
|
-
|
|
36869
|
-
`.${
|
|
36958
|
+
await mkdir10(path26.dirname(filePath), { recursive: true, mode: 448 });
|
|
36959
|
+
const temporary = path26.join(
|
|
36960
|
+
path26.dirname(filePath),
|
|
36961
|
+
`.${path26.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
|
|
36870
36962
|
);
|
|
36871
36963
|
try {
|
|
36872
36964
|
await copyFile3(sourcePath, temporary);
|
|
@@ -36907,8 +36999,8 @@ function removeManagedProfileBlock(contents) {
|
|
|
36907
36999
|
function installManagedProfileBlock(contents, manifest) {
|
|
36908
37000
|
const base = removeManagedProfileBlock(contents);
|
|
36909
37001
|
const environment = [
|
|
36910
|
-
`export CODEX_INSTALL_DIR=${shellQuote(
|
|
36911
|
-
`export PATH=${shellQuote(
|
|
37002
|
+
`export CODEX_INSTALL_DIR=${shellQuote(path26.dirname(manifest.wrapperPath))}`,
|
|
37003
|
+
`export PATH=${shellQuote(path26.dirname(manifest.wrapperPath))}:${shellQuote(path26.dirname(manifest.nodePath))}:${shellQuote(path26.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
|
|
36912
37004
|
`export CODEXHOST_STOCK_CODEX_PATH=${shellQuote(manifest.stockCodexPath)}`,
|
|
36913
37005
|
`export CODEXHOST_HOST_NODE_PATH=${shellQuote(manifest.nodePath)}`,
|
|
36914
37006
|
`export CODEXHOST_HOST_RUNTIME_PATH=${shellQuote(manifest.hostRuntimePath)}`,
|
|
@@ -36924,7 +37016,7 @@ function installManagedProfileBlock(contents, manifest) {
|
|
|
36924
37016
|
PROFILE_END,
|
|
36925
37017
|
""
|
|
36926
37018
|
].join("\n");
|
|
36927
|
-
if (
|
|
37019
|
+
if (path26.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
|
|
36928
37020
|
const separator = base.length > 0 && !base.endsWith("\n") ? "\n" : "";
|
|
36929
37021
|
return `${base}${separator}${block}`;
|
|
36930
37022
|
}
|
|
@@ -36990,9 +37082,9 @@ async function readManifest(filePath) {
|
|
|
36990
37082
|
];
|
|
36991
37083
|
const optionalPaths = ["claudeCommand", "profileBackupPath"];
|
|
36992
37084
|
if (manifest.format !== MANIFEST_FORMAT || Object.keys(manifest).some((key) => !allowed.has(key)) || requiredPaths.some(
|
|
36993
|
-
(key) => typeof manifest[key] !== "string" || !
|
|
37085
|
+
(key) => typeof manifest[key] !== "string" || !path26.isAbsolute(manifest[key])
|
|
36994
37086
|
) || optionalPaths.some(
|
|
36995
|
-
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !
|
|
37087
|
+
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path26.isAbsolute(manifest[key]))
|
|
36996
37088
|
) || manifest.entrypointSha256 !== void 0 && (typeof manifest.entrypointSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(manifest.entrypointSha256))) {
|
|
36997
37089
|
throw new Error("Remote Host manifest has an unsupported format");
|
|
36998
37090
|
}
|
|
@@ -37218,7 +37310,7 @@ async function uninstallRemoteHost(options2) {
|
|
|
37218
37310
|
import { spawn as spawn5 } from "node:child_process";
|
|
37219
37311
|
import { stat as stat7 } from "node:fs/promises";
|
|
37220
37312
|
import net3 from "node:net";
|
|
37221
|
-
import
|
|
37313
|
+
import path27 from "node:path";
|
|
37222
37314
|
import { Duplex } from "node:stream";
|
|
37223
37315
|
|
|
37224
37316
|
// packages/host-runtime/src/app-server-websocket-options.ts
|
|
@@ -37245,9 +37337,9 @@ function classifyRemoteHostProbeResponse(response, socketPath) {
|
|
|
37245
37337
|
}
|
|
37246
37338
|
var lifecycleDependencyOverrides = {};
|
|
37247
37339
|
function socketPathFor(environment) {
|
|
37248
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
37340
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path27.join(environment.HOME, ".codex") : void 0);
|
|
37249
37341
|
if (!codexHome) throw new Error("CODEX_HOME or HOME is required for remote Host lifecycle");
|
|
37250
|
-
return
|
|
37342
|
+
return path27.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
37251
37343
|
}
|
|
37252
37344
|
async function defaultSocketExists(socketPath) {
|
|
37253
37345
|
const metadata = await stat7(socketPath).catch((error51) => {
|
|
@@ -37377,14 +37469,14 @@ function installedManifest(status) {
|
|
|
37377
37469
|
function managedEnvironment(manifest, environment) {
|
|
37378
37470
|
return {
|
|
37379
37471
|
...environment,
|
|
37380
|
-
CODEX_INSTALL_DIR:
|
|
37472
|
+
CODEX_INSTALL_DIR: path27.dirname(manifest.wrapperPath),
|
|
37381
37473
|
CODEXHOST_STOCK_CODEX_PATH: manifest.stockCodexPath,
|
|
37382
37474
|
CODEXHOST_HOST_NODE_PATH: manifest.nodePath,
|
|
37383
37475
|
CODEXHOST_HOST_RUNTIME_PATH: manifest.hostRuntimePath,
|
|
37384
37476
|
CODEXHOST_DATA_DIR: manifest.dataDirectory,
|
|
37385
37477
|
CODEXHOST_DEFAULT_AGENT: "codex",
|
|
37386
37478
|
CODEXHOST_REMOTE_SSH_MANAGED: "1",
|
|
37387
|
-
PATH: `${
|
|
37479
|
+
PATH: `${path27.dirname(manifest.wrapperPath)}${path27.delimiter}${path27.dirname(manifest.stockCodexPath)}${path27.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
|
|
37388
37480
|
};
|
|
37389
37481
|
}
|
|
37390
37482
|
async function defaultRunTerminator(manifest, socketPath, role, environment) {
|
|
@@ -37723,25 +37815,25 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
37723
37815
|
|
|
37724
37816
|
// packages/harness-broker/dist/paths.js
|
|
37725
37817
|
import os7 from "node:os";
|
|
37726
|
-
import
|
|
37818
|
+
import path28 from "node:path";
|
|
37727
37819
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
37728
37820
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
37729
37821
|
var HARNESS_BROKER_SOCKET_FILE = "claude-code-broker-v1.sock";
|
|
37730
37822
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
37731
37823
|
const home = environment.HOME || os7.homedir();
|
|
37732
|
-
return
|
|
37824
|
+
return path28.join(home, ".codexhost", "harness-broker");
|
|
37733
37825
|
}
|
|
37734
37826
|
function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
|
|
37735
37827
|
harnessPluginIdSchema.parse(harnessId);
|
|
37736
37828
|
if (harnessId !== "claude-code")
|
|
37737
|
-
return
|
|
37738
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
37829
|
+
return path28.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
|
|
37830
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path28.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
37739
37831
|
}
|
|
37740
37832
|
function defaultHarnessBrokerSocketPath(environment = process.env, harnessId = "claude-code") {
|
|
37741
37833
|
harnessPluginIdSchema.parse(harnessId);
|
|
37742
37834
|
if (harnessId !== "claude-code")
|
|
37743
|
-
return
|
|
37744
|
-
return
|
|
37835
|
+
return path28.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
|
|
37836
|
+
return path28.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
|
|
37745
37837
|
}
|
|
37746
37838
|
|
|
37747
37839
|
// packages/harness-broker/dist/validation.js
|
|
@@ -37978,7 +38070,7 @@ var harnessOutputSchema = external_exports.custom((value2) => {
|
|
|
37978
38070
|
import { randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
|
|
37979
38071
|
import { chmod as chmod5, lstat as lstat9, mkdir as mkdir11, open as open8, readFile as readFile11, rename as rename8, rm as rm11 } from "node:fs/promises";
|
|
37980
38072
|
import net4, {} from "node:net";
|
|
37981
|
-
import
|
|
38073
|
+
import path29 from "node:path";
|
|
37982
38074
|
function harnessError(message, retryable = true) {
|
|
37983
38075
|
return { code: "unavailable", message, retryable, stage: "harnessBroker" };
|
|
37984
38076
|
}
|
|
@@ -38101,13 +38193,13 @@ async function prepareUnixSocketPath(socketPath) {
|
|
|
38101
38193
|
}
|
|
38102
38194
|
async function startHarnessBrokerServer(input) {
|
|
38103
38195
|
harnessPluginIdSchema.parse(input.adapter.harnessId);
|
|
38104
|
-
if (process.platform !== "win32" &&
|
|
38196
|
+
if (process.platform !== "win32" && path29.dirname(input.descriptorPath) !== path29.dirname(input.socketPath)) {
|
|
38105
38197
|
throw new Error("Harness broker descriptor and socket must share one private directory");
|
|
38106
38198
|
}
|
|
38107
38199
|
if (process.platform === "darwin" && Buffer.byteLength(input.socketPath) > 103) {
|
|
38108
38200
|
throw new Error("Harness broker Unix socket path is too long for macOS");
|
|
38109
38201
|
}
|
|
38110
|
-
await privateDirectory(
|
|
38202
|
+
await privateDirectory(path29.dirname(input.descriptorPath));
|
|
38111
38203
|
await assertNoLiveDescriptor(input.descriptorPath);
|
|
38112
38204
|
if (process.platform !== "win32")
|
|
38113
38205
|
await prepareUnixSocketPath(input.socketPath);
|
|
@@ -38796,10 +38888,205 @@ async function runClaudeAquaHarnessBroker(environment = process.env, requestedHa
|
|
|
38796
38888
|
}
|
|
38797
38889
|
}
|
|
38798
38890
|
|
|
38891
|
+
// packages/host-runtime/src/runtime-log.ts
|
|
38892
|
+
import {
|
|
38893
|
+
chmodSync,
|
|
38894
|
+
closeSync,
|
|
38895
|
+
fstatSync,
|
|
38896
|
+
mkdirSync,
|
|
38897
|
+
openSync,
|
|
38898
|
+
readdirSync,
|
|
38899
|
+
renameSync,
|
|
38900
|
+
rmSync,
|
|
38901
|
+
statSync,
|
|
38902
|
+
writeFileSync
|
|
38903
|
+
} from "node:fs";
|
|
38904
|
+
import os8 from "node:os";
|
|
38905
|
+
import path30 from "node:path";
|
|
38906
|
+
var DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
|
|
38907
|
+
var DEFAULT_MAX_DIRECTORY_BYTES = 50 * 1024 * 1024;
|
|
38908
|
+
var DEFAULT_MAX_FILES = 20;
|
|
38909
|
+
var RUNTIME_LOG_FILE = /^host-runtime-(\d+)\.log(\.1)?$/u;
|
|
38910
|
+
function processIsActive(pid) {
|
|
38911
|
+
try {
|
|
38912
|
+
process.kill(pid, 0);
|
|
38913
|
+
return true;
|
|
38914
|
+
} catch (error51) {
|
|
38915
|
+
const code = error51.code;
|
|
38916
|
+
if (code === "ESRCH") return false;
|
|
38917
|
+
return true;
|
|
38918
|
+
}
|
|
38919
|
+
}
|
|
38920
|
+
function pruneRuntimeLogs(input) {
|
|
38921
|
+
try {
|
|
38922
|
+
const files = [];
|
|
38923
|
+
for (const entry of readdirSync(input.directory, { withFileTypes: true })) {
|
|
38924
|
+
if (!entry.isFile()) continue;
|
|
38925
|
+
const match = RUNTIME_LOG_FILE.exec(entry.name);
|
|
38926
|
+
if (!match) continue;
|
|
38927
|
+
const pid = Number(match[1]);
|
|
38928
|
+
if (!Number.isSafeInteger(pid)) continue;
|
|
38929
|
+
try {
|
|
38930
|
+
const filePath = path30.join(input.directory, entry.name);
|
|
38931
|
+
const stats = statSync(filePath);
|
|
38932
|
+
files.push({
|
|
38933
|
+
filePath,
|
|
38934
|
+
pid,
|
|
38935
|
+
rotated: match[2] === ".1",
|
|
38936
|
+
size: stats.size,
|
|
38937
|
+
modifiedAt: stats.mtimeMs
|
|
38938
|
+
});
|
|
38939
|
+
} catch {
|
|
38940
|
+
}
|
|
38941
|
+
}
|
|
38942
|
+
let total = files.reduce((sum, file2) => sum + file2.size, 0);
|
|
38943
|
+
let count = files.length;
|
|
38944
|
+
if (total <= input.maxBytes && count <= input.maxFiles) return;
|
|
38945
|
+
const active = /* @__PURE__ */ new Map();
|
|
38946
|
+
const isActive = (pid) => {
|
|
38947
|
+
if (pid === input.currentPid) return true;
|
|
38948
|
+
const known = active.get(pid);
|
|
38949
|
+
if (known !== void 0) return known;
|
|
38950
|
+
const value2 = input.isProcessActive(pid);
|
|
38951
|
+
active.set(pid, value2);
|
|
38952
|
+
return value2;
|
|
38953
|
+
};
|
|
38954
|
+
const candidates = files.filter((file2) => file2.rotated || !isActive(file2.pid)).sort((left, right) => left.modifiedAt - right.modifiedAt);
|
|
38955
|
+
for (const file2 of candidates) {
|
|
38956
|
+
if (total <= input.maxBytes && count <= input.maxFiles) break;
|
|
38957
|
+
try {
|
|
38958
|
+
rmSync(file2.filePath, { force: true });
|
|
38959
|
+
total -= file2.size;
|
|
38960
|
+
count -= 1;
|
|
38961
|
+
} catch {
|
|
38962
|
+
}
|
|
38963
|
+
}
|
|
38964
|
+
} catch {
|
|
38965
|
+
}
|
|
38966
|
+
}
|
|
38967
|
+
function runtimeLogPath(environment, pid) {
|
|
38968
|
+
const dataDirectory = environment.CODEXHOST_DATA_DIR ? path30.resolve(environment.CODEXHOST_DATA_DIR) : path30.join(os8.homedir(), ".codexhost");
|
|
38969
|
+
return path30.join(dataDirectory, "logs", `host-runtime-${pid}.log`);
|
|
38970
|
+
}
|
|
38971
|
+
function installRuntimeLog(input) {
|
|
38972
|
+
const { filePath, stream } = input;
|
|
38973
|
+
const maxBytes = input.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
38974
|
+
const maxDirectoryBytes = input.maxDirectoryBytes ?? DEFAULT_MAX_DIRECTORY_BYTES;
|
|
38975
|
+
const maxFiles = input.maxFiles ?? DEFAULT_MAX_FILES;
|
|
38976
|
+
const logDirectory = path30.dirname(filePath);
|
|
38977
|
+
const prune = () => pruneRuntimeLogs({
|
|
38978
|
+
directory: logDirectory,
|
|
38979
|
+
// Reserve room for this process's current file before it grows.
|
|
38980
|
+
maxBytes: Math.max(0, maxDirectoryBytes - maxBytes),
|
|
38981
|
+
maxFiles,
|
|
38982
|
+
currentPid: input.process.pid,
|
|
38983
|
+
isProcessActive: input.isProcessActive ?? processIsActive
|
|
38984
|
+
});
|
|
38985
|
+
let descriptor;
|
|
38986
|
+
let size = 0;
|
|
38987
|
+
let atLineStart = true;
|
|
38988
|
+
const open9 = () => {
|
|
38989
|
+
descriptor = openSync(filePath, "a", 384);
|
|
38990
|
+
chmodSync(filePath, 384);
|
|
38991
|
+
size = fstatSync(descriptor).size;
|
|
38992
|
+
};
|
|
38993
|
+
const close = () => {
|
|
38994
|
+
if (descriptor === void 0) return;
|
|
38995
|
+
try {
|
|
38996
|
+
closeSync(descriptor);
|
|
38997
|
+
} catch {
|
|
38998
|
+
}
|
|
38999
|
+
descriptor = void 0;
|
|
39000
|
+
};
|
|
39001
|
+
try {
|
|
39002
|
+
mkdirSync(logDirectory, { recursive: true, mode: 448 });
|
|
39003
|
+
chmodSync(logDirectory, 448);
|
|
39004
|
+
open9();
|
|
39005
|
+
try {
|
|
39006
|
+
chmodSync(`${filePath}.1`, 384);
|
|
39007
|
+
} catch (error51) {
|
|
39008
|
+
if (error51.code !== "ENOENT") throw error51;
|
|
39009
|
+
}
|
|
39010
|
+
prune();
|
|
39011
|
+
} catch {
|
|
39012
|
+
close();
|
|
39013
|
+
return () => {
|
|
39014
|
+
};
|
|
39015
|
+
}
|
|
39016
|
+
const append = (text2) => {
|
|
39017
|
+
try {
|
|
39018
|
+
let bytes = Buffer.from(text2);
|
|
39019
|
+
if (bytes.length > maxBytes) {
|
|
39020
|
+
let start = bytes.length - maxBytes;
|
|
39021
|
+
while (start < bytes.length && (bytes.readUInt8(start) & 192) === 128) start += 1;
|
|
39022
|
+
bytes = bytes.subarray(start);
|
|
39023
|
+
}
|
|
39024
|
+
if (descriptor === void 0) open9();
|
|
39025
|
+
if (size > 0 && size + bytes.length > maxBytes) {
|
|
39026
|
+
close();
|
|
39027
|
+
rmSync(`${filePath}.1`, { force: true });
|
|
39028
|
+
renameSync(filePath, `${filePath}.1`);
|
|
39029
|
+
open9();
|
|
39030
|
+
prune();
|
|
39031
|
+
}
|
|
39032
|
+
if (descriptor === void 0) return;
|
|
39033
|
+
writeFileSync(descriptor, bytes);
|
|
39034
|
+
size += bytes.length;
|
|
39035
|
+
} catch {
|
|
39036
|
+
}
|
|
39037
|
+
};
|
|
39038
|
+
const stamped = (chunk) => {
|
|
39039
|
+
let output = "";
|
|
39040
|
+
for (const part of chunk.split(/(?<=\n)/u)) {
|
|
39041
|
+
if (!part) continue;
|
|
39042
|
+
if (atLineStart) output += `${(/* @__PURE__ */ new Date()).toISOString()} [${input.process.pid}] `;
|
|
39043
|
+
output += part;
|
|
39044
|
+
atLineStart = part.endsWith("\n");
|
|
39045
|
+
}
|
|
39046
|
+
return output;
|
|
39047
|
+
};
|
|
39048
|
+
const line = (text2) => {
|
|
39049
|
+
append(stamped(`${atLineStart ? "" : "\n"}${text2}
|
|
39050
|
+
`));
|
|
39051
|
+
};
|
|
39052
|
+
const originalWrite = stream.write;
|
|
39053
|
+
stream.write = function write(...arguments_2) {
|
|
39054
|
+
const chunk = arguments_2[0];
|
|
39055
|
+
append(
|
|
39056
|
+
stamped(typeof chunk === "string" ? chunk : Buffer.from(chunk).toString())
|
|
39057
|
+
);
|
|
39058
|
+
return Reflect.apply(originalWrite, this, arguments_2);
|
|
39059
|
+
};
|
|
39060
|
+
const onFatal = (error51, origin) => line(
|
|
39061
|
+
`FATAL ${origin}: ${error51 instanceof Error ? error51.stack ?? error51.message : String(error51)}`
|
|
39062
|
+
);
|
|
39063
|
+
const onExit = (code) => {
|
|
39064
|
+
line(`Host Runtime exited with code ${code}`);
|
|
39065
|
+
close();
|
|
39066
|
+
};
|
|
39067
|
+
input.process.on("uncaughtExceptionMonitor", onFatal);
|
|
39068
|
+
input.process.on("exit", onExit);
|
|
39069
|
+
line("Host Runtime started");
|
|
39070
|
+
return () => {
|
|
39071
|
+
stream.write = originalWrite;
|
|
39072
|
+
input.process.off("uncaughtExceptionMonitor", onFatal);
|
|
39073
|
+
input.process.off("exit", onExit);
|
|
39074
|
+
close();
|
|
39075
|
+
};
|
|
39076
|
+
}
|
|
39077
|
+
|
|
38799
39078
|
// packages/host-runtime/src/release-main.ts
|
|
38800
39079
|
var arguments_ = process.argv.slice(2);
|
|
38801
|
-
|
|
38802
|
-
|
|
38803
|
-
|
|
38804
|
-
|
|
38805
|
-
|
|
39080
|
+
function runLoggedHostRuntime() {
|
|
39081
|
+
installRuntimeLog({
|
|
39082
|
+
filePath: runtimeLogPath(process.env, process.pid),
|
|
39083
|
+
stream: process.stderr,
|
|
39084
|
+
process
|
|
39085
|
+
});
|
|
39086
|
+
return runHostRuntime({
|
|
39087
|
+
arguments: arguments_,
|
|
39088
|
+
environment: process.env,
|
|
39089
|
+
hostRuntimeUrl: import.meta.url
|
|
39090
|
+
});
|
|
39091
|
+
}
|
|
39092
|
+
process.exitCode = arguments_[0] === "--codexhost-delegation-cli" ? await runDelegationCli({ arguments: arguments_.slice(1), environment: process.env }) : arguments_[0] === "--codexhost-harness-broker" ? await runClaudeAquaHarnessBroker(process.env, arguments_[1] ?? "claude-code") : arguments_[0] === "--codexhost-remote" ? await runRemoteHostCli({ arguments: arguments_.slice(1), environment: process.env }) : arguments_[0] === "--codexhost-remote-control-bridge" ? await runRemoteControlAppServerBridge() : await runLoggedHostRuntime();
|