replicas-engine 0.1.1407 → 0.1.1408

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.
@@ -5,12 +5,12 @@ import {
5
5
  CODEX_ULTRAFAST_SERVICE_TIER,
6
6
  getCodexAspHost,
7
7
  listCodexModels,
8
- listRunningCodexModels,
8
+ listCodexModelsForDetails,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-JCICIY7M.js";
11
+ } from "./chunk-LGCVUZYL.js";
12
12
  import "./chunk-DWQGWBB3.js";
13
- import "./chunk-ZRCY3WDY.js";
13
+ import "./chunk-XMROA6MX.js";
14
14
  import "./chunk-5Q5Z7YD5.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
16
  import "./chunk-4N4FOCTR.js";
@@ -19,7 +19,7 @@ export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
20
20
  getCodexAspHost,
21
21
  listCodexModels,
22
- listRunningCodexModels,
22
+ listCodexModelsForDetails,
23
23
  restartCodexAspHost,
24
24
  restartCodexAspHostIfRunning
25
25
  };
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  AspClient
6
- } from "./chunk-ZRCY3WDY.js";
6
+ } from "./chunk-XMROA6MX.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-ZRCY3WDY.js";
17
+ } from "./chunk-XMROA6MX.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
@@ -319,7 +319,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
319
319
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
320
320
  await this.applyCredentialsResponse(data);
321
321
  setAgentCredentialSnapshot("codex", data);
322
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-QW4IL7KX.js");
322
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-S42EWE45.js");
323
323
  await restartCodexAspHostIfRunning2();
324
324
  });
325
325
  await this.start(true);
@@ -341,7 +341,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
341
341
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
342
342
  await this.applyCredentialsResponse(data);
343
343
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
344
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-QW4IL7KX.js");
344
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-S42EWE45.js");
345
345
  await restartCodexAspHostIfRunning2();
346
346
  }
347
347
  setAgentCredentialSnapshot("codex", data);
