ax 0.10.1 → 0.10.3

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/index.cjs CHANGED
@@ -70,6 +70,20 @@ async function errorBody(res) {
70
70
  payload
71
71
  };
72
72
  }
73
+ async function usageLimitMessage(res) {
74
+ let body = null;
75
+ try {
76
+ body = await res.clone().json();
77
+ } catch {
78
+ return null;
79
+ }
80
+ if (body?.error !== "usage_limit_reached") return null;
81
+ const used = body.used !== void 0 && body.limit !== void 0 ? ` (${body.used} of ${body.limit})` : "";
82
+ const resets = body.resets_at ? ` It resets at ${body.resets_at}.` : "";
83
+ const scope = body.kind ? `${body.kind} limit` : "usage limit";
84
+ const period = body.period ? ` for the ${body.period}` : "";
85
+ return `this API key has used its ${scope}${period}${used}.${resets} GET /api/usage shows the numbers; ask ora to raise the limit.`;
86
+ }
73
87
  async function errorBodyText(res) {
74
88
  return (await errorBody(res)).message;
75
89
  }
@@ -142,7 +156,7 @@ async function fetchAgentFiles(domain, options = {}) {
142
156
  }
143
157
 
144
158
  // src/contract/version.ts
145
- var BUILT_AGAINST = "1.31.0";
159
+ var BUILT_AGAINST = "1.38.0";
146
160
 
147
161
  // src/contract/index.ts
148
162
  function minor(version) {
@@ -220,6 +234,8 @@ async function consumeScanStream(base, target, options) {
220
234
  }
221
235
  if (res.status === 429) {
222
236
  dog.disarm();
237
+ const usage = await usageLimitMessage(res);
238
+ if (usage) throw new AuditApiError(`ora usage limit reached: ${usage}`);
223
239
  const wait = res.headers.get("retry-after");
224
240
  throw new AuditApiError(
225
241
  `ora rate limit exceeded${wait ? ` \u2014 retry after ${wait}s` : ""} (burst: 10 scans/min/IP; daily: 30 scans + 6 force per 24h). An ora-issued scan API key lifts these limits: set ORA_SCAN_API_KEY or pass --api-key.`
@@ -452,6 +468,8 @@ async function triggerRun(base, target, options) {
452
468
  );
453
469
  }
454
470
  if (res.status === 429) {
471
+ const usage = await usageLimitMessage(res);
472
+ if (usage) throw new DeepJourneyApiError(`ora usage limit reached: ${usage}`);
455
473
  const wait = res.headers.get("retry-after");
456
474
  const caps = options.apiKey ? "keyed allowance: 1000 runs per 24h per key" : "burst: 20/min/IP; daily: 20 runs per 24h per IP \u2014 an ora partner API key raises this to 1000/24h per key: set ORA_PARTNER_API_KEY or pass --api-key";
457
475
  throw new DeepJourneyApiError(
package/dist/index.js CHANGED
@@ -32,6 +32,20 @@ async function errorBody(res) {
32
32
  payload
33
33
  };
34
34
  }
35
+ async function usageLimitMessage(res) {
36
+ let body = null;
37
+ try {
38
+ body = await res.clone().json();
39
+ } catch {
40
+ return null;
41
+ }
42
+ if (body?.error !== "usage_limit_reached") return null;
43
+ const used = body.used !== void 0 && body.limit !== void 0 ? ` (${body.used} of ${body.limit})` : "";
44
+ const resets = body.resets_at ? ` It resets at ${body.resets_at}.` : "";
45
+ const scope = body.kind ? `${body.kind} limit` : "usage limit";
46
+ const period = body.period ? ` for the ${body.period}` : "";
47
+ return `this API key has used its ${scope}${period}${used}.${resets} GET /api/usage shows the numbers; ask ora to raise the limit.`;
48
+ }
35
49
  async function errorBodyText(res) {
36
50
  return (await errorBody(res)).message;
37
51
  }
@@ -104,7 +118,7 @@ async function fetchAgentFiles(domain, options = {}) {
104
118
  }
105
119
 
106
120
  // src/contract/version.ts
107
- var BUILT_AGAINST = "1.31.0";
121
+ var BUILT_AGAINST = "1.38.0";
108
122
 
109
123
  // src/contract/index.ts
110
124
  function minor(version) {
@@ -182,6 +196,8 @@ async function consumeScanStream(base, target, options) {
182
196
  }
183
197
  if (res.status === 429) {
184
198
  dog.disarm();
199
+ const usage = await usageLimitMessage(res);
200
+ if (usage) throw new AuditApiError(`ora usage limit reached: ${usage}`);
185
201
  const wait = res.headers.get("retry-after");
186
202
  throw new AuditApiError(
187
203
  `ora rate limit exceeded${wait ? ` \u2014 retry after ${wait}s` : ""} (burst: 10 scans/min/IP; daily: 30 scans + 6 force per 24h). An ora-issued scan API key lifts these limits: set ORA_SCAN_API_KEY or pass --api-key.`
@@ -414,6 +430,8 @@ async function triggerRun(base, target, options) {
414
430
  );
415
431
  }
416
432
  if (res.status === 429) {
433
+ const usage = await usageLimitMessage(res);
434
+ if (usage) throw new DeepJourneyApiError(`ora usage limit reached: ${usage}`);
417
435
  const wait = res.headers.get("retry-after");
418
436
  const caps = options.apiKey ? "keyed allowance: 1000 runs per 24h per key" : "burst: 20/min/IP; daily: 20 runs per 24h per IP \u2014 an ora partner API key raises this to 1000/24h per key: set ORA_PARTNER_API_KEY or pass --api-key";
419
437
  throw new DeepJourneyApiError(