remote-codex 0.11.42 → 0.11.44

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,48 @@ 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
- const output = [...models];
12105
- const defaultSonnet = DEFAULT_CLAUDE_MODELS[0];
12106
- const oneMillionSonnet = DEFAULT_CLAUDE_MODELS[1];
12107
- const fable = DEFAULT_CLAUDE_MODELS[2];
12131
+ const discoveredSonnet = models.find((model) => /^Sonnet · /.test(model.displayName));
12132
+ const discoveredFable = models.find((model) => /^Fable · /.test(model.displayName));
12133
+ const discoveredOpus = models.find((model) => /^Opus · /.test(model.displayName));
12134
+ const output = models.filter(
12135
+ (model) => model !== discoveredFable || discoveredFable.model === "fable"
12136
+ );
12137
+ const defaultSonnet = versionedAlias(DEFAULT_CLAUDE_MODELS[0], discoveredSonnet);
12138
+ const oneMillionSonnet = versionedAlias(
12139
+ DEFAULT_CLAUDE_MODELS[1],
12140
+ discoveredSonnet,
12141
+ " (1M context)"
12142
+ );
12143
+ const fable = versionedAlias(DEFAULT_CLAUDE_MODELS[2], discoveredFable);
12144
+ const opus = versionedAlias(DEFAULT_CLAUDE_MODELS[3], discoveredOpus);
12108
12145
  const hasSonnetAlias = output.some((model) => model.model === "sonnet");
12109
12146
  if (!hasSonnetAlias) {
12110
12147
  output.unshift(defaultSonnet);
@@ -12115,6 +12152,10 @@ function withClaudeCodeModelAliases(models) {
12115
12152
  if (!output.some((model) => model.model === "fable")) {
12116
12153
  output.splice(2, 0, fable);
12117
12154
  }
12155
+ if (!output.some((model) => model.model === "opus")) {
12156
+ const discoveredOpusIndex = output.findIndex((model) => /^Opus · /.test(model.displayName));
12157
+ output.splice(discoveredOpusIndex >= 0 ? discoveredOpusIndex : output.length, 0, opus);
12158
+ }
12118
12159
  return output.map((model, index) => ({
12119
12160
  ...model,
12120
12161
  isDefault: index === 0
@@ -12613,6 +12654,7 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12613
12654
  subscriptionUsageWindows = /* @__PURE__ */ new Map();
12614
12655
  subscriptionAuthKind = "unknown";
12615
12656
  subscriptionUsageObservedAt = null;
12657
+ modelOptionsCache = null;
12616
12658
  historicalTurnIdAliases = /* @__PURE__ */ new Map();
12617
12659
  clientApp;
12618
12660
  sdkLoadError = null;
@@ -12733,14 +12775,33 @@ var ClaudeRuntimeAdapter = class extends EventEmitter5 {
12733
12775
  }
12734
12776
  async listModels() {
12735
12777
  const active = [...this.activeTurns.values()][0];
12736
- if (!active) {
12737
- return DEFAULT_CLAUDE_MODELS;
12778
+ if (!active && this.modelOptionsCache) {
12779
+ return this.modelOptionsCache;
12738
12780
  }
12781
+ let query = active?.query ?? null;
12739
12782
  try {
12740
- const models = await active.query.supportedModels();
12741
- return withClaudeCodeModelAliases(models.map(mapModelInfo));
12783
+ query ??= this.queryFactory({
12784
+ prompt: "",
12785
+ options: queryOptionsForRuntime({
12786
+ home: this.options.home,
12787
+ command: this.options.command,
12788
+ clientApp: this.clientApp,
12789
+ approvalMode: "guarded",
12790
+ includePartialMessages: false,
12791
+ tools: [],
12792
+ maxTurns: 1
12793
+ })
12794
+ });
12795
+ const models = await query.supportedModels();
12796
+ const mapped = withClaudeCodeModelAliases(models.map(mapModelInfo));
12797
+ this.modelOptionsCache = mapped;
12798
+ return mapped;
12742
12799
  } catch {
12743
- return DEFAULT_CLAUDE_MODELS;
12800
+ return this.modelOptionsCache ?? DEFAULT_CLAUDE_MODELS;
12801
+ } finally {
12802
+ if (!active && query) {
12803
+ query.close();
12804
+ }
12744
12805
  }
12745
12806
  }
12746
12807
  async listSessions() {