@codexhost/cli-darwin-x64 0.9.1 → 0.9.2

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.
@@ -2278,7 +2278,7 @@ var require_websocket = __commonJS({
2278
2278
  var http = __require("http");
2279
2279
  var net5 = __require("net");
2280
2280
  var tls = __require("tls");
2281
- var { randomBytes: randomBytes4, createHash: createHash10 } = __require("crypto");
2281
+ var { randomBytes: randomBytes4, createHash: createHash11 } = __require("crypto");
2282
2282
  var { Duplex: Duplex2, Readable } = __require("stream");
2283
2283
  var { URL: URL2 } = __require("url");
2284
2284
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -2946,7 +2946,7 @@ var require_websocket = __commonJS({
2946
2946
  abortHandshake(websocket, socket, "Invalid Upgrade header");
2947
2947
  return;
2948
2948
  }
2949
- const digest2 = createHash10("sha1").update(key + GUID).digest("base64");
2949
+ const digest2 = createHash11("sha1").update(key + GUID).digest("base64");
2950
2950
  if (res.headers["sec-websocket-accept"] !== digest2) {
2951
2951
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
2952
2952
  return;
@@ -3315,7 +3315,7 @@ var require_websocket_server = __commonJS({
3315
3315
  var EventEmitter = __require("events");
3316
3316
  var http = __require("http");
3317
3317
  var { Duplex: Duplex2 } = __require("stream");
3318
- var { createHash: createHash10 } = __require("crypto");
3318
+ var { createHash: createHash11 } = __require("crypto");
3319
3319
  var extension2 = require_extension();
3320
3320
  var PerMessageDeflate2 = require_permessage_deflate();
3321
3321
  var subprotocol2 = require_subprotocol();
@@ -3622,7 +3622,7 @@ var require_websocket_server = __commonJS({
3622
3622
  );
3623
3623
  }
3624
3624
  if (this._state > RUNNING) return abortHandshake(socket, 503);
3625
- const digest2 = createHash10("sha1").update(key + GUID).digest("base64");
3625
+ const digest2 = createHash11("sha1").update(key + GUID).digest("base64");
3626
3626
  const headers = [
3627
3627
  "HTTP/1.1 101 Switching Protocols",
3628
3628
  "Upgrade: websocket",
@@ -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 path21 from "node:path";
4286
+ import path22 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, path26) {
5982
- if (!path26)
5981
+ function getElementAtPath(obj, path27) {
5982
+ if (!path27)
5983
5983
  return obj;
5984
- return path26.reduce((acc, key) => acc?.[key], obj);
5984
+ return path27.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(path26, issues) {
6393
+ function prefixIssues(path27, issues) {
6394
6394
  return issues.map((iss) => {
6395
6395
  var _a3;
6396
6396
  (_a3 = iss).path ?? (_a3.path = []);
6397
- iss.path.unshift(path26);
6397
+ iss.path.unshift(path27);
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, path26 = []) => {
6544
+ const processError = (error52, path27 = []) => {
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 }, [...path26, ...issue2.path]));
6547
+ issue2.errors.map((issues) => processError({ issues }, [...path27, ...issue2.path]));
6548
6548
  } else if (issue2.code === "invalid_key") {
6549
- processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6549
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
6550
6550
  } else if (issue2.code === "invalid_element") {
6551
- processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6551
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
6552
6552
  } else {
6553
- const fullpath = [...path26, ...issue2.path];
6553
+ const fullpath = [...path27, ...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, path26 = []) => {
6580
+ const processError = (error52, path27 = []) => {
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 }, [...path26, ...issue2.path]));
6584
+ issue2.errors.map((issues) => processError({ issues }, [...path27, ...issue2.path]));
6585
6585
  } else if (issue2.code === "invalid_key") {
6586
- processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6586
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
6587
6587
  } else if (issue2.code === "invalid_element") {
6588
- processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6588
+ processError({ issues: issue2.issues }, [...path27, ...issue2.path]);
6589
6589
  } else {
6590
- const fullpath = [...path26, ...issue2.path];
6590
+ const fullpath = [...path27, ...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 path26 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6623
- for (const seg of path26) {
6622
+ const path27 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6623
+ for (const seg of path27) {
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 path26 = ref.slice(1).split("/").filter(Boolean);
19316
- if (path26.length === 0) {
19315
+ const path27 = ref.slice(1).split("/").filter(Boolean);
19316
+ if (path27.length === 0) {
19317
19317
  return ctx.rootSchema;
19318
19318
  }
19319
19319
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19320
- if (path26[0] === defsKey) {
19321
- const key = path26[1];
19320
+ if (path27[0] === defsKey) {
19321
+ const key = path27[1];
19322
19322
  if (!key || !ctx.defs[key]) {
19323
19323
  throw new Error(`Reference not found: ${ref}`);
19324
19324
  }
@@ -19726,6 +19726,62 @@ function date4(params) {
19726
19726
  // node_modules/zod/v4/classic/external.js
19727
19727
  config(en_default());
19728
19728
 
19729
+ // packages/shared-contracts/dist/credential-imports.js
19730
+ var credentialSourceSchema = external_exports.object({
19731
+ id: external_exports.string().min(1).max(256),
19732
+ harnessId: external_exports.string().min(1),
19733
+ label: external_exports.string().min(1).max(512),
19734
+ provider: external_exports.enum(["openai-codex", "xai"])
19735
+ }).strict();
19736
+ var credentialImportNameSchema = external_exports.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
19737
+ var credentialImportRecordSchema = external_exports.object({
19738
+ name: credentialImportNameSchema,
19739
+ source: credentialSourceSchema,
19740
+ importedAt: external_exports.string()
19741
+ }).strict();
19742
+ var credentialImportsRequestSchema = external_exports.discriminatedUnion("action", [
19743
+ external_exports.object({ action: external_exports.literal("list") }).strict(),
19744
+ external_exports.object({
19745
+ action: external_exports.literal("import"),
19746
+ sourceId: external_exports.string().min(1).max(256),
19747
+ name: credentialImportNameSchema,
19748
+ confirmed: external_exports.literal(true)
19749
+ }).strict(),
19750
+ external_exports.object({
19751
+ action: external_exports.literal("reimport"),
19752
+ sourceId: external_exports.string().min(1).max(256),
19753
+ name: credentialImportNameSchema,
19754
+ confirmed: external_exports.literal(true)
19755
+ }).strict(),
19756
+ external_exports.object({
19757
+ action: external_exports.literal("remove"),
19758
+ name: credentialImportNameSchema,
19759
+ confirmed: external_exports.literal(true)
19760
+ }).strict()
19761
+ ]);
19762
+ var credentialOtherLoginSchema = external_exports.object({
19763
+ provider: external_exports.string().min(1).max(128),
19764
+ type: external_exports.enum(["oauth", "api_key", "unknown"]),
19765
+ /** Best-effort account label (e.g. the email in a Codex token), derived locally when present. */
19766
+ label: external_exports.string().min(1).max(512).optional(),
19767
+ /** Recognized credential vendor, derived from the OAuth token issuer. Absent when unknown. */
19768
+ vendor: external_exports.enum(["openai-codex", "xai"]).optional()
19769
+ }).strict();
19770
+ var credentialImportsResultSchema = external_exports.object({
19771
+ sources: external_exports.array(credentialSourceSchema),
19772
+ targets: external_exports.array(external_exports.object({
19773
+ harnessId: external_exports.string(),
19774
+ providers: external_exports.array(external_exports.enum(["openai-codex", "xai"])),
19775
+ imports: external_exports.array(credentialImportRecordSchema),
19776
+ others: external_exports.array(credentialOtherLoginSchema).default([])
19777
+ }).strict())
19778
+ }).strict();
19779
+ var credentialImportsParamsSchema = external_exports.object({
19780
+ targetHarnessId: external_exports.string().min(1).max(128).optional(),
19781
+ request: credentialImportsRequestSchema
19782
+ }).strict();
19783
+ var CREDENTIAL_IMPORTS_METHOD = "codexhost/harness/credential-imports";
19784
+
19729
19785
  // packages/shared-contracts/dist/version.js
19730
19786
  var WORKSPACE_CONTRACT_VERSION = 1;
19731
19787
 
@@ -20630,6 +20686,97 @@ var updateStatusResultSchema = external_exports.strictObject({
20630
20686
  // packages/shared-contracts/dist/index.js
20631
20687
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
20632
20688
 
20689
+ // packages/host-runtime/src/account/codex-credential-export.ts
20690
+ import { createHash as createHash2 } from "node:crypto";
20691
+ import { readFile as readFile4 } from "node:fs/promises";
20692
+ import os from "node:os";
20693
+ import path5 from "node:path";
20694
+ async function readCodexCredential(environment) {
20695
+ try {
20696
+ const home = environment.CODEX_HOME ?? path5.join(environment.HOME ?? os.homedir(), ".codex");
20697
+ const auth = JSON.parse(await readFile4(path5.join(home, "auth.json"), "utf8"));
20698
+ if (auth.OPENAI_API_KEY || auth.auth_mode && auth.auth_mode !== "chatgpt") return [];
20699
+ const t = auth.tokens;
20700
+ if (!t || ![t.access_token, t.refresh_token, t.account_id].every(
20701
+ (v) => typeof v === "string" && v.length
20702
+ ))
20703
+ return [];
20704
+ const claims = JSON.parse(Buffer.from(t.access_token.split(".")[1], "base64url").toString());
20705
+ if (claims.client_id !== "app_EMoamEEZ73f0CkXaXp7hrann" || !Number.isFinite(claims.exp * 1e3))
20706
+ return [];
20707
+ const account = claims["https://api.openai.com/auth"]?.chatgpt_account_id;
20708
+ if (account !== t.account_id) return [];
20709
+ let email3;
20710
+ try {
20711
+ email3 = JSON.parse(Buffer.from(t.id_token.split(".")[1], "base64url").toString()).email;
20712
+ } catch {
20713
+ }
20714
+ const identity = `${t.account_id}:${claims.sub ?? ""}`;
20715
+ return [
20716
+ {
20717
+ source: {
20718
+ id: `codex:${createHash2("sha256").update(identity).digest("hex")}`,
20719
+ harnessId: "codex",
20720
+ provider: "openai-codex",
20721
+ label: typeof email3 === "string" && email3 ? email3 : "Codex"
20722
+ },
20723
+ oauth: {
20724
+ access: t.access_token,
20725
+ refresh: t.refresh_token,
20726
+ expires: claims.exp * 1e3,
20727
+ accountId: t.account_id
20728
+ }
20729
+ }
20730
+ ];
20731
+ } catch {
20732
+ return [];
20733
+ }
20734
+ }
20735
+
20736
+ // packages/host-runtime/src/credential-imports.ts
20737
+ async function handleCredentialImports(params, adapters, environment) {
20738
+ const input = credentialImportsParamsSchema.parse(params);
20739
+ const installed = [...adapters];
20740
+ const sources = await readCodexCredential(environment);
20741
+ for (const adapter of installed) {
20742
+ if (adapter.credentialExport) sources.push(...await adapter.credentialExport.read());
20743
+ }
20744
+ const request = input.request;
20745
+ if (request.action !== "list") {
20746
+ const target = installed.find((a) => a.harnessId === input.targetHarnessId)?.credentialImports;
20747
+ if (!target) throw new Error("Target Harness does not support credential imports");
20748
+ if (request.action === "remove") await target.remove(request.name);
20749
+ else {
20750
+ const source = sources.find((s) => s.source.id === request.sourceId);
20751
+ if (!source || !target.providers.includes(source.source.provider))
20752
+ throw new Error("Source login changed or is unavailable; refresh and confirm again");
20753
+ if (request.action === "reimport") await target.reimport(request.name, source);
20754
+ else await target.add(request.name, source);
20755
+ }
20756
+ }
20757
+ const targets = [];
20758
+ for (const adapter of installed) {
20759
+ if (!adapter.credentialImports) continue;
20760
+ try {
20761
+ targets.push({
20762
+ harnessId: adapter.harnessId,
20763
+ providers: [...adapter.credentialImports.providers],
20764
+ imports: await adapter.credentialImports.list(),
20765
+ others: await listOthers(adapter)
20766
+ });
20767
+ } catch {
20768
+ }
20769
+ }
20770
+ return credentialImportsResultSchema.parse({ sources: sources.map((s) => s.source), targets });
20771
+ }
20772
+ async function listOthers(adapter) {
20773
+ try {
20774
+ return await adapter.credentialImports?.listOthers?.() ?? [];
20775
+ } catch {
20776
+ return [];
20777
+ }
20778
+ }
20779
+
20633
20780
  // packages/harness-adapter/dist/output-channel.js
20634
20781
  var HarnessOutputChannel = class {
20635
20782
  outputs;
@@ -20779,8 +20926,8 @@ var packageMetadata = {
20779
20926
  import { execFileSync } from "node:child_process";
20780
20927
  import { randomUUID as randomUUID2 } from "node:crypto";
20781
20928
  import { constants } from "node:fs";
20782
- import { copyFile as copyFile2, mkdir as mkdir3, open as open3, readFile as readFile4, readdir as readdir2, rename as rename2, rm as rm3, stat } from "node:fs/promises";
20783
- import path5 from "node:path";
20929
+ import { copyFile as copyFile2, mkdir as mkdir3, open as open3, readFile as readFile5, readdir as readdir2, rename as rename2, rm as rm3, stat } from "node:fs/promises";
20930
+ import path6 from "node:path";
20784
20931
 
20785
20932
  // packages/mapping-store/dist/records.js
20786
20933
  var nonBlankTextSchema6 = external_exports.string().refine((value2) => value2.trim().length > 0, {
@@ -21041,12 +21188,12 @@ var MappingStore = class {
21041
21188
  #initialized = false;
21042
21189
  #lockHandle = null;
21043
21190
  constructor(options2) {
21044
- this.#directory = path5.resolve(options2.directory);
21045
- this.#threadsDirectory = path5.join(this.#directory, "threads");
21046
- this.#delegationsDirectory = path5.join(this.#directory, "delegations");
21047
- this.#backupsDirectory = path5.join(this.#directory, "backups");
21048
- this.#quarantineDirectory = path5.join(this.#directory, "quarantine");
21049
- this.#lockPath = path5.join(this.#directory, "store.lock");
21191
+ this.#directory = path6.resolve(options2.directory);
21192
+ this.#threadsDirectory = path6.join(this.#directory, "threads");
21193
+ this.#delegationsDirectory = path6.join(this.#directory, "delegations");
21194
+ this.#backupsDirectory = path6.join(this.#directory, "backups");
21195
+ this.#quarantineDirectory = path6.join(this.#directory, "quarantine");
21196
+ this.#lockPath = path6.join(this.#directory, "store.lock");
21050
21197
  this.#instanceId = options2.instanceId ?? randomUUID2();
21051
21198
  this.#now = options2.now ?? (() => /* @__PURE__ */ new Date());
21052
21199
  this.#beforeReplace = options2.beforeReplace;
@@ -21065,8 +21212,8 @@ var MappingStore = class {
21065
21212
  await this.#cleanupResidue();
21066
21213
  const names = (await readdir2(this.#threadsDirectory)).filter((name) => name.endsWith(".json"));
21067
21214
  for (const name of names) {
21068
- const primary = path5.join(this.#threadsDirectory, name);
21069
- const backup = path5.join(this.#backupsDirectory, name);
21215
+ const primary = path6.join(this.#threadsDirectory, name);
21216
+ const backup = path6.join(this.#backupsDirectory, name);
21070
21217
  let record3 = null;
21071
21218
  try {
21072
21219
  record3 = await this.#readRecord(primary, name);
@@ -21075,7 +21222,7 @@ var MappingStore = class {
21075
21222
  record3 = await this.#readRecord(backup, name);
21076
21223
  await this.#replaceFile(primary, record3, false);
21077
21224
  } catch (backupError) {
21078
- const quarantine = path5.join(this.#quarantineDirectory, `${name}.${this.#now().getTime()}.invalid`);
21225
+ const quarantine = path6.join(this.#quarantineDirectory, `${name}.${this.#now().getTime()}.invalid`);
21079
21226
  await rename2(primary, quarantine).catch(() => void 0);
21080
21227
  void primaryError;
21081
21228
  void backupError;
@@ -21091,14 +21238,14 @@ var MappingStore = class {
21091
21238
  }
21092
21239
  const delegationNames = (await readdir2(this.#delegationsDirectory)).filter((name) => name.endsWith(".json"));
21093
21240
  for (const name of delegationNames) {
21094
- const file2 = path5.join(this.#delegationsDirectory, name);
21241
+ const file2 = path6.join(this.#delegationsDirectory, name);
21095
21242
  try {
21096
- const parsed = storedDelegationRecordV1Schema.parse(JSON.parse(await readFile4(file2, "utf8")));
21243
+ const parsed = storedDelegationRecordV1Schema.parse(JSON.parse(await readFile5(file2, "utf8")));
21097
21244
  if (`${parsed.delegationId}.json` !== name)
21098
21245
  throw new Error("filename mismatch");
21099
21246
  this.#delegations.set(parsed.delegationId, parsed);
21100
21247
  } catch {
21101
- const quarantine = path5.join(this.#quarantineDirectory, `${name}.${this.#now().getTime()}.invalid-delegation`);
21248
+ const quarantine = path6.join(this.#quarantineDirectory, `${name}.${this.#now().getTime()}.invalid-delegation`);
21102
21249
  await rename2(file2, quarantine).catch(() => void 0);
21103
21250
  }
21104
21251
  }
@@ -21384,7 +21531,7 @@ var MappingStore = class {
21384
21531
  if (handle)
21385
21532
  await handle.close().catch(() => void 0);
21386
21533
  try {
21387
- const current = JSON.parse(await readFile4(this.#lockPath, "utf8"));
21534
+ const current = JSON.parse(await readFile5(this.#lockPath, "utf8"));
21388
21535
  if (current.instanceId === this.#instanceId)
21389
21536
  await rm3(this.#lockPath, { force: true });
21390
21537
  } catch {
@@ -21500,7 +21647,7 @@ var MappingStore = class {
21500
21647
  }
21501
21648
  }
21502
21649
  async #readRecord(file2, expectedName) {
21503
- const parsed = storedThreadRecordV1Schema.safeParse(JSON.parse(await readFile4(file2, "utf8")));
21650
+ const parsed = storedThreadRecordV1Schema.safeParse(JSON.parse(await readFile5(file2, "utf8")));
21504
21651
  if (!parsed.success) {
21505
21652
  throw new MappingStoreError("INVALID_RECORD", "Mapping Store record is invalid", {
21506
21653
  cause: parsed.error
@@ -21518,10 +21665,10 @@ var MappingStore = class {
21518
21665
  readdir2(this.#directory)
21519
21666
  ]);
21520
21667
  await Promise.all([
21521
- ...threadNames.filter((name) => name.includes(".tmp-")).map((name) => rm3(path5.join(this.#threadsDirectory, name), { force: true })),
21522
- ...delegationNames.filter((name) => name.includes(".tmp-")).map((name) => rm3(path5.join(this.#delegationsDirectory, name), { force: true })),
21668
+ ...threadNames.filter((name) => name.includes(".tmp-")).map((name) => rm3(path6.join(this.#threadsDirectory, name), { force: true })),
21669
+ ...delegationNames.filter((name) => name.includes(".tmp-")).map((name) => rm3(path6.join(this.#delegationsDirectory, name), { force: true })),
21523
21670
  // Renamed aside by #acquireLock; nothing reads them back, and they accumulate one per run.
21524
- ...rootNames.filter((name) => name.startsWith(`${path5.basename(this.#lockPath)}.stale-`)).map((name) => rm3(path5.join(this.#directory, name), { force: true }))
21671
+ ...rootNames.filter((name) => name.startsWith(`${path6.basename(this.#lockPath)}.stale-`)).map((name) => rm3(path6.join(this.#directory, name), { force: true }))
21525
21672
  ]);
21526
21673
  }
21527
21674
  async #acquireLock() {
@@ -21548,7 +21695,7 @@ var MappingStore = class {
21548
21695
  }
21549
21696
  let existing = {};
21550
21697
  try {
21551
- existing = JSON.parse(await readFile4(this.#lockPath, "utf8"));
21698
+ existing = JSON.parse(await readFile5(this.#lockPath, "utf8"));
21552
21699
  } catch {
21553
21700
  }
21554
21701
  if (typeof existing.pid === "number" && lockOwnerIsLive(existing)) {
@@ -21622,13 +21769,13 @@ var MappingStore = class {
21622
21769
  await next;
21623
21770
  }
21624
21771
  #recordPath(hostThreadId) {
21625
- return path5.join(this.#threadsDirectory, `${hostThreadId}.json`);
21772
+ return path6.join(this.#threadsDirectory, `${hostThreadId}.json`);
21626
21773
  }
21627
21774
  #delegationPath(delegationId) {
21628
- return path5.join(this.#delegationsDirectory, `${delegationId}.json`);
21775
+ return path6.join(this.#delegationsDirectory, `${delegationId}.json`);
21629
21776
  }
21630
21777
  #backupPath(hostThreadId) {
21631
- return path5.join(this.#backupsDirectory, `${hostThreadId}.json`);
21778
+ return path6.join(this.#backupsDirectory, `${hostThreadId}.json`);
21632
21779
  }
21633
21780
  #requireInitialized() {
21634
21781
  if (!this.#initialized) {
@@ -22316,16 +22463,16 @@ var Diff = class {
22316
22463
  }
22317
22464
  }
22318
22465
  }
22319
- addToPath(path26, added, removed, oldPosInc, options2) {
22320
- const last = path26.lastComponent;
22466
+ addToPath(path27, added, removed, oldPosInc, options2) {
22467
+ const last = path27.lastComponent;
22321
22468
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
22322
22469
  return {
22323
- oldPos: path26.oldPos + oldPosInc,
22470
+ oldPos: path27.oldPos + oldPosInc,
22324
22471
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
22325
22472
  };
22326
22473
  } else {
22327
22474
  return {
22328
- oldPos: path26.oldPos + oldPosInc,
22475
+ oldPos: path27.oldPos + oldPosInc,
22329
22476
  lastComponent: { count: 1, added, removed, previousComponent: last }
22330
22477
  };
22331
22478
  }
@@ -22754,10 +22901,10 @@ function splitLines(text) {
22754
22901
  }
22755
22902
 
22756
22903
  // packages/protocol-core/dist/file-change-summary.js
22757
- import path6 from "node:path";
22904
+ import path7 from "node:path";
22758
22905
  function filePathKey(file2, cwd) {
22759
22906
  const windows = /^[a-z]:[/\\]/i.test(cwd) || /^[a-z]:[/\\]/i.test(file2);
22760
- const paths = windows ? path6.win32 : path6.posix;
22907
+ const paths = windows ? path7.win32 : path7.posix;
22761
22908
  const resolved = paths.resolve(cwd, file2).replaceAll("\\", "/");
22762
22909
  return windows ? resolved.toLowerCase() : resolved;
22763
22910
  }
@@ -23026,8 +23173,8 @@ function projectFileChangeKind(kind) {
23026
23173
  return { type: kind };
23027
23174
  }
23028
23175
  function projectFileChanges(changes) {
23029
- return changes.map(({ path: path26, kind, unifiedDiff }) => ({
23030
- path: path26,
23176
+ return changes.map(({ path: path27, kind, unifiedDiff }) => ({
23177
+ path: path27,
23031
23178
  kind: projectFileChangeKind(kind),
23032
23179
  diff: unifiedDiff
23033
23180
  }));
@@ -23965,13 +24112,13 @@ function decodeThreadForkRequest(request) {
23965
24112
  if (runtimeWorkspaceRoots !== void 0 && runtimeWorkspaceRoots !== null && (!Array.isArray(runtimeWorkspaceRoots) || runtimeWorkspaceRoots.some((root) => typeof root !== "string" || root.length === 0))) {
23966
24113
  throw new Error("thread/fork params.runtimeWorkspaceRoots must be text paths or null");
23967
24114
  }
23968
- const path26 = optionalText(params, "path", { allowEmpty: true });
24115
+ const path27 = optionalText(params, "path", { allowEmpty: true });
23969
24116
  const ephemeral = optionalBoolean(params, "ephemeral");
23970
24117
  return {
23971
24118
  threadId: threadId2,
23972
24119
  ...lastTurnText ? { lastTurnId: hostTurnIdSchema.parse(lastTurnText) } : {},
23973
24120
  ...beforeTurnText ? { beforeTurnId: hostTurnIdSchema.parse(beforeTurnText) } : {},
23974
- ...path26 ? { path: path26 } : {},
24121
+ ...path27 ? { path: path27 } : {},
23975
24122
  ...optionalField(params, "model"),
23976
24123
  ...optionalField(params, "modelProvider"),
23977
24124
  ...optionalField(params, "cwd"),
@@ -24064,7 +24211,7 @@ function threadForkResult(thread, input) {
24064
24211
  }
24065
24212
 
24066
24213
  // packages/protocol-core/dist/thread-management.js
24067
- import { createHash as createHash2 } from "node:crypto";
24214
+ import { createHash as createHash3 } from "node:crypto";
24068
24215
  var HOST_CURSOR_PREFIX = "codexhost:thread-list:v1:";
24069
24216
  var MAX_CURSOR_LENGTH = 65536;
24070
24217
  var DEFAULT_PAGE_SIZE = 25;
@@ -24161,7 +24308,7 @@ function decodeSortKey(value2) {
24161
24308
  return value2;
24162
24309
  }
24163
24310
  function queryFingerprint(value2) {
24164
- return createHash2("sha256").update(JSON.stringify(value2)).digest("hex");
24311
+ return createHash3("sha256").update(JSON.stringify(value2)).digest("hex");
24165
24312
  }
24166
24313
  function cursorPayload(value2) {
24167
24314
  return {
@@ -25147,22 +25294,22 @@ var HarnessAccountInspectionCache = class {
25147
25294
  };
25148
25295
 
25149
25296
  // packages/host-runtime/src/app-server-host.ts
25150
- import { createHash as createHash6, randomUUID as randomUUID9 } from "node:crypto";
25151
- import os3 from "node:os";
25152
- import path12 from "node:path";
25297
+ import { createHash as createHash7, randomUUID as randomUUID9 } from "node:crypto";
25298
+ import os4 from "node:os";
25299
+ import path13 from "node:path";
25153
25300
 
25154
25301
  // packages/host-runtime/src/external-thread-fork.ts
25155
25302
  import nodePath from "node:path";
25156
25303
 
25157
25304
  // packages/host-runtime/src/external-thread-repository.ts
25158
25305
  import { randomUUID as randomUUID4 } from "node:crypto";
25159
- import os from "node:os";
25160
- import path7 from "node:path";
25306
+ import os2 from "node:os";
25307
+ import path8 from "node:path";
25161
25308
 
25162
25309
  // packages/host-runtime/src/external-subagent-threads.ts
25163
- import { createHash as createHash3, randomUUID as randomUUID3 } from "node:crypto";
25310
+ import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
25164
25311
  function childCreateRequest(parent, nativeRef, id2) {
25165
- const key = createHash3("sha256").update(JSON.stringify([parent.hostThreadId, parent.harnessId, nativeRef.nativeSessionId, id2])).digest("hex");
25312
+ const key = createHash4("sha256").update(JSON.stringify([parent.hostThreadId, parent.harnessId, nativeRef.nativeSessionId, id2])).digest("hex");
25166
25313
  return `subagent:${key}`;
25167
25314
  }
25168
25315
  function subagentMaterializer(store, parent, previousParent) {
@@ -25297,8 +25444,8 @@ function sameMapping(left, right) {
25297
25444
  }
25298
25445
  function defaultMappingStoreDirectory(environment) {
25299
25446
  const dataDirectory = environment.CODEXHOST_DATA_DIR;
25300
- return path7.join(
25301
- dataDirectory ? path7.resolve(dataDirectory) : path7.join(os.homedir(), ".codexhost"),
25447
+ return path8.join(
25448
+ dataDirectory ? path8.resolve(dataDirectory) : path8.join(os2.homedir(), ".codexhost"),
25302
25449
  "mapping-store"
25303
25450
  );
25304
25451
  }
@@ -27334,11 +27481,11 @@ var ExternalTurnSteering = class {
27334
27481
  };
27335
27482
 
27336
27483
  // packages/host-runtime/src/harness-delegation-coordinator.ts
27337
- import { createHash as createHash5, randomUUID as randomUUID5 } from "node:crypto";
27338
- import path8 from "node:path";
27484
+ import { createHash as createHash6, randomUUID as randomUUID5 } from "node:crypto";
27485
+ import path9 from "node:path";
27339
27486
 
27340
27487
  // packages/host-runtime/src/delegation-snapshot.ts
27341
- import { createHash as createHash4 } from "node:crypto";
27488
+ import { createHash as createHash5 } from "node:crypto";
27342
27489
  var CURSOR_PREFIX = "codexhost:thread-messages:v1:";
27343
27490
  var DEFAULT_MESSAGE_LIMIT = 25;
27344
27491
  var MAX_MESSAGE_LIMIT = 100;
@@ -27392,7 +27539,7 @@ function allVisibleMessages(turns) {
27392
27539
  return messages;
27393
27540
  }
27394
27541
  function cursorFingerprint(threadId2) {
27395
- return createHash4("sha256").update(threadId2).digest("hex");
27542
+ return createHash5("sha256").update(threadId2).digest("hex");
27396
27543
  }
27397
27544
  function encodeCursor(threadId2, offset) {
27398
27545
  const payload = JSON.stringify({ version: 1, fingerprint: cursorFingerprint(threadId2), offset });
@@ -27487,10 +27634,10 @@ function terminal(status) {
27487
27634
  return status === "completed" || status === "failed" || status === "interrupted";
27488
27635
  }
27489
27636
  function taskDigest(input) {
27490
- return createHash5("sha256").update(
27637
+ return createHash6("sha256").update(
27491
27638
  JSON.stringify({
27492
27639
  task: input.task,
27493
- cwd: path8.resolve(input.cwd),
27640
+ cwd: path9.resolve(input.cwd),
27494
27641
  modelId: input.model?.id ?? null,
27495
27642
  thinkingOptionId: input.thinkingOptionId ?? null
27496
27643
  })
@@ -27561,7 +27708,7 @@ var HarnessDelegationCoordinator = class {
27561
27708
  return {
27562
27709
  harnessId: input.harnessId,
27563
27710
  inspection: await adapter.inspect({
27564
- ...input.cwd ? { cwd: path8.resolve(input.cwd) } : {},
27711
+ ...input.cwd ? { cwd: path9.resolve(input.cwd) } : {},
27565
27712
  ...input.refresh !== void 0 ? { refresh: input.refresh } : {}
27566
27713
  })
27567
27714
  };
@@ -27575,7 +27722,7 @@ var HarnessDelegationCoordinator = class {
27575
27722
  const result = await this.#startOfficial({ ...input, parentThreadId, cwd: selectedCwd });
27576
27723
  return { ...result, parentThreadId, cwd: result.cwd ?? selectedCwd };
27577
27724
  }
27578
- const startInput = { ...input, parentThreadId, cwd: path8.resolve(selectedCwd) };
27725
+ const startInput = { ...input, parentThreadId, cwd: path9.resolve(selectedCwd) };
27579
27726
  if (!this.#adapters.has(input.harnessId)) {
27580
27727
  throw new DelegationControlError(
27581
27728
  "HARNESS_NOT_FOUND",
@@ -28004,7 +28151,7 @@ var HarnessDelegationCoordinator = class {
28004
28151
 
28005
28152
  // packages/host-runtime/src/harness-plugin-loader.ts
28006
28153
  import { readdir as readdir3, realpath as realpath2 } from "node:fs/promises";
28007
- import path10 from "node:path";
28154
+ import path11 from "node:path";
28008
28155
  import { pathToFileURL } from "node:url";
28009
28156
 
28010
28157
  // packages/host-runtime/src/harness-plugin-registry.ts
@@ -28042,16 +28189,16 @@ var HarnessPluginRegistry = class {
28042
28189
 
28043
28190
  // packages/host-runtime/src/plugin-files.ts
28044
28191
  import { open as open4, realpath, stat as stat2 } from "node:fs/promises";
28045
- import path9 from "node:path";
28192
+ import path10 from "node:path";
28046
28193
  function inside(root, candidate) {
28047
- const relative = path9.relative(root, candidate);
28048
- return relative !== "" && !path9.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path9.sep}`);
28194
+ const relative = path10.relative(root, candidate);
28195
+ return relative !== "" && !path10.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path10.sep}`);
28049
28196
  }
28050
28197
  async function pluginResourcePath(root, relative) {
28051
- if (path9.isAbsolute(relative) || !inside(root, path9.resolve(root, relative))) {
28198
+ if (path10.isAbsolute(relative) || !inside(root, path10.resolve(root, relative))) {
28052
28199
  throw new Error("Plugin resource escapes its root");
28053
28200
  }
28054
- const resolved = await realpath(path9.resolve(root, relative));
28201
+ const resolved = await realpath(path10.resolve(root, relative));
28055
28202
  if (!inside(root, resolved) || !(await stat2(resolved)).isFile()) {
28056
28203
  throw new Error("Plugin resource must be a regular file inside its root");
28057
28204
  }
@@ -28213,7 +28360,7 @@ async function loadHarnessPlugins(options2) {
28213
28360
  const enabledIds = /* @__PURE__ */ new Set();
28214
28361
  const roots = /* @__PURE__ */ new Set();
28215
28362
  for (const configuredRoot of options2.roots) {
28216
- if (!path10.isAbsolute(configuredRoot)) {
28363
+ if (!path11.isAbsolute(configuredRoot)) {
28217
28364
  diagnose({ code: "invalidRoot" });
28218
28365
  continue;
28219
28366
  }
@@ -28243,7 +28390,7 @@ async function loadHarnessPlugins(options2) {
28243
28390
  for (const directory of directories) {
28244
28391
  try {
28245
28392
  const file2 = await pluginResourcePath(root, `${directory.name}/manifest.json`);
28246
- const pluginRoot = await realpath2(path10.join(root, directory.name));
28393
+ const pluginRoot = await realpath2(path11.join(root, directory.name));
28247
28394
  await pluginResourcePath(pluginRoot, "manifest.json");
28248
28395
  const manifest = harnessPluginManifestSchema.parse(
28249
28396
  JSON.parse(
@@ -28339,27 +28486,27 @@ async function loadHarnessPlugins(options2) {
28339
28486
 
28340
28487
  // packages/host-runtime/src/harness-launch-settings.ts
28341
28488
  import { randomUUID as randomUUID6 } from "node:crypto";
28342
- import { mkdir as mkdir4, readFile as readFile5, rename as rename3, rm as rm4, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
28343
- import os2 from "node:os";
28344
- import path11 from "node:path";
28489
+ import { mkdir as mkdir4, readFile as readFile6, rename as rename3, rm as rm4, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
28490
+ import os3 from "node:os";
28491
+ import path12 from "node:path";
28345
28492
  var HarnessLaunchSettingsStore = class {
28346
28493
  #directory;
28347
28494
  #initial = /* @__PURE__ */ new Map();
28348
28495
  constructor(environment) {
28349
- this.#directory = path11.join(
28350
- environment.CODEXHOST_DATA_DIR ? path11.resolve(environment.CODEXHOST_DATA_DIR) : path11.join(os2.homedir(), ".codexhost"),
28496
+ this.#directory = path12.join(
28497
+ environment.CODEXHOST_DATA_DIR ? path12.resolve(environment.CODEXHOST_DATA_DIR) : path12.join(os3.homedir(), ".codexhost"),
28351
28498
  "harness-launch-settings"
28352
28499
  );
28353
28500
  }
28354
28501
  #file(id2) {
28355
- return path11.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
28502
+ return path12.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
28356
28503
  }
28357
28504
  async #read(id2) {
28358
28505
  try {
28359
28506
  const value2 = harnessLaunchPathSchema.parse(
28360
- JSON.parse(await readFile5(this.#file(id2), "utf8"))
28507
+ JSON.parse(await readFile6(this.#file(id2), "utf8"))
28361
28508
  );
28362
- if (!path11.isAbsolute(value2)) throw new Error("Expected an absolute entrypoint path");
28509
+ if (!path12.isAbsolute(value2)) throw new Error("Expected an absolute entrypoint path");
28363
28510
  return value2;
28364
28511
  } catch (error51) {
28365
28512
  if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
@@ -28388,7 +28535,7 @@ var HarnessLaunchSettingsStore = class {
28388
28535
  await rm4(file2, { force: true });
28389
28536
  } else {
28390
28537
  value2 = harnessLaunchPathSchema.parse(value2);
28391
- if (!path11.isAbsolute(value2))
28538
+ if (!path12.isAbsolute(value2))
28392
28539
  throw new Error("Use an absolute entrypoint path without arguments");
28393
28540
  const metadata = await stat3(value2).catch(() => void 0);
28394
28541
  if (!metadata?.isDirectory() && !metadata?.isFile())
@@ -29523,25 +29670,25 @@ function resolveExternalSessionTreeIds(records) {
29523
29670
  const resolve = (start) => {
29524
29671
  const cached2 = resolved.get(start.hostThreadId);
29525
29672
  if (cached2) return cached2;
29526
- const path26 = [];
29673
+ const path27 = [];
29527
29674
  const visited = /* @__PURE__ */ new Set();
29528
29675
  let current = start;
29529
29676
  while (true) {
29530
29677
  const known = resolved.get(current.hostThreadId);
29531
29678
  if (known) {
29532
- for (const record3 of path26) resolved.set(record3.hostThreadId, known);
29679
+ for (const record3 of path27) resolved.set(record3.hostThreadId, known);
29533
29680
  return known;
29534
29681
  }
29535
29682
  if (visited.has(current.hostThreadId)) {
29536
29683
  throw new Error("External Thread Fork tree contains a cycle");
29537
29684
  }
29538
29685
  visited.add(current.hostThreadId);
29539
- path26.push(current);
29686
+ path27.push(current);
29540
29687
  const sourceId = current.subagent?.parentHostThreadId ?? current.forkSource?.hostThreadId;
29541
29688
  const source = sourceId ? byId.get(sourceId) : void 0;
29542
29689
  if (!source) {
29543
29690
  const root = current.hostThreadId;
29544
- for (const record3 of path26) resolved.set(record3.hostThreadId, root);
29691
+ for (const record3 of path27) resolved.set(record3.hostThreadId, root);
29545
29692
  return root;
29546
29693
  }
29547
29694
  current = source;
@@ -29997,7 +30144,7 @@ var AppServerHost = class {
29997
30144
  this.#launchSettings = new HarnessLaunchSettingsStore(
29998
30145
  this.#options.pluginContext?.environment ?? environment
29999
30146
  );
30000
- const permanentHome = path12.resolve(environment.CODEX_HOME ?? path12.join(os3.homedir(), ".codex"));
30147
+ const permanentHome = path13.resolve(environment.CODEX_HOME ?? path13.join(os4.homedir(), ".codex"));
30001
30148
  this.#ownsOfficialRuntimeScope = options2.officialRuntimeScope === void 0;
30002
30149
  this.#officialRuntimeScope = options2.officialRuntimeScope ?? new OfficialRuntimeScope({
30003
30150
  diagnosticOutput: this.#options.diagnosticOutput,
@@ -30010,7 +30157,8 @@ var AppServerHost = class {
30010
30157
  ...officialEnvironment(environment),
30011
30158
  CODEX_HOME: permanentHome
30012
30159
  },
30013
- ...this.#options.spawnOfficial ? { spawnOfficial: this.#options.spawnOfficial } : {}
30160
+ ...this.#options.spawnOfficial ? { spawnOfficial: this.#options.spawnOfficial } : {},
30161
+ ...this.#options.officialCloseTimeoutMs === void 0 ? {} : { closeTimeoutMs: this.#options.officialCloseTimeoutMs }
30014
30162
  })
30015
30163
  )
30016
30164
  });
@@ -30346,6 +30494,32 @@ var AppServerHost = class {
30346
30494
  this.#dispatchDesktopRequest(() => this.#handleCodexAccountRequest(request));
30347
30495
  return;
30348
30496
  }
30497
+ if (request.method === CREDENTIAL_IMPORTS_METHOD) {
30498
+ this.#dispatchDesktopRequest(async () => {
30499
+ if (!credentialImportsParamsSchema.safeParse(request.params).success) {
30500
+ await this.#writer.json(rpcError(request, -32602, "Invalid credential import request"));
30501
+ return;
30502
+ }
30503
+ await this.#waitForPlugins();
30504
+ try {
30505
+ const result = await handleCredentialImports(
30506
+ request.params,
30507
+ this.#externalAdapters.values(),
30508
+ this.#options.environment ?? process.env
30509
+ );
30510
+ await this.#writer.json(rpcEnvelope(request, { result: jsonValueSchema.parse(result) }));
30511
+ } catch {
30512
+ await this.#writer.json(
30513
+ rpcError(
30514
+ request,
30515
+ -32077,
30516
+ "Credential operation failed. Check the source login, choose an unused Provider name, and verify Pi configuration access."
30517
+ )
30518
+ );
30519
+ }
30520
+ });
30521
+ return;
30522
+ }
30349
30523
  if (request.method === "codexhost/harness/accounts/sources") {
30350
30524
  this.#dispatchDesktopRequest(async () => {
30351
30525
  if (!harnessAccountSourceListParamsSchema.safeParse(request.params).success) {
@@ -31036,7 +31210,7 @@ var AppServerHost = class {
31036
31210
  throw new DelegationControlError("INVALID_ARGUMENT", "Official Model Ref is invalid");
31037
31211
  }
31038
31212
  const nativeModelId = requestedModel ? decodeOfficialCodexModelRef(requestedModel) : void 0;
31039
- const digest2 = createHash6("sha256").update(
31213
+ const digest2 = createHash7("sha256").update(
31040
31214
  JSON.stringify({
31041
31215
  task: input.task,
31042
31216
  cwd: input.cwd,
@@ -33330,17 +33504,17 @@ var AppServerHost = class {
33330
33504
  // packages/host-runtime/src/native-account-host.ts
33331
33505
  import { mkdir as mkdir7, realpath as realpath3 } from "node:fs/promises";
33332
33506
  import { homedir } from "node:os";
33333
- import path16 from "node:path";
33507
+ import path17 from "node:path";
33334
33508
 
33335
33509
  // packages/host-runtime/src/codex-runtime/owned-official-backends.ts
33336
- import { createHash as createHash7, randomBytes } from "node:crypto";
33510
+ import { createHash as createHash8, randomBytes } from "node:crypto";
33337
33511
  import { Writable as Writable2 } from "node:stream";
33338
33512
 
33339
33513
  // packages/host-runtime/src/remote-app-server.ts
33340
33514
  import { createServer } from "node:http";
33341
33515
  import net from "node:net";
33342
33516
  import { chmod as chmod3, lstat as lstat6, mkdir as mkdir6, rm as rm6 } from "node:fs/promises";
33343
- import path14 from "node:path";
33517
+ import path15 from "node:path";
33344
33518
  import { PassThrough } from "node:stream";
33345
33519
 
33346
33520
  // node_modules/ws/wrapper.mjs
@@ -33356,9 +33530,9 @@ var wrapper_default = import_websocket.default;
33356
33530
 
33357
33531
  // packages/host-runtime/src/remote-socket-lock.ts
33358
33532
  import { randomUUID as randomUUID10 } from "node:crypto";
33359
- import { chmod as chmod2, lstat as lstat5, mkdir as mkdir5, open as open5, readFile as readFile6, readdir as readdir4, rename as rename4, rm as rm5 } from "node:fs/promises";
33533
+ import { chmod as chmod2, lstat as lstat5, mkdir as mkdir5, open as open5, readFile as readFile7, readdir as readdir4, rename as rename4, rm as rm5 } from "node:fs/promises";
33360
33534
  import { uptime } from "node:os";
33361
- import path13 from "node:path";
33535
+ import path14 from "node:path";
33362
33536
  import { setTimeout as delay4 } from "node:timers/promises";
33363
33537
  var LOCK_RETRY_COUNT = 200;
33364
33538
  var LOCK_RETRY_DELAY_MS = 25;
@@ -33421,7 +33595,7 @@ async function readLockEntrySnapshot(filePath) {
33421
33595
  throw error51;
33422
33596
  });
33423
33597
  if (metadata === null || !metadata.isFile()) return null;
33424
- const source = await readFile6(filePath, "utf8").catch((error51) => {
33598
+ const source = await readFile7(filePath, "utf8").catch((error51) => {
33425
33599
  if (error51.code === "ENOENT") return null;
33426
33600
  throw error51;
33427
33601
  });
@@ -33432,7 +33606,7 @@ async function readLockEntrySnapshot(filePath) {
33432
33606
  source,
33433
33607
  identity: { dev: metadata.dev, ino: metadata.ino },
33434
33608
  mtimeMs: metadata.mtimeMs,
33435
- record: record3 && path13.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
33609
+ record: record3 && path14.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
33436
33610
  };
33437
33611
  }
33438
33612
  function lockEntryIsAbandoned(snapshot) {
@@ -33453,7 +33627,7 @@ async function readLockEntryCatalog(lockDirectory) {
33453
33627
  let unsettled = false;
33454
33628
  for (const name of names) {
33455
33629
  if (!name.startsWith(LOCK_ENTRY_PREFIX) || !name.endsWith(LOCK_ENTRY_SUFFIX)) continue;
33456
- const snapshot = await readLockEntrySnapshot(path13.join(lockDirectory, name));
33630
+ const snapshot = await readLockEntrySnapshot(path14.join(lockDirectory, name));
33457
33631
  if (snapshot === null) continue;
33458
33632
  if (lockEntryIsAbandoned(snapshot)) {
33459
33633
  if (!await removeAbandonedLockEntry(snapshot)) unsettled = true;
@@ -33481,7 +33655,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
33481
33655
  await chmod2(lockDirectory, 448);
33482
33656
  }
33483
33657
  async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
33484
- const temporary = path13.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID10()}`);
33658
+ const temporary = path14.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID10()}`);
33485
33659
  const handle = await open5(temporary, "wx", 384);
33486
33660
  try {
33487
33661
  await handle.writeFile(`${JSON.stringify(record3)}
@@ -33508,7 +33682,7 @@ async function legacyLockState(legacyPath) {
33508
33682
  });
33509
33683
  if (metadata === null) return "absent";
33510
33684
  if (!metadata.isFile()) return "blocking";
33511
- const source = await readFile6(legacyPath, "utf8").catch((error51) => {
33685
+ const source = await readFile7(legacyPath, "utf8").catch((error51) => {
33512
33686
  if (error51.code === "ENOENT") return null;
33513
33687
  throw error51;
33514
33688
  });
@@ -33557,7 +33731,7 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
33557
33731
  const lockDirectory = `${socketPath}.initializers`;
33558
33732
  await preparePrivateLockDirectory(lockDirectory);
33559
33733
  const ownerToken = randomUUID10();
33560
- const entryPath = path13.join(lockDirectory, lockEntryName(ownerToken));
33734
+ const entryPath = path14.join(lockDirectory, lockEntryName(ownerToken));
33561
33735
  const baseRecord = {
33562
33736
  version: 2,
33563
33737
  ownerToken,
@@ -33731,14 +33905,14 @@ function remoteAppServerSocketPath(environment, listenUrl = "unix://") {
33731
33905
  throw new Error("Remote app-server listener must use a Unix URL");
33732
33906
  }
33733
33907
  const explicit = listenUrl.slice("unix://".length);
33734
- if (explicit.length > 0) return path14.posix.resolve(decodeURIComponent(explicit));
33735
- const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path14.posix.join(environment.HOME, ".codex") : void 0);
33908
+ if (explicit.length > 0) return path15.posix.resolve(decodeURIComponent(explicit));
33909
+ const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path15.posix.join(environment.HOME, ".codex") : void 0);
33736
33910
  if (!codexHome)
33737
33911
  throw new Error("CODEX_HOME or HOME is required for the remote app-server socket");
33738
- return path14.posix.join(codexHome, "app-server-control", "app-server-control.sock");
33912
+ return path15.posix.join(codexHome, "app-server-control", "app-server-control.sock");
33739
33913
  }
33740
33914
  function officialListenerArgumentsForRemoteListener(arguments_2, socketPath) {
33741
- if (!path14.posix.isAbsolute(socketPath)) {
33915
+ if (!path15.posix.isAbsolute(socketPath)) {
33742
33916
  throw new Error("Shared official app-server socket path must be absolute");
33743
33917
  }
33744
33918
  if (remoteUnixListenerUrl(arguments_2) === null) {
@@ -33849,7 +34023,7 @@ async function removeStaleSocket(socketPath) {
33849
34023
  await rm6(socketPath, { force: true });
33850
34024
  }
33851
34025
  async function prepareRemoteAppServerSocketDirectory(socketPath) {
33852
- const socketDirectory = path14.dirname(socketPath);
34026
+ const socketDirectory = path15.dirname(socketPath);
33853
34027
  const existing = await lstat6(socketDirectory).catch((error51) => {
33854
34028
  if (error51.code === "ENOENT") return null;
33855
34029
  throw error51;
@@ -34056,18 +34230,18 @@ function createRemoteAppServerWebSocketListener(input) {
34056
34230
  import { spawn as spawn3 } from "node:child_process";
34057
34231
  import { randomUUID as randomUUID11 } from "node:crypto";
34058
34232
  import { lstat as lstat7, rm as rm7 } from "node:fs/promises";
34059
- import path15 from "node:path";
34233
+ import path16 from "node:path";
34060
34234
  var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
34061
34235
  var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
34062
34236
  function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID11()) {
34063
- if (!path15.posix.isAbsolute(desktopControlSocketPath)) {
34237
+ if (!path16.posix.isAbsolute(desktopControlSocketPath)) {
34064
34238
  throw new Error("Desktop control socket path must be absolute");
34065
34239
  }
34066
34240
  if (!/^[A-Za-z0-9-]+$/u.test(token) || !/[A-Za-z0-9]/u.test(token)) {
34067
34241
  throw new Error("Shared official app-server socket token is invalid");
34068
34242
  }
34069
34243
  const compactToken = token.replaceAll("-", "").slice(0, 15);
34070
- return path15.posix.join(path15.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
34244
+ return path16.posix.join(path16.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
34071
34245
  }
34072
34246
  function errorMessage4(error51) {
34073
34247
  return error51 instanceof Error ? error51.message : String(error51);
@@ -34500,7 +34674,7 @@ function createOwnedLoopbackBackend(input) {
34500
34674
  "--ws-auth",
34501
34675
  "capability-token",
34502
34676
  "--ws-token-sha256",
34503
- createHash7("sha256").update(capabilityToken).digest("hex")
34677
+ createHash8("sha256").update(capabilityToken).digest("hex")
34504
34678
  ],
34505
34679
  // Managed stderr may carry credential-bearing errors. Never forward raw bytes.
34506
34680
  diagnosticOutput: new Writable2({
@@ -34553,19 +34727,19 @@ function createOwnedUnixBackend(input) {
34553
34727
 
34554
34728
  // packages/host-runtime/src/native-account-host.ts
34555
34729
  async function canonicalCodexHome(home) {
34556
- const absolute = path16.resolve(home);
34730
+ const absolute = path17.resolve(home);
34557
34731
  try {
34558
34732
  return await realpath3(absolute);
34559
34733
  } catch (error51) {
34560
34734
  if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT")) throw error51;
34561
- const parent = path16.dirname(absolute);
34735
+ const parent = path17.dirname(absolute);
34562
34736
  if (parent === absolute) throw error51;
34563
- return path16.join(await canonicalCodexHome(parent), path16.basename(absolute));
34737
+ return path17.join(await canonicalCodexHome(parent), path17.basename(absolute));
34564
34738
  }
34565
34739
  }
34566
34740
  async function prepareLocalCodex(input) {
34567
34741
  const home = await canonicalCodexHome(
34568
- input.environment.CODEX_HOME ?? path16.join(homedir(), ".codex")
34742
+ input.environment.CODEX_HOME ?? path17.join(homedir(), ".codex")
34569
34743
  );
34570
34744
  await mkdir7(home, { recursive: true });
34571
34745
  const scope = new OfficialRuntimeScope({
@@ -34731,18 +34905,18 @@ var DelegationControlRegistry = class {
34731
34905
  };
34732
34906
 
34733
34907
  // packages/host-runtime/src/installed-harness-plugins.ts
34734
- import os4 from "node:os";
34735
- import path18 from "node:path";
34908
+ import os5 from "node:os";
34909
+ import path19 from "node:path";
34736
34910
  import { fileURLToPath } from "node:url";
34737
34911
 
34738
34912
  // packages/host-runtime/src/launcher-url-opener.ts
34739
34913
  import { spawn as spawn4 } from "node:child_process";
34740
- import path17 from "node:path";
34914
+ import path18 from "node:path";
34741
34915
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
34742
34916
  var OPEN_TIMEOUT_MS = 1e4;
34743
34917
  function createLauncherUrlOpener(environment, spawnLauncher = (command, arguments_2, options2) => spawn4(command, arguments_2, options2)) {
34744
34918
  const launcher = environment.CODEXHOST_LAUNCHER_EXECUTABLE;
34745
- if (!launcher || !path17.isAbsolute(launcher)) return void 0;
34919
+ if (!launcher || !path18.isAbsolute(launcher)) return void 0;
34746
34920
  const launcherEnvironment = Object.fromEntries(
34747
34921
  Object.entries(environment).filter(([name]) => {
34748
34922
  const normalized = name.toUpperCase();
@@ -34800,9 +34974,9 @@ function installedHarnessPluginOptions(environment, managedRemoteHost = false, h
34800
34974
  const opener = managedRemoteHost ? void 0 : createLauncherUrlOpener(environment);
34801
34975
  return {
34802
34976
  pluginRoots: [
34803
- path18.join(path18.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
34804
- environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path18.join(
34805
- environment.CODEXHOST_DATA_DIR ? path18.resolve(environment.CODEXHOST_DATA_DIR) : path18.join(os4.homedir(), ".codexhost"),
34977
+ path19.join(path19.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
34978
+ environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path19.join(
34979
+ environment.CODEXHOST_DATA_DIR ? path19.resolve(environment.CODEXHOST_DATA_DIR) : path19.join(os5.homedir(), ".codexhost"),
34806
34980
  "plugins"
34807
34981
  )
34808
34982
  ],
@@ -34927,12 +35101,12 @@ async function startDelegationControlServer(input) {
34927
35101
  }
34928
35102
 
34929
35103
  // packages/host-runtime/src/delegation-skill.ts
34930
- import { createHash as createHash8, randomUUID as randomUUID12 } from "node:crypto";
34931
- import { mkdir as mkdir8, open as open6, readFile as readFile7, rename as rename5, rm as rm8, stat as stat4 } from "node:fs/promises";
34932
- import os5 from "node:os";
34933
- import path19 from "node:path";
35104
+ import { createHash as createHash9, randomUUID as randomUUID12 } from "node:crypto";
35105
+ import { mkdir as mkdir8, open as open6, readFile as readFile8, rename as rename5, rm as rm8, stat as stat4 } from "node:fs/promises";
35106
+ import os6 from "node:os";
35107
+ import path20 from "node:path";
34934
35108
  var SKILL_VERSION = 7;
34935
- var SKILL_RELATIVE_PATH = path19.join("skills", "codexhost-delegation", "SKILL.md");
35109
+ var SKILL_RELATIVE_PATH = path20.join("skills", "codexhost-delegation", "SKILL.md");
34936
35110
  var PREVIOUS_MANAGED_DIGESTS = [
34937
35111
  "9d2f491850fb0b4084a31ba9b5e4a550b5e833747af322090d8ed0ff80b88c30",
34938
35112
  "2bb0aebb9b06febbc6c0c0bcdb0b32506c7cdbf8dc3b734cc6b2a86621270e4e",
@@ -34987,9 +35161,9 @@ user’s request and the task:
34987
35161
  Report the result returned by read or a completed wait, together with the target
34988
35162
  agent, status, and a labeled task link. Keep internal tracking IDs in tool calls.
34989
35163
  `;
34990
- var CURRENT_DIGEST = createHash8("sha256").update(CODEXHOST_DELEGATION_SKILL).digest("hex");
35164
+ var CURRENT_DIGEST = createHash9("sha256").update(CODEXHOST_DELEGATION_SKILL).digest("hex");
34991
35165
  function digest(value2) {
34992
- return createHash8("sha256").update(value2).digest("hex");
35166
+ return createHash9("sha256").update(value2).digest("hex");
34993
35167
  }
34994
35168
  function managedVersion(value2) {
34995
35169
  const match = /^version:\s*(\d+)\s*$/mu.exec(value2);
@@ -34997,15 +35171,15 @@ function managedVersion(value2) {
34997
35171
  }
34998
35172
  async function readOptional(filePath) {
34999
35173
  try {
35000
- return await readFile7(filePath, "utf8");
35174
+ return await readFile8(filePath, "utf8");
35001
35175
  } catch (error51) {
35002
35176
  if (error51.code === "ENOENT") return null;
35003
35177
  throw error51;
35004
35178
  }
35005
35179
  }
35006
35180
  async function atomicWrite(filePath, content) {
35007
- await mkdir8(path19.dirname(filePath), { recursive: true, mode: 448 });
35008
- const temporaryPath = path19.join(path19.dirname(filePath), `.SKILL.md.${randomUUID12()}.tmp`);
35181
+ await mkdir8(path20.dirname(filePath), { recursive: true, mode: 448 });
35182
+ const temporaryPath = path20.join(path20.dirname(filePath), `.SKILL.md.${randomUUID12()}.tmp`);
35009
35183
  const handle = await open6(temporaryPath, "wx", 384);
35010
35184
  try {
35011
35185
  await handle.writeFile(content, "utf8");
@@ -35020,10 +35194,10 @@ async function atomicWrite(filePath, content) {
35020
35194
  }
35021
35195
  }
35022
35196
  async function installDelegationSkills(input = {}) {
35023
- const home = input.homeDirectory ?? os5.homedir();
35197
+ const home = input.homeDirectory ?? os6.homedir();
35024
35198
  const destinations = [
35025
- path19.join(home, ".agents", SKILL_RELATIVE_PATH),
35026
- path19.join(home, ".claude", SKILL_RELATIVE_PATH)
35199
+ path20.join(home, ".agents", SKILL_RELATIVE_PATH),
35200
+ path20.join(home, ".claude", SKILL_RELATIVE_PATH)
35027
35201
  ];
35028
35202
  const knownDigests = /* @__PURE__ */ new Set([
35029
35203
  CURRENT_DIGEST,
@@ -35068,7 +35242,7 @@ async function installDelegationSkills(input = {}) {
35068
35242
  }
35069
35243
  for (const result of results) {
35070
35244
  if (result.status === "conflict") continue;
35071
- const source = await readFile7(result.path, "utf8");
35245
+ const source = await readFile8(result.path, "utf8");
35072
35246
  const metadata = await stat4(result.path);
35073
35247
  if (!metadata.isFile() || source !== CODEXHOST_DELEGATION_SKILL) {
35074
35248
  throw new Error(`Delegation Skill verification failed: ${result.path}`);
@@ -35079,7 +35253,7 @@ async function installDelegationSkills(input = {}) {
35079
35253
  throw new Error("Delegation Skill copies are inconsistent");
35080
35254
  }
35081
35255
  if (results.every((result) => result.status !== "conflict")) {
35082
- const copies = await Promise.all(results.map((result) => readFile7(result.path, "utf8")));
35256
+ const copies = await Promise.all(results.map((result) => readFile8(result.path, "utf8")));
35083
35257
  if (copies.some((copy) => copy !== copies[0])) {
35084
35258
  throw new Error("Delegation Skill copies are inconsistent");
35085
35259
  }
@@ -35090,7 +35264,7 @@ async function installDelegationSkills(input = {}) {
35090
35264
  // packages/host-runtime/src/remote-control-app-server.ts
35091
35265
  import { randomUUID as randomUUID13 } from "node:crypto";
35092
35266
  import { mkdir as mkdir9, open as open7, rename as rename6, rm as rm9 } from "node:fs/promises";
35093
- import path20 from "node:path";
35267
+ import path21 from "node:path";
35094
35268
  var REMOTE_CONTROL_BRIDGE_PIPE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_PIPE";
35095
35269
  var REMOTE_CONTROL_BRIDGE_NODE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_NODE_PATH";
35096
35270
  var REMOTE_CONTROL_BRIDGE_RUNTIME_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_RUNTIME_PATH";
@@ -35101,8 +35275,8 @@ var BRIDGE_READY_METHOD = "codexhost/remote-control-bridge/ready";
35101
35275
  function absoluteEnvironmentPath2(environment, name, fallback, platform = process.platform) {
35102
35276
  const value2 = environment[name] ?? fallback;
35103
35277
  if (!value2) return null;
35104
- if (path20.isAbsolute(value2)) return path20.normalize(value2);
35105
- return platform === "win32" && path20.win32.isAbsolute(value2) ? path20.win32.normalize(value2) : null;
35278
+ if (path21.isAbsolute(value2)) return path21.normalize(value2);
35279
+ return platform === "win32" && path21.win32.isAbsolute(value2) ? path21.win32.normalize(value2) : null;
35106
35280
  }
35107
35281
  function nodeCompatibleWindowsPath(value2) {
35108
35282
  if (value2.startsWith("\\\\?\\UNC\\")) return `\\\\${value2.slice(8)}`;
@@ -35116,13 +35290,13 @@ function remoteControlBridgePipePath(processId = process.pid, instanceId = rando
35116
35290
  }
35117
35291
  function remoteControlBridgeDescriptorPath(environment) {
35118
35292
  const root = environment.LOCALAPPDATA;
35119
- if (!root || !path20.isAbsolute(root)) return null;
35120
- return path20.join(path20.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
35293
+ if (!root || !path21.isAbsolute(root)) return null;
35294
+ return path21.join(path21.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
35121
35295
  }
35122
35296
  async function publishRemoteControlAppServerDescriptor(plan) {
35123
- const directory = path20.dirname(plan.descriptorPath);
35297
+ const directory = path21.dirname(plan.descriptorPath);
35124
35298
  await mkdir9(directory, { recursive: true, mode: 448 });
35125
- const temporaryPath = path20.join(
35299
+ const temporaryPath = path21.join(
35126
35300
  directory,
35127
35301
  `.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID13()}.tmp`
35128
35302
  );
@@ -35423,9 +35597,9 @@ function hasLauncherManagedUpdateRuntime(environment, hostRuntimePath) {
35423
35597
  if (!environment[UPDATE_RUNTIME_ENV.launcherPid]) return false;
35424
35598
  const npmPackageRoot = environment[UPDATE_RUNTIME_ENV.npmPackageRoot];
35425
35599
  if (!npmPackageRoot || !hostRuntimePath) return true;
35426
- if (!path21.isAbsolute(npmPackageRoot) || !path21.isAbsolute(hostRuntimePath)) return false;
35427
- const runtimePackageRoot = path21.dirname(path21.dirname(path21.normalize(hostRuntimePath)));
35428
- return path21.relative(path21.normalize(npmPackageRoot), runtimePackageRoot) === "";
35600
+ if (!path22.isAbsolute(npmPackageRoot) || !path22.isAbsolute(hostRuntimePath)) return false;
35601
+ const runtimePackageRoot = path22.dirname(path22.dirname(path22.normalize(hostRuntimePath)));
35602
+ return path22.relative(path22.normalize(npmPackageRoot), runtimePackageRoot) === "";
35429
35603
  }
35430
35604
  function requiredRuntimeConfiguration(environment) {
35431
35605
  const stockCodexPath = environment[STOCK_CODEX_PATH_ENV];
@@ -35571,8 +35745,8 @@ async function runHostRuntime(input) {
35571
35745
  const socketPath = remoteAppServerSocketPath(delegationEnvironment, listenUrl);
35572
35746
  const officialPlan = createRemoteOfficialAppServerPlan(input.arguments, socketPath);
35573
35747
  const officialRuntimeScope = new OfficialRuntimeScope({
35574
- permanentHome: path21.resolve(
35575
- delegationEnvironment.CODEX_HOME ?? path21.join(homedir2(), ".codex")
35748
+ permanentHome: path22.resolve(
35749
+ delegationEnvironment.CODEX_HOME ?? path22.join(homedir2(), ".codex")
35576
35750
  ),
35577
35751
  diagnosticOutput: process.stderr,
35578
35752
  createBackend: () => createOwnedUnixBackend({
@@ -35653,7 +35827,7 @@ async function runHostRuntime(input) {
35653
35827
  }
35654
35828
 
35655
35829
  // packages/host-runtime/src/remote-host-install.ts
35656
- import { createHash as createHash9, randomUUID as randomUUID14 } from "node:crypto";
35830
+ import { createHash as createHash10, randomUUID as randomUUID14 } from "node:crypto";
35657
35831
  import { constants as fsConstants } from "node:fs";
35658
35832
  import {
35659
35833
  access,
@@ -35661,14 +35835,14 @@ import {
35661
35835
  copyFile as copyFile3,
35662
35836
  lstat as lstat8,
35663
35837
  mkdir as mkdir10,
35664
- readFile as readFile8,
35838
+ readFile as readFile9,
35665
35839
  rename as rename7,
35666
35840
  rm as rm10,
35667
35841
  rmdir,
35668
35842
  stat as stat5,
35669
35843
  writeFile as writeFile4
35670
35844
  } from "node:fs/promises";
35671
- import path22 from "node:path";
35845
+ import path23 from "node:path";
35672
35846
  var MANIFEST_FORMAT = 1;
35673
35847
  var WRAPPER_MARKER = "# codexhost remote SSH wrapper v1";
35674
35848
  var PROFILE_START = "# >>> codexhost remote SSH >>>";
@@ -35679,25 +35853,25 @@ function resolvePaths(options2) {
35679
35853
  if (!configuredHome) {
35680
35854
  throw new Error("A non-root HOME is required for remote Host installation");
35681
35855
  }
35682
- const home = path22.resolve(configuredHome);
35683
- if (!home || home === path22.parse(home).root) {
35856
+ const home = path23.resolve(configuredHome);
35857
+ if (!home || home === path23.parse(home).root) {
35684
35858
  throw new Error("A non-root HOME is required for remote Host installation");
35685
35859
  }
35686
- const installRoot = path22.resolve(options2.installRoot ?? path22.join(home, ".codexhost", "remote"));
35687
- const profilePath = path22.resolve(
35688
- options2.profilePath ?? path22.join(
35860
+ const installRoot = path23.resolve(options2.installRoot ?? path23.join(home, ".codexhost", "remote"));
35861
+ const profilePath = path23.resolve(
35862
+ options2.profilePath ?? path23.join(
35689
35863
  home,
35690
- path22.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path22.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
35864
+ path23.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path23.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
35691
35865
  )
35692
35866
  );
35693
- const binDirectory = path22.join(installRoot, "bin");
35867
+ const binDirectory = path23.join(installRoot, "bin");
35694
35868
  return {
35695
35869
  home,
35696
35870
  installRoot,
35697
35871
  binDirectory,
35698
- wrapperPath: path22.join(binDirectory, "codex"),
35699
- manifestPath: path22.join(installRoot, "manifest.json"),
35700
- dataDirectory: path22.join(installRoot, "data"),
35872
+ wrapperPath: path23.join(binDirectory, "codex"),
35873
+ manifestPath: path23.join(installRoot, "manifest.json"),
35874
+ dataDirectory: path23.join(installRoot, "data"),
35701
35875
  profilePath
35702
35876
  };
35703
35877
  }
@@ -35706,17 +35880,17 @@ function shellQuote(value2) {
35706
35880
  }
35707
35881
  async function existingText(filePath) {
35708
35882
  try {
35709
- return await readFile8(filePath, "utf8");
35883
+ return await readFile9(filePath, "utf8");
35710
35884
  } catch (error51) {
35711
35885
  if (error51.code === "ENOENT") return null;
35712
35886
  throw error51;
35713
35887
  }
35714
35888
  }
35715
35889
  async function fileSha256(filePath) {
35716
- return createHash9("sha256").update(await readFile8(filePath)).digest("hex");
35890
+ return createHash10("sha256").update(await readFile9(filePath)).digest("hex");
35717
35891
  }
35718
35892
  async function executable(filePath, label) {
35719
- const absolute = path22.resolve(filePath);
35893
+ const absolute = path23.resolve(filePath);
35720
35894
  try {
35721
35895
  if (!(await stat5(absolute)).isFile()) throw new Error("not a regular file");
35722
35896
  await access(absolute, fsConstants.X_OK);
@@ -35726,7 +35900,7 @@ async function executable(filePath, label) {
35726
35900
  return absolute;
35727
35901
  }
35728
35902
  async function existingFile(filePath, label) {
35729
- const absolute = path22.resolve(filePath);
35903
+ const absolute = path23.resolve(filePath);
35730
35904
  try {
35731
35905
  const metadata = await stat5(absolute);
35732
35906
  if (!metadata.isFile()) throw new Error("not a regular file");
@@ -35736,9 +35910,9 @@ async function existingFile(filePath, label) {
35736
35910
  return absolute;
35737
35911
  }
35738
35912
  async function discoverExecutable(name, environment) {
35739
- for (const directory of (environment.PATH ?? "").split(path22.delimiter)) {
35913
+ for (const directory of (environment.PATH ?? "").split(path23.delimiter)) {
35740
35914
  if (!directory) continue;
35741
- const candidate = path22.resolve(directory, name);
35915
+ const candidate = path23.resolve(directory, name);
35742
35916
  try {
35743
35917
  await access(candidate, fsConstants.X_OK);
35744
35918
  return candidate;
@@ -35749,10 +35923,10 @@ async function discoverExecutable(name, environment) {
35749
35923
  return null;
35750
35924
  }
35751
35925
  async function writeAtomic(filePath, contents, mode) {
35752
- await mkdir10(path22.dirname(filePath), { recursive: true, mode: 448 });
35753
- const temporary = path22.join(
35754
- path22.dirname(filePath),
35755
- `.${path22.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
35926
+ await mkdir10(path23.dirname(filePath), { recursive: true, mode: 448 });
35927
+ const temporary = path23.join(
35928
+ path23.dirname(filePath),
35929
+ `.${path23.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
35756
35930
  );
35757
35931
  try {
35758
35932
  if (typeof contents === "string") {
@@ -35773,10 +35947,10 @@ async function writeAtomic(filePath, contents, mode) {
35773
35947
  }
35774
35948
  }
35775
35949
  async function writeAtomicExecutable(filePath, sourcePath) {
35776
- await mkdir10(path22.dirname(filePath), { recursive: true, mode: 448 });
35777
- const temporary = path22.join(
35778
- path22.dirname(filePath),
35779
- `.${path22.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
35950
+ await mkdir10(path23.dirname(filePath), { recursive: true, mode: 448 });
35951
+ const temporary = path23.join(
35952
+ path23.dirname(filePath),
35953
+ `.${path23.basename(filePath)}.${process.pid}.${randomUUID14()}.tmp`
35780
35954
  );
35781
35955
  try {
35782
35956
  await copyFile3(sourcePath, temporary);
@@ -35817,15 +35991,14 @@ function removeManagedProfileBlock(contents) {
35817
35991
  function installManagedProfileBlock(contents, manifest) {
35818
35992
  const base = removeManagedProfileBlock(contents);
35819
35993
  const environment = [
35820
- `export CODEX_INSTALL_DIR=${shellQuote(path22.dirname(manifest.wrapperPath))}`,
35821
- `export PATH=${shellQuote(path22.dirname(manifest.wrapperPath))}:${shellQuote(path22.dirname(manifest.nodePath))}:${shellQuote(path22.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
35994
+ `export CODEX_INSTALL_DIR=${shellQuote(path23.dirname(manifest.wrapperPath))}`,
35995
+ `export PATH=${shellQuote(path23.dirname(manifest.wrapperPath))}:${shellQuote(path23.dirname(manifest.nodePath))}:${shellQuote(path23.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
35822
35996
  `export CODEXHOST_STOCK_CODEX_PATH=${shellQuote(manifest.stockCodexPath)}`,
35823
35997
  `export CODEXHOST_HOST_NODE_PATH=${shellQuote(manifest.nodePath)}`,
35824
35998
  `export CODEXHOST_HOST_RUNTIME_PATH=${shellQuote(manifest.hostRuntimePath)}`,
35825
35999
  `export CODEXHOST_DATA_DIR=${shellQuote(manifest.dataDirectory)}`,
35826
36000
  "export CODEXHOST_DEFAULT_AGENT='codex'",
35827
- "export CODEXHOST_REMOTE_SSH_MANAGED='1'",
35828
- ...manifest.claudeCommand ? [`export CODEXHOST_CLAUDE_COMMAND=${shellQuote(manifest.claudeCommand)}`] : []
36001
+ "export CODEXHOST_REMOTE_SSH_MANAGED='1'"
35829
36002
  ];
35830
36003
  const block = [
35831
36004
  PROFILE_START,
@@ -35835,7 +36008,7 @@ function installManagedProfileBlock(contents, manifest) {
35835
36008
  PROFILE_END,
35836
36009
  ""
35837
36010
  ].join("\n");
35838
- if (path22.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
36011
+ if (path23.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
35839
36012
  const separator = base.length > 0 && !base.endsWith("\n") ? "\n" : "";
35840
36013
  return `${base}${separator}${block}`;
35841
36014
  }
@@ -35847,16 +36020,16 @@ async function managedEntrypointState(manifest) {
35847
36020
  if (metadata === null) return "missing";
35848
36021
  if (!metadata.isFile()) return "modified";
35849
36022
  if (process.platform !== "win32" && (metadata.mode & 73) === 0) return "modified";
35850
- const entrypoint = await readFile8(manifest.wrapperPath);
36023
+ const entrypoint = await readFile9(manifest.wrapperPath);
35851
36024
  if (entrypoint.subarray(0, 256).toString("utf8").startsWith(`#!/usr/bin/env sh
35852
36025
  ${WRAPPER_MARKER}
35853
36026
  `)) {
35854
36027
  return "legacy-wrapper";
35855
36028
  }
35856
36029
  if (manifest.entrypointSha256 !== void 0) {
35857
- return createHash9("sha256").update(entrypoint).digest("hex") === manifest.entrypointSha256 ? "native" : "modified";
36030
+ return createHash10("sha256").update(entrypoint).digest("hex") === manifest.entrypointSha256 ? "native" : "modified";
35858
36031
  }
35859
- const shim = await readFile8(manifest.shimPath).catch((error51) => {
36032
+ const shim = await readFile9(manifest.shimPath).catch((error51) => {
35860
36033
  if (error51.code === "ENOENT") return null;
35861
36034
  throw error51;
35862
36035
  });
@@ -35887,6 +36060,7 @@ async function readManifest(filePath) {
35887
36060
  "dataDirectory",
35888
36061
  "entrypointSha256",
35889
36062
  "claudeCommand",
36063
+ // Inert metadata accepted from older format-1 manifests.
35890
36064
  "profileBackupPath"
35891
36065
  ]);
35892
36066
  const requiredPaths = [
@@ -35900,9 +36074,9 @@ async function readManifest(filePath) {
35900
36074
  ];
35901
36075
  const optionalPaths = ["claudeCommand", "profileBackupPath"];
35902
36076
  if (manifest.format !== MANIFEST_FORMAT || Object.keys(manifest).some((key) => !allowed.has(key)) || requiredPaths.some(
35903
- (key) => typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key])
36077
+ (key) => typeof manifest[key] !== "string" || !path23.isAbsolute(manifest[key])
35904
36078
  ) || optionalPaths.some(
35905
- (key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key]))
36079
+ (key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path23.isAbsolute(manifest[key]))
35906
36080
  ) || manifest.entrypointSha256 !== void 0 && (typeof manifest.entrypointSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(manifest.entrypointSha256))) {
35907
36081
  throw new Error("Remote Host manifest has an unsupported format");
35908
36082
  }
@@ -35924,7 +36098,7 @@ async function installRemoteHost(options2) {
35924
36098
  const paths = resolvePaths(options2);
35925
36099
  const previousManifest = await readManifest(paths.manifestPath);
35926
36100
  const previousManifestFile = previousManifest ? {
35927
- contents: await readFile8(paths.manifestPath),
36101
+ contents: await readFile9(paths.manifestPath),
35928
36102
  mode: (await stat5(paths.manifestPath)).mode & 511
35929
36103
  } : null;
35930
36104
  const existingEntrypoint = await lstat8(paths.wrapperPath).catch(
@@ -35949,7 +36123,7 @@ async function installRemoteHost(options2) {
35949
36123
  }
35950
36124
  const profilePath = previousManifest?.profilePath ?? paths.profilePath;
35951
36125
  const previousEntrypoint = existingEntrypoint?.isFile() ? {
35952
- contents: await readFile8(paths.wrapperPath),
36126
+ contents: await readFile9(paths.wrapperPath),
35953
36127
  mode: existingEntrypoint.mode & 511
35954
36128
  } : null;
35955
36129
  const discoveredStock = options2.stockCodexPath ?? previousManifest?.stockCodexPath ?? await discoverExecutable("codex", environment);
@@ -35966,8 +36140,6 @@ async function installRemoteHost(options2) {
35966
36140
  const nodePath2 = await executable(options2.nodePath, "Node runtime");
35967
36141
  const shimPath = await executable(options2.shimPath, "codexhost Shim");
35968
36142
  const hostRuntimePath = await existingFile(options2.hostRuntimePath, "codexhost Host Runtime");
35969
- const discoveredClaude = options2.claudeCommand ?? previousManifest?.claudeCommand ?? await discoverExecutable("claude", environment);
35970
- const claudeCommand = discoveredClaude ? await executable(discoveredClaude, "Claude Code command") : void 0;
35971
36143
  let manifest = {
35972
36144
  format: MANIFEST_FORMAT,
35973
36145
  wrapperPath: paths.wrapperPath,
@@ -35977,7 +36149,6 @@ async function installRemoteHost(options2) {
35977
36149
  shimPath,
35978
36150
  hostRuntimePath,
35979
36151
  dataDirectory: paths.dataDirectory,
35980
- ...claudeCommand ? { claudeCommand } : {},
35981
36152
  ...previousManifest?.profileBackupPath ? { profileBackupPath: previousManifest.profileBackupPath } : {}
35982
36153
  };
35983
36154
  const existingProfileSource = await existingText(profilePath);
@@ -36131,7 +36302,7 @@ async function uninstallRemoteHost(options2) {
36131
36302
  import { spawn as spawn5 } from "node:child_process";
36132
36303
  import { stat as stat6 } from "node:fs/promises";
36133
36304
  import net3 from "node:net";
36134
- import path23 from "node:path";
36305
+ import path24 from "node:path";
36135
36306
  import { Duplex } from "node:stream";
36136
36307
  var CODEXHOST_STATUS_METHOD = "codexhost/update/status";
36137
36308
  var DIRECT_PROBE_TIMEOUT_MS = 5e3;
@@ -36150,9 +36321,9 @@ function classifyRemoteHostProbeResponse(response, socketPath) {
36150
36321
  }
36151
36322
  var lifecycleDependencyOverrides = {};
36152
36323
  function socketPathFor(environment) {
36153
- const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path23.join(environment.HOME, ".codex") : void 0);
36324
+ const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path24.join(environment.HOME, ".codex") : void 0);
36154
36325
  if (!codexHome) throw new Error("CODEX_HOME or HOME is required for remote Host lifecycle");
36155
- return path23.join(codexHome, "app-server-control", "app-server-control.sock");
36326
+ return path24.join(codexHome, "app-server-control", "app-server-control.sock");
36156
36327
  }
36157
36328
  async function defaultSocketExists(socketPath) {
36158
36329
  const metadata = await stat6(socketPath).catch((error51) => {
@@ -36279,15 +36450,14 @@ function installedManifest(status) {
36279
36450
  function managedEnvironment(manifest, environment) {
36280
36451
  return {
36281
36452
  ...environment,
36282
- CODEX_INSTALL_DIR: path23.dirname(manifest.wrapperPath),
36453
+ CODEX_INSTALL_DIR: path24.dirname(manifest.wrapperPath),
36283
36454
  CODEXHOST_STOCK_CODEX_PATH: manifest.stockCodexPath,
36284
36455
  CODEXHOST_HOST_NODE_PATH: manifest.nodePath,
36285
36456
  CODEXHOST_HOST_RUNTIME_PATH: manifest.hostRuntimePath,
36286
36457
  CODEXHOST_DATA_DIR: manifest.dataDirectory,
36287
36458
  CODEXHOST_DEFAULT_AGENT: "codex",
36288
36459
  CODEXHOST_REMOTE_SSH_MANAGED: "1",
36289
- ...manifest.claudeCommand ? { CODEXHOST_CLAUDE_COMMAND: manifest.claudeCommand } : {},
36290
- PATH: `${path23.dirname(manifest.wrapperPath)}${path23.delimiter}${path23.dirname(manifest.stockCodexPath)}${path23.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
36460
+ PATH: `${path24.dirname(manifest.wrapperPath)}${path24.delimiter}${path24.dirname(manifest.stockCodexPath)}${path24.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
36291
36461
  };
36292
36462
  }
36293
36463
  async function defaultRunTerminator(manifest, socketPath, role, environment) {
@@ -36435,9 +36605,6 @@ function parseRemoteCliArguments(arguments_2) {
36435
36605
  case "--stock-codex":
36436
36606
  options2.stockCodexPath = value2;
36437
36607
  break;
36438
- case "--claude-command":
36439
- options2.claudeCommand = value2;
36440
- break;
36441
36608
  case "--node":
36442
36609
  resources.nodePath = value2;
36443
36610
  break;
@@ -36464,7 +36631,7 @@ async function runRemoteHostCli(input) {
36464
36631
  output.write(
36465
36632
  [
36466
36633
  "usage:",
36467
- " codexhost remote install [--stock-codex PATH] [--claude-command PATH]",
36634
+ " codexhost remote install [--stock-codex PATH]",
36468
36635
  " codexhost remote start",
36469
36636
  " codexhost remote stop",
36470
36637
  " codexhost remote status",
@@ -36625,26 +36792,26 @@ function consumeBrokerFrames(socket, onFrame, onError) {
36625
36792
  }
36626
36793
 
36627
36794
  // packages/harness-broker/dist/paths.js
36628
- import os6 from "node:os";
36629
- import path24 from "node:path";
36795
+ import os7 from "node:os";
36796
+ import path25 from "node:path";
36630
36797
  var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
36631
36798
  var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
36632
36799
  var HARNESS_BROKER_SOCKET_FILE = "claude-code-broker-v1.sock";
36633
36800
  function defaultHarnessBrokerDirectory(environment = process.env) {
36634
- const home = environment.HOME || os6.homedir();
36635
- return path24.join(home, ".codexhost", "harness-broker");
36801
+ const home = environment.HOME || os7.homedir();
36802
+ return path25.join(home, ".codexhost", "harness-broker");
36636
36803
  }
36637
36804
  function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
36638
36805
  harnessPluginIdSchema.parse(harnessId);
36639
36806
  if (harnessId !== "claude-code")
36640
- return path24.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
36641
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path24.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
36807
+ return path25.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
36808
+ return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path25.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
36642
36809
  }
36643
36810
  function defaultHarnessBrokerSocketPath(environment = process.env, harnessId = "claude-code") {
36644
36811
  harnessPluginIdSchema.parse(harnessId);
36645
36812
  if (harnessId !== "claude-code")
36646
- return path24.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
36647
- return path24.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
36813
+ return path25.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
36814
+ return path25.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
36648
36815
  }
36649
36816
 
36650
36817
  // packages/harness-broker/dist/validation.js
@@ -36858,9 +37025,9 @@ var harnessOutputSchema = external_exports.custom((value2) => {
36858
37025
 
36859
37026
  // packages/harness-broker/dist/server.js
36860
37027
  import { randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
36861
- import { chmod as chmod5, lstat as lstat9, mkdir as mkdir11, open as open8, readFile as readFile9, rename as rename8, rm as rm11 } from "node:fs/promises";
37028
+ import { chmod as chmod5, lstat as lstat9, mkdir as mkdir11, open as open8, readFile as readFile10, rename as rename8, rm as rm11 } from "node:fs/promises";
36862
37029
  import net4, {} from "node:net";
36863
- import path25 from "node:path";
37030
+ import path26 from "node:path";
36864
37031
  function harnessError(message, retryable = true) {
36865
37032
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
36866
37033
  }
@@ -36906,7 +37073,7 @@ async function assertNoLiveDescriptor(descriptorPath) {
36906
37073
  throw new Error("Harness broker descriptor is not owner-only");
36907
37074
  }
36908
37075
  }
36909
- const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile9(descriptorPath, "utf8")));
37076
+ const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile10(descriptorPath, "utf8")));
36910
37077
  if (processIsAlive2(descriptor.ownerPid)) {
36911
37078
  throw new Error("Harness broker descriptor already has a live owner");
36912
37079
  }
@@ -36983,13 +37150,13 @@ async function prepareUnixSocketPath(socketPath) {
36983
37150
  }
36984
37151
  async function startHarnessBrokerServer(input) {
36985
37152
  harnessPluginIdSchema.parse(input.adapter.harnessId);
36986
- if (process.platform !== "win32" && path25.dirname(input.descriptorPath) !== path25.dirname(input.socketPath)) {
37153
+ if (process.platform !== "win32" && path26.dirname(input.descriptorPath) !== path26.dirname(input.socketPath)) {
36987
37154
  throw new Error("Harness broker descriptor and socket must share one private directory");
36988
37155
  }
36989
37156
  if (process.platform === "darwin" && Buffer.byteLength(input.socketPath) > 103) {
36990
37157
  throw new Error("Harness broker Unix socket path is too long for macOS");
36991
37158
  }
36992
- await privateDirectory(path25.dirname(input.descriptorPath));
37159
+ await privateDirectory(path26.dirname(input.descriptorPath));
36993
37160
  await assertNoLiveDescriptor(input.descriptorPath);
36994
37161
  if (process.platform !== "win32")
36995
37162
  await prepareUnixSocketPath(input.socketPath);