@sireai/optimus 0.1.11 → 0.1.14

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.
Files changed (26) hide show
  1. package/dist/cli/optimus.js +58 -11
  2. package/dist/cli/optimus.js.map +1 -1
  3. package/dist/config/load-config.js +1 -1
  4. package/dist/problem-solving-core/codex/codex-auth-resolver.d.ts +3 -0
  5. package/dist/problem-solving-core/codex/codex-auth-resolver.js +101 -17
  6. package/dist/problem-solving-core/codex/codex-auth-resolver.js.map +1 -1
  7. package/dist/problem-solving-core/codex/codex-connectivity-checks.js +24 -14
  8. package/dist/problem-solving-core/codex/codex-connectivity-checks.js.map +1 -1
  9. package/dist/problem-solving-core/codex/codex-preflight.d.ts +0 -1
  10. package/dist/problem-solving-core/codex/codex-preflight.js +13 -21
  11. package/dist/problem-solving-core/codex/codex-preflight.js.map +1 -1
  12. package/dist/problem-solving-core/codex/codex-provider-profile.js +3 -0
  13. package/dist/problem-solving-core/codex/codex-provider-profile.js.map +1 -1
  14. package/dist/problem-solving-core/codex/codex-runner.js +10 -2
  15. package/dist/problem-solving-core/codex/codex-runner.js.map +1 -1
  16. package/dist/task-environment/observability/runtime-panel.d.ts +1 -1
  17. package/dist/task-environment/observability/runtime-panel.js +4 -1
  18. package/dist/task-environment/observability/runtime-panel.js.map +1 -1
  19. package/dist/task-environment/orchestration/triage-runner.js +10 -2
  20. package/dist/task-environment/orchestration/triage-runner.js.map +1 -1
  21. package/dist/task-environment/runtime/optimus-runtime.d.ts +1 -0
  22. package/dist/task-environment/runtime/optimus-runtime.js +1 -1
  23. package/dist/task-environment/runtime/optimus-runtime.js.map +1 -1
  24. package/dist/types.d.ts +15 -1
  25. package/optimus.config.template.json +1 -1
  26. package/package.json +1 -1
@@ -1039,12 +1039,13 @@ async function resolveDefaultSetupAnswers() {
1039
1039
  enableSentry: false
1040
1040
  };
1041
1041
  }
1042
+ const rawConfig = await readRawProjectConfig(configPath);
1042
1043
  const config = await loadConfig(configPath);
1043
1044
  const store = new SQLiteTaskStore(config.storage.rootDir);
1044
1045
  await store.init();
1045
1046
  const repositories = await store.listRepositoryRoots();
1046
1047
  const primaryRepository = repositories[0];
1047
- const provider = config.codex.provider;
1048
+ const provider = config.codex.provider ?? resolveSetupCachedProvider(rawConfig);
1048
1049
  return {
1049
1050
  repoPath: primaryRepository?.path ?? "",
1050
1051
  repoAlias: primaryRepository?.alias ?? "",
@@ -1183,8 +1184,45 @@ function resolveSetupCodexApiKeyEnvName(answers) {
1183
1184
  }
1184
1185
  return undefined;
1185
1186
  }
