@codexhost/cli-win32-arm64 0.9.1-test.2 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 path20 from "node:path";
4286
+ import path21 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, path25) {
5982
- if (!path25)
5981
+ function getElementAtPath(obj, path26) {
5982
+ if (!path26)
5983
5983
  return obj;
5984
- return path25.reduce((acc, key) => acc?.[key], obj);
5984
+ return path26.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(path25, issues) {
6393
+ function prefixIssues(path26, issues) {
6394
6394
  return issues.map((iss) => {
6395
6395
  var _a3;
6396
6396
  (_a3 = iss).path ?? (_a3.path = []);
6397
- iss.path.unshift(path25);
6397
+ iss.path.unshift(path26);
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, path25 = []) => {
6544
+ const processError = (error52, path26 = []) => {
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 }, [...path25, ...issue2.path]));
6547
+ issue2.errors.map((issues) => processError({ issues }, [...path26, ...issue2.path]));
6548
6548
  } else if (issue2.code === "invalid_key") {
6549
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
6549
+ processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6550
6550
  } else if (issue2.code === "invalid_element") {
6551
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
6551
+ processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6552
6552
  } else {
6553
- const fullpath = [...path25, ...issue2.path];
6553
+ const fullpath = [...path26, ...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, path25 = []) => {
6580
+ const processError = (error52, path26 = []) => {
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 }, [...path25, ...issue2.path]));
6584
+ issue2.errors.map((issues) => processError({ issues }, [...path26, ...issue2.path]));
6585
6585
  } else if (issue2.code === "invalid_key") {
6586
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
6586
+ processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6587
6587
  } else if (issue2.code === "invalid_element") {
6588
- processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
6588
+ processError({ issues: issue2.issues }, [...path26, ...issue2.path]);
6589
6589
  } else {
6590
- const fullpath = [...path25, ...issue2.path];
6590
+ const fullpath = [...path26, ...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 path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6623
- for (const seg of path25) {
6622
+ const path26 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6623
+ for (const seg of path26) {
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 path25 = ref.slice(1).split("/").filter(Boolean);
19316
- if (path25.length === 0) {
19315
+ const path26 = ref.slice(1).split("/").filter(Boolean);
19316
+ if (path26.length === 0) {
19317
19317
  return ctx.rootSchema;
19318
19318
  }
19319
19319
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
19320
- if (path25[0] === defsKey) {
19321
- const key = path25[1];
19320
+ if (path26[0] === defsKey) {
19321
+ const key = path26[1];
19322
19322
  if (!key || !ctx.defs[key]) {
19323
19323
  throw new Error(`Reference not found: ${ref}`);
19324
19324
  }
@@ -20261,6 +20261,8 @@ var pluginPresentationShape = {
20261
20261
  id: harnessPluginIdSchema,
20262
20262
  name: external_exports.string().trim().min(1).max(128),
20263
20263
  version: external_exports.string().min(1).max(128),
20264
+ /** The factory accepts a persisted local entrypoint through its construction context. */
20265
+ launchCommand: external_exports.literal(true).optional(),
20264
20266
  links: external_exports.object({
20265
20267
  documentation: documentationUrlSchema.optional(),
20266
20268
  installation: documentationUrlSchema.optional()
@@ -20322,6 +20324,21 @@ function decodeHarnessPluginRoute(value2) {
20322
20324
  }
20323
20325
  }
20324
20326
 
20327
+ // packages/shared-contracts/dist/harness-launch-settings.js
20328
+ var HARNESS_LAUNCH_SETTINGS_GET_METHOD = "codexhost/harness/launch-settings/get";
20329
+ var HARNESS_LAUNCH_SETTINGS_SET_METHOD = "codexhost/harness/launch-settings/set";
20330
+ var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value2) => !/[\u0000\r\n]/u.test(value2), "Invalid entrypoint path");
20331
+ var harnessLaunchSettingsGetSchema = external_exports.object({
20332
+ harnessId: harnessPluginIdSchema
20333
+ }).strict();
20334
+ var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
20335
+ path: harnessLaunchPathSchema.nullable()
20336
+ });
20337
+ var harnessLaunchSettingsSchema = external_exports.object({
20338
+ path: harnessLaunchPathSchema.nullable(),
20339
+ restartRequired: external_exports.boolean()
20340
+ }).strict();
20341
+
20325
20342
  // packages/shared-contracts/dist/codex-accounts.js
20326
20343
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
20327
20344
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
@@ -22299,16 +22316,16 @@ var Diff = class {
22299
22316
  }
22300
22317
  }
22301
22318
  }
22302
- addToPath(path25, added, removed, oldPosInc, options2) {
22303
- const last = path25.lastComponent;
22319
+ addToPath(path26, added, removed, oldPosInc, options2) {
22320
+ const last = path26.lastComponent;
22304
22321
  if (last && !options2.oneChangePerToken && last.added === added && last.removed === removed) {
22305
22322
  return {
22306
- oldPos: path25.oldPos + oldPosInc,
22323
+ oldPos: path26.oldPos + oldPosInc,
22307
22324
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
22308
22325
  };
22309
22326
  } else {
22310
22327
  return {
22311
- oldPos: path25.oldPos + oldPosInc,
22328
+ oldPos: path26.oldPos + oldPosInc,
22312
22329
  lastComponent: { count: 1, added, removed, previousComponent: last }
22313
22330
  };
22314
22331
  }
@@ -23009,8 +23026,8 @@ function projectFileChangeKind(kind) {
23009
23026
  return { type: kind };
23010
23027
  }
23011
23028
  function projectFileChanges(changes) {
23012
- return changes.map(({ path: path25, kind, unifiedDiff }) => ({
23013
- path: path25,
23029
+ return changes.map(({ path: path26, kind, unifiedDiff }) => ({
23030
+ path: path26,
23014
23031
  kind: projectFileChangeKind(kind),
23015
23032
  diff: unifiedDiff
23016
23033
  }));
@@ -23948,13 +23965,13 @@ function decodeThreadForkRequest(request) {
23948
23965
  if (runtimeWorkspaceRoots !== void 0 && runtimeWorkspaceRoots !== null && (!Array.isArray(runtimeWorkspaceRoots) || runtimeWorkspaceRoots.some((root) => typeof root !== "string" || root.length === 0))) {
23949
23966
  throw new Error("thread/fork params.runtimeWorkspaceRoots must be text paths or null");
23950
23967
  }
23951
- const path25 = optionalText(params, "path", { allowEmpty: true });
23968
+ const path26 = optionalText(params, "path", { allowEmpty: true });
23952
23969
  const ephemeral = optionalBoolean(params, "ephemeral");
23953
23970
  return {
23954
23971
  threadId: threadId2,
23955
23972
  ...lastTurnText ? { lastTurnId: hostTurnIdSchema.parse(lastTurnText) } : {},
23956
23973
  ...beforeTurnText ? { beforeTurnId: hostTurnIdSchema.parse(beforeTurnText) } : {},
23957
- ...path25 ? { path: path25 } : {},
23974
+ ...path26 ? { path: path26 } : {},
23958
23975
  ...optionalField(params, "model"),
23959
23976
  ...optionalField(params, "modelProvider"),
23960
23977
  ...optionalField(params, "cwd"),
@@ -25130,9 +25147,9 @@ var HarnessAccountInspectionCache = class {
25130
25147
  };
25131
25148
 
25132
25149
  // packages/host-runtime/src/app-server-host.ts
25133
- import { createHash as createHash6, randomUUID as randomUUID8 } from "node:crypto";
25134
- import os2 from "node:os";
25135
- import path11 from "node:path";
25150
+ import { createHash as createHash6, randomUUID as randomUUID9 } from "node:crypto";
25151
+ import os3 from "node:os";
25152
+ import path12 from "node:path";
25136
25153
 
25137
25154
  // packages/host-runtime/src/external-thread-fork.ts
25138
25155
  import nodePath from "node:path";
@@ -28278,6 +28295,7 @@ async function loadHarnessPlugins(options2) {
28278
28295
  id: manifest.id,
28279
28296
  name: manifest.name,
28280
28297
  version: manifest.version,
28298
+ ...manifest.launchCommand && !options2.context.managedRemoteHost ? { launchCommand: true } : {},
28281
28299
  ...manifest.links ? { links: manifest.links } : {}
28282
28300
  });
28283
28301
  let adapter;
@@ -28288,9 +28306,10 @@ async function loadHarnessPlugins(options2) {
28288
28306
  } else {
28289
28307
  try {
28290
28308
  if (manifest.icon) descriptor.icon = await readPluginIcon(candidate.root, manifest.icon);
28309
+ const launchCommand = descriptor.launchCommand ? await options2.launchCommandForPlugin?.(manifest.id) : void 0;
28291
28310
  adapter = await loadAdapter(
28292
28311
  candidate,
28293
- options2.context,
28312
+ { ...options2.context, ...launchCommand ? { launchCommand } : {} },
28294
28313
  timeoutMs,
28295
28314
  diagnose,
28296
28315
  options2.warmup !== false,
@@ -28318,6 +28337,76 @@ async function loadHarnessPlugins(options2) {
28318
28337
  return registry2;
28319
28338
  }
28320
28339
 
28340
+ // packages/host-runtime/src/harness-launch-settings.ts
28341
+ 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";
28345
+ var HarnessLaunchSettingsStore = class {
28346
+ #directory;
28347
+ #initial = /* @__PURE__ */ new Map();
28348
+ constructor(environment) {
28349
+ this.#directory = path11.join(
28350
+ environment.CODEXHOST_DATA_DIR ? path11.resolve(environment.CODEXHOST_DATA_DIR) : path11.join(os2.homedir(), ".codexhost"),
28351
+ "harness-launch-settings"
28352
+ );
28353
+ }
28354
+ #file(id2) {
28355
+ return path11.join(this.#directory, `${harnessPluginIdSchema.parse(id2)}.json`);
28356
+ }
28357
+ async #read(id2) {
28358
+ try {
28359
+ const value2 = harnessLaunchPathSchema.parse(
28360
+ JSON.parse(await readFile5(this.#file(id2), "utf8"))
28361
+ );
28362
+ if (!path11.isAbsolute(value2)) throw new Error("Expected an absolute entrypoint path");
28363
+ return value2;
28364
+ } catch (error51) {
28365
+ if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
28366
+ return null;
28367
+ throw new Error("Could not read Harness launch settings");
28368
+ }
28369
+ }
28370
+ /** Capture the value used to construct this Host's Adapter; changes require a restart. */
28371
+ async initialCommand(id2) {
28372
+ let initial = this.#initial.get(id2);
28373
+ if (!initial) {
28374
+ initial = this.#read(id2);
28375
+ this.#initial.set(id2, initial);
28376
+ }
28377
+ return await initial ?? void 0;
28378
+ }
28379
+ async get(id2) {
28380
+ const initial = await this.initialCommand(id2) ?? null;
28381
+ const value2 = await this.#read(id2);
28382
+ return { path: value2, restartRequired: value2 !== initial };
28383
+ }
28384
+ async set(id2, value2) {
28385
+ const initial = await this.initialCommand(id2) ?? null;
28386
+ const file2 = this.#file(id2);
28387
+ if (value2 === null) {
28388
+ await rm4(file2, { force: true });
28389
+ } else {
28390
+ value2 = harnessLaunchPathSchema.parse(value2);
28391
+ if (!path11.isAbsolute(value2))
28392
+ throw new Error("Use an absolute entrypoint path without arguments");
28393
+ const metadata = await stat3(value2).catch(() => void 0);
28394
+ if (!metadata?.isDirectory() && !metadata?.isFile())
28395
+ throw new Error("The installation path must be an existing directory on this Host");
28396
+ await mkdir4(this.#directory, { recursive: true, mode: 448 });
28397
+ const temporary = `${file2}.${randomUUID6()}.tmp`;
28398
+ try {
28399
+ await writeFile3(temporary, `${JSON.stringify(value2)}
28400
+ `, { mode: 384, flag: "wx" });
28401
+ await rename3(temporary, file2);
28402
+ } finally {
28403
+ await rm4(temporary, { force: true });
28404
+ }
28405
+ }
28406
+ return { path: value2, restartRequired: value2 !== initial };
28407
+ }
28408
+ };
28409
+
28321
28410
  // packages/host-runtime/src/official-codex-model-ref.ts
28322
28411
  import { Buffer as Buffer2 } from "node:buffer";
28323
28412
  var OFFICIAL_CODEX_MODEL_REF_PREFIX = "codex-model-v1.";
@@ -28508,10 +28597,10 @@ var SingleNativeCodexAccount = class {
28508
28597
  };
28509
28598
 
28510
28599
  // packages/host-runtime/src/codex-runtime/official-runtime-owner.ts
28511
- import { randomUUID as randomUUID7 } from "node:crypto";
28600
+ import { randomUUID as randomUUID8 } from "node:crypto";
28512
28601
 
28513
28602
  // packages/host-runtime/src/official-request-broker.ts
28514
- import { randomUUID as randomUUID6 } from "node:crypto";
28603
+ import { randomUUID as randomUUID7 } from "node:crypto";
28515
28604
  var INTERNAL_REQUEST_PREFIX = "codexhost:official:";
28516
28605
  var MAX_RETIRED_IDS = 1024;
28517
28606
  function isRecord10(value2) {
@@ -28527,7 +28616,7 @@ var OfficialRequestBroker = class {
28527
28616
  constructor(input) {
28528
28617
  this.#send = input.send;
28529
28618
  this.#timeoutMs = input.timeoutMs ?? 3e4;
28530
- this.#nextId = input.nextId ?? (() => `${INTERNAL_REQUEST_PREFIX}${randomUUID6()}`);
28619
+ this.#nextId = input.nextId ?? (() => `${INTERNAL_REQUEST_PREFIX}${randomUUID7()}`);
28531
28620
  }
28532
28621
  get pendingCount() {
28533
28622
  return this.#pending.size;
@@ -28881,7 +28970,7 @@ var OfficialRuntimeOwner = class {
28881
28970
  }
28882
28971
  #attach(role, output, onBackendStopped) {
28883
28972
  const client = {
28884
- id: randomUUID7(),
28973
+ id: randomUUID8(),
28885
28974
  role,
28886
28975
  output,
28887
28976
  ...onBackendStopped ? { onBackendStopped } : {},
@@ -29039,7 +29128,7 @@ var OfficialRuntimeOwner = class {
29039
29128
  if (!object4(value2)) return client.output(event);
29040
29129
  if (typeof value2.id === "string" || typeof value2.id === "number") {
29041
29130
  if (typeof value2.method === "string") {
29042
- const id2 = `codexhost:server:${client.id}:${event.generation}:${randomUUID7()}`;
29131
+ const id2 = `codexhost:server:${client.id}:${event.generation}:${randomUUID8()}`;
29043
29132
  client.serverRequests.set(id2, value2.id);
29044
29133
  const projected = { ...value2, id: id2 };
29045
29134
  return client.output({
@@ -29434,25 +29523,25 @@ function resolveExternalSessionTreeIds(records) {
29434
29523
  const resolve = (start) => {
29435
29524
  const cached2 = resolved.get(start.hostThreadId);
29436
29525
  if (cached2) return cached2;
29437
- const path25 = [];
29526
+ const path26 = [];
29438
29527
  const visited = /* @__PURE__ */ new Set();
29439
29528
  let current = start;
29440
29529
  while (true) {
29441
29530
  const known = resolved.get(current.hostThreadId);
29442
29531
  if (known) {
29443
- for (const record3 of path25) resolved.set(record3.hostThreadId, known);
29532
+ for (const record3 of path26) resolved.set(record3.hostThreadId, known);
29444
29533
  return known;
29445
29534
  }
29446
29535
  if (visited.has(current.hostThreadId)) {
29447
29536
  throw new Error("External Thread Fork tree contains a cycle");
29448
29537
  }
29449
29538
  visited.add(current.hostThreadId);
29450
- path25.push(current);
29539
+ path26.push(current);
29451
29540
  const sourceId = current.subagent?.parentHostThreadId ?? current.forkSource?.hostThreadId;
29452
29541
  const source = sourceId ? byId.get(sourceId) : void 0;
29453
29542
  if (!source) {
29454
29543
  const root = current.hostThreadId;
29455
- for (const record3 of path25) resolved.set(record3.hostThreadId, root);
29544
+ for (const record3 of path26) resolved.set(record3.hostThreadId, root);
29456
29545
  return root;
29457
29546
  }
29458
29547
  current = source;
@@ -29863,6 +29952,7 @@ var AppServerHost = class {
29863
29952
  #nativeAccountObserver;
29864
29953
  #externalAdapters;
29865
29954
  #pluginDescriptors = [];
29955
+ #launchSettings;
29866
29956
  #accountInspections = new HarnessAccountInspectionCache();
29867
29957
  #externalRuntime;
29868
29958
  #externalSteering = new ExternalTurnSteering();
@@ -29904,7 +29994,10 @@ var AppServerHost = class {
29904
29994
  };
29905
29995
  this.#writer = new OrderedWriter(this.#options.desktopOutput);
29906
29996
  const environment = this.#options.environment ?? process.env;
29907
- const permanentHome = path11.resolve(environment.CODEX_HOME ?? path11.join(os2.homedir(), ".codex"));
29997
+ this.#launchSettings = new HarnessLaunchSettingsStore(
29998
+ this.#options.pluginContext?.environment ?? environment
29999
+ );
30000
+ const permanentHome = path12.resolve(environment.CODEX_HOME ?? path12.join(os3.homedir(), ".codex"));
29908
30001
  this.#ownsOfficialRuntimeScope = options2.officialRuntimeScope === void 0;
29909
30002
  this.#officialRuntimeScope = options2.officialRuntimeScope ?? new OfficialRuntimeScope({
29910
30003
  diagnosticOutput: this.#options.diagnosticOutput,
@@ -30051,6 +30144,7 @@ var AppServerHost = class {
30051
30144
  if (!this.#options.pluginRoots || this.#pluginLoadAbort.signal.aborted) return;
30052
30145
  const plugins = await loadHarnessPlugins({
30053
30146
  roots: this.#options.pluginRoots,
30147
+ launchCommandForPlugin: (id2) => this.#launchSettings.initialCommand(id2),
30054
30148
  context: this.#options.pluginContext ?? {
30055
30149
  environment: this.#options.environment ?? process.env,
30056
30150
  platform: process.platform,
@@ -30323,6 +30417,41 @@ var AppServerHost = class {
30323
30417
  this.#dispatchDesktopRequest(() => this.#openHarnessWebUi(request));
30324
30418
  return;
30325
30419
  }
30420
+ if (request.method === HARNESS_LAUNCH_SETTINGS_GET_METHOD || request.method === HARNESS_LAUNCH_SETTINGS_SET_METHOD) {
30421
+ this.#dispatchDesktopRequest(async () => {
30422
+ const schema = request.method === HARNESS_LAUNCH_SETTINGS_SET_METHOD ? harnessLaunchSettingsSetSchema : harnessLaunchSettingsGetSchema;
30423
+ const params = schema.safeParse(request.params);
30424
+ if (!params.success) {
30425
+ await this.#writer.json(rpcError(request, -32602, "Invalid Harness launch settings"));
30426
+ return;
30427
+ }
30428
+ await this.#waitForPlugins();
30429
+ if (!this.#pluginDescriptors.some(
30430
+ (plugin) => plugin.id === params.data.harnessId && plugin.launchCommand
30431
+ )) {
30432
+ await this.#writer.json(
30433
+ rpcError(request, -32602, "Harness launch settings are unavailable")
30434
+ );
30435
+ return;
30436
+ }
30437
+ try {
30438
+ const result = request.method === HARNESS_LAUNCH_SETTINGS_SET_METHOD ? await this.#launchSettings.set(
30439
+ params.data.harnessId,
30440
+ harnessLaunchSettingsSetSchema.parse(request.params).path
30441
+ ) : await this.#launchSettings.get(params.data.harnessId);
30442
+ await this.#writer.json(rpcEnvelope(request, { result: jsonValueSchema.parse(result) }));
30443
+ } catch {
30444
+ await this.#writer.json(
30445
+ rpcError(
30446
+ request,
30447
+ -32602,
30448
+ "Could not read or save launch settings. Use an existing absolute installation directory on this Host, without arguments, and check configuration permissions."
30449
+ )
30450
+ );
30451
+ }
30452
+ });
30453
+ return;
30454
+ }
30326
30455
  if (request.method === "codexhost/harness/plugins/list") {
30327
30456
  this.#dispatchDesktopRequest(async () => {
30328
30457
  if (!harnessPluginListParamsSchema.safeParse(request.params).success) {
@@ -31008,7 +31137,7 @@ var AppServerHost = class {
31008
31137
  throw error51;
31009
31138
  }
31010
31139
  this.#activeOfficialTurns.set(threadId2, turnId);
31011
- const delegationId = hostThreadIdSchema.parse(randomUUID8());
31140
+ const delegationId = hostThreadIdSchema.parse(randomUUID9());
31012
31141
  try {
31013
31142
  const source = await this.#repository.find(input.parentThreadId);
31014
31143
  const pendingTerminal = this.#pendingOfficialTerminalStatuses.get(threadId2);
@@ -31172,7 +31301,7 @@ var AppServerHost = class {
31172
31301
  async #listDelegationThreads(input) {
31173
31302
  const [sortKey, sortDirection2] = input.sort.split("-");
31174
31303
  const request = {
31175
- id: `codexhost:delegation-list:${randomUUID8()}`,
31304
+ id: `codexhost:delegation-list:${randomUUID9()}`,
31176
31305
  method: "thread/list",
31177
31306
  params: {
31178
31307
  cwd: input.cwd ? [input.cwd] : null,
@@ -31618,7 +31747,7 @@ var AppServerHost = class {
31618
31747
  );
31619
31748
  return;
31620
31749
  }
31621
- const turnId = requestedTurnId ?? hostTurnIdSchema.parse(randomUUID8());
31750
+ const turnId = requestedTurnId ?? hostTurnIdSchema.parse(randomUUID9());
31622
31751
  const projection = {
31623
31752
  projector: new CodexTurnProjector({
31624
31753
  threadId: thread.id,
@@ -32485,7 +32614,7 @@ var AppServerHost = class {
32485
32614
  if (thread.running || thread.activeTurnId || this.#pendingExternalCommandRequests.has(thread.id)) {
32486
32615
  throw new ExternalSteerError(-32072, "External Thread already has an active Turn");
32487
32616
  }
32488
- const turnId = hostTurnIdSchema.parse(randomUUID8());
32617
+ const turnId = hostTurnIdSchema.parse(randomUUID9());
32489
32618
  const startedAtMs = Date.now();
32490
32619
  const projection = {
32491
32620
  projector: new CodexTurnProjector({
@@ -33033,7 +33162,7 @@ var AppServerHost = class {
33033
33162
  try {
33034
33163
  result = projection.projector.projectQuestion(
33035
33164
  interaction,
33036
- hostItemIdSchema.parse(randomUUID8())
33165
+ hostItemIdSchema.parse(randomUUID9())
33037
33166
  );
33038
33167
  } catch (error51) {
33039
33168
  this.#diagnose(error51);
@@ -33199,9 +33328,9 @@ var AppServerHost = class {
33199
33328
  };
33200
33329
 
33201
33330
  // packages/host-runtime/src/native-account-host.ts
33202
- import { mkdir as mkdir6, realpath as realpath3 } from "node:fs/promises";
33331
+ import { mkdir as mkdir7, realpath as realpath3 } from "node:fs/promises";
33203
33332
  import { homedir } from "node:os";
33204
- import path15 from "node:path";
33333
+ import path16 from "node:path";
33205
33334
 
33206
33335
  // packages/host-runtime/src/codex-runtime/owned-official-backends.ts
33207
33336
  import { createHash as createHash7, randomBytes } from "node:crypto";
@@ -33210,8 +33339,8 @@ import { Writable as Writable2 } from "node:stream";
33210
33339
  // packages/host-runtime/src/remote-app-server.ts
33211
33340
  import { createServer } from "node:http";
33212
33341
  import net from "node:net";
33213
- import { chmod as chmod3, lstat as lstat6, mkdir as mkdir5, rm as rm5 } from "node:fs/promises";
33214
- import path13 from "node:path";
33342
+ import { chmod as chmod3, lstat as lstat6, mkdir as mkdir6, rm as rm6 } from "node:fs/promises";
33343
+ import path14 from "node:path";
33215
33344
  import { PassThrough } from "node:stream";
33216
33345
 
33217
33346
  // node_modules/ws/wrapper.mjs
@@ -33226,10 +33355,10 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
33226
33355
  var wrapper_default = import_websocket.default;
33227
33356
 
33228
33357
  // packages/host-runtime/src/remote-socket-lock.ts
33229
- import { randomUUID as randomUUID9 } from "node:crypto";
33230
- import { chmod as chmod2, lstat as lstat5, mkdir as mkdir4, open as open5, readFile as readFile5, readdir as readdir4, rename as rename3, rm as rm4 } from "node:fs/promises";
33358
+ 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";
33231
33360
  import { uptime } from "node:os";
33232
- import path12 from "node:path";
33361
+ import path13 from "node:path";
33233
33362
  import { setTimeout as delay4 } from "node:timers/promises";
33234
33363
  var LOCK_RETRY_COUNT = 200;
33235
33364
  var LOCK_RETRY_DELAY_MS = 25;
@@ -33292,7 +33421,7 @@ async function readLockEntrySnapshot(filePath) {
33292
33421
  throw error51;
33293
33422
  });
33294
33423
  if (metadata === null || !metadata.isFile()) return null;
33295
- const source = await readFile5(filePath, "utf8").catch((error51) => {
33424
+ const source = await readFile6(filePath, "utf8").catch((error51) => {
33296
33425
  if (error51.code === "ENOENT") return null;
33297
33426
  throw error51;
33298
33427
  });
@@ -33303,7 +33432,7 @@ async function readLockEntrySnapshot(filePath) {
33303
33432
  source,
33304
33433
  identity: { dev: metadata.dev, ino: metadata.ino },
33305
33434
  mtimeMs: metadata.mtimeMs,
33306
- record: record3 && path12.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
33435
+ record: record3 && path13.basename(filePath) === lockEntryName(record3.ownerToken) ? record3 : null
33307
33436
  };
33308
33437
  }
33309
33438
  function lockEntryIsAbandoned(snapshot) {
@@ -33315,7 +33444,7 @@ async function removeAbandonedLockEntry(snapshot) {
33315
33444
  if (current === null || current.source !== snapshot.source || !sameUnixFileIdentity(current.identity, snapshot.identity) || !lockEntryIsAbandoned(current)) {
33316
33445
  return false;
33317
33446
  }
33318
- await rm4(snapshot.filePath, { force: true });
33447
+ await rm5(snapshot.filePath, { force: true });
33319
33448
  return true;
33320
33449
  }
33321
33450
  async function readLockEntryCatalog(lockDirectory) {
@@ -33324,7 +33453,7 @@ async function readLockEntryCatalog(lockDirectory) {
33324
33453
  let unsettled = false;
33325
33454
  for (const name of names) {
33326
33455
  if (!name.startsWith(LOCK_ENTRY_PREFIX) || !name.endsWith(LOCK_ENTRY_SUFFIX)) continue;
33327
- const snapshot = await readLockEntrySnapshot(path12.join(lockDirectory, name));
33456
+ const snapshot = await readLockEntrySnapshot(path13.join(lockDirectory, name));
33328
33457
  if (snapshot === null) continue;
33329
33458
  if (lockEntryIsAbandoned(snapshot)) {
33330
33459
  if (!await removeAbandonedLockEntry(snapshot)) unsettled = true;
@@ -33339,7 +33468,7 @@ async function readLockEntryCatalog(lockDirectory) {
33339
33468
  return { entries, unsettled };
33340
33469
  }
33341
33470
  async function preparePrivateLockDirectory(lockDirectory) {
33342
- await mkdir4(lockDirectory, { mode: 448 }).catch((error51) => {
33471
+ await mkdir5(lockDirectory, { mode: 448 }).catch((error51) => {
33343
33472
  if (error51.code !== "EEXIST") throw error51;
33344
33473
  });
33345
33474
  const metadata = await lstat5(lockDirectory);
@@ -33352,7 +33481,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
33352
33481
  await chmod2(lockDirectory, 448);
33353
33482
  }
33354
33483
  async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
33355
- const temporary = path12.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID9()}`);
33484
+ const temporary = path13.join(lockDirectory, `.tmp-${record3.ownerToken}-${randomUUID10()}`);
33356
33485
  const handle = await open5(temporary, "wx", 384);
33357
33486
  try {
33358
33487
  await handle.writeFile(`${JSON.stringify(record3)}
@@ -33362,15 +33491,15 @@ async function writeLockRecordAtomic(lockDirectory, entryPath, record3) {
33362
33491
  await handle.close();
33363
33492
  }
33364
33493
  try {
33365
- await rename3(temporary, entryPath);
33494
+ await rename4(temporary, entryPath);
33366
33495
  } finally {
33367
- await rm4(temporary, { force: true });
33496
+ await rm5(temporary, { force: true });
33368
33497
  }
33369
33498
  }
33370
33499
  async function removeOwnedLockEntry(entryPath, ownerToken) {
33371
33500
  const snapshot = await readLockEntrySnapshot(entryPath);
33372
33501
  if (snapshot?.record?.ownerToken !== ownerToken) return;
33373
- await rm4(entryPath, { force: true });
33502
+ await rm5(entryPath, { force: true });
33374
33503
  }
33375
33504
  async function legacyLockState(legacyPath) {
33376
33505
  const metadata = await lstat5(legacyPath).catch((error51) => {
@@ -33379,7 +33508,7 @@ async function legacyLockState(legacyPath) {
33379
33508
  });
33380
33509
  if (metadata === null) return "absent";
33381
33510
  if (!metadata.isFile()) return "blocking";
33382
- const source = await readFile5(legacyPath, "utf8").catch((error51) => {
33511
+ const source = await readFile6(legacyPath, "utf8").catch((error51) => {
33383
33512
  if (error51.code === "ENOENT") return null;
33384
33513
  throw error51;
33385
33514
  });
@@ -33416,7 +33545,7 @@ async function releaseLegacyCompatibilityGuard(legacyPath, guard) {
33416
33545
  throw error51;
33417
33546
  });
33418
33547
  if (metadata?.isFile() && sameUnixFileIdentity({ dev: metadata.dev, ino: metadata.ino }, guard.identity)) {
33419
- await rm4(legacyPath, { force: true });
33548
+ await rm5(legacyPath, { force: true });
33420
33549
  }
33421
33550
  }
33422
33551
  }
@@ -33427,8 +33556,8 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
33427
33556
  const legacyPath = `${socketPath}.initializing`;
33428
33557
  const lockDirectory = `${socketPath}.initializers`;
33429
33558
  await preparePrivateLockDirectory(lockDirectory);
33430
- const ownerToken = randomUUID9();
33431
- const entryPath = path12.join(lockDirectory, lockEntryName(ownerToken));
33559
+ const ownerToken = randomUUID10();
33560
+ const entryPath = path13.join(lockDirectory, lockEntryName(ownerToken));
33432
33561
  const baseRecord = {
33433
33562
  version: 2,
33434
33563
  ownerToken,
@@ -33602,14 +33731,14 @@ function remoteAppServerSocketPath(environment, listenUrl = "unix://") {
33602
33731
  throw new Error("Remote app-server listener must use a Unix URL");
33603
33732
  }
33604
33733
  const explicit = listenUrl.slice("unix://".length);
33605
- if (explicit.length > 0) return path13.posix.resolve(decodeURIComponent(explicit));
33606
- const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path13.posix.join(environment.HOME, ".codex") : void 0);
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);
33607
33736
  if (!codexHome)
33608
33737
  throw new Error("CODEX_HOME or HOME is required for the remote app-server socket");
33609
- return path13.posix.join(codexHome, "app-server-control", "app-server-control.sock");
33738
+ return path14.posix.join(codexHome, "app-server-control", "app-server-control.sock");
33610
33739
  }
33611
33740
  function officialListenerArgumentsForRemoteListener(arguments_2, socketPath) {
33612
- if (!path13.posix.isAbsolute(socketPath)) {
33741
+ if (!path14.posix.isAbsolute(socketPath)) {
33613
33742
  throw new Error("Shared official app-server socket path must be absolute");
33614
33743
  }
33615
33744
  if (remoteUnixListenerUrl(arguments_2) === null) {
@@ -33717,10 +33846,10 @@ async function removeStaleSocket(socketPath) {
33717
33846
  });
33718
33847
  });
33719
33848
  if (active) throw new Error(`Remote app-server socket is already in use at ${socketPath}`);
33720
- await rm5(socketPath, { force: true });
33849
+ await rm6(socketPath, { force: true });
33721
33850
  }
33722
33851
  async function prepareRemoteAppServerSocketDirectory(socketPath) {
33723
- const socketDirectory = path13.dirname(socketPath);
33852
+ const socketDirectory = path14.dirname(socketPath);
33724
33853
  const existing = await lstat6(socketDirectory).catch((error51) => {
33725
33854
  if (error51.code === "ENOENT") return null;
33726
33855
  throw error51;
@@ -33734,7 +33863,7 @@ async function prepareRemoteAppServerSocketDirectory(socketPath) {
33734
33863
  );
33735
33864
  }
33736
33865
  }
33737
- await mkdir5(socketDirectory, { recursive: true, mode: 448 });
33866
+ await mkdir6(socketDirectory, { recursive: true, mode: 448 });
33738
33867
  await chmod3(socketDirectory, 448);
33739
33868
  }
33740
33869
  function sendOutputFrames(socket, output) {
@@ -33907,7 +34036,7 @@ function createRemoteAppServerWebSocketListener(input) {
33907
34036
  if (ownedSocketIdentity) {
33908
34037
  const current = await unixSocketIdentity(input.socketPath);
33909
34038
  if (current && sameUnixFileIdentity2(current, ownedSocketIdentity)) {
33910
- await rm5(input.socketPath, { force: true });
34039
+ await rm6(input.socketPath, { force: true });
33911
34040
  }
33912
34041
  ownedSocketIdentity = null;
33913
34042
  }
@@ -33925,20 +34054,20 @@ function createRemoteAppServerWebSocketListener(input) {
33925
34054
 
33926
34055
  // packages/host-runtime/src/remote-official-app-server.ts
33927
34056
  import { spawn as spawn3 } from "node:child_process";
33928
- import { randomUUID as randomUUID10 } from "node:crypto";
33929
- import { lstat as lstat7, rm as rm6 } from "node:fs/promises";
33930
- import path14 from "node:path";
34057
+ import { randomUUID as randomUUID11 } from "node:crypto";
34058
+ import { lstat as lstat7, rm as rm7 } from "node:fs/promises";
34059
+ import path15 from "node:path";
33931
34060
  var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
33932
34061
  var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
33933
- function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID10()) {
33934
- if (!path14.posix.isAbsolute(desktopControlSocketPath)) {
34062
+ function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID11()) {
34063
+ if (!path15.posix.isAbsolute(desktopControlSocketPath)) {
33935
34064
  throw new Error("Desktop control socket path must be absolute");
33936
34065
  }
33937
34066
  if (!/^[A-Za-z0-9-]+$/u.test(token) || !/[A-Za-z0-9]/u.test(token)) {
33938
34067
  throw new Error("Shared official app-server socket token is invalid");
33939
34068
  }
33940
34069
  const compactToken = token.replaceAll("-", "").slice(0, 15);
33941
- return path14.posix.join(path14.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
34070
+ return path15.posix.join(path15.posix.dirname(desktopControlSocketPath), `.c-${compactToken}.sock`);
33942
34071
  }
33943
34072
  function errorMessage4(error51) {
33944
34073
  return error51 instanceof Error ? error51.message : String(error51);
@@ -34010,7 +34139,7 @@ function createRemoteOfficialAppServerListener(input) {
34010
34139
  if (ownedSocketIdentity === null) return;
34011
34140
  const current = await socketIdentity(input.socketPath).catch(() => null);
34012
34141
  if (current && sameUnixFileIdentity3(current, ownedSocketIdentity)) {
34013
- await rm6(input.socketPath, { force: true });
34142
+ await rm7(input.socketPath, { force: true });
34014
34143
  }
34015
34144
  ownedSocketIdentity = null;
34016
34145
  };
@@ -34424,21 +34553,21 @@ function createOwnedUnixBackend(input) {
34424
34553
 
34425
34554
  // packages/host-runtime/src/native-account-host.ts
34426
34555
  async function canonicalCodexHome(home) {
34427
- const absolute = path15.resolve(home);
34556
+ const absolute = path16.resolve(home);
34428
34557
  try {
34429
34558
  return await realpath3(absolute);
34430
34559
  } catch (error51) {
34431
34560
  if (!(error51 instanceof Error && "code" in error51 && error51.code === "ENOENT")) throw error51;
34432
- const parent = path15.dirname(absolute);
34561
+ const parent = path16.dirname(absolute);
34433
34562
  if (parent === absolute) throw error51;
34434
- return path15.join(await canonicalCodexHome(parent), path15.basename(absolute));
34563
+ return path16.join(await canonicalCodexHome(parent), path16.basename(absolute));
34435
34564
  }
34436
34565
  }
34437
34566
  async function prepareLocalCodex(input) {
34438
34567
  const home = await canonicalCodexHome(
34439
- input.environment.CODEX_HOME ?? path15.join(homedir(), ".codex")
34568
+ input.environment.CODEX_HOME ?? path16.join(homedir(), ".codex")
34440
34569
  );
34441
- await mkdir6(home, { recursive: true });
34570
+ await mkdir7(home, { recursive: true });
34442
34571
  const scope = new OfficialRuntimeScope({
34443
34572
  permanentHome: home,
34444
34573
  diagnosticOutput: input.diagnosticOutput,
@@ -34602,18 +34731,18 @@ var DelegationControlRegistry = class {
34602
34731
  };
34603
34732
 
34604
34733
  // packages/host-runtime/src/installed-harness-plugins.ts
34605
- import os3 from "node:os";
34606
- import path17 from "node:path";
34734
+ import os4 from "node:os";
34735
+ import path18 from "node:path";
34607
34736
  import { fileURLToPath } from "node:url";
34608
34737
 
34609
34738
  // packages/host-runtime/src/launcher-url-opener.ts
34610
34739
  import { spawn as spawn4 } from "node:child_process";
34611
- import path16 from "node:path";
34740
+ import path17 from "node:path";
34612
34741
  var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
34613
34742
  var OPEN_TIMEOUT_MS = 1e4;
34614
34743
  function createLauncherUrlOpener(environment, spawnLauncher = (command, arguments_2, options2) => spawn4(command, arguments_2, options2)) {
34615
34744
  const launcher = environment.CODEXHOST_LAUNCHER_EXECUTABLE;
34616
- if (!launcher || !path16.isAbsolute(launcher)) return void 0;
34745
+ if (!launcher || !path17.isAbsolute(launcher)) return void 0;
34617
34746
  const launcherEnvironment = Object.fromEntries(
34618
34747
  Object.entries(environment).filter(([name]) => {
34619
34748
  const normalized = name.toUpperCase();
@@ -34671,9 +34800,9 @@ function installedHarnessPluginOptions(environment, managedRemoteHost = false, h
34671
34800
  const opener = managedRemoteHost ? void 0 : createLauncherUrlOpener(environment);
34672
34801
  return {
34673
34802
  pluginRoots: [
34674
- path17.join(path17.dirname(fileURLToPath(hostRuntimeUrl)), "plugins"),
34675
- environment[HARNESS_PLUGIN_DIRECTORY_ENV] ?? path17.join(
34676
- environment.CODEXHOST_DATA_DIR ? path17.resolve(environment.CODEXHOST_DATA_DIR) : path17.join(os3.homedir(), ".codexhost"),
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"),
34677
34806
  "plugins"
34678
34807
  )
34679
34808
  ],
@@ -34798,12 +34927,12 @@ async function startDelegationControlServer(input) {
34798
34927
  }
34799
34928
 
34800
34929
  // packages/host-runtime/src/delegation-skill.ts
34801
- import { createHash as createHash8, randomUUID as randomUUID11 } from "node:crypto";
34802
- import { mkdir as mkdir7, open as open6, readFile as readFile6, rename as rename4, rm as rm7, stat as stat3 } from "node:fs/promises";
34803
- import os4 from "node:os";
34804
- import path18 from "node:path";
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";
34805
34934
  var SKILL_VERSION = 7;
34806
- var SKILL_RELATIVE_PATH = path18.join("skills", "codexhost-delegation", "SKILL.md");
34935
+ var SKILL_RELATIVE_PATH = path19.join("skills", "codexhost-delegation", "SKILL.md");
34807
34936
  var PREVIOUS_MANAGED_DIGESTS = [
34808
34937
  "9d2f491850fb0b4084a31ba9b5e4a550b5e833747af322090d8ed0ff80b88c30",
34809
34938
  "2bb0aebb9b06febbc6c0c0bcdb0b32506c7cdbf8dc3b734cc6b2a86621270e4e",
@@ -34868,15 +34997,15 @@ function managedVersion(value2) {
34868
34997
  }
34869
34998
  async function readOptional(filePath) {
34870
34999
  try {
34871
- return await readFile6(filePath, "utf8");
35000
+ return await readFile7(filePath, "utf8");
34872
35001
  } catch (error51) {
34873
35002
  if (error51.code === "ENOENT") return null;
34874
35003
  throw error51;
34875
35004
  }
34876
35005
  }
34877
35006
  async function atomicWrite(filePath, content) {
34878
- await mkdir7(path18.dirname(filePath), { recursive: true, mode: 448 });
34879
- const temporaryPath = path18.join(path18.dirname(filePath), `.SKILL.md.${randomUUID11()}.tmp`);
35007
+ await mkdir8(path19.dirname(filePath), { recursive: true, mode: 448 });
35008
+ const temporaryPath = path19.join(path19.dirname(filePath), `.SKILL.md.${randomUUID12()}.tmp`);
34880
35009
  const handle = await open6(temporaryPath, "wx", 384);
34881
35010
  try {
34882
35011
  await handle.writeFile(content, "utf8");
@@ -34885,16 +35014,16 @@ async function atomicWrite(filePath, content) {
34885
35014
  await handle.close();
34886
35015
  }
34887
35016
  try {
34888
- await rename4(temporaryPath, filePath);
35017
+ await rename5(temporaryPath, filePath);
34889
35018
  } finally {
34890
- await rm7(temporaryPath, { force: true });
35019
+ await rm8(temporaryPath, { force: true });
34891
35020
  }
34892
35021
  }
34893
35022
  async function installDelegationSkills(input = {}) {
34894
- const home = input.homeDirectory ?? os4.homedir();
35023
+ const home = input.homeDirectory ?? os5.homedir();
34895
35024
  const destinations = [
34896
- path18.join(home, ".agents", SKILL_RELATIVE_PATH),
34897
- path18.join(home, ".claude", SKILL_RELATIVE_PATH)
35025
+ path19.join(home, ".agents", SKILL_RELATIVE_PATH),
35026
+ path19.join(home, ".claude", SKILL_RELATIVE_PATH)
34898
35027
  ];
34899
35028
  const knownDigests = /* @__PURE__ */ new Set([
34900
35029
  CURRENT_DIGEST,
@@ -34939,8 +35068,8 @@ async function installDelegationSkills(input = {}) {
34939
35068
  }
34940
35069
  for (const result of results) {
34941
35070
  if (result.status === "conflict") continue;
34942
- const source = await readFile6(result.path, "utf8");
34943
- const metadata = await stat3(result.path);
35071
+ const source = await readFile7(result.path, "utf8");
35072
+ const metadata = await stat4(result.path);
34944
35073
  if (!metadata.isFile() || source !== CODEXHOST_DELEGATION_SKILL) {
34945
35074
  throw new Error(`Delegation Skill verification failed: ${result.path}`);
34946
35075
  }
@@ -34950,7 +35079,7 @@ async function installDelegationSkills(input = {}) {
34950
35079
  throw new Error("Delegation Skill copies are inconsistent");
34951
35080
  }
34952
35081
  if (results.every((result) => result.status !== "conflict")) {
34953
- const copies = await Promise.all(results.map((result) => readFile6(result.path, "utf8")));
35082
+ const copies = await Promise.all(results.map((result) => readFile7(result.path, "utf8")));
34954
35083
  if (copies.some((copy) => copy !== copies[0])) {
34955
35084
  throw new Error("Delegation Skill copies are inconsistent");
34956
35085
  }
@@ -34959,9 +35088,9 @@ async function installDelegationSkills(input = {}) {
34959
35088
  }
34960
35089
 
34961
35090
  // packages/host-runtime/src/remote-control-app-server.ts
34962
- import { randomUUID as randomUUID12 } from "node:crypto";
34963
- import { mkdir as mkdir8, open as open7, rename as rename5, rm as rm8 } from "node:fs/promises";
34964
- import path19 from "node:path";
35091
+ import { randomUUID as randomUUID13 } from "node:crypto";
35092
+ import { mkdir as mkdir9, open as open7, rename as rename6, rm as rm9 } from "node:fs/promises";
35093
+ import path20 from "node:path";
34965
35094
  var REMOTE_CONTROL_BRIDGE_PIPE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_PIPE";
34966
35095
  var REMOTE_CONTROL_BRIDGE_NODE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_NODE_PATH";
34967
35096
  var REMOTE_CONTROL_BRIDGE_RUNTIME_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_RUNTIME_PATH";
@@ -34972,30 +35101,30 @@ var BRIDGE_READY_METHOD = "codexhost/remote-control-bridge/ready";
34972
35101
  function absoluteEnvironmentPath2(environment, name, fallback, platform = process.platform) {
34973
35102
  const value2 = environment[name] ?? fallback;
34974
35103
  if (!value2) return null;
34975
- if (path19.isAbsolute(value2)) return path19.normalize(value2);
34976
- return platform === "win32" && path19.win32.isAbsolute(value2) ? path19.win32.normalize(value2) : null;
35104
+ if (path20.isAbsolute(value2)) return path20.normalize(value2);
35105
+ return platform === "win32" && path20.win32.isAbsolute(value2) ? path20.win32.normalize(value2) : null;
34977
35106
  }
34978
35107
  function nodeCompatibleWindowsPath(value2) {
34979
35108
  if (value2.startsWith("\\\\?\\UNC\\")) return `\\\\${value2.slice(8)}`;
34980
35109
  if (value2.startsWith("\\\\?\\")) return value2.slice(4);
34981
35110
  return value2;
34982
35111
  }
34983
- function remoteControlBridgePipePath(processId = process.pid, instanceId = randomUUID12()) {
35112
+ function remoteControlBridgePipePath(processId = process.pid, instanceId = randomUUID13()) {
34984
35113
  const safeInstance = instanceId.replaceAll(/[^a-zA-Z0-9-]/gu, "");
34985
35114
  if (!safeInstance) throw new Error("Remote Control bridge instance ID is invalid");
34986
35115
  return `\\\\.\\pipe\\codexhost-remote-control-${processId}-${safeInstance}`;
34987
35116
  }
34988
35117
  function remoteControlBridgeDescriptorPath(environment) {
34989
35118
  const root = environment.LOCALAPPDATA;
34990
- if (!root || !path19.isAbsolute(root)) return null;
34991
- return path19.join(path19.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
35119
+ if (!root || !path20.isAbsolute(root)) return null;
35120
+ return path20.join(path20.normalize(root), "codexhost", REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE);
34992
35121
  }
34993
35122
  async function publishRemoteControlAppServerDescriptor(plan) {
34994
- const directory = path19.dirname(plan.descriptorPath);
34995
- await mkdir8(directory, { recursive: true, mode: 448 });
34996
- const temporaryPath = path19.join(
35123
+ const directory = path20.dirname(plan.descriptorPath);
35124
+ await mkdir9(directory, { recursive: true, mode: 448 });
35125
+ const temporaryPath = path20.join(
34997
35126
  directory,
34998
- `.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID12()}.tmp`
35127
+ `.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID13()}.tmp`
34999
35128
  );
35000
35129
  const handle = await open7(temporaryPath, "wx", 384);
35001
35130
  try {
@@ -35006,9 +35135,9 @@ async function publishRemoteControlAppServerDescriptor(plan) {
35006
35135
  await handle.close();
35007
35136
  }
35008
35137
  try {
35009
- await rename5(temporaryPath, plan.descriptorPath);
35138
+ await rename6(temporaryPath, plan.descriptorPath);
35010
35139
  } finally {
35011
- await rm8(temporaryPath, { force: true });
35140
+ await rm9(temporaryPath, { force: true });
35012
35141
  }
35013
35142
  }
35014
35143
  function createRemoteControlAppServerPlan(input) {
@@ -35294,9 +35423,9 @@ function hasLauncherManagedUpdateRuntime(environment, hostRuntimePath) {
35294
35423
  if (!environment[UPDATE_RUNTIME_ENV.launcherPid]) return false;
35295
35424
  const npmPackageRoot = environment[UPDATE_RUNTIME_ENV.npmPackageRoot];
35296
35425
  if (!npmPackageRoot || !hostRuntimePath) return true;
35297
- if (!path20.isAbsolute(npmPackageRoot) || !path20.isAbsolute(hostRuntimePath)) return false;
35298
- const runtimePackageRoot = path20.dirname(path20.dirname(path20.normalize(hostRuntimePath)));
35299
- return path20.relative(path20.normalize(npmPackageRoot), runtimePackageRoot) === "";
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) === "";
35300
35429
  }
35301
35430
  function requiredRuntimeConfiguration(environment) {
35302
35431
  const stockCodexPath = environment[STOCK_CODEX_PATH_ENV];
@@ -35442,8 +35571,8 @@ async function runHostRuntime(input) {
35442
35571
  const socketPath = remoteAppServerSocketPath(delegationEnvironment, listenUrl);
35443
35572
  const officialPlan = createRemoteOfficialAppServerPlan(input.arguments, socketPath);
35444
35573
  const officialRuntimeScope = new OfficialRuntimeScope({
35445
- permanentHome: path20.resolve(
35446
- delegationEnvironment.CODEX_HOME ?? path20.join(homedir2(), ".codex")
35574
+ permanentHome: path21.resolve(
35575
+ delegationEnvironment.CODEX_HOME ?? path21.join(homedir2(), ".codex")
35447
35576
  ),
35448
35577
  diagnosticOutput: process.stderr,
35449
35578
  createBackend: () => createOwnedUnixBackend({
@@ -35524,22 +35653,22 @@ async function runHostRuntime(input) {
35524
35653
  }
35525
35654
 
35526
35655
  // packages/host-runtime/src/remote-host-install.ts
35527
- import { createHash as createHash9, randomUUID as randomUUID13 } from "node:crypto";
35656
+ import { createHash as createHash9, randomUUID as randomUUID14 } from "node:crypto";
35528
35657
  import { constants as fsConstants } from "node:fs";
35529
35658
  import {
35530
35659
  access,
35531
35660
  chmod as chmod4,
35532
35661
  copyFile as copyFile3,
35533
35662
  lstat as lstat8,
35534
- mkdir as mkdir9,
35535
- readFile as readFile7,
35536
- rename as rename6,
35537
- rm as rm9,
35663
+ mkdir as mkdir10,
35664
+ readFile as readFile8,
35665
+ rename as rename7,
35666
+ rm as rm10,
35538
35667
  rmdir,
35539
- stat as stat4,
35540
- writeFile as writeFile3
35668
+ stat as stat5,
35669
+ writeFile as writeFile4
35541
35670
  } from "node:fs/promises";
35542
- import path21 from "node:path";
35671
+ import path22 from "node:path";
35543
35672
  var MANIFEST_FORMAT = 1;
35544
35673
  var WRAPPER_MARKER = "# codexhost remote SSH wrapper v1";
35545
35674
  var PROFILE_START = "# >>> codexhost remote SSH >>>";
@@ -35550,25 +35679,25 @@ function resolvePaths(options2) {
35550
35679
  if (!configuredHome) {
35551
35680
  throw new Error("A non-root HOME is required for remote Host installation");
35552
35681
  }
35553
- const home = path21.resolve(configuredHome);
35554
- if (!home || home === path21.parse(home).root) {
35682
+ const home = path22.resolve(configuredHome);
35683
+ if (!home || home === path22.parse(home).root) {
35555
35684
  throw new Error("A non-root HOME is required for remote Host installation");
35556
35685
  }
35557
- const installRoot = path21.resolve(options2.installRoot ?? path21.join(home, ".codexhost", "remote"));
35558
- const profilePath = path21.resolve(
35559
- options2.profilePath ?? path21.join(
35686
+ const installRoot = path22.resolve(options2.installRoot ?? path22.join(home, ".codexhost", "remote"));
35687
+ const profilePath = path22.resolve(
35688
+ options2.profilePath ?? path22.join(
35560
35689
  home,
35561
- path21.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path21.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
35690
+ path22.basename(environment.SHELL ?? "") === "zsh" ? ".zshenv" : path22.basename(environment.SHELL ?? "") === "bash" ? ".bashrc" : ".profile"
35562
35691
  )
35563
35692
  );
35564
- const binDirectory = path21.join(installRoot, "bin");
35693
+ const binDirectory = path22.join(installRoot, "bin");
35565
35694
  return {
35566
35695
  home,
35567
35696
  installRoot,
35568
35697
  binDirectory,
35569
- wrapperPath: path21.join(binDirectory, "codex"),
35570
- manifestPath: path21.join(installRoot, "manifest.json"),
35571
- dataDirectory: path21.join(installRoot, "data"),
35698
+ wrapperPath: path22.join(binDirectory, "codex"),
35699
+ manifestPath: path22.join(installRoot, "manifest.json"),
35700
+ dataDirectory: path22.join(installRoot, "data"),
35572
35701
  profilePath
35573
35702
  };
35574
35703
  }
@@ -35577,19 +35706,19 @@ function shellQuote(value2) {
35577
35706
  }
35578
35707
  async function existingText(filePath) {
35579
35708
  try {
35580
- return await readFile7(filePath, "utf8");
35709
+ return await readFile8(filePath, "utf8");
35581
35710
  } catch (error51) {
35582
35711
  if (error51.code === "ENOENT") return null;
35583
35712
  throw error51;
35584
35713
  }
35585
35714
  }
35586
35715
  async function fileSha256(filePath) {
35587
- return createHash9("sha256").update(await readFile7(filePath)).digest("hex");
35716
+ return createHash9("sha256").update(await readFile8(filePath)).digest("hex");
35588
35717
  }
35589
35718
  async function executable(filePath, label) {
35590
- const absolute = path21.resolve(filePath);
35719
+ const absolute = path22.resolve(filePath);
35591
35720
  try {
35592
- if (!(await stat4(absolute)).isFile()) throw new Error("not a regular file");
35721
+ if (!(await stat5(absolute)).isFile()) throw new Error("not a regular file");
35593
35722
  await access(absolute, fsConstants.X_OK);
35594
35723
  } catch {
35595
35724
  throw new Error(`${label} is not an executable file: ${absolute}`);
@@ -35597,9 +35726,9 @@ async function executable(filePath, label) {
35597
35726
  return absolute;
35598
35727
  }
35599
35728
  async function existingFile(filePath, label) {
35600
- const absolute = path21.resolve(filePath);
35729
+ const absolute = path22.resolve(filePath);
35601
35730
  try {
35602
- const metadata = await stat4(absolute);
35731
+ const metadata = await stat5(absolute);
35603
35732
  if (!metadata.isFile()) throw new Error("not a regular file");
35604
35733
  } catch {
35605
35734
  throw new Error(`${label} is not a regular file: ${absolute}`);
@@ -35607,9 +35736,9 @@ async function existingFile(filePath, label) {
35607
35736
  return absolute;
35608
35737
  }
35609
35738
  async function discoverExecutable(name, environment) {
35610
- for (const directory of (environment.PATH ?? "").split(path21.delimiter)) {
35739
+ for (const directory of (environment.PATH ?? "").split(path22.delimiter)) {
35611
35740
  if (!directory) continue;
35612
- const candidate = path21.resolve(directory, name);
35741
+ const candidate = path22.resolve(directory, name);
35613
35742
  try {
35614
35743
  await access(candidate, fsConstants.X_OK);
35615
35744
  return candidate;
@@ -35620,47 +35749,47 @@ async function discoverExecutable(name, environment) {
35620
35749
  return null;
35621
35750
  }
35622
35751
  async function writeAtomic(filePath, contents, mode) {
35623
- await mkdir9(path21.dirname(filePath), { recursive: true, mode: 448 });
35624
- const temporary = path21.join(
35625
- path21.dirname(filePath),
35626
- `.${path21.basename(filePath)}.${process.pid}.${randomUUID13()}.tmp`
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`
35627
35756
  );
35628
35757
  try {
35629
35758
  if (typeof contents === "string") {
35630
- await writeFile3(temporary, contents, { encoding: "utf8", flag: "wx", mode });
35759
+ await writeFile4(temporary, contents, { encoding: "utf8", flag: "wx", mode });
35631
35760
  } else {
35632
- await writeFile3(temporary, contents, { flag: "wx", mode });
35761
+ await writeFile4(temporary, contents, { flag: "wx", mode });
35633
35762
  }
35634
35763
  await chmod4(temporary, mode);
35635
35764
  try {
35636
- await rename6(temporary, filePath);
35765
+ await rename7(temporary, filePath);
35637
35766
  } catch (error51) {
35638
35767
  if (process.platform !== "win32") throw error51;
35639
- await rm9(filePath, { force: true });
35640
- await rename6(temporary, filePath);
35768
+ await rm10(filePath, { force: true });
35769
+ await rename7(temporary, filePath);
35641
35770
  }
35642
35771
  } finally {
35643
- await rm9(temporary, { force: true });
35772
+ await rm10(temporary, { force: true });
35644
35773
  }
35645
35774
  }
35646
35775
  async function writeAtomicExecutable(filePath, sourcePath) {
35647
- await mkdir9(path21.dirname(filePath), { recursive: true, mode: 448 });
35648
- const temporary = path21.join(
35649
- path21.dirname(filePath),
35650
- `.${path21.basename(filePath)}.${process.pid}.${randomUUID13()}.tmp`
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`
35651
35780
  );
35652
35781
  try {
35653
35782
  await copyFile3(sourcePath, temporary);
35654
35783
  await chmod4(temporary, 448);
35655
35784
  try {
35656
- await rename6(temporary, filePath);
35785
+ await rename7(temporary, filePath);
35657
35786
  } catch (error51) {
35658
35787
  if (process.platform !== "win32") throw error51;
35659
- await rm9(filePath, { force: true });
35660
- await rename6(temporary, filePath);
35788
+ await rm10(filePath, { force: true });
35789
+ await rename7(temporary, filePath);
35661
35790
  }
35662
35791
  } finally {
35663
- await rm9(temporary, { force: true });
35792
+ await rm10(temporary, { force: true });
35664
35793
  }
35665
35794
  }
35666
35795
  function managedBlockRange(contents) {
@@ -35688,8 +35817,8 @@ function removeManagedProfileBlock(contents) {
35688
35817
  function installManagedProfileBlock(contents, manifest) {
35689
35818
  const base = removeManagedProfileBlock(contents);
35690
35819
  const environment = [
35691
- `export CODEX_INSTALL_DIR=${shellQuote(path21.dirname(manifest.wrapperPath))}`,
35692
- `export PATH=${shellQuote(path21.dirname(manifest.wrapperPath))}:${shellQuote(path21.dirname(manifest.nodePath))}:${shellQuote(path21.dirname(manifest.stockCodexPath))}:"\${PATH:-/usr/local/bin:/usr/bin:/bin}"`,
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}"`,
35693
35822
  `export CODEXHOST_STOCK_CODEX_PATH=${shellQuote(manifest.stockCodexPath)}`,
35694
35823
  `export CODEXHOST_HOST_NODE_PATH=${shellQuote(manifest.nodePath)}`,
35695
35824
  `export CODEXHOST_HOST_RUNTIME_PATH=${shellQuote(manifest.hostRuntimePath)}`,
@@ -35706,7 +35835,7 @@ function installManagedProfileBlock(contents, manifest) {
35706
35835
  PROFILE_END,
35707
35836
  ""
35708
35837
  ].join("\n");
35709
- if (path21.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
35838
+ if (path22.basename(manifest.profilePath) === ".bashrc") return `${block}${base}`;
35710
35839
  const separator = base.length > 0 && !base.endsWith("\n") ? "\n" : "";
35711
35840
  return `${base}${separator}${block}`;
35712
35841
  }
@@ -35718,7 +35847,7 @@ async function managedEntrypointState(manifest) {
35718
35847
  if (metadata === null) return "missing";
35719
35848
  if (!metadata.isFile()) return "modified";
35720
35849
  if (process.platform !== "win32" && (metadata.mode & 73) === 0) return "modified";
35721
- const entrypoint = await readFile7(manifest.wrapperPath);
35850
+ const entrypoint = await readFile8(manifest.wrapperPath);
35722
35851
  if (entrypoint.subarray(0, 256).toString("utf8").startsWith(`#!/usr/bin/env sh
35723
35852
  ${WRAPPER_MARKER}
35724
35853
  `)) {
@@ -35727,7 +35856,7 @@ ${WRAPPER_MARKER}
35727
35856
  if (manifest.entrypointSha256 !== void 0) {
35728
35857
  return createHash9("sha256").update(entrypoint).digest("hex") === manifest.entrypointSha256 ? "native" : "modified";
35729
35858
  }
35730
- const shim = await readFile7(manifest.shimPath).catch((error51) => {
35859
+ const shim = await readFile8(manifest.shimPath).catch((error51) => {
35731
35860
  if (error51.code === "ENOENT") return null;
35732
35861
  throw error51;
35733
35862
  });
@@ -35771,9 +35900,9 @@ async function readManifest(filePath) {
35771
35900
  ];
35772
35901
  const optionalPaths = ["claudeCommand", "profileBackupPath"];
35773
35902
  if (manifest.format !== MANIFEST_FORMAT || Object.keys(manifest).some((key) => !allowed.has(key)) || requiredPaths.some(
35774
- (key) => typeof manifest[key] !== "string" || !path21.isAbsolute(manifest[key])
35903
+ (key) => typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key])
35775
35904
  ) || optionalPaths.some(
35776
- (key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path21.isAbsolute(manifest[key]))
35905
+ (key) => manifest[key] !== void 0 && (typeof manifest[key] !== "string" || !path22.isAbsolute(manifest[key]))
35777
35906
  ) || manifest.entrypointSha256 !== void 0 && (typeof manifest.entrypointSha256 !== "string" || !/^[a-f0-9]{64}$/u.test(manifest.entrypointSha256))) {
35778
35907
  throw new Error("Remote Host manifest has an unsupported format");
35779
35908
  }
@@ -35782,7 +35911,7 @@ async function readManifest(filePath) {
35782
35911
  async function backupProfile(profilePath, contents, action) {
35783
35912
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replaceAll(/[-:.TZ]/gu, "");
35784
35913
  const backupPath = `${profilePath}.codexhost-${action}-${timestamp}.bak`;
35785
- const metadata = await stat4(profilePath).catch(() => null);
35914
+ const metadata = await stat5(profilePath).catch(() => null);
35786
35915
  await writeAtomic(backupPath, contents, metadata?.mode ?? 384);
35787
35916
  return backupPath;
35788
35917
  }
@@ -35795,8 +35924,8 @@ async function installRemoteHost(options2) {
35795
35924
  const paths = resolvePaths(options2);
35796
35925
  const previousManifest = await readManifest(paths.manifestPath);
35797
35926
  const previousManifestFile = previousManifest ? {
35798
- contents: await readFile7(paths.manifestPath),
35799
- mode: (await stat4(paths.manifestPath)).mode & 511
35927
+ contents: await readFile8(paths.manifestPath),
35928
+ mode: (await stat5(paths.manifestPath)).mode & 511
35800
35929
  } : null;
35801
35930
  const existingEntrypoint = await lstat8(paths.wrapperPath).catch(
35802
35931
  (error51) => {
@@ -35820,7 +35949,7 @@ async function installRemoteHost(options2) {
35820
35949
  }
35821
35950
  const profilePath = previousManifest?.profilePath ?? paths.profilePath;
35822
35951
  const previousEntrypoint = existingEntrypoint?.isFile() ? {
35823
- contents: await readFile7(paths.wrapperPath),
35952
+ contents: await readFile8(paths.wrapperPath),
35824
35953
  mode: existingEntrypoint.mode & 511
35825
35954
  } : null;
35826
35955
  const discoveredStock = options2.stockCodexPath ?? previousManifest?.stockCodexPath ?? await discoverExecutable("codex", environment);
@@ -35855,14 +35984,14 @@ async function installRemoteHost(options2) {
35855
35984
  const existingProfile = existingProfileSource ?? "";
35856
35985
  const nextProfile = installManagedProfileBlock(existingProfile, manifest);
35857
35986
  const profileChanged = nextProfile !== existingProfile;
35858
- const profileMetadata = await stat4(profilePath).catch(() => null);
35987
+ const profileMetadata = await stat5(profilePath).catch(() => null);
35859
35988
  try {
35860
35989
  if (profileChanged) {
35861
35990
  const profileBackupPath = await backupProfile(profilePath, existingProfile, "install");
35862
35991
  manifest = { ...manifest, profileBackupPath };
35863
35992
  await writeAtomic(profilePath, nextProfile, profileMetadata?.mode ?? 384);
35864
35993
  }
35865
- await mkdir9(paths.dataDirectory, { recursive: true, mode: 448 });
35994
+ await mkdir10(paths.dataDirectory, { recursive: true, mode: 448 });
35866
35995
  await chmod4(paths.dataDirectory, 448);
35867
35996
  await writeAtomicExecutable(paths.wrapperPath, manifest.shimPath);
35868
35997
  manifest = { ...manifest, entrypointSha256: await fileSha256(paths.wrapperPath) };
@@ -35875,7 +36004,7 @@ async function installRemoteHost(options2) {
35875
36004
  if (previousEntrypoint) {
35876
36005
  await writeAtomic(paths.wrapperPath, previousEntrypoint.contents, previousEntrypoint.mode);
35877
36006
  } else {
35878
- await rm9(paths.wrapperPath, { force: true });
36007
+ await rm10(paths.wrapperPath, { force: true });
35879
36008
  }
35880
36009
  } catch (rollbackError) {
35881
36010
  rollbackErrors.push(rollbackError);
@@ -35883,7 +36012,7 @@ async function installRemoteHost(options2) {
35883
36012
  if (profileChanged) {
35884
36013
  try {
35885
36014
  if (existingProfileSource === null) {
35886
- await rm9(profilePath, { force: true });
36015
+ await rm10(profilePath, { force: true });
35887
36016
  } else {
35888
36017
  await writeAtomic(profilePath, existingProfile, profileMetadata?.mode ?? 384);
35889
36018
  }
@@ -35899,7 +36028,7 @@ async function installRemoteHost(options2) {
35899
36028
  previousManifestFile.mode
35900
36029
  );
35901
36030
  } else {
35902
- await rm9(paths.manifestPath, { force: true });
36031
+ await rm10(paths.manifestPath, { force: true });
35903
36032
  }
35904
36033
  } catch (rollbackError) {
35905
36034
  rollbackErrors.push(rollbackError);
@@ -35946,7 +36075,7 @@ async function inspectRemoteHostInstallation(options2) {
35946
36075
  if (!profileMatches && profileIssue === null)
35947
36076
  profileIssue = "shell profile does not configure the managed native entrypoint";
35948
36077
  if (profileIssue !== null) issues.push(profileIssue);
35949
- const dataDirectory = await stat4(manifest.dataDirectory).catch(() => null);
36078
+ const dataDirectory = await stat5(manifest.dataDirectory).catch(() => null);
35950
36079
  if (!dataDirectory?.isDirectory()) issues.push("remote Host data directory is unavailable");
35951
36080
  for (const [label, filePath, requiresExecutable] of [
35952
36081
  ["stock Codex", manifest.stockCodexPath, true],
@@ -35956,7 +36085,7 @@ async function inspectRemoteHostInstallation(options2) {
35956
36085
  ]) {
35957
36086
  try {
35958
36087
  if (requiresExecutable) await executable(filePath, label);
35959
- else if (!(await stat4(filePath)).isFile()) throw new Error("not a regular file");
36088
+ else if (!(await stat5(filePath)).isFile()) throw new Error("not a regular file");
35960
36089
  } catch {
35961
36090
  issues.push(`${label} is unavailable`);
35962
36091
  }
@@ -35985,11 +36114,11 @@ async function uninstallRemoteHost(options2) {
35985
36114
  const nextProfile = removeManagedProfileBlock(profile);
35986
36115
  if (nextProfile !== profile) {
35987
36116
  await backupProfile(manifest.profilePath, profile, "uninstall");
35988
- const metadata = await stat4(manifest.profilePath).catch(() => null);
36117
+ const metadata = await stat5(manifest.profilePath).catch(() => null);
35989
36118
  await writeAtomic(manifest.profilePath, nextProfile, metadata?.mode ?? 384);
35990
36119
  }
35991
- await rm9(manifest.wrapperPath, { force: true });
35992
- await rm9(paths.manifestPath, { force: true });
36120
+ await rm10(manifest.wrapperPath, { force: true });
36121
+ await rm10(paths.manifestPath, { force: true });
35993
36122
  await rmdir(paths.binDirectory).catch((error51) => {
35994
36123
  if (error51.code !== "ENOENT" && error51.code !== "ENOTEMPTY") throw error51;
35995
36124
  });
@@ -36000,9 +36129,9 @@ async function uninstallRemoteHost(options2) {
36000
36129
 
36001
36130
  // packages/host-runtime/src/remote-host-lifecycle.ts
36002
36131
  import { spawn as spawn5 } from "node:child_process";
36003
- import { stat as stat5 } from "node:fs/promises";
36132
+ import { stat as stat6 } from "node:fs/promises";
36004
36133
  import net3 from "node:net";
36005
- import path22 from "node:path";
36134
+ import path23 from "node:path";
36006
36135
  import { Duplex } from "node:stream";
36007
36136
  var CODEXHOST_STATUS_METHOD = "codexhost/update/status";
36008
36137
  var DIRECT_PROBE_TIMEOUT_MS = 5e3;
@@ -36021,12 +36150,12 @@ function classifyRemoteHostProbeResponse(response, socketPath) {
36021
36150
  }
36022
36151
  var lifecycleDependencyOverrides = {};
36023
36152
  function socketPathFor(environment) {
36024
- const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path22.join(environment.HOME, ".codex") : void 0);
36153
+ const codexHome = environment.CODEX_HOME ?? (environment.HOME ? path23.join(environment.HOME, ".codex") : void 0);
36025
36154
  if (!codexHome) throw new Error("CODEX_HOME or HOME is required for remote Host lifecycle");
36026
- return path22.join(codexHome, "app-server-control", "app-server-control.sock");
36155
+ return path23.join(codexHome, "app-server-control", "app-server-control.sock");
36027
36156
  }
36028
36157
  async function defaultSocketExists(socketPath) {
36029
- const metadata = await stat5(socketPath).catch((error51) => {
36158
+ const metadata = await stat6(socketPath).catch((error51) => {
36030
36159
  if (error51.code === "ENOENT") return null;
36031
36160
  throw error51;
36032
36161
  });
@@ -36150,7 +36279,7 @@ function installedManifest(status) {
36150
36279
  function managedEnvironment(manifest, environment) {
36151
36280
  return {
36152
36281
  ...environment,
36153
- CODEX_INSTALL_DIR: path22.dirname(manifest.wrapperPath),
36282
+ CODEX_INSTALL_DIR: path23.dirname(manifest.wrapperPath),
36154
36283
  CODEXHOST_STOCK_CODEX_PATH: manifest.stockCodexPath,
36155
36284
  CODEXHOST_HOST_NODE_PATH: manifest.nodePath,
36156
36285
  CODEXHOST_HOST_RUNTIME_PATH: manifest.hostRuntimePath,
@@ -36158,7 +36287,7 @@ function managedEnvironment(manifest, environment) {
36158
36287
  CODEXHOST_DEFAULT_AGENT: "codex",
36159
36288
  CODEXHOST_REMOTE_SSH_MANAGED: "1",
36160
36289
  ...manifest.claudeCommand ? { CODEXHOST_CLAUDE_COMMAND: manifest.claudeCommand } : {},
36161
- PATH: `${path22.dirname(manifest.wrapperPath)}${path22.delimiter}${path22.dirname(manifest.stockCodexPath)}${path22.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
36290
+ PATH: `${path23.dirname(manifest.wrapperPath)}${path23.delimiter}${path23.dirname(manifest.stockCodexPath)}${path23.delimiter}${environment.PATH ?? "/usr/bin:/bin"}`
36162
36291
  };
36163
36292
  }
36164
36293
  async function defaultRunTerminator(manifest, socketPath, role, environment) {
@@ -36496,26 +36625,26 @@ function consumeBrokerFrames(socket, onFrame, onError) {
36496
36625
  }
36497
36626
 
36498
36627
  // packages/harness-broker/dist/paths.js
36499
- import os5 from "node:os";
36500
- import path23 from "node:path";
36628
+ import os6 from "node:os";
36629
+ import path24 from "node:path";
36501
36630
  var HARNESS_BROKER_DESCRIPTOR_ENV = "CODEXHOST_CLAUDE_BROKER_DESCRIPTOR";
36502
36631
  var HARNESS_BROKER_DESCRIPTOR_FILE = "claude-code-broker-v1.json";
36503
36632
  var HARNESS_BROKER_SOCKET_FILE = "claude-code-broker-v1.sock";
36504
36633
  function defaultHarnessBrokerDirectory(environment = process.env) {
36505
- const home = environment.HOME || os5.homedir();
36506
- return path23.join(home, ".codexhost", "harness-broker");
36634
+ const home = environment.HOME || os6.homedir();
36635
+ return path24.join(home, ".codexhost", "harness-broker");
36507
36636
  }
36508
36637
  function defaultHarnessBrokerDescriptorPath(environment = process.env, harnessId = "claude-code") {
36509
36638
  harnessPluginIdSchema.parse(harnessId);
36510
36639
  if (harnessId !== "claude-code")
36511
- return path23.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.json`);
36512
- return environment[HARNESS_BROKER_DESCRIPTOR_ENV] ?? path23.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_DESCRIPTOR_FILE);
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);
36513
36642
  }
36514
36643
  function defaultHarnessBrokerSocketPath(environment = process.env, harnessId = "claude-code") {
36515
36644
  harnessPluginIdSchema.parse(harnessId);
36516
36645
  if (harnessId !== "claude-code")
36517
- return path23.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
36518
- return path23.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
36646
+ return path24.join(defaultHarnessBrokerDirectory(environment), `${harnessId}-broker-v1.sock`);
36647
+ return path24.join(defaultHarnessBrokerDirectory(environment), HARNESS_BROKER_SOCKET_FILE);
36519
36648
  }
36520
36649
 
36521
36650
  // packages/harness-broker/dist/validation.js
@@ -36728,10 +36857,10 @@ var harnessOutputSchema = external_exports.custom((value2) => {
36728
36857
  });
36729
36858
 
36730
36859
  // packages/harness-broker/dist/server.js
36731
- import { randomBytes as randomBytes3, randomUUID as randomUUID14 } from "node:crypto";
36732
- import { chmod as chmod5, lstat as lstat9, mkdir as mkdir10, open as open8, readFile as readFile8, rename as rename7, rm as rm10 } from "node:fs/promises";
36860
+ 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";
36733
36862
  import net4, {} from "node:net";
36734
- import path24 from "node:path";
36863
+ import path25 from "node:path";
36735
36864
  function harnessError(message, retryable = true) {
36736
36865
  return { code: "unavailable", message, retryable, stage: "harnessBroker" };
36737
36866
  }
@@ -36742,7 +36871,7 @@ function nativeWriterKey(nativeSessionId) {
36742
36871
  return nativeSessionId;
36743
36872
  }
36744
36873
  async function privateDirectory(directory) {
36745
- await mkdir10(directory, { recursive: true, mode: 448 });
36874
+ await mkdir11(directory, { recursive: true, mode: 448 });
36746
36875
  if (process.platform === "win32")
36747
36876
  return;
36748
36877
  const metadata = await lstat9(directory);
@@ -36777,7 +36906,7 @@ async function assertNoLiveDescriptor(descriptorPath) {
36777
36906
  throw new Error("Harness broker descriptor is not owner-only");
36778
36907
  }
36779
36908
  }
36780
- const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile8(descriptorPath, "utf8")));
36909
+ const descriptor = harnessBrokerDescriptorSchema.parse(JSON.parse(await readFile9(descriptorPath, "utf8")));
36781
36910
  if (processIsAlive2(descriptor.ownerPid)) {
36782
36911
  throw new Error("Harness broker descriptor already has a live owner");
36783
36912
  }
@@ -36787,7 +36916,7 @@ async function assertNoLiveDescriptor(descriptorPath) {
36787
36916
  }
36788
36917
  }
36789
36918
  async function publishDescriptor(descriptorPath, descriptor) {
36790
- const temporary = `${descriptorPath}.${process.pid}.${randomUUID14()}.tmp`;
36919
+ const temporary = `${descriptorPath}.${process.pid}.${randomUUID15()}.tmp`;
36791
36920
  const handle = await open8(temporary, "wx", 384);
36792
36921
  try {
36793
36922
  await handle.writeFile(`${JSON.stringify(descriptor)}
@@ -36796,7 +36925,7 @@ async function publishDescriptor(descriptorPath, descriptor) {
36796
36925
  } finally {
36797
36926
  await handle.close();
36798
36927
  }
36799
- await rename7(temporary, descriptorPath);
36928
+ await rename8(temporary, descriptorPath);
36800
36929
  if (process.platform !== "win32")
36801
36930
  await chmod5(descriptorPath, 384);
36802
36931
  }
@@ -36846,7 +36975,7 @@ async function prepareUnixSocketPath(socketPath) {
36846
36975
  if (await socketAcceptsConnections(socketPath)) {
36847
36976
  throw new Error("Harness broker socket is already active");
36848
36977
  }
36849
- await rm10(socketPath);
36978
+ await rm11(socketPath);
36850
36979
  } catch (error51) {
36851
36980
  if (error51.code !== "ENOENT")
36852
36981
  throw error51;
@@ -36854,17 +36983,17 @@ async function prepareUnixSocketPath(socketPath) {
36854
36983
  }
36855
36984
  async function startHarnessBrokerServer(input) {
36856
36985
  harnessPluginIdSchema.parse(input.adapter.harnessId);
36857
- if (process.platform !== "win32" && path24.dirname(input.descriptorPath) !== path24.dirname(input.socketPath)) {
36986
+ if (process.platform !== "win32" && path25.dirname(input.descriptorPath) !== path25.dirname(input.socketPath)) {
36858
36987
  throw new Error("Harness broker descriptor and socket must share one private directory");
36859
36988
  }
36860
36989
  if (process.platform === "darwin" && Buffer.byteLength(input.socketPath) > 103) {
36861
36990
  throw new Error("Harness broker Unix socket path is too long for macOS");
36862
36991
  }
36863
- await privateDirectory(path24.dirname(input.descriptorPath));
36992
+ await privateDirectory(path25.dirname(input.descriptorPath));
36864
36993
  await assertNoLiveDescriptor(input.descriptorPath);
36865
36994
  if (process.platform !== "win32")
36866
36995
  await prepareUnixSocketPath(input.socketPath);
36867
- const generation = input.generation ?? randomUUID14();
36996
+ const generation = input.generation ?? randomUUID15();
36868
36997
  const token = input.token ?? randomBytes3(32).toString("hex");
36869
36998
  const descriptor = {
36870
36999
  schemaVersion: 1,
@@ -36882,7 +37011,7 @@ async function startHarnessBrokerServer(input) {
36882
37011
  let closed = false;
36883
37012
  const server = net4.createServer((socket) => {
36884
37013
  const state = {
36885
- id: randomUUID14(),
37014
+ id: randomUUID15(),
36886
37015
  socket,
36887
37016
  authenticated: false,
36888
37017
  inputSequence: 0,
@@ -37097,7 +37226,7 @@ async function startHarnessBrokerServer(input) {
37097
37226
  }
37098
37227
  };
37099
37228
  }
37100
- const openReservation = randomUUID14();
37229
+ const openReservation = randomUUID15();
37101
37230
  if (sourceKey)
37102
37231
  nativeWriters.set(sourceKey, openReservation);
37103
37232
  const provisionalReservation = openInput.kind === "create" ? openReservation : void 0;
@@ -37377,7 +37506,7 @@ async function startHarnessBrokerServer(input) {
37377
37506
  }
37378
37507
  state.authenticated = true;
37379
37508
  state.inputSequence = 1;
37380
- await send({ kind: "response", id: randomUUID14(), ok: true, value: { ready: true } });
37509
+ await send({ kind: "response", id: randomUUID15(), ok: true, value: { ready: true } });
37381
37510
  return;
37382
37511
  }
37383
37512
  const parsed = harnessBrokerRequestSchema.safeParse(raw);
@@ -37425,7 +37554,7 @@ async function startHarnessBrokerServer(input) {
37425
37554
  } catch (error51) {
37426
37555
  await new Promise((resolve) => server.close(() => resolve()));
37427
37556
  if (process.platform !== "win32")
37428
- await rm10(input.socketPath, { force: true });
37557
+ await rm11(input.socketPath, { force: true });
37429
37558
  throw error51;
37430
37559
  }
37431
37560
  return {
@@ -37443,8 +37572,8 @@ async function startHarnessBrokerServer(input) {
37443
37572
  await input.adapter.close().catch(() => void 0);
37444
37573
  await new Promise((resolve) => server.close(() => resolve()));
37445
37574
  if (process.platform !== "win32")
37446
- await rm10(input.socketPath, { force: true });
37447
- await rm10(input.descriptorPath, { force: true });
37575
+ await rm11(input.socketPath, { force: true });
37576
+ await rm11(input.descriptorPath, { force: true });
37448
37577
  }
37449
37578
  };
37450
37579
  }