@codexhost/cli-darwin-arm64 0.3.0-test.3 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @codexhost/cli@0.3.0-test.3
10
+ npm install -g @codexhost/cli@0.3.1
11
11
  ```
12
12
 
13
13
  Do not install this package directly. npm selects it through the optional dependencies of `@codexhost/cli`.
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.3.0-test.3","distribution":"npm","target":"macos-arm64"}
1
+ {"schemaVersion":1,"version":"0.3.1","distribution":"npm","target":"macos-arm64"}
@@ -45631,6 +45631,16 @@ function isExecutable(candidate, platform) {
45631
45631
  return false;
45632
45632
  }
45633
45633
  }
45634
+ function claudeNpmNativeExecutable(npmDirectory) {
45635
+ return path4.join(npmDirectory, "node_modules", "@anthropic-ai", "claude-code", "bin", "claude.exe");
45636
+ }
45637
+ function runnableCandidate(candidate, platform) {
45638
+ if (platform === "win32" && path4.basename(candidate).toLowerCase() === "claude.cmd") {
45639
+ const nativeExecutable = claudeNpmNativeExecutable(path4.dirname(candidate));
45640
+ return isExecutable(nativeExecutable, platform) ? nativeExecutable : void 0;
45641
+ }
45642
+ return candidate;
45643
+ }
45634
45644
  function nvmCandidates(homeDirectory) {
45635
45645
  const versionsDirectory = path4.join(homeDirectory, ".nvm", "versions", "node");
45636
45646
  try {
@@ -45643,6 +45653,7 @@ function userInstallCandidates(platform, environment, homeDirectory) {
45643
45653
  if (platform === "win32") {
45644
45654
  const appData = environment.APPDATA ?? path4.join(homeDirectory, "AppData", "Roaming");
45645
45655
  return [
45656
+ claudeNpmNativeExecutable(path4.join(appData, "npm")),
45646
45657
  path4.join(appData, "npm", "claude.cmd"),
45647
45658
  path4.join(homeDirectory, ".local", "bin", "claude.exe"),
45648
45659
  path4.join(homeDirectory, ".local", "bin", "claude.cmd")
@@ -45667,7 +45678,7 @@ function resolveClaudeCodeExecutable(input = {}) {
45667
45678
  ...candidates(command, platform, environment),
45668
45679
  ...configuredCommand ? [] : userInstallCandidates(platform, environment, homeDirectory)
45669
45680
  ];
45670
- const executable2 = resolutionCandidates.find((candidate) => isExecutable(candidate, platform));
45681
+ const executable2 = resolutionCandidates.map((candidate) => runnableCandidate(candidate, platform)).find((candidate) => candidate !== void 0 && isExecutable(candidate, platform));
45671
45682
  if (!executable2)
45672
45683
  throw new ClaudeCodeExecutableError("Claude Code is not installed");
45673
45684
  return path4.resolve(executable2);
@@ -68879,22 +68890,27 @@ function createRemoteAppServerWebSocketListener(input) {
68879
68890
  closing = (async () => {
68880
68891
  for (const socket of webSockets.clients) socket.terminate();
68881
68892
  await new Promise((resolve2) => webSockets.close(() => resolve2()));
68882
- if (listening) {
68893
+ const closeServer = async () => {
68894
+ if (!listening) return;
68883
68895
  await new Promise(
68884
68896
  (resolve2, reject) => server.close((error54) => error54 ? reject(error54) : resolve2())
68885
68897
  );
68886
- }
68887
- await Promise.allSettled(sessions);
68888
- if (process.platform !== "win32" && ownedSocketIdentity) {
68889
- const identity = ownedSocketIdentity;
68898
+ };
68899
+ if (process.platform !== "win32" && listening) {
68890
68900
  await withRemoteAppServerSocketInitializationLock(input.socketPath, async () => {
68891
- const current = await unixSocketIdentity(input.socketPath);
68892
- if (current && sameUnixFileIdentity2(current, identity)) {
68893
- await rm6(input.socketPath, { force: true });
68901
+ await closeServer();
68902
+ if (ownedSocketIdentity) {
68903
+ const current = await unixSocketIdentity(input.socketPath);
68904
+ if (current && sameUnixFileIdentity2(current, ownedSocketIdentity)) {
68905
+ await rm6(input.socketPath, { force: true });
68906
+ }
68907
+ ownedSocketIdentity = null;
68894
68908
  }
68895
68909
  });
68896
- ownedSocketIdentity = null;
68910
+ } else {
68911
+ await closeServer();
68897
68912
  }
68913
+ await Promise.allSettled(sessions);
68898
68914
  closed.resolve(void 0);
68899
68915
  })();
68900
68916
  return closing;
@@ -21451,6 +21451,10 @@ ${error51.stderrTail}`] : []
21451
21451
  if (!isLateConversationTarget(mountedTarget, currentTarget)) return "none";