1186
- function buildSetupConfig(answers) {
1187
+ function normalizeSetupCachedProvider(input) {
1188
+ if (!input || typeof input !== "object") {
1189
+ return undefined;
1190
+ }
1191
+ const candidate = input;
1192
+ const id = candidate.id?.trim();
1193
+ const displayName = candidate.displayName?.trim();
1194
+ const baseUrl = candidate.baseUrl?.trim();
1195
+ const apiKeyEnvName = candidate.apiKeyEnvName?.trim();
1196
+ const wireApi = candidate.wireApi;
1197
+ if (!id || !displayName || !baseUrl || !apiKeyEnvName || (wireApi !== "responses" && wireApi !== "chat")) {
1198
+ return undefined;
1199
+ }
1200
+ return {
1201
+ id,
1202
+ displayName,
1203
+ baseUrl,
1204
+ apiKeyEnvName,
1205
+ wireApi
1206
+ };
1207
+ }
1208
+ function resolveSetupCachedProvider(rawConfig) {
1209
+ const activeProvider = normalizeSetupCachedProvider(rawConfig?.codex?.provider);
1210
+ if (activeProvider) {
1211
+ return activeProvider;
1212
+ }
1213
+ return normalizeSetupCachedProvider(rawConfig?.codex?.setupCache?.modelProvider);
1214
+ }
1215
+ function buildSetupConfig(answers, rawConfig) {
1187
1216
  const config = buildDefaultConfig();
1217
+ const cachedProvider = answers.codexAuthMode === "model_provider"
1218
+ ? {
1219
+ id: answers.codexProviderId.trim(),
1220
+ displayName: answers.codexProviderDisplayName.trim(),
1221
+ baseUrl: answers.codexProviderBaseUrl.trim(),
1222
+ apiKeyEnvName: answers.codexProviderApiKeyEnvName.trim(),
1223
+ wireApi: "responses"
1224
+ }
1225
+ : resolveSetupCachedProvider(rawConfig);
1188
1226
  config.codex.auth.mode = answers.codexAuthMode;
1189
1227
  if (answers.codexAuthMode === "model_provider") {
1190
1228
  config.codex.provider = {
@@ -1198,6 +1236,14 @@ function buildSetupConfig(answers) {
1198
1236
  else {
1199
1237
  delete config.codex.provider;
1200
1238
  }
1239
+ if (cachedProvider) {
1240
+ config.codex.setupCache = {
1241
+ modelProvider: cachedProvider
1242
+ };
1243
+ }
1244
+ else {
1245
+ delete config.codex.setupCache;
1246
+ }
1201
1247
  config.delivery.channels = answers.enableFeishu ? ["console", "feishu"] : ["console"];
1202
1248
  config.delivery.feishu = {
1203
1249
  ...config.delivery.feishu,
@@ -1329,18 +1375,16 @@ async function runQuickDoctor(configPath = resolveDefaultConfigPath()) {
1329
1375
  if (!codexAuth.authenticated) {
1330
1376
  blocking.push({
1331
1377
  code: "codex_auth_missing",
1332
- message: `Codex authentication is missing. Required credential: ${codexAuth.apiKeyEnvName ?? "runtime login"}.`,
1333
- fix: codexAuth.apiKeyEnvName
1334
- ? `Provide ${codexAuth.apiKeyEnvName} in .env.local, or rerun \`optimus setup\` and enter the Codex API key.`
1335
- : "Rerun `optimus setup` and select a supported Codex auth mode."
1378
+ message: `Codex authentication is missing for ${codexAuth.validationPath}. Required credential: ${codexAuth.requirement}.`,
1379
+ fix: codexAuth.fixHint
1336
1380
  });
1337
1381
  next.add("optimus setup");
1338
1382
  }
1339
- if (codexAuth.mode === "codex_cli_login") {
1383
+ if (codexAuth.mode === "codex_cli_login" && codexAuth.authenticated) {
1340
1384
  warnings.push({
1341
- code: "codex_cli_login_runtime_validation",
1385
+ code: "codex_cli_login_resolved",
1342
1386
  message: "Codex auth mode is codex_cli_login.",
1343
- impact: "Quick doctor cannot statically verify local Codex CLI login; the first runtime turn will validate it."
1387
+ impact: `Local Codex CLI login was resolved from ${codexAuth.authFilePath ?? "~/.codex/auth.json"}.`
1344
1388
  });
1345
1389
  }
1346
1390
  if (!config.codex.model?.trim()) {
@@ -1502,8 +1546,9 @@ async function runSetup(args) {
1502
1546
  const resolvedExecutionMode = existingRepository?.executionMode ?? describeRepositoryExecutionPlan({ executionMode: "copy" }, inspection).resolvedDefaultMode;
1503
1547
  const previewExecutionPlan = describeRepositoryExecutionPlan({ executionMode: resolvedExecutionMode }, inspection);
1504
1548
  const reviewSystem = await detectRepositoryReviewSystem(normalizedRepoPath, inspection);
1549
+ const rawConfig = configExists ? await readRawProjectConfig(configPath) : undefined;
1505
1550
  await mkdir(dirname(configPath), { recursive: true });
1506
- await writeFile(configPath, `${buildSetupConfig({ ...answers, repoPath: normalizedRepoPath })}\n`, "utf8");
1551
+ await writeFile(configPath, `${buildSetupConfig({ ...answers, repoPath: normalizedRepoPath }, rawConfig)}\n`, "utf8");
1507
1552
  const codexAuthEnvName = resolveSetupCodexApiKeyEnvName(answers);
1508
1553
  if (answers.codexApiKey && codexAuthEnvName) {
1509
1554
  await mkdir(dirname(envPath), { recursive: true });
@@ -1916,8 +1961,10 @@ async function main() {
1916
1961
  const logger = new OptimusLogger(config);
1917
1962
  const eventStore = new SQLiteEventStore(config.storage.rootDir);
1918
1963
  const taskOrchestrator = new TaskOrchestrator(store, codexRunner, config);
1919
- const runtime = new OptimusRuntime(store, taskOrchestrator, config);
1920
1964
  const currentVersion = await readPackageVersion();
1965
+ const runtime = new OptimusRuntime(store, taskOrchestrator, config, {
1966
+ version: currentVersion
1967
+ });
1921
1968
  if (command === "start" || command === "submit") {
1922
1969
  const selfUpdateOutcome = await maybeHandleStartupSelfUpdate({
1923
1970
  command,