omniagent 0.1.8 → 0.1.9

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/dist/cli.js CHANGED
@@ -1402,7 +1402,7 @@ const codexTarget = {
1402
1402
  timeoutMs: 6e4
1403
1403
  },
1404
1404
  extract: async (context) => {
1405
- const { extractCodexUsage } = await import("./codex-Cl1dWwMk.js");
1405
+ const { extractCodexUsage } = await import("./codex-D1RuzsY6.js");
1406
1406
  return extractCodexUsage(context);
1407
1407
  }
1408
1408
  }
@@ -8376,7 +8376,7 @@ function getTargetCliCommands(target) {
8376
8376
  add(target.cli?.modes?.oneShot?.command);
8377
8377
  return commands;
8378
8378
  }
8379
- async function checkCliOnPath(command) {
8379
+ async function checkCliOnPath(command, options = {}) {
8380
8380
  const normalized = normalizeCommand(command);
8381
8381
  if (!normalized) {
8382
8382
  return { command: command ?? "", result: "unavailable" };
@@ -8387,7 +8387,7 @@ async function checkCliOnPath(command) {
8387
8387
  if (hasPathSeparator(normalized)) {
8388
8388
  for (const candidate of candidates) {
8389
8389
  const check = await checkExecutable(candidate);
8390
- if (check.status === "available") {
8390
+ if (check.status === "available" && await isValidCandidate(check.resolvedPath, options.validateCandidate)) {
8391
8391
  return { command: normalized, result: "available", resolvedPath: check.resolvedPath };
8392
8392
  }
8393
8393
  if (check.status === "inconclusive") {
@@ -8415,7 +8415,7 @@ async function checkCliOnPath(command) {
8415
8415
  for (const candidate of candidates) {
8416
8416
  const fullPath = path.join(entry2, candidate);
8417
8417
  const check = await checkExecutable(fullPath);
8418
- if (check.status === "available") {
8418
+ if (check.status === "available" && await isValidCandidate(check.resolvedPath, options.validateCandidate)) {
8419
8419
  return { command: normalized, result: "available", resolvedPath: check.resolvedPath };
8420
8420
  }
8421
8421
  if (check.status === "inconclusive") {
@@ -8432,6 +8432,16 @@ async function checkCliOnPath(command) {
8432
8432
  }
8433
8433
  return { command: normalized, result: "unavailable" };
8434
8434
  }
8435
+ async function isValidCandidate(resolvedPath, validateCandidate) {
8436
+ if (!validateCandidate) {
8437
+ return true;
8438
+ }
8439
+ try {
8440
+ return await validateCandidate(resolvedPath);
8441
+ } catch {
8442
+ return false;
8443
+ }
8444
+ }
8435
8445
  async function checkTargetAvailability(target) {
8436
8446
  const commands = getTargetCliCommands(target);
8437
8447
  if (commands.length === 0) {
@@ -10666,7 +10676,9 @@ async function checkUsageCommandAvailability(target) {
10666
10676
  warnings: []
10667
10677
  };
10668
10678
  }
10669
- const check = await checkCliOnPath(command);
10679
+ const check = await checkCliOnPath(command, {
10680
+ validateCandidate: target.id === "codex" && command === "codex" ? validateCodexCommand : void 0
10681
+ });
10670
10682
  if (check.result === "available") {
10671
10683
  return {
10672
10684
  status: "available",
@@ -10688,6 +10700,29 @@ async function checkUsageCommandAvailability(target) {
10688
10700
  warnings: []
10689
10701
  };
10690
10702
  }
10703
+ function validateCodexCommand(candidate) {
10704
+ return new Promise((resolve) => {
10705
+ const child = spawn(candidate, ["--version"], {
10706
+ stdio: "ignore"
10707
+ });
10708
+ let settled = false;
10709
+ let timeout;
10710
+ const finish = (valid) => {
10711
+ if (settled) {
10712
+ return;
10713
+ }
10714
+ settled = true;
10715
+ clearTimeout(timeout);
10716
+ resolve(valid);
10717
+ };
10718
+ timeout = setTimeout(() => {
10719
+ child.kill();
10720
+ finish(false);
10721
+ }, 2e3);
10722
+ child.on("error", () => finish(false));
10723
+ child.on("exit", (code) => finish(code === 0));
10724
+ });
10725
+ }
10691
10726
  function buildContext(options) {
10692
10727
  const windows = uniqueNormalizedWindows(options.target.usage?.windows ?? []);
10693
10728
  const launch = {
@@ -10988,16 +11023,20 @@ function formatWindowLabel(window) {
10988
11023
  }
10989
11024
  return window;
10990
11025
  }
11026
+ function formatUsageAgentName(targetId, displayName) {
11027
+ return targetId === "codex" && displayName === "OpenAI Codex" ? "Codex CLI" : displayName;
11028
+ }
10991
11029
  function formatUsageTable(envelope, sortKey) {
10992
11030
  const useColor = shouldUseColor();
10993
11031
  const generatedAt = parseDate(envelope.generatedAt) ?? /* @__PURE__ */ new Date();
10994
11032
  const rows = [];
10995
11033
  for (const target of envelope.targets) {
10996
11034
  const limitLabels = formatLimitLabels(target.limits);
11035
+ const agentName = formatUsageAgentName(target.targetId, target.displayName);
10997
11036
  target.limits.forEach((limit, index) => {
10998
11037
  rows.push({
10999
11038
  status: "ok",
11000
- agent: sortKey == null && index > 0 ? "" : target.displayName,
11039
+ agent: sortKey == null && index > 0 ? "" : agentName,
11001
11040
  limitLabel: limitLabels[index] ?? formatLimitLabel(limit),
11002
11041
  reset: formatResetValue(limit, generatedAt),
11003
11042
  limit
@@ -11007,7 +11046,7 @@ function formatUsageTable(envelope, sortKey) {
11007
11046
  for (const error of envelope.errors) {
11008
11047
  rows.push({
11009
11048
  status: "error",
11010
- agent: error.displayName,
11049
+ agent: formatUsageAgentName(error.targetId, error.displayName),
11011
11050
  limitLabel: "error",
11012
11051
  message: error.message
11013
11052
  });
@@ -11262,16 +11301,7 @@ async function runUsageCommand(argv) {
11262
11301
  return null;
11263
11302
  }
11264
11303
  const startDir = process.cwd();
11265
- const repoRoot = await findRepoRoot(startDir);
11266
- if (!repoRoot) {
11267
- printError({
11268
- json: jsonOutput,
11269
- code: "repo_not_found",
11270
- message: `Repository root not found starting from ${startDir}. Looked for .git or package.json.`,
11271
- exitCode: 1
11272
- });
11273
- return null;
11274
- }
11304
+ const repoRoot = await findRepoRoot(startDir) ?? startDir;
11275
11305
  const agentsDirResolution = resolveAgentsDir(repoRoot, argv.agentsDir);
11276
11306
  if (agentsDirResolution.source === "override") {
11277
11307
  const validation2 = await validateAgentsDir(repoRoot, argv.agentsDir, { requireWrite: false });
@@ -11535,7 +11565,7 @@ const usageCommand = {
11535
11565
  describe: "Per-agent extraction timeout. Bare numbers are seconds; units include ms, s, and m."
11536
11566
  }).option("agentsDir", {
11537
11567
  type: "string",
11538
- describe: "Override the agents directory (relative paths resolve from the project root)",
11568
+ describe: "Override the agents directory (relative paths resolve from the project root, or the current directory outside a repo)",
11539
11569
  defaultDescription: DEFAULT_AGENTS_DIR,
11540
11570
  coerce: (value) => {
11541
11571
  if (typeof value !== "string") {
@@ -1,5 +1,5 @@
1
1
  import { c as cleanControlOutput, b as parsePercentRemaining, m as makeUsageLimit, d as parseResetText } from "./cli.js";
2
- import { r as runPtyScenario, t as typeTextSteps, e as enterKey } from "./pty-CZBSAJzE.js";
2
+ import { r as runPtyScenario, e as enterKey, t as typeTextSteps } from "./pty-CZBSAJzE.js";
3
3
  const CODEX_WINDOWS = [
4
4
  ["main", "5h", "main5hLimit"],
5
5
  ["main", "weekly", "mainWeeklyLimit"],
@@ -12,13 +12,15 @@ async function extractCodexUsage(context) {
12
12
  const ptyResult = await runPtyScenario({
13
13
  command,
14
14
  args: context.launch?.args ?? ["--no-alt-screen"],
15
- cwd: context.repoRoot,
15
+ cwd: context.homeDir,
16
16
  cols: 100,
17
17
  rows: 40,
18
18
  timeoutMs: context.launch?.timeoutMs ?? 6e4,
19
19
  signal: context.signal,
20
20
  debug: context.debug,
21
21
  steps: [
22
+ { waitFor: isCodexPromptReadyOrTrustPrompt, waitForTimeoutMs: 1e4 },
23
+ { write: enterKey(), skipIf: isCodexPromptReady },
22
24
  { waitFor: isCodexPromptReady, waitForTimeoutMs: 1e4 },
23
25
  ...typeTextSteps("/status", 20),
24
26
  { write: enterKey() },
@@ -81,6 +83,14 @@ function isCodexPromptReady(snapshot) {
81
83
  ${snapshot.raw}`);
82
84
  return /(?:\u203a|>)\s/.test(cleanedOutput) && /\bContext\b/i.test(cleanedOutput);
83
85
  }
86
+ function isCodexPromptReadyOrTrustPrompt(snapshot) {
87
+ return isCodexPromptReady(snapshot) || isCodexTrustPrompt(snapshot);
88
+ }
89
+ function isCodexTrustPrompt(snapshot) {
90
+ const cleanedOutput = cleanControlOutput(`${snapshot.screen}
91
+ ${snapshot.raw}`);
92
+ return /do you trust the contents of this directory/i.test(cleanedOutput);
93
+ }
84
94
  function hasCodexStatusLimits(snapshot) {
85
95
  const cleanedOutput = cleanControlOutput(`${snapshot.screen}
86
96
  ${snapshot.raw}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniagent",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Unified agent configuration CLI that compiles canonical agent configs to multiple runtimes.",
5
5
  "type": "module",
6
6
  "bin": {