remote-codex 0.11.42 → 0.11.43

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.
@@ -4702,6 +4702,10 @@ function buildRelayServer(config2, options = {}) {
4702
4702
  parsed.clientId
4703
4703
  );
4704
4704
  const eventThreadId = threadIdFromSocketPayload(parsed.payload);
4705
+ const shellEventForClient = clientConnection ? isShellEventForClient(
4706
+ parsed.payload,
4707
+ clientConnection.attachedShellId
4708
+ ) : false;
4705
4709
  if (clientConnection) {
4706
4710
  const freshAccess = store.effectiveAccess(
4707
4711
  clientConnection.user.id,
@@ -4724,7 +4728,7 @@ function buildRelayServer(config2, options = {}) {
4724
4728
  clientConnection.user.id
4725
4729
  );
4726
4730
  const connectionControlEvent = parsed.payload.type === "supervisor.connected" || parsed.payload.type === "supervisor.pong";
4727
- if (isolation?.enabled && !connectionControlEvent && (!eventThreadId || !store.ownsHostedThread(
4731
+ if (isolation?.enabled && !connectionControlEvent && !shellEventForClient && (!eventThreadId || !store.ownsHostedThread(
4728
4732
  isolation.sandboxId,
4729
4733
  clientConnection.user.id,
4730
4734
  eventThreadId
@@ -4734,7 +4738,8 @@ function buildRelayServer(config2, options = {}) {
4734
4738
  }
4735
4739
  if (clientConnection && clientConnection.socket.readyState === WEBSOCKET_OPEN && shouldForwardSocketEvent(
4736
4740
  parsed.payload,
4737
- clientConnection.threadId
4741
+ clientConnection.threadId,
4742
+ clientConnection.attachedShellId
4738
4743
  )) {
4739
4744
  clientConnection.socket.send(JSON.stringify(parsed.payload));
4740
4745
  }
@@ -5319,6 +5324,7 @@ function connectRelayWebsocket(supervisor, socket, store, user, deviceId, thread
5319
5324
  supervisor.clientSockets.set(clientId, {
5320
5325
  socket,
5321
5326
  threadId,
5327
+ attachedShellId: null,
5322
5328
  deviceId,
5323
5329
  user,
5324
5330
  access
@@ -5351,6 +5357,10 @@ function connectRelayWebsocket(supervisor, socket, store, user, deviceId, thread
5351
5357
  socket.close(1008, "Shared read-only session cannot control supervisor.");
5352
5358
  return;
5353
5359
  }
5360
+ const attachedShellId = shellAttachIdFromSocketPayload(payload);
5361
+ if (clientConnection && attachedShellId) {
5362
+ clientConnection.attachedShellId = attachedShellId;
5363
+ }
5354
5364
  sendToSupervisor(supervisor, {
5355
5365
  type: "relay.client.message",
5356
5366
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6047,14 +6057,25 @@ function isAllowedSharedWorkspacePath(access, methodName, pathname, workspaceId)
6047
6057
  ];
6048
6058
  return ["POST", "PUT", "PATCH", "DELETE"].includes(methodName) && writePatterns.some((pattern) => pattern.test(pathname));
6049
6059
  }
6050
- function shouldForwardSocketEvent(event, threadId) {
6060
+ function shouldForwardSocketEvent(event, threadId, attachedShellId) {
6051
6061
  if (!threadId) {
6052
6062
  return true;
6053
6063
  }
6054
6064
  if (event.type === "supervisor.connected" || event.type === "supervisor.pong") {
6055
6065
  return true;
6056
6066
  }
6057
- return "threadId" in event && event.threadId === threadId;
6067
+ if ("threadId" in event && event.threadId === threadId) {
6068
+ return true;
6069
+ }
6070
+ return isShellEventForClient(event, attachedShellId);
6071
+ }
6072
+ function shellAttachIdFromSocketPayload(payload) {
6073
+ return isObject(payload) && payload.type === "shell.attach" && typeof payload.shellId === "string" ? payload.shellId : null;
6074
+ }
6075
+ function isShellEventForClient(event, attachedShellId) {
6076
+ return Boolean(
6077
+ attachedShellId && event.type.startsWith("shell.") && "shellId" in event && event.shellId === attachedShellId
6078
+ );
6058
6079
  }
6059
6080
  function relayRequestBody(body) {
6060
6081
  if (body === void 0 || body === null) {
@@ -12089,7 +12089,7 @@ function mapModelInfo(model, index) {
12089
12089
  return {
12090
12090
  id: model.value,
12091
12091
  model: model.value,
12092
- displayName: model.displayName,
12092
+ displayName: versionedClaudeModelDisplayName(model),
12093
12093
  description: model.description,
12094
12094
  isDefault: index === 0,
12095
12095
  hidden: false,
@@ -12100,11 +12100,44 @@ function mapModelInfo(model, index) {
12100
12100
  defaultReasoningEffort: model.supportsEffort ? "medium" : null
12101
12101
  };
12102
12102
  }
12103
+ function versionedClaudeModelDisplayName(model) {
12104
+ const resolved = model.resolvedModel?.match(
12105
+ /^claude-(sonnet|opus|haiku|fable)-(\d+)(?:-(\d+))?(?:-|\[|$)/i
12106
+ );
12107
+ if (!resolved) {
12108
+ return model.displayName;
12109
+ }
12110
+ const family = `${resolved[1][0].toUpperCase()}${resolved[1].slice(1).toLowerCase()}`;
12111
+ const version2 = resolved[3] ? `${resolved[2]}.${resolved[3]}` : resolved[2];
12112
+ if (model.value === "default") {
12113
+ return `Default \xB7 ${family} ${version2}`;
12114
+ }
12115
+ const qualifier = model.displayName.match(/\s*(\([^)]+\))\s*$/)?.[1];
12116
+ return `${family} \xB7 ${version2}${qualifier ? ` ${qualifier}` : ""}`;
12117
+ }
12118
+ function versionedAlias(alias, discovered, qualifier) {
12119
+ if (!discovered) {
12120
+ return alias;
12121
+ }
12122
+ return {
12123
+ ...alias,
12124
+ displayName: `${discovered.displayName.replace(/\s+\([^)]+\)\s*$/, "")}${qualifier ?? ""}`,
12125
+ description: discovered.description,
12126
+ supportedReasoningEfforts: discovered.supportedReasoningEfforts,
12127
+ defaultReasoningEffort: discovered.defaultReasoningEffort
12128
+ };
12129
+ }
12103
12130
  function withClaudeCodeModelAliases(models) {
12104
12131
  const output = [...models];
12105
- const defaultSonnet = DEFAULT_CLAUDE_MODELS[0];
12106
- const oneMillionSonnet = DEFAULT_CLAUDE_MODELS[1];
12107
- const fable = DEFAULT_CLAUDE_MODELS[2];
12132
+ const discoveredSonnet = output.find((model) => /^Sonnet · /.test(model.displayName));
12133
+ const discoveredFable = output.find((model) => /^Fable · /.test(model.displayName));
12134
+ const defaultSonnet = versionedAlias(DEFAULT_CLAUDE_MODELS[0], discoveredSonnet);
12135
+ const oneMillionSonnet = versionedAlias(
12136
+ DEFAULT_CLAUDE_MODELS[1],
12137
+ discoveredSonnet,
12138
+ " (1M context)"
12139
+ );
12140
+ const fable = versionedAlias(DEFAULT_CLAUDE_MODELS[2], discoveredFable);
12108
12141
  const hasSonnetAlias = output.some((model) => model.model === "sonnet");
12109
12142
  if (!hasSonnetAlias) {
12110
12143
  output.unshift(defaultSonnet);
@@ -12613,6 +12646,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12613
12646
  subscriptionUsageWindows = /* @__PURE__ */ new Map();
12614
12647
  subscriptionAuthKind = "unknown";
12615
12648
  subscriptionUsageObservedAt = null;
12649
+ modelOptionsCache = null;
12616
12650
  historicalTurnIdAliases = /* @__PURE__ */ new Map();
12617
12651
  clientApp;
12618
12652
  sdkLoadError = null;
@@ -12733,14 +12767,33 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12733
12767
  }
12734
12768
  async listModels() {
12735
12769
  const active = [...this.activeTurns.values()][0];
12736
- if (!active) {
12737
- return DEFAULT_CLAUDE_MODELS;
12770
+ if (!active && this.modelOptionsCache) {
12771
+ return this.modelOptionsCache;
12738
12772
  }
12773
+ let query = active?.query ?? null;
12739
12774
  try {
12740
- const models = await active.query.supportedModels();
12741
- return withClaudeCodeModelAliases(models.map(mapModelInfo));
12775
+ query ??= this.queryFactory({
12776
+ prompt: "",
12777
+ options: queryOptionsForRuntime({
12778
+ home: this.options.home,
12779
+ command: this.options.command,
12780
+ clientApp: this.clientApp,
12781
+ approvalMode: "guarded",
12782
+ includePartialMessages: false,
12783
+ tools: [],
12784
+ maxTurns: 1
12785
+ })
12786
+ });
12787
+ const models = await query.supportedModels();
12788
+ const mapped = withClaudeCodeModelAliases(models.map(mapModelInfo));
12789
+ this.modelOptionsCache = mapped;
12790
+ return mapped;
12742
12791
  } catch {
12743
- return DEFAULT_CLAUDE_MODELS;
12792
+ return this.modelOptionsCache ?? DEFAULT_CLAUDE_MODELS;
12793
+ } finally {
12794
+ if (!active && query) {
12795
+ query.close();
12796
+ }
12744
12797
  }
12745
12798
  }
12746
12799
  async listSessions() {