omniagent 0.1.12 → 0.1.13

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.
@@ -50,7 +50,7 @@ async function extractClaudeUsageFromTui(context) {
50
50
  { waitFor: /Claude|>|❯/u, waitForSource: "screen", waitForTimeoutMs: 8e3 },
51
51
  { write: `/usage${enterKey()}` },
52
52
  {
53
- waitFor: hasClaudeUsageRows,
53
+ waitFor: hasClaudeUsageResult,
54
54
  waitForTimeoutMs: 15e3,
55
55
  capture: "usage",
56
56
  captureWaitMs: 500
@@ -65,6 +65,12 @@ async function extractClaudeUsageFromTui(context) {
65
65
  const parsed = parseClaudeUsage(usageSnapshot.screen, cleanedOutput);
66
66
  const limits = buildClaudeUsageLimits(parsed, context);
67
67
  if (limits.length === 0) {
68
+ const usageError = extractClaudeUsageError(usageSnapshot.screen, cleanedOutput);
69
+ if (usageError != null) {
70
+ const error = new Error(`Claude usage error: ${usageError}`);
71
+ Object.assign(error, { debug: ptyResult.debug });
72
+ throw error;
73
+ }
68
74
  throw new Error("Claude usage output did not include session or weekly usage rows.");
69
75
  }
70
76
  return {
@@ -288,6 +294,26 @@ function hasClaudeUsageRows(snapshot) {
288
294
  const parsed = parseClaudeUsage(snapshot.screen, cleanControlOutput(snapshot.raw));
289
295
  return Boolean(parsed.currentSessionUsed || parsed.currentWeekUsed);
290
296
  }
297
+ function hasClaudeUsageResult(snapshot) {
298
+ return hasClaudeUsageRows(snapshot) || extractClaudeUsageError(snapshot.screen) != null;
299
+ }
300
+ function extractClaudeUsageError(screen, cleanedOutput = "") {
301
+ for (const source of [screen, cleanedOutput]) {
302
+ for (const line of compactLines(source)) {
303
+ const errorMatch = /^Error:\s*(.+)$/i.exec(line);
304
+ if (errorMatch?.[1]) {
305
+ return errorMatch[1].trim();
306
+ }
307
+ if (isClaudeAuthErrorLine(line)) {
308
+ return line;
309
+ }
310
+ }
311
+ }
312
+ return null;
313
+ }
314
+ function isClaudeAuthErrorLine(line) {
315
+ return /\b(?:auth(?:entication)?|credentials?|login|logged in|token)\b/i.test(line) && /\b(?:error|expired|failed|invalid|missing|not|please|required|sign in)\b/i.test(line);
316
+ }
291
317
  function buildClaudeUsageLimits(parsed, context) {
292
318
  const sessionUsed = parsePercentUsed(parsed.currentSessionUsed);
293
319
  const weekUsed = parsePercentUsed(parsed.currentWeekUsed);
package/dist/cli.js CHANGED
@@ -1322,7 +1322,7 @@ const claudeTarget = {
1322
1322
  timeoutMs: 6e4
1323
1323
  },
1324
1324
  extract: async (context) => {
1325
- const { extractClaudeUsage } = await import("./claude-Blr7YqBx.js");
1325
+ const { extractClaudeUsage } = await import("./claude-DWeyS4fP.js");
1326
1326
  return extractClaudeUsage(context);
1327
1327
  }
1328
1328
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omniagent",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Unified agent configuration CLI that compiles canonical agent configs to multiple runtimes.",
5
5
  "type": "module",
6
6
  "bin": {