21452
21452
  return mountedTarget?.[0] === "default" && (sourcePhase === "locked" || submissionPending) ? "transfer" : "inspect";
21453
21453
  }
21454
+ function scopedComposerTarget(target, hostId) {
21455
+ if (target?.[0] !== "conversation" || !hostId) return target;
21456
+ return ["conversation", target[1], hostId];
21457
+ }
21454
21458
  function isComposerModelWriteAllowed(target) {
21455
21459
  return target?.[0] === "default";
21456
21460
  }
@@ -21504,6 +21508,11 @@ ${error51.stderrTail}`] : []
21504
21508
  let adapterDispose = null;
21505
21509
  let applyAdapterAgent = null;
21506
21510
  let modelControl = null;
21511
+ const activeModelHostId = () => {
21512
+ if (!modelControl) return null;
21513
+ return modelControl.currentHostId ? modelControl.currentHostId() : "local";
21514
+ };
21515
+ const controllerTarget = (target, hostId) => scopedComposerTarget(target, hostId);
21507
21516
  let usageNotificationDispose = null;
21508
21517
  const localAgentForSidebarThread = (input) => {
21509
21518
  const mountedHostId = modelControl?.currentHostId?.() ?? "local";
@@ -21722,14 +21731,18 @@ ${error51.stderrTail}`] : []
21722
21731
  mounted.ownershipStatus = "not-required";
21723
21732
  return;
21724
21733
  }
21734
+ const requestModelControl = modelControl;
21735
+ const requestHostId = activeModelHostId();
21736
+ const client = requestModelControl && requestHostId ? requestModelControl.clientForHost?.(requestHostId) ?? requestModelControl : null;
21725
21737
  const generation = controller.beginOwnershipRequest(mounted.composer);
21726
21738
  const usageGeneration = mounted.usageRequestGeneration;
21727
21739
  mounted.ownershipStatus = "loading";
21728
21740
  renderMounted(mounted);
21729
21741
  try {
21730
- if (!modelControl) throw new Error("Thread ownership control is unavailable");
21731
- const inspection = await modelControl.inspectThread({ threadId });
21732
- if (!isCurrentOwnershipRequest(mounted, generation) || mountedByComposer.get(mounted.composer) !== mounted || threadIdFromComposerModelTarget(mounted.modelTarget) !== threadId) {
21742
+ if (!client || !requestHostId) throw new Error("Thread ownership control is unavailable");
21743
+ mounted.hostId = requestHostId;
21744
+ const inspection = await client.inspectThread({ threadId });
21745
+ if (!isCurrentOwnershipRequest(mounted, generation) || mountedByComposer.get(mounted.composer) !== mounted || threadIdFromComposerModelTarget(mounted.modelTarget) !== threadId || mounted.hostId !== requestHostId || modelControl !== requestModelControl || activeModelHostId() !== requestHostId) {
21733
21746
  return;
21734
21747
  }
21735
21748
  const { agent, model, thinkingOptionId, permissionModeId } = restoredThreadOwnership(inspection);
@@ -21794,8 +21807,11 @@ ${error51.stderrTail}`] : []
21794
21807
  );
21795
21808
  if (resolution === "none") return false;
21796
21809
  const previousTarget = mounted.modelTarget;
21810
+ const nextHostId = activeModelHostId() ?? mounted.hostId;
21811
+ const nextControllerTarget = controllerTarget(currentTarget, nextHostId);
21797
21812
  mounted.modelTarget = currentTarget;
21798
- const rebound = resolution === "transfer" ? controller.transfer(mounted.composer, mounted.composer, currentTarget) : controller.rebindConversation(mounted.composer, currentTarget) !== null;
21813
+ mounted.hostId = nextHostId;
21814
+ const rebound = resolution === "transfer" ? controller.transfer(mounted.composer, mounted.composer, nextControllerTarget) : controller.rebindConversation(mounted.composer, nextControllerTarget) !== null;
21799
21815
  if (!rebound) {
21800
21816
  mounted.ownershipStatus = "error";
21801
21817
  renderMounted(mounted);
@@ -22510,12 +22526,43 @@ ${error51.stderrTail}`] : []
22510
22526
  );
22511
22527
  return promise2;
22512
22528
  }
