@liberseek/boft-cli-win32-arm64 0.6.3 → 0.6.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/app/codexhost-distribution.json +1 -1
- package/app/host-runtime.mjs +204 -131
- package/app/plugins/claude-code/plugin.mjs +664 -229
- package/app/plugins/deepseek-harness/plugin.mjs +82 -17
- package/app/plugins/grok/plugin.mjs +920 -85
- package/app/plugins/kiro-cli/plugin.mjs +77 -61
- package/app/plugins/omp/plugin.mjs +6 -0
- package/app/plugins/opencode/plugin.mjs +292 -142
- package/app/plugins/pi/plugin.mjs +1489 -1304
- package/app/renderer-extension.js +661 -31
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
package/app/host-runtime.mjs
CHANGED
|
@@ -4100,7 +4100,8 @@ async function runDelegationCli(input) {
|
|
|
4100
4100
|
|
|
4101
4101
|
// packages/host-runtime/src/run-host-runtime.ts
|
|
4102
4102
|
import { randomBytes } from "node:crypto";
|
|
4103
|
-
import
|
|
4103
|
+
import path21 from "node:path";
|
|
4104
|
+
import { homedir } from "node:os";
|
|
4104
4105
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
4105
4106
|
|
|
4106
4107
|
// packages/update-manager/dist/distribution.js
|
|
@@ -5958,10 +5959,10 @@ function mergeDefs(...defs) {
|
|
|
5958
5959
|
function cloneDef(schema) {
|
|
5959
5960
|
return mergeDefs(schema._zod.def);
|
|
5960
5961
|
}
|
|
5961
|
-
function getElementAtPath(obj,
|
|
5962
|
-
if (!
|
|
5962
|
+
function getElementAtPath(obj, path26) {
|
|
5963
|
+
if (!path26)
|
|
5963
5964
|
return obj;
|
|
5964
|
-
return
|
|
5965
|
+
return path26.reduce((acc, key) => acc?.[key], obj);
|
|
5965
5966
|
}
|
|
5966
5967
|
function promiseAllObject(promisesObj) {
|
|
5967
5968
|
const keys = Object.keys(promisesObj);
|
|
@@ -6370,11 +6371,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
6370
6371
|
}
|
|
6371
6372
|
return false;
|
|
6372
6373
|
}
|
|
6373
|
-
function prefixIssues(
|
|
6374
|
+
function prefixIssues(path26, issues) {
|
|
6374
6375
|
return issues.map((iss) => {
|
|
6375
6376
|
var _a3;
|
|
6376
6377
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
6377
|
-
iss.path.unshift(
|
|
6378
|
+
iss.path.unshift(path26);
|
|
6378
6379
|
return iss;
|
|
6379
6380
|
});
|
|
6380
6381
|
}
|
|
@@ -6521,16 +6522,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6521
6522
|
}
|
|
6522
6523
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
6523
6524
|
const fieldErrors = { _errors: [] };
|
|
6524
|
-
const processError = (error52,
|
|
6525
|
+
const processError = (error52, path26 = []) => {
|
|
6525
6526
|
for (const issue2 of error52.issues) {
|
|
6526
6527
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6527
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6528
|
+
issue2.errors.map((issues) => processError({ issues }, [...path26, ...issue2.path]));
|
|
6528
6529
|
} else if (issue2.code === "invalid_key") {
|
|
6529
|
-
processError({ issues: issue2.issues }, [...
|
|
6530
|
+
processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
|
|
6530
6531
|
} else if (issue2.code === "invalid_element") {
|
|
6531
|
-
processError({ issues: issue2.issues }, [...
|
|
6532
|
+
processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
|
|
6532
6533
|
} else {
|
|
6533
|
-
const fullpath = [...
|
|
6534
|
+
const fullpath = [...path26, ...issue2.path];
|
|
6534
6535
|
if (fullpath.length === 0) {
|
|
6535
6536
|
fieldErrors._errors.push(mapper(issue2));
|
|
6536
6537
|
} else {
|
|
@@ -6557,17 +6558,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6557
6558
|
}
|
|
6558
6559
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
6559
6560
|
const result = { errors: [] };
|
|
6560
|
-
const processError = (error52,
|
|
6561
|
+
const processError = (error52, path26 = []) => {
|
|
6561
6562
|
var _a3, _b;
|
|
6562
6563
|
for (const issue2 of error52.issues) {
|
|
6563
6564
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
6564
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
6565
|
+
issue2.errors.map((issues) => processError({ issues }, [...path26, ...issue2.path]));
|
|
6565
6566
|
} else if (issue2.code === "invalid_key") {
|
|
6566
|
-
processError({ issues: issue2.issues }, [...
|
|
6567
|
+
processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
|
|
6567
6568
|
} else if (issue2.code === "invalid_element") {
|
|
6568
|
-
processError({ issues: issue2.issues }, [...
|
|
6569
|
+
processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
|
|
6569
6570
|
} else {
|
|
6570
|
-
const fullpath = [...
|
|
6571
|
+
const fullpath = [...path26, ...issue2.path];
|
|
6571
6572
|
if (fullpath.length === 0) {
|
|
6572
6573
|
result.errors.push(mapper(issue2));
|
|
6573
6574
|
continue;
|
|
@@ -6599,8 +6600,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
6599
6600
|
}
|
|
6600
6601
|
function toDotPath(_path) {
|
|
6601
6602
|
const segs = [];
|
|
6602
|
-
const
|
|
6603
|
-
for (const seg of
|
|
6603
|
+
const path26 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
6604
|
+
for (const seg of path26) {
|
|
6604
6605
|
if (typeof seg === "number")
|
|
6605
6606
|
segs.push(`[${seg}]`);
|
|
6606
6607
|
else if (typeof seg === "symbol")
|
|
@@ -19292,13 +19293,13 @@ function resolveRef(ref, ctx) {
|
|
|
19292
19293
|
if (!ref.startsWith("#")) {
|
|
19293
19294
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19294
19295
|
}
|
|
19295
|
-
const
|
|
19296
|
-
if (
|
|
19296
|
+
const path26 = ref.slice(1).split("/").filter(Boolean);
|
|
19297
|
+
if (path26.length === 0) {
|
|
19297
19298
|
return ctx.rootSchema;
|
|
19298
19299
|
}
|
|
19299
19300
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19300
|
-
if (
|
|
19301
|
-
const key =
|
|
19301
|
+
if (path26[0] === defsKey) {
|
|
19302
|
+
const key = path26[1];
|
|
19302
19303
|
if (!key || !ctx.defs[key]) {
|
|
19303
19304
|
throw new Error(`Reference not found: ${ref}`);
|
|
19304
19305
|
}
|
|
@@ -20687,6 +20688,12 @@ function parseHostUsage(value2) {
|
|
|
20687
20688
|
throw new Error(`Harness Usage contains unknown field '${key}'`);
|
|
20688
20689
|
}
|
|
20689
20690
|
}
|
|
20691
|
+
for (const field of ["totalCredits", "contextUsagePercent"]) {
|
|
20692
|
+
const candidate = value2[field];
|
|
20693
|
+
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isFinite(candidate) || candidate < 0)) {
|
|
20694
|
+
throw new Error(`Harness Usage '${field}' must be a finite non-negative number`);
|
|
20695
|
+
}
|
|
20696
|
+
}
|
|
20690
20697
|
for (const field of tokenFields) {
|
|
20691
20698
|
const candidate = value2[field];
|
|
20692
20699
|
if (candidate !== void 0 && (typeof candidate !== "number" || !Number.isSafeInteger(candidate) || candidate < 0)) {
|
|
@@ -22329,8 +22336,8 @@ function projectFileChangeKind(kind) {
|
|
|
22329
22336
|
return { type: kind };
|
|
22330
22337
|
}
|
|
22331
22338
|
function projectFileChanges(changes) {
|
|
22332
|
-
return changes.map(({ path:
|
|
22333
|
-
path:
|
|
22339
|
+
return changes.map(({ path: path26, kind, unifiedDiff }) => ({
|
|
22340
|
+
path: path26,
|
|
22334
22341
|
kind: projectFileChangeKind(kind),
|
|
22335
22342
|
diff: unifiedDiff
|
|
22336
22343
|
}));
|
|
@@ -22559,7 +22566,8 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
22559
22566
|
changes: projectFileChanges(item.changes),
|
|
22560
22567
|
status: itemStatus(outcome)
|
|
22561
22568
|
};
|
|
22562
|
-
case "subagentDelegation":
|
|
22569
|
+
case "subagentDelegation": {
|
|
22570
|
+
const primary = item.subagents[0];
|
|
22563
22571
|
return {
|
|
22564
22572
|
id: item.itemId,
|
|
22565
22573
|
type: "collabAgentToolCall",
|
|
@@ -22568,13 +22576,14 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
|
|
|
22568
22576
|
senderThreadId: senderThreadId ?? "",
|
|
22569
22577
|
receiverThreadIds: item.subagents.map(({ subagentId }) => subagentId),
|
|
22570
22578
|
prompt: item.prompt ?? null,
|
|
22571
|
-
model: null,
|
|
22572
|
-
reasoningEffort: null,
|
|
22579
|
+
model: primary?.model ?? null,
|
|
22580
|
+
reasoningEffort: primary?.reasoningEffort ?? null,
|
|
22573
22581
|
agentsStates: Object.fromEntries(item.subagents.map(({ subagentId, status, resultSummary }) => [
|
|
22574
22582
|
subagentId,
|
|
22575
22583
|
{ status: collabAgentStatus(status), message: resultSummary ?? null }
|
|
22576
22584
|
]))
|
|
22577
22585
|
};
|
|
22586
|
+
}
|
|
22578
22587
|
}
|
|
22579
22588
|
}
|
|
22580
22589
|
function reasoningPreviewItemId(itemId) {
|
|
@@ -22623,7 +22632,9 @@ function projectHistoricalTurn(input) {
|
|
|
22623
22632
|
codexErrorInfo: "other",
|
|
22624
22633
|
additionalDetails: null
|
|
22625
22634
|
} : null;
|
|
22626
|
-
const
|
|
22635
|
+
const startedAtMs = snapshot.startedAtMs;
|
|
22636
|
+
const completedAtMs = snapshot.completedAtMs;
|
|
22637
|
+
const hasTiming = startedAtMs !== void 0 && completedAtMs !== void 0 && Number.isFinite(startedAtMs) && Number.isFinite(completedAtMs) && startedAtMs >= 0 && completedAtMs >= startedAtMs;
|
|
22627
22638
|
return {
|
|
22628
22639
|
id: turnId,
|
|
22629
22640
|
status: historicalStatus(snapshot.outcome),
|
|
@@ -22654,9 +22665,9 @@ function projectHistoricalTurn(input) {
|
|
|
22654
22665
|
})
|
|
22655
22666
|
],
|
|
22656
22667
|
error: error51,
|
|
22657
|
-
startedAt:
|
|
22658
|
-
completedAt:
|
|
22659
|
-
durationMs:
|
|
22668
|
+
startedAt: hasTiming ? Math.floor(startedAtMs / 1e3) : null,
|
|
22669
|
+
completedAt: hasTiming ? Math.floor(completedAtMs / 1e3) : null,
|
|
22670
|
+
durationMs: hasTiming ? completedAtMs - startedAtMs : null,
|
|
22660
22671
|
itemsView: "full"
|
|
22661
22672
|
};
|
|
22662
22673
|
}
|
|
@@ -23283,13 +23294,13 @@ function decodeThreadForkRequest(request) {
|
|
|
23283
23294
|
if (runtimeWorkspaceRoots !== void 0 && runtimeWorkspaceRoots !== null && (!Array.isArray(runtimeWorkspaceRoots) || runtimeWorkspaceRoots.some((root) => typeof root !== "string" || root.length === 0))) {
|
|
23284
23295
|
throw new Error("thread/fork params.runtimeWorkspaceRoots must be text paths or null");
|
|
23285
23296
|
}
|
|
23286
|
-
const
|
|
23297
|
+
const path26 = optionalText(params, "path", { allowEmpty: true });
|
|
23287
23298
|
const ephemeral = optionalBoolean(params, "ephemeral");
|
|
23288
23299
|
return {
|
|
23289
23300
|
threadId: threadId3,
|
|
23290
23301
|
...lastTurnText ? { lastTurnId: hostTurnIdSchema.parse(lastTurnText) } : {},
|
|
23291
23302
|
...beforeTurnText ? { beforeTurnId: hostTurnIdSchema.parse(beforeTurnText) } : {},
|
|
23292
|
-
...
|
|
23303
|
+
...path26 ? { path: path26 } : {},
|
|
23293
23304
|
...optionalField(params, "model"),
|
|
23294
23305
|
...optionalField(params, "modelProvider"),
|
|
23295
23306
|
...optionalField(params, "cwd"),
|
|
@@ -24601,6 +24612,19 @@ function createExternalThreadRecordInput(input) {
|
|
|
24601
24612
|
...input.subagent ? { subagent: input.subagent } : {}
|
|
24602
24613
|
};
|
|
24603
24614
|
}
|
|
24615
|
+
function subagentThreadModelFields(record3) {
|
|
24616
|
+
if (!record3.subagent) return {};
|
|
24617
|
+
try {
|
|
24618
|
+
const selection = decodeExternalTransportSelection(record3.harnessId, record3.transportModelId);
|
|
24619
|
+
if (!selection) return {};
|
|
24620
|
+
return {
|
|
24621
|
+
...selection.model?.id ? { model: selection.model.id } : {},
|
|
24622
|
+
...selection.thinkingOptionId ? { reasoningEffort: selection.thinkingOptionId } : {}
|
|
24623
|
+
};
|
|
24624
|
+
} catch {
|
|
24625
|
+
return {};
|
|
24626
|
+
}
|
|
24627
|
+
}
|
|
24604
24628
|
function externalThreadValue(input) {
|
|
24605
24629
|
const { record: record3 } = input;
|
|
24606
24630
|
const createdAt = Math.floor(Date.parse(record3.createdAt) / 1e3);
|
|
@@ -24647,7 +24671,8 @@ function externalThreadValue(input) {
|
|
|
24647
24671
|
isPinned: record3.isPinned,
|
|
24648
24672
|
agentNickname: record3.subagent ? record3.title || null : null,
|
|
24649
24673
|
agentRole: record3.subagent?.role ?? null,
|
|
24650
|
-
extra: null
|
|
24674
|
+
extra: null,
|
|
24675
|
+
...subagentThreadModelFields(record3)
|
|
24651
24676
|
};
|
|
24652
24677
|
}
|
|
24653
24678
|
|
|
@@ -25268,6 +25293,7 @@ async function executeCurrentLastTurnRollback(input) {
|
|
|
25268
25293
|
error: { code: -32079, message: "External Native Session is unavailable" }
|
|
25269
25294
|
};
|
|
25270
25295
|
}
|
|
25296
|
+
const configuration = currentConfiguration(current);
|
|
25271
25297
|
let opened;
|
|
25272
25298
|
try {
|
|
25273
25299
|
opened = await adapter.open({
|
|
@@ -25277,7 +25303,10 @@ async function executeCurrentLastTurnRollback(input) {
|
|
|
25277
25303
|
...input.environment ?? process.env,
|
|
25278
25304
|
[DELEGATION_THREAD_ID_ENV]: current.id
|
|
25279
25305
|
},
|
|
25280
|
-
sourceRef: currentNativeRef
|
|
25306
|
+
sourceRef: currentNativeRef,
|
|
25307
|
+
...configuration.effectiveModel ? { model: configuration.effectiveModel } : {},
|
|
25308
|
+
...configuration.effectiveThinkingOptionId ? { thinkingOptionId: configuration.effectiveThinkingOptionId } : {},
|
|
25309
|
+
...configuration.effectivePermissionModeId ? { permissionModeId: configuration.effectivePermissionModeId } : {}
|
|
25281
25310
|
});
|
|
25282
25311
|
} catch {
|
|
25283
25312
|
return { ok: false, error: { code: -32076, message: "External Thread rollback failed" } };
|
|
@@ -25294,7 +25323,6 @@ async function executeCurrentLastTurnRollback(input) {
|
|
|
25294
25323
|
error: { code: -32076, message: "External rollback did not return a valid Session" }
|
|
25295
25324
|
};
|
|
25296
25325
|
}
|
|
25297
|
-
const configuration = currentConfiguration(current);
|
|
25298
25326
|
const configurationError = await restoreCurrentConfiguration(session, configuration);
|
|
25299
25327
|
if (configurationError) {
|
|
25300
25328
|
await session.close().catch(() => void 0);
|
|
@@ -25866,6 +25894,8 @@ var ExternalThreadRuntime = class {
|
|
|
25866
25894
|
environment: { ...this.#environment, [DELEGATION_THREAD_ID_ENV]: record3.hostThreadId },
|
|
25867
25895
|
nativeRef: record3.nativeSessionRef,
|
|
25868
25896
|
knownTurnRefs: record3.turnMappings.map(({ nativeTurnRef }) => nativeTurnRef),
|
|
25897
|
+
...restoredSelection?.model ? { model: restoredSelection.model } : {},
|
|
25898
|
+
...restoredSelection?.thinkingOptionId ? { thinkingOptionId: restoredSelection.thinkingOptionId } : {},
|
|
25869
25899
|
...harnessId === "grok" && restoredSelection?.permissionModeId ? { permissionModeId: restoredSelection.permissionModeId } : {}
|
|
25870
25900
|
});
|
|
25871
25901
|
if (!opened.ok) {
|
|
@@ -27782,25 +27812,25 @@ function resolveExternalSessionTreeIds(records) {
|
|
|
27782
27812
|
const resolve = (start) => {
|
|
27783
27813
|
const cached2 = resolved.get(start.hostThreadId);
|
|
27784
27814
|
if (cached2) return cached2;
|
|
27785
|
-
const
|
|
27815
|
+
const path26 = [];
|
|
27786
27816
|
const visited = /* @__PURE__ */ new Set();
|
|
27787
27817
|
let current = start;
|
|
27788
27818
|
while (true) {
|
|
27789
27819
|
const known = resolved.get(current.hostThreadId);
|
|
27790
27820
|
if (known) {
|
|
27791
|
-
for (const record3 of
|
|
27821
|
+
for (const record3 of path26) resolved.set(record3.hostThreadId, known);
|
|
27792
27822
|
return known;
|
|
27793
27823
|
}
|
|
27794
27824
|
if (visited.has(current.hostThreadId)) {
|
|
27795
27825
|
throw new Error("External Thread Fork tree contains a cycle");
|
|
27796
27826
|
}
|
|
27797
27827
|
visited.add(current.hostThreadId);
|
|
27798
|
-
|
|
27828
|
+
path26.push(current);
|
|
27799
27829
|
const sourceId = current.forkSource?.hostThreadId;
|
|
27800
27830
|
const source = sourceId ? byId.get(sourceId) : void 0;
|
|
27801
27831
|
if (!source) {
|
|
27802
27832
|
const root = current.hostThreadId;
|
|
27803
|
-
for (const record3 of
|
|
27833
|
+
for (const record3 of path26) resolved.set(record3.hostThreadId, root);
|
|
27804
27834
|
return root;
|
|
27805
27835
|
}
|
|
27806
27836
|
current = source;
|
|
@@ -28345,6 +28375,8 @@ function approvalServerName(harnessId) {
|
|
|
28345
28375
|
return "Oh My Pi";
|
|
28346
28376
|
case "antigravity":
|
|
28347
28377
|
return "Antigravity CLI";
|
|
28378
|
+
case "kiro-cli":
|
|
28379
|
+
return "Kiro CLI";
|
|
28348
28380
|
default:
|
|
28349
28381
|
return harnessId;
|
|
28350
28382
|
}
|
|
@@ -31697,6 +31729,8 @@ var AppServerHost = class {
|
|
|
31697
31729
|
sessionId: parent.sessionId,
|
|
31698
31730
|
running: status === "active"
|
|
31699
31731
|
});
|
|
31732
|
+
if (subagent.model) thread.model = subagent.model;
|
|
31733
|
+
if (subagent.reasoningEffort) thread.reasoningEffort = subagent.reasoningEffort;
|
|
31700
31734
|
this.#subagentThreadStatuses.set(record3.hostThreadId, status);
|
|
31701
31735
|
this.#trackRunningSubagent(parent.id, record3.hostThreadId, status);
|
|
31702
31736
|
await this.#writer.json({
|
|
@@ -32089,6 +32123,40 @@ var AppServerHost = class {
|
|
|
32089
32123
|
}
|
|
32090
32124
|
};
|
|
32091
32125
|
|
|
32126
|
+
// packages/host-runtime/src/codex-runtime/account-official-listeners.ts
|
|
32127
|
+
import path13 from "node:path";
|
|
32128
|
+
var AccountOfficialListeners = class {
|
|
32129
|
+
constructor(createListener) {
|
|
32130
|
+
this.createListener = createListener;
|
|
32131
|
+
}
|
|
32132
|
+
createListener;
|
|
32133
|
+
#listeners = /* @__PURE__ */ new Map();
|
|
32134
|
+
#starting = /* @__PURE__ */ new Map();
|
|
32135
|
+
#closed = false;
|
|
32136
|
+
async endpoint(account) {
|
|
32137
|
+
if (this.#closed) throw new Error("Account official listeners are closed");
|
|
32138
|
+
const key = path13.resolve(account.codexHome);
|
|
32139
|
+
const existing = this.#starting.get(key);
|
|
32140
|
+
if (existing) return existing;
|
|
32141
|
+
const listener = this.createListener(account);
|
|
32142
|
+
this.#listeners.set(key, listener);
|
|
32143
|
+
const starting = listener.listen().catch(async (error51) => {
|
|
32144
|
+
await listener.close();
|
|
32145
|
+
this.#listeners.delete(key);
|
|
32146
|
+
this.#starting.delete(key);
|
|
32147
|
+
throw error51;
|
|
32148
|
+
});
|
|
32149
|
+
this.#starting.set(key, starting);
|
|
32150
|
+
return starting;
|
|
32151
|
+
}
|
|
32152
|
+
async close() {
|
|
32153
|
+
this.#closed = true;
|
|
32154
|
+
await Promise.all([...this.#listeners.values()].map((listener) => listener.close()));
|
|
32155
|
+
this.#listeners.clear();
|
|
32156
|
+
this.#starting.clear();
|
|
32157
|
+
}
|
|
32158
|
+
};
|
|
32159
|
+
|
|
32092
32160
|
// packages/host-runtime/src/delegation-control-registry.ts
|
|
32093
32161
|
function only(values, message) {
|
|
32094
32162
|
const value2 = values.length === 1 ? values[0] : void 0;
|
|
@@ -32197,17 +32265,17 @@ var DelegationControlRegistry = class {
|
|
|
32197
32265
|
|
|
32198
32266
|
// packages/host-runtime/src/installed-harness-plugins.ts
|
|
32199
32267
|
import os3 from "node:os";
|
|
32200
|
-
import
|
|
32268
|
+
import path15 from "node:path";
|
|
32201
32269
|
import { fileURLToPath } from "node:url";
|
|
32202
32270
|
|
|
32203
32271
|
// packages/host-runtime/src/launcher-url-opener.ts
|
|
32204
32272
|
import { spawn as spawn3 } from "node:child_process";
|
|
32205
|
-
import
|
|
32273
|
+
import path14 from "node:path";
|
|
32206
32274
|
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
|
|
32207
32275
|
var OPEN_TIMEOUT_MS = 1e4;
|
|
32208
32276
|
function createLauncherUrlOpener(environment, spawnLauncher = (command, arguments_2, options2) => spawn3(command, arguments_2, options2)) {
|
|
32209
32277
|
const launcher = environment.CODEXHOST_LAUNCHER_EXECUTABLE;
|
|
32210
|
-
if (!launcher || !
|
|
32278
|
+
if (!launcher || !path14.isAbsolute(launcher)) return void 0;
|
|
32211
32279
|
const launcherEnvironment = Object.fromEntries(
|
|
32212
32280
|
Object.entries(environment).filter(([name]) => {
|
|
32213
32281
|
const normalized = name.toUpperCase();
|
|
@@ -32265,9 +32333,9 @@ function installedHarnessPluginOptions(environment, managedRemoteHost = false, h
|
|
|
32265
32333
|
const opener = managedRemoteHost ? void 0 : createLauncherUrlOpener(environment);
|
|
32266
32334
|
return {
|
|
32267
32335
|
pluginRoots: [
|
|
32268
|
-
|
|
32269
|
-
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ??
|
|
32270
|
-
environment.CODEXHOST_DATA_DIR ?
|
|
32336
|
+
path15.join(path15.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
|
|
32337
|
+
environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path15.join(
|
|
32338
|
+
environment.CODEXHOST_DATA_DIR ? path15.resolve(environment.CODEXHOST_DATA_DIR) : path15.join(os3.homedir(), ".codexhost"),
|
|
32271
32339
|
"plugins"
|
|
32272
32340
|
)
|
|
32273
32341
|
],
|
|
@@ -32392,9 +32460,9 @@ async function startDelegationControlServer(input) {
|
|
|
32392
32460
|
import { createHash as createHash6, randomUUID as randomUUID9 } from "node:crypto";
|
|
32393
32461
|
import { mkdir as mkdir7, open as open5, readFile as readFile8, rename as rename5, rm as rm5, stat as stat3 } from "node:fs/promises";
|
|
32394
32462
|
import os4 from "node:os";
|
|
32395
|
-
import
|
|
32463
|
+
import path16 from "node:path";
|
|
32396
32464
|
var SKILL_VERSION = 5;
|
|
32397
|
-
var SKILL_RELATIVE_PATH =
|
|
32465
|
+
var SKILL_RELATIVE_PATH = path16.join("skills", "codexhost-delegation", "SKILL.md");
|
|
32398
32466
|
var PREVIOUS_MANAGED_DIGESTS = [
|
|
32399
32467
|
"aff258622dc8ff321f32b15620d081e578cb9c9ed1134d6a57f35ca8e7762c0a",
|
|
32400
32468
|
"ba509f57e5448e796b3dfdd5031dcb08672eded50b61c0a54de84cfa02c49dd3",
|
|
@@ -32483,8 +32551,8 @@ async function readOptional(filePath) {
|
|
|
32483
32551
|
}
|
|
32484
32552
|
}
|
|
32485
32553
|
async function atomicWrite(filePath, content) {
|
|
32486
|
-
await mkdir7(
|
|
32487
|
-
const temporaryPath =
|
|
32554
|
+
await mkdir7(path16.dirname(filePath), { recursive: true, mode: 448 });
|
|
32555
|
+
const temporaryPath = path16.join(path16.dirname(filePath), `.SKILL.md.${randomUUID9()}.tmp`);
|
|
32488
32556
|
const handle = await open5(temporaryPath, "wx", 384);
|
|
32489
32557
|
try {
|
|
32490
32558
|
await handle.writeFile(content, "utf8");
|
|
@@ -32501,8 +32569,8 @@ async function atomicWrite(filePath, content) {
|
|
|
32501
32569
|
async function installDelegationSkills(input = {}) {
|
|
32502
32570
|
const home = input.homeDirectory ?? os4.homedir();
|
|
32503
32571
|
const destinations = [
|
|
32504
|
-
|
|
32505
|
-
|
|
32572
|
+
path16.join(home, ".agents", SKILL_RELATIVE_PATH),
|
|
32573
|
+
path16.join(home, ".claude", SKILL_RELATIVE_PATH)
|
|
32506
32574
|
];
|
|
32507
32575
|
const knownDigests = /* @__PURE__ */ new Set([
|
|
32508
32576
|
CURRENT_DIGEST,
|
|
@@ -32569,7 +32637,7 @@ async function installDelegationSkills(input = {}) {
|
|
|
32569
32637
|
// packages/host-runtime/src/remote-control-app-server.ts
|
|
32570
32638
|
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
32571
32639
|
import { mkdir as mkdir8, open as open6, rename as rename6, rm as rm6 } from "node:fs/promises";
|
|
32572
|
-
import
|
|
32640
|
+
import path17 from "node:path";
|
|
32573
32641
|
|
|
32574
32642
|
// packages/host-runtime/src/remote-official-connection.ts
|
|
32575
32643
|
import net from "node:net";
|
|
@@ -32759,8 +32827,8 @@ var BRIDGE_READY_METHOD = "codexhost/remote-control-bridge/ready";
|
|
|
32759
32827
|
function absoluteEnvironmentPath2(environment, name, fallback, platform = process.platform) {
|
|
32760
32828
|
const value2 = environment[name] ?? fallback;
|
|
32761
32829
|
if (!value2) return null;
|
|
32762
|
-
if (
|
|
32763
|
-
return platform === "win32" &&
|
|
32830
|
+
if (path17.isAbsolute(value2)) return path17.normalize(value2);
|
|
32831
|
+
return platform === "win32" && path17.win32.isAbsolute(value2) ? path17.win32.normalize(value2) : null;
|
|
32764
32832
|
}
|
|
32765
32833
|
function nodeCompatibleWindowsPath(value2) {
|
|
32766
32834
|
if (value2.startsWith("\\\\?\\UNC\\")) return `\\\\${value2.slice(8)}`;
|
|
@@ -32774,13 +32842,13 @@ function remoteControlBridgePipePath(processId = process.pid, instanceId = rando
|
|
|
32774
32842
|
}
|
|
32775
32843
|
function remoteControlBridgeDescriptorPath(environment) {
|
|
32776
32844
|
const root = environment.LOCALAPPDATA;
|
|
32777
|
-
if (!root || !
|
|
32778
|
-
return
|
|
32845
|
+
if (!root || !path17.isAbsolute(root)) return null;
|
|
32846
|
+
return path17.join(path17.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
|
|
32779
32847
|
}
|
|
32780
32848
|
async function publishRemoteControlAppServerDescriptor(plan) {
|
|
32781
|
-
const directory =
|
|
32849
|
+
const directory = path17.dirname(plan.descriptorPath);
|
|
32782
32850
|
await mkdir8(directory, { recursive: true, mode: 448 });
|
|
32783
|
-
const temporaryPath =
|
|
32851
|
+
const temporaryPath = path17.join(
|
|
32784
32852
|
directory,
|
|
32785
32853
|
`.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID10()}.tmp`
|
|
32786
32854
|
);
|
|
@@ -32873,14 +32941,14 @@ async function runRemoteControlAppServerBridge(input = {}) {
|
|
|
32873
32941
|
import { createServer as createServer2 } from "node:http";
|
|
32874
32942
|
import net2 from "node:net";
|
|
32875
32943
|
import { chmod as chmod3, lstat as lstat6, mkdir as mkdir10, rm as rm8 } from "node:fs/promises";
|
|
32876
|
-
import
|
|
32944
|
+
import path19 from "node:path";
|
|
32877
32945
|
import { PassThrough as PassThrough2 } from "node:stream";
|
|
32878
32946
|
|
|
32879
32947
|
// packages/host-runtime/src/remote-socket-lock.ts
|
|
32880
32948
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
32881
32949
|
import { chmod as chmod2, lstat as lstat5, mkdir as mkdir9, open as open7, readFile as readFile9, readdir as readdir4, rename as rename7, rm as rm7 } from "node:fs/promises";
|
|
32882
32950
|
import { uptime } from "node:os";
|
|
32883
|
-
import
|
|
32951
|
+
import path18 from "node:path";
|
|
32884
32952
|
import { setTimeout as delay4 } from "node:timers/promises";
|
|
32885
32953
|
var LOCK_RETRY_COUNT = 200;
|
|
32886
32954
|
var LOCK_RETRY_DELAY_MS = 25;
|
|
@@ -32954,7 +33022,7 @@ async function readLockEntrySnapshot(filePath) {
|
|
|
32954
33022
|
source,
|
|
32955
33023
|
identity: { dev: metadata.dev, ino: metadata.ino },
|
|
32956
33024
|
mtimeMs: metadata.mtimeMs,
|
|
32957
|
-
record: record3 &&
|
|
33025
|
+
record: record3 && path18.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
|
|
32958
33026
|
};
|
|
32959
33027
|
}
|
|
32960
33028
|
function lockEntryIsAbandoned(snapshot) {
|
|
@@ -32975,7 +33043,7 @@ async function readLockEntryCatalog(lockDirectory) {
|
|
|
32975
33043
|
let unsettled = false;
|
|
32976
33044
|
for (const name of names) {
|
|
32977
33045
|
if (!name.startsWith(LOCK_ENTRY_PREFIX) || !name.endsWith(LOCK_ENTRY_SUFFIX)) continue;
|
|
32978
|
-
const snapshot = await readLockEntrySnapshot(
|
|
33046
|
+
const snapshot = await readLockEntrySnapshot(path18.join(lockDirectory, name));
|
|
32979
33047
|
if (snapshot === null) continue;
|
|
32980
33048
|
if (lockEntryIsAbandoned(snapshot)) {
|
|
32981
33049
|
if (!await removeAbandonedLockEntry(snapshot)) unsettled = true;
|
|
@@ -33003,7 +33071,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
|
|
|
33003
33071
|
await chmod2(lockDirectory, 448);
|
|
33004
33072
|
}
|
|
33005
33073
|
async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
|
|
33006
|
-
const temporary =
|
|
33074
|
+
const temporary = path18.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID11()}`);
|
|
33007
33075
|
const handle = await open7(temporary, "wx", 384);
|
|
33008
33076
|
try {
|
|
33009
33077
|
await handle.writeFile(`${JSON.stringify(record3)}
|
|
@@ -33079,7 +33147,7 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
|
|
|
33079
33147
|
const lockDirectory = `${socketPath}.initializers`;
|
|
33080
33148
|
await preparePrivateLockDirectory(lockDirectory);
|
|
33081
33149
|
const ownerToken = randomUUID11();
|
|
33082
|
-
const entryPath =
|
|
33150
|
+
const entryPath = path18.join(lockDirectory, lockEntryName(ownerToken));
|
|
33083
33151
|
const baseRecord = {
|
|
33084
33152
|
version: 2,
|
|
33085
33153
|
ownerToken,
|
|
@@ -33253,14 +33321,14 @@ function remoteAppServerSocketPath(environment, listenUrl = "unix://") {
|
|
|
33253
33321
|
throw new Error("Remote app-server listener must use a Unix URL");
|
|
33254
33322
|
}
|
|
33255
33323
|
const explicit = listenUrl.slice("unix://".length);
|
|
33256
|
-
if (explicit.length > 0) return
|
|
33257
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
33324
|
+
if (explicit.length > 0) return path19.posix.resolve(decodeURIComponent(explicit));
|
|
33325
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path19.posix.join(environment.HOME, ".codex") : void 0);
|
|
33258
33326
|
if (!codexHome)
|
|
33259
33327
|
throw new Error("CODEX_HOME or HOME is required for the remote app-server socket");
|
|
33260
|
-
return
|
|
33328
|
+
return path19.posix.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
33261
33329
|
}
|
|
33262
33330
|
function officialListenerArgumentsForRemoteListener(arguments_2, socketPath) {
|
|
33263
|
-
if (!
|
|
33331
|
+
if (!path19.posix.isAbsolute(socketPath)) {
|
|
33264
33332
|
throw new Error("Shared official app-server socket path must be absolute");
|
|
33265
33333
|
}
|
|
33266
33334
|
if (remoteUnixListenerUrl(arguments_2) === null) {
|
|
@@ -33371,7 +33439,7 @@ async function removeStaleSocket(socketPath) {
|
|
|
33371
33439
|
await rm8(socketPath, { force: true });
|
|
33372
33440
|
}
|
|
33373
33441
|
async function prepareRemoteAppServerSocketDirectory(socketPath) {
|
|
33374
|
-
const socketDirectory =
|
|
33442
|
+
const socketDirectory = path19.dirname(socketPath);
|
|
33375
33443
|
const existing = await lstat6(socketDirectory).catch((error51) => {
|
|
33376
33444
|
if (error51.code === "ENOENT") return null;
|
|
33377
33445
|
throw error51;
|
|
@@ -33578,18 +33646,18 @@ function createRemoteAppServerWebSocketListener(input) {
|
|
|
33578
33646
|
import { spawn as spawn4 } from "node:child_process";
|
|
33579
33647
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
33580
33648
|
import { lstat as lstat7, rm as rm9 } from "node:fs/promises";
|
|
33581
|
-
import
|
|
33649
|
+
import path20 from "node:path";
|
|
33582
33650
|
var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
|
|
33583
33651
|
var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
|
|
33584
33652
|
function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID12()) {
|
|
33585
|
-
if (!
|
|
33653
|
+
if (!path20.posix.isAbsolute(desktopControlSocketPath)) {
|
|
33586
33654
|
throw new Error("Desktop control socket path must be absolute");
|
|
33587
33655
|
}
|
|
33588
33656
|
if (!/^[A-Za-z0-9-]+$/u.test(token) || !/[A-Za-z0-9]/u.test(token)) {
|
|
33589
33657
|
throw new Error("Shared official app-server socket token is invalid");
|
|
33590
33658
|
}
|
|
33591
33659
|
const compactToken = token.replaceAll("-", "").slice(0, 15);
|
|
33592
|
-
return
|
|
33660
|
+
return path20.posix.join(path20.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
|
|
33593
33661
|
}
|
|
33594
33662
|
function errorMessage5(error51) {
|
|
33595
33663
|
return error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -34056,9 +34124,9 @@ function hasLauncherManagedUpdateRuntime(environment, hostRuntimePath) {
|
|
|
34056
34124
|
if (!environment[UPDATE_RUNTIME_ENV.launcherPid]) return false;
|
|
34057
34125
|
const npmPackageRoot = environment[UPDATE_RUNTIME_ENV.npmPackageRoot];
|
|
34058
34126
|
if (!npmPackageRoot || !hostRuntimePath) return true;
|
|
34059
|
-
if (!
|
|
34060
|
-
const runtimePackageRoot =
|
|
34061
|
-
return
|
|
34127
|
+
if (!path21.isAbsolute(npmPackageRoot) || !path21.isAbsolute(hostRuntimePath)) return false;
|
|
34128
|
+
const runtimePackageRoot = path21.dirname(path21.dirname(path21.normalize(hostRuntimePath)));
|
|
34129
|
+
return path21.relative(path21.normalize(npmPackageRoot), runtimePackageRoot) === "";
|
|
34062
34130
|
}
|
|
34063
34131
|
function requiredRuntimeConfiguration(environment) {
|
|
34064
34132
|
const stockCodexPath = environment[STOCK_CODEX_PATH_ENV];
|
|
@@ -34139,19 +34207,15 @@ async function runHostRuntime(input) {
|
|
|
34139
34207
|
const officialPlan = createRemoteControlOfficialAppServerPlan(
|
|
34140
34208
|
remoteControlPlan.officialArguments
|
|
34141
34209
|
);
|
|
34142
|
-
const
|
|
34143
|
-
|
|
34144
|
-
|
|
34145
|
-
|
|
34146
|
-
|
|
34147
|
-
|
|
34148
|
-
|
|
34149
|
-
|
|
34150
|
-
|
|
34151
|
-
throw new Error("Shared official app-server endpoint is unavailable");
|
|
34152
|
-
}
|
|
34153
|
-
return createRemoteOfficialAppServerConnection(officialEndpoint);
|
|
34154
|
-
};
|
|
34210
|
+
const officialListeners = new AccountOfficialListeners(
|
|
34211
|
+
(account) => createLoopbackOfficialAppServerListener({
|
|
34212
|
+
stockCodexPath,
|
|
34213
|
+
arguments: officialPlan.listenerArguments,
|
|
34214
|
+
environment: officialAccountEnvironment(delegationEnvironment, account),
|
|
34215
|
+
diagnosticOutput: process.stderr
|
|
34216
|
+
})
|
|
34217
|
+
);
|
|
34218
|
+
const createOfficialConnection = async (account) => createRemoteOfficialAppServerConnection(await officialListeners.endpoint(account));
|
|
34155
34219
|
const mappingStore = createProductionExternalThreadStore(delegationEnvironment);
|
|
34156
34220
|
await mappingStore.initialize();
|
|
34157
34221
|
const host = new AppServerHost({
|
|
@@ -34188,7 +34252,11 @@ async function runHostRuntime(input) {
|
|
|
34188
34252
|
}
|
|
34189
34253
|
});
|
|
34190
34254
|
try {
|
|
34191
|
-
|
|
34255
|
+
await officialListeners.endpoint({
|
|
34256
|
+
codexHome: path21.resolve(
|
|
34257
|
+
delegationEnvironment.CODEX_HOME ?? path21.join(homedir(), ".codex")
|
|
34258
|
+
)
|
|
34259
|
+
});
|
|
34192
34260
|
await listener.listen();
|
|
34193
34261
|
await publishRemoteControlAppServerDescriptor(remoteControlPlan);
|
|
34194
34262
|
return await host.run();
|
|
@@ -34197,7 +34265,7 @@ async function runHostRuntime(input) {
|
|
|
34197
34265
|
await listener.close();
|
|
34198
34266
|
} finally {
|
|
34199
34267
|
try {
|
|
34200
|
-
await
|
|
34268
|
+
await officialListeners.close();
|
|
34201
34269
|
} finally {
|
|
34202
34270
|
await mappingStore.close();
|
|
34203
34271
|
}
|
|
@@ -34302,7 +34370,7 @@ import {
|
|
|
34302
34370
|
stat as stat4,
|
|
34303
34371
|
writeFile as writeFile5
|
|
34304
34372
|
} from "node:fs/promises";
|
|
34305
|
-
import
|
|
34373
|
+
import path22 from "node:path";
|
|
34306
34374
|
var MANIFEST_FORMAT = 1;
|
|
34307
34375
|
var WRAPPER_MARKER = "# codexhost remote SSH wrapper v1";
|
|
34308
34376
|
var PROFILE_START = "# >>> codexhost remote SSH >>>";
|
|
@@ -34313,25 +34381,25 @@ function resolvePaths(options2) {
|
|
|
34313
34381
|
if (!configuredHome) {
|
|
34314
34382
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
34315
34383
|
}
|
|
34316
|
-
const home =
|
|
34317
|
-
if (!home || home ===
|
|
34384
|
+
const home = path22.resolve(configuredHome);
|
|
34385
|
+
if (!home || home === path22.parse(home).root) {
|
|
34318
34386
|
throw new Error("A non-root HOME is required for remote Host installation");
|
|
34319
34387
|
}
|
|
34320
|
-
const installRoot =
|
|
34321
|
-
const profilePath =
|
|
34322
|
-
options2.profilePath ??
|
|
34388
|
+
const installRoot = path22.resolve(options2.installRoot ?? path22.join(home, ".codexhost", "remote"));
|
|
34389
|
+
const profilePath = path22.resolve(
|
|
34390
|
+
options2.profilePath ?? path22.join(
|
|
34323
34391
|
home,
|
|
34324
|
-
|
|
34392
|
+
path22.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path22.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
|
|
34325
34393
|
)
|
|
34326
34394
|
);
|
|
34327
|
-
const binDirectory =
|
|
34395
|
+
const binDirectory = path22.join(installRoot, "bin");
|
|
34328
34396
|
return {
|
|
34329
34397
|
home,
|
|
34330
34398
|
installRoot,
|
|
34331
34399
|
binDirectory,
|
|
34332
|
-
wrapperPath:
|
|
34333
|
-
manifestPath:
|
|
34334
|
-
dataDirectory:
|
|
34400
|
+
wrapperPath: path22.join(binDirectory, "codex"),
|
|
34401
|
+
manifestPath: path22.join(installRoot, "manifest.json"),
|
|
34402
|
+
dataDirectory: path22.join(installRoot, "data"),
|
|
34335
34403
|
profilePath
|
|
34336
34404
|
};
|
|
34337
34405
|
}
|
|
@@ -34350,7 +34418,7 @@ async function fileSha256(filePath) {
|
|
|
34350
34418
|
return createHash7("sha256").update(await readFile10(filePath)).digest("hex");
|
|
34351
34419
|
}
|
|
34352
34420
|
async function executable(filePath, label) {
|
|
34353
|
-
const absolute =
|
|
34421
|
+
const absolute = path22.resolve(filePath);
|
|
34354
34422
|
try {
|
|
34355
34423
|
if (!(await stat4(absolute)).isFile()) throw new Error("not a regular file");
|
|
34356
34424
|
await access(absolute, fsConstants.X_OK);
|
|
@@ -34360,7 +34428,7 @@ async function executable(filePath, label) {
|
|
|
34360
34428
|
return absolute;
|
|
34361
34429
|
}
|
|
34362
34430
|
async function existingFile(filePath, label) {
|
|
34363
|
-
const absolute =
|
|
34431
|
+
const absolute = path22.resolve(filePath);
|
|
34364
34432
|
try {
|
|
34365
34433
|
const metadata = await stat4(absolute);
|
|
34366
34434
|
if (!metadata.isFile()) throw new Error("not a regular file");
|
|
@@ -34370,9 +34438,9 @@ async function existingFile(filePath, label) {
|
|
|
34370
34438
|
return absolute;
|
|
34371
34439
|
}
|
|
34372
34440
|
async function discoverExecutable(name, environment) {
|
|
34373
|
-
for (const directory of (environment.PATH ?? "").split(
|
|
34441
|
+
for (const directory of (environment.PATH ?? "").split(path22.delimiter)) {
|
|
34374
34442
|
if (!directory) continue;
|
|
34375
|
-
const candidate =
|
|
34443
|
+
const candidate = path22.resolve(directory, name);
|
|
34376
34444
|
try {
|
|
34377
34445
|
await access(candidate, fsConstants.X_OK);
|
|
34378
34446
|
return candidate;
|
|
@@ -34383,10 +34451,10 @@ async function discoverExecutable(name, environment) {
|
|
|
34383
34451
|
return null;
|
|
34384
34452
|
}
|
|
34385
34453
|
async function writeAtomic(filePath, contents, mode) {
|
|
34386
|
-
await mkdir11(
|
|
34387
|
-
const temporary =
|
|
34388
|
-
|
|
34389
|
-
`.${
|
|
34454
|
+
await mkdir11(path22.dirname(filePath), { recursive: true, mode: 448 });
|
|
34455
|
+
const temporary = path22.join(
|
|
34456
|
+
path22.dirname(filePath),
|
|
34457
|
+
`.${path22.basename(filePath)}.${process.pid}.${randomUUID13()}.tmp`
|
|
34390
34458
|
);
|
|
34391
34459
|
try {
|
|
34392
34460
|
if (typeof contents === "string") {
|
|
@@ -34407,10 +34475,10 @@ async function writeAtomic(filePath, contents, mode) {
|
|
|
34407
34475
|
}
|
|
34408
34476
|
}
|
|
34409
34477
|
async function writeAtomicExecutable(filePath, sourcePath) {
|
|
34410
|
-
await mkdir11(
|
|
34411
|
-
const temporary =
|
|
34412
|
-
|
|
34413
|
-
`.${
|
|
34478
|
+
await mkdir11(path22.dirname(filePath), { recursive: true, mode: 448 });
|
|
34479
|
+
const temporary = path22.join(
|
|
34480
|
+
path22.dirname(filePath),
|
|
34481
|
+
`.${path22.basename(filePath)}.${process.pid}.${randomUUID13()}.tmp`
|
|
34414
34482
|
);
|
|
34415
34483
|
try {
|
|
34416
34484
|
await copyFile3(sourcePath, temporary);
|
|
@@ -34451,8 +34519,8 @@ function removeManagedProfileBlock(contents) {
|
|
|
34451
34519
|
function installManagedProfileBlock(contents, manifest) {
|
|
34452
34520
|
const base = removeManagedProfileBlock(contents);
|
|
34453
34521
|
const environment = [
|
|
34454
|
-
`export CODEX_INSTALL_DIR=${shellQuote(
|
|
34455
|
-
`export PATH=${shellQuote(
|
|
34522
|
+
`export CODEX_INSTALL_DIR=${shellQuote(path22.dirname(manifest.wrapperPath))}`,
|
|
34523
|
+
`export PATH=${shellQuote(path22.dirname(manifest.wrapperPath))}:${shellQuote(path22.dirname(manifest.nodePath))}:${shellQuote(path22.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
|
|
34456
34524
|
`export CODEXHOST_STOCK_CODEX_PATH=${shellQuote(manifest.stockCodexPath)}`,
|
|
34457
34525
|
`export CODEXHOST_HOST_NODE_PATH=${shellQuote(manifest.nodePath)}`,
|
|
34458
34526
|
`export CODEXHOST_HOST_RUNTIME_PATH=${shellQuote(manifest.hostRuntimePath)}`,
|
|
@@ -34469,7 +34537,7 @@ function installManagedProfileBlock(contents, manifest) {
|
|
|
34469
34537
|
PROFILE_END,
|
|
34470
34538
|
""
|
|
34471
34539
|
].join("\n");
|
|
34472
|
-
if (
|
|
34540
|
+
if (path22.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
|
|
34473
34541
|
const separator = base.length > 0 && !base.endsWith("\n") ? "\n" : "";
|
|
34474
34542
|
return `${base}${separator}${block}`;
|
|
34475
34543
|
}
|
|
@@ -34534,9 +34602,9 @@ async function readManifest(filePath) {
|
|
|
34534
34602
|
];
|
|
34535
34603
|
const optionalPaths = ["claudeCommand", "profileBackupPath"];
|
|
34536
34604
|
if (manifest.format !== MANIFEST_FORMAT || Object.keys(manifest).some((key) => !allowed.has(key)) || requiredPaths.some(
|
|
34537
|
-
(key) => typeof manifest[key] !== "string" || !
|
|
34605
|
+
(key) => typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key])
|
|
34538
34606
|
) || optionalPaths.some(
|
|
34539
|
-
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !
|
|
34607
|
+
(key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key]))
|
|
34540
34608
|
) || manifest.entrypointSha256 !== void 0 && (typeof manifest.entrypointSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(manifest.entrypointSha256))) {
|
|
34541
34609
|
throw new Error("Remote Host manifest has an unsupported format");
|
|
34542
34610
|
}
|
|
@@ -34765,7 +34833,7 @@ async function uninstallRemoteHost(options2) {
|
|
|
34765
34833
|
import { spawn as spawn5 } from "node:child_process";
|
|
34766
34834
|
import { stat as stat5 } from "node:fs/promises";
|
|
34767
34835
|
import net3 from "node:net";
|
|
34768
|
-
import
|
|
34836
|
+
import path23 from "node:path";
|
|
34769
34837
|
import { Duplex } from "node:stream";
|
|
34770
34838
|
var CODEXHOST_STATUS_METHOD = "codexhost/update/status";
|
|
34771
34839
|
var DIRECT_PROBE_TIMEOUT_MS = 5e3;
|
|
@@ -34784,9 +34852,9 @@ function classifyRemoteHostProbeResponse(response, socketPath) {
|
|
|
34784
34852
|
}
|
|
34785
34853
|
var lifecycleDependencyOverrides = {};
|
|
34786
34854
|
function socketPathFor(environment) {
|
|
34787
|
-
const codexHome = environment.CODEX_HOME ?? (environment.HOME ?
|
|
34855
|
+
const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path23.join(environment.HOME, ".codex") : void 0);
|
|
34788
34856
|
if (!codexHome) throw new Error("CODEX_HOME or HOME is required for remote Host lifecycle");
|
|
34789
|
-
return
|
|
34857
|
+
return path23.join(codexHome, "app-server-control", "app-server-control.sock");
|
|
34790
34858
|
}
|
|
34791
34859
|
async function defaultSocketExists(socketPath) {
|
|
34792
34860
|
const metadata = await stat5(socketPath).catch((error51) => {
|
|
@@ -34916,7 +34984,7 @@ function installedManifest(status) {
|
|
|
34916
34984
|
function managedEnvironment(manifest, environment) {
|
|
34917
34985
|
return {
|
|
34918
34986
|
...environment,
|
|
34919
|
-
CODEX_INSTALL_DIR:
|
|
34987
|
+
CODEX_INSTALL_DIR: path23.dirname(manifest.wrapperPath),
|
|
34920
34988
|
CODEXHOST_STOCK_CODEX_PATH: manifest.stockCodexPath,
|
|
34921
34989
|
CODEXHOST_HOST_NODE_PATH: manifest.nodePath,
|
|
34922
34990
|
CODEXHOST_HOST_RUNTIME_PATH: manifest.hostRuntimePath,
|
|
@@ -34924,7 +34992,7 @@ function managedEnvironment(manifest, environment) {
|
|
|
34924
34992
|
CODEXHOST_DEFAULT_AGENT: "codex",
|
|
34925
34993
|
CODEXHOST_REMOTE_SSH_MANAGED: "1",
|
|
34926
34994
|
...manifest.claudeCommand ? { CODEXHOST_CLAUDE_COMMAND: manifest.claudeCommand } : {},
|
|
34927
|
-
PATH: `${
|
|
34995
|
+
PATH: `${path23.dirname(manifest.wrapperPath)}${path23.delimiter}${path23.dirname(manifest.stockCodexPath)}${path23.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
|
|
34928
34996
|
};
|
|
34929
34997
|
}
|
|
34930
34998
|
async function defaultRunTerminator(manifest, socketPath, role, environment) {
|
|
@@ -35266,19 +35334,19 @@ function consumeBrokerFrames(socket, onFrame, onError) {
|
|
|
35266
35334
|
|
|
35267
35335
|
// packages/harness-broker/dist/paths.js
|
|
35268
35336
|
import os5 from "node:os";
|
|
35269
|
-
import
|
|
35337
|
+
import path24 from "node:path";
|
|
35270
35338
|
var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
|
|
35271
35339
|
var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
|
|
35272
35340
|
var HARNESS_BROKER_SOCKET_FILE = "claude-code-broker-v1.sock";
|
|
35273
35341
|
function defaultHarnessBrokerDirectory(environment = process.env) {
|
|
35274
35342
|
const home = environment.HOME || os5.homedir();
|
|
35275
|
-
return
|
|
35343
|
+
return path24.join(home, ".codexhost", "harness-broker");
|
|
35276
35344
|
}
|
|
35277
35345
|
function defaultHarnessBrokerDescriptorPath(environment = process.env) {
|
|
35278
|
-
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ??
|
|
35346
|
+
return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path24.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
|
|
35279
35347
|
}
|
|
35280
35348
|
function defaultHarnessBrokerSocketPath(environment = process.env) {
|
|
35281
|
-
return
|
|
35349
|
+
return path24.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
|
|
35282
35350
|
}
|
|
35283
35351
|
|
|
35284
35352
|
// packages/harness-broker/dist/validation.js
|
|
@@ -35293,6 +35361,8 @@ var createSchema = external_exports.object({
|
|
|
35293
35361
|
}).strict();
|
|
35294
35362
|
var resumeSchema = external_exports.object({
|
|
35295
35363
|
kind: external_exports.literal("resume"),
|
|
35364
|
+
model: harnessModelRefSchema.optional(),
|
|
35365
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
35296
35366
|
nativeRef: nativeSessionRefSchema,
|
|
35297
35367
|
cwd: cwdSchema,
|
|
35298
35368
|
knownTurnRefs: external_exports.array(nativeTurnRefSchema).max(1e5).optional()
|
|
@@ -35305,6 +35375,9 @@ var forkSchema = external_exports.object({
|
|
|
35305
35375
|
}).strict();
|
|
35306
35376
|
var rollbackSchema = external_exports.object({
|
|
35307
35377
|
kind: external_exports.literal("rollbackLastTurn"),
|
|
35378
|
+
model: harnessModelRefSchema.optional(),
|
|
35379
|
+
thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
|
|
35380
|
+
permissionModeId: harnessPermissionModeIdSchema.optional(),
|
|
35308
35381
|
sourceRef: nativeSessionRefSchema,
|
|
35309
35382
|
cwd: cwdSchema
|
|
35310
35383
|
}).strict();
|
|
@@ -35499,7 +35572,7 @@ var harnessOutputSchema = external_exports.custom((value2) => {
|
|
|
35499
35572
|
import { randomBytes as randomBytes2, randomUUID as randomUUID14 } from "node:crypto";
|
|
35500
35573
|
import { chmod as chmod5, lstat as lstat9, mkdir as mkdir12, open as open8, readFile as readFile11, rename as rename9, rm as rm11 } from "node:fs/promises";
|
|
35501
35574
|
import net4, {} from "node:net";
|
|
35502
|
-
import
|
|
35575
|
+
import path25 from "node:path";
|
|
35503
35576
|
function harnessError(message, retryable = true) {
|
|
35504
35577
|
return { code: "unavailable", message, retryable, stage: "harnessBroker" };
|
|
35505
35578
|
}
|
|
@@ -35624,13 +35697,13 @@ async function startHarnessBrokerServer(input) {
|
|
|
35624
35697
|
if (input.adapter.harnessId !== "claude-code") {
|
|
35625
35698
|
throw new Error("Harness broker accepts only the claude-code adapter");
|
|
35626
35699
|
}
|
|
35627
|
-
if (process.platform !== "win32" &&
|
|
35700
|
+
if (process.platform !== "win32" && path25.dirname(input.descriptorPath) !== path25.dirname(input.socketPath)) {
|
|
35628
35701
|
throw new Error("Harness broker descriptor and socket must share one private directory");
|
|
35629
35702
|
}
|
|
35630
35703
|
if (process.platform === "darwin" && Buffer.byteLength(input.socketPath) > 103) {
|
|
35631
35704
|
throw new Error("Harness broker Unix socket path is too long for macOS");
|
|
35632
35705
|
}
|
|
35633
|
-
await privateDirectory(
|
|
35706
|
+
await privateDirectory(path25.dirname(input.descriptorPath));
|
|
35634
35707
|
await assertNoLiveDescriptor(input.descriptorPath);
|
|
35635
35708
|
if (process.platform !== "win32")
|
|
35636
35709
|
await prepareUnixSocketPath(input.socketPath);
|