@@ -1988,24 +1988,29 @@ async function getOpenAICompatibleCodexModelCatalogConfig() {
1988
1988
 
1989
1989
  // src/managers/codex-asp/asp-host.ts
1990
1990
  var CODEX_ULTRAFAST_SERVICE_TIER = "ultrafast";
1991
- var RUNNING_MODEL_LIST_TIMEOUT_MS = 3e3;
1991
+ var MODEL_LIST_TIMEOUT_MS = 3e3;
1992
+ var PROBE_RETRY_MS = 10 * 6e4;
1992
1993
  var hostPromise = null;
1993
1994
  var activeProcess = null;
1994
1995
  var restartPromise = null;
1995
1996
  var modelCatalog = null;
1997
+ var probedCatalog = null;
1998
+ async function createAppServerProcess() {
1999
+ const oauthOptions = await codexTokenManager.prepareAspOauthOptions();
2000
+ return new AppServerProcess({
2001
+ cwd: ENGINE_ENV.WORKSPACE_ROOT,
2002
+ env: buildCodexAgentEnv(),
2003
+ configOverrides: await getOpenAICompatibleCodexModelCatalogConfig(),
2004
+ ...oauthOptions
2005
+ });
2006
+ }
1996
2007
  async function getCodexAspHost() {
1997
2008
  if (restartPromise) {
1998
2009
  await restartPromise;
1999
2010
  }
2000
2011
  hostPromise ??= (async () => {
2001
2012
  try {
2002
- const oauthOptions = await codexTokenManager.prepareAspOauthOptions();
2003
- const process2 = new AppServerProcess({
2004
- cwd: ENGINE_ENV.WORKSPACE_ROOT,
2005
- env: buildCodexAgentEnv(),
2006
- configOverrides: await getOpenAICompatibleCodexModelCatalogConfig(),
2007
- ...oauthOptions
2008
- });
2013
+ const process2 = await createAppServerProcess();
2009
2014
  const { client } = await process2.start();
2010
2015
  activeProcess = process2;
2011
2016
  process2.on("exit", () => {
@@ -2043,21 +2048,22 @@ async function restartCodexAspHost() {
2043
2048
  async function restartCodexAspHostIfRunning() {
2044
2049
  if (activeProcess) await restartCodexAspHost();
2045
2050
  }
2051
+ async function requestCodexModels(client) {
2052
+ const models = [];
2053
+ let cursor = null;
2054
+ do {
2055
+ const response = await client.request(
2056
+ MODEL_LIST_METHOD,
2057
+ { cursor, includeHidden: true }
2058
+ );
2059
+ models.push(...response.data);
2060
+ cursor = response.nextCursor;
2061
+ } while (cursor);
2062
+ return models;
2063
+ }
2046
2064
  function listCodexModels(host) {
2047
2065
  if (modelCatalog?.client !== host.client) {
2048
- const models = (async () => {
2049
- const models2 = [];
2050
- let cursor = null;
2051
- do {
2052
- const response = await host.client.request(
2053
- MODEL_LIST_METHOD,
2054
- { cursor, includeHidden: true }
2055
- );
2056
- models2.push(...response.data);
2057
- cursor = response.nextCursor;
2058
- } while (cursor);
2059
- return models2;
2060
- })();
2066
+ const models = requestCodexModels(host.client);
2061
2067
  modelCatalog = { client: host.client, models };
2062
2068
  models.catch(() => {
2063
2069
  if (modelCatalog?.models === models) modelCatalog = null;
@@ -2065,14 +2071,38 @@ function listCodexModels(host) {
2065
2071
  }
2066
2072
  return modelCatalog.models;
2067
2073
  }
2068
- async function listRunningCodexModels() {
2069
- if (!activeProcess || !hostPromise) return void 0;
2074
+ async function listCodexModelsForDetails() {
2075
+ let models;
2076
+ if (activeProcess && hostPromise) {
2077
+ models = hostPromise.then(listCodexModels);
2078
+ } else {
2079
+ const codex = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex;
2080
+ if (ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD !== "oauth" || !codex?.credentialId) return void 0;
2081
+ const credentialId = `${codex.credentialId}:${codex.revision ?? ""}`;
2082
+ if (probedCatalog?.credentialId !== credentialId || probedCatalog.failedAt && Date.now() - probedCatalog.failedAt > PROBE_RETRY_MS) {
2083
+ const probe = { credentialId, models: probeCodexModels() };
2084
+ probe.models.catch(() => {
2085
+ probe.failedAt = Date.now();
2086
+ });
2087
+ probedCatalog = probe;
2088
+ }
2089
+ models = probedCatalog.models;
2090
+ }
2070
2091
  try {
2071
- return await withTimeout(hostPromise.then(listCodexModels), RUNNING_MODEL_LIST_TIMEOUT_MS, "Codex model list timed out");
2092
+ return await withTimeout(models, MODEL_LIST_TIMEOUT_MS, "Codex model list timed out");
2072
2093
  } catch {
2073
2094
  return void 0;
2074
2095
  }
2075
2096
  }
2097
+ async function probeCodexModels() {
2098
+ const process2 = await createAppServerProcess();
2099
+ try {
2100
+ const { client } = await process2.start();
2101
+ return await requestCodexModels(client);
2102
+ } finally {
2103
+ await process2.stop();
2104
+ }
2105
+ }
2076
2106
 
2077
2107
  export {
2078
2108
  clearCredentialFallbacks,
@@ -2146,7 +2176,7 @@ export {
2146
2176
  restartCodexAspHost,
2147
2177
  restartCodexAspHostIfRunning,
2148
2178
  listCodexModels,
2149
- listRunningCodexModels,
2179
+ listCodexModelsForDetails,
2150
2180
  CodexAspAuthMethodChangedError,
2151
2181
  codexTokenManager
2152
2182
  };
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1406";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1408";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -14,11 +14,11 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-4IGFD7WQ.js";
17
+ } from "./chunk-5JF4CG3T.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-ZRCY3WDY.js";
21
+ } from "./chunk-XMROA6MX.js";
22
22
  import "./chunk-5Q5Z7YD5.js";
23
23
  import {
24
24
  AGENT,
package/dist/src/index.js CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-4IGFD7WQ.js";
68
+ } from "./chunk-5JF4CG3T.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
71
  } from "./chunk-7PAMLAID.js";
@@ -124,8 +124,8 @@ import {
124
124
  isQuotaTurnFailure,
125
125
  itemToTranscriptItem,
126
126
  listCodexModels,
127
+ listCodexModelsForDetails,
127
128
  listCredentialFallbacks,
128
- listRunningCodexModels,
129
129
  loadRepoState,
130
130
  normalizeImages,
131
131
  recordCredentialFallback,
@@ -143,7 +143,7 @@ import {
143
143
  timestampFromSeconds,
144
144
  upsertCredentialFileLines,
145
145
  writeSecureCredentialFile
146
- } from "./chunk-JCICIY7M.js";
146
+ } from "./chunk-LGCVUZYL.js";
147
147
  import {
148
148
  ENGINE_ENV,
149
149
  monolithRequest,
@@ -156,7 +156,7 @@ import {
156
156
  } from "./chunk-DWQGWBB3.js";
157
157
  import {
158
158
  getCodexModelProvider
159
- } from "./chunk-ZRCY3WDY.js";
159
+ } from "./chunk-XMROA6MX.js";
160
160
  import {
161
161
  SUBPROCESS_MAX_BUFFER,
162
162
  execAsync,
@@ -9675,7 +9675,7 @@ var EnvironmentDetailsService = class {
9675
9675
  detectGitIdentityConfigured(),
9676
9676
  detectGitLabAccessConfigured(),
9677
9677
  getPiProviderCredentials(),
9678
- listRunningCodexModels()
9678
+ listCodexModelsForDetails()
9679
9679
  ]);
9680
9680
  details.engineVersion = ENGINE_ENV.REPLICAS_SANDBOX_IMAGE_VERSION;
9681
9681
  details.supportsMidTurnSteering = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1407",
3
+ "version": "0.1.1408",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",