22529
+ const reloadMountedOwnershipForHost = (hostId) => {
22530
+ for (const mounted of mountedByComposer.values()) {
22531
+ if (mounted.hostId === hostId || !threadIdFromComposerModelTarget(mounted.modelTarget)) {
22532
+ continue;
22533
+ }
22534
+ const target = controllerTarget(mounted.modelTarget, hostId);
22535
+ if (controller.rebindConversation(mounted.composer, target) === null) {
22536
+ mounted.ownershipStatus = "error";
22537
+ renderMounted(mounted);
22538
+ continue;
22539
+ }
22540
+ mounted.hostId = hostId;
22541
+ mounted.composerId = controller.get(mounted.composer).composerId;
22542
+ mounted.modelView = { status: "idle" };
22543
+ mounted.permissionModeView = { status: "idle" };
22544
+ mounted.threadConfiguration = void 0;
22545
+ mounted.ownershipStatus = "loading";
22546
+ mounted.usage = null;
22547
+ mounted.accountCredits = null;
22548
+ mounted.usageRequestGeneration += 1;
22549
+ usageRefreshAttempts.delete(mounted.composer);
22550
+ const timer = usageRefreshTimers.get(mounted.composer);
22551
+ if (timer !== void 0) {
22552
+ window.clearTimeout(timer);
22553
+ usageRefreshTimers.delete(mounted.composer);
22554
+ }
22555
+ renderMounted(mounted);
22556
+ void loadThreadOwnership(mounted);
22557
+ }
22558
+ sidebarAgentIcons.refresh();
22559
+ };
22513
22560
  function reconcileHarnessAvailabilityHost() {
22514
- const reportedHostId = modelControl?.currentHostId?.();
22515
- const hostId = reportedHostId ?? (modelControl?.currentHostId ? activeAvailabilityHostId : "local");
22516
- if (hostId === activeAvailabilityHostId) return;
22561
+ const hostId = activeModelHostId();
22562
+ if (!hostId || hostId === activeAvailabilityHostId) return;
22517
22563
  activeAvailabilityHostId = hostId;
22518
22564
  hostHarnessAvailabilityState(hostId);
22565
+ reloadMountedOwnershipForHost(hostId);
22519
22566
  publishConnectionStatus();
22520
22567
  for (const mounted of mountedByComposer.values()) renderMounted(mounted);
22521
22568
  void refreshHarnessAvailabilityForHost(hostId);
@@ -22565,11 +22612,12 @@ ${error51.stderrTail}`] : []
22565
22612
  const sendButton = sendButtonWithin(composer) ?? allButtons.at(-1) ?? null;
22566
22613
  if (!sendButton) return;
22567
22614
  const modelTarget = findComposerModelTarget(composer);
22615
+ const hostId = activeModelHostId();
22568
22616
  const editor = composer.querySelector(EDITOR_SELECTOR);
22569
22617
  if (!editor) return;
22570
22618
  const state = controller.mount(
22571
22619
  composer,
22572
- modelTarget,
22620
+ controllerTarget(modelTarget, hostId),
22573
22621
  modelTarget?.[0] === "default" ? readNewThreadAgentPreference(enabledAgentSet) : void 0
22574
22622
  );
22575
22623
  const inherited = pendingReplacements.get(composer)?.source;
@@ -22615,6 +22663,7 @@ ${error51.stderrTail}`] : []
22615
22663
  threadConfiguration: inherited?.threadConfiguration,
22616
22664
  usage: inherited?.usage ?? null,
22617
22665
  accountCredits: inherited?.accountCredits ?? null,
22666
+ hostId: inherited?.hostId ?? hostId,
22618
22667
  usageRequestGeneration: 0
22619
22668
  };
22620
22669
  mountedByComposer.set(composer, mounted);
@@ -22650,12 +22699,17 @@ ${error51.stderrTail}`] : []
22650
22699
  for (const [target, replacement] of pendingReplacements) {
22651
22700
  const sourceState = controller.get(replacement.source.composer);
22652
22701
  const replacementTarget = findComposerModelTarget(target);
22702
+ const replacementHostId = activeModelHostId() ?? replacement.source.hostId;
22653
22703
  if (!shouldTransferComposerState(
22654
22704
  replacement.sourceModelTarget,
22655
22705
  replacementTarget,
22656
22706
  sourceState.phase,
22657
22707
  controller.isSubmissionPending(replacement.source.composer)
22658
- ) || !controller.transfer(replacement.source.composer, target, replacementTarget)) {
22708
+ ) || !controller.transfer(
22709
+ replacement.source.composer,
22710
+ target,
22711
+ controllerTarget(replacementTarget, replacementHostId)
22712
+ )) {
22659
22713
  pendingReplacements.delete(target);
22660
22714
  }
22661
22715
  }
package/bin/codexhost CHANGED
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codexhost/cli-darwin-arm64",
3
- "version": "0.3.0-test.3",
3
+ "version": "0.3.1",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [