@oxygen-agent/cli 1.162.10 → 1.177.0
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/README.md +1 -1
- package/dist/http-client.js +2 -78
- package/dist/index.js +1312 -527
- package/dist/run-wait.d.ts +23 -0
- package/dist/run-wait.js +57 -0
- package/node_modules/@oxygen/recipe-sdk/dist/index.d.ts +0 -5
- package/node_modules/@oxygen/shared/dist/cell-format.d.ts +2 -14
- package/node_modules/@oxygen/shared/dist/cell-format.js +3 -10
- package/node_modules/@oxygen/shared/dist/cli-envelope.d.ts +27 -0
- package/node_modules/@oxygen/shared/dist/cli-envelope.js +102 -0
- package/node_modules/@oxygen/shared/dist/cli-result.d.ts +39 -0
- package/node_modules/@oxygen/shared/dist/cli-result.js +52 -0
- package/node_modules/@oxygen/shared/dist/credit-guidance.d.ts +0 -1
- package/node_modules/@oxygen/shared/dist/credit-guidance.js +1 -1
- package/node_modules/@oxygen/shared/dist/file-import.js +1 -1
- package/node_modules/@oxygen/shared/dist/index.d.ts +3 -39
- package/node_modules/@oxygen/shared/dist/index.js +3 -44
- package/node_modules/@oxygen/shared/dist/log.d.ts +0 -1
- package/node_modules/@oxygen/shared/dist/log.js +8 -3
- package/node_modules/@oxygen/shared/dist/object-storage.d.ts +0 -3
- package/node_modules/@oxygen/shared/dist/object-storage.js +1 -24
- package/node_modules/@oxygen/shared/dist/redaction.js +45 -4
- package/node_modules/@oxygen/shared/dist/search-vocab.d.ts +18 -0
- package/node_modules/@oxygen/shared/dist/search-vocab.js +151 -0
- package/node_modules/@oxygen/shared/dist/select-options.d.ts +18 -0
- package/node_modules/@oxygen/shared/dist/select-options.js +121 -0
- package/node_modules/@oxygen/shared/dist/sequences.js +1 -1
- package/node_modules/@oxygen/shared/dist/sql-error.d.ts +0 -6
- package/node_modules/@oxygen/shared/dist/sql-error.js +67 -58
- package/node_modules/@oxygen/shared/dist/telemetry.d.ts +0 -1
- package/node_modules/@oxygen/shared/dist/telemetry.js +23 -18
- package/node_modules/@oxygen/shared/dist/version.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/version.js +1 -1
- package/node_modules/@oxygen/shared/dist/worker-failures-queue.d.ts +22 -0
- package/node_modules/@oxygen/shared/dist/worker-failures-queue.js +56 -0
- package/node_modules/@oxygen/workflows/dist/index.d.ts +12 -11
- package/node_modules/@oxygen/workflows/dist/index.js +58 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/http-client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OXYGEN_VERSION, OxygenError, isVersionGreater } from "@oxygen/shared";
|
|
1
|
+
import { OXYGEN_VERSION, OxygenError, isCliResult, isVersionGreater, readEnvelopeCompatibility, vercelProtectionBypassHeaders, withRetryAfterDetails, } from "@oxygen/shared";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { defaultApiUrl, loadCredentials } from "./credentials.js";
|
|
4
4
|
import { resolveCliUpdateGuidance } from "./runtime.js";
|
|
@@ -28,7 +28,7 @@ path, options = {}) {
|
|
|
28
28
|
// even against clients that predate the client-side envelope gate.
|
|
29
29
|
"X-Oxygen-Client-Version": OXYGEN_VERSION,
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
Object.assign(headers, vercelProtectionBypassHeaders(apiUrl));
|
|
32
32
|
if (credentials?.token) {
|
|
33
33
|
headers.Authorization = `Bearer ${credentials.token}`;
|
|
34
34
|
}
|
|
@@ -188,56 +188,6 @@ function assertCliMeetsMinimumApiVersion(compatibility, options, apiUrl) {
|
|
|
188
188
|
exitCode: 1,
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
function readEnvelopeCompatibility(envelope) {
|
|
192
|
-
const meta = envelope.meta;
|
|
193
|
-
if (!meta || typeof meta !== "object" || Array.isArray(meta))
|
|
194
|
-
return {};
|
|
195
|
-
const record = meta;
|
|
196
|
-
const compatibility = {};
|
|
197
|
-
if (typeof record.version === "string")
|
|
198
|
-
compatibility.version = record.version;
|
|
199
|
-
if (typeof record.minimum_cli_version === "string") {
|
|
200
|
-
compatibility.minimumCliVersion = record.minimum_cli_version;
|
|
201
|
-
}
|
|
202
|
-
return compatibility;
|
|
203
|
-
}
|
|
204
|
-
// Surface the server's 429 backoff as a first-class `retry_after_seconds` detail
|
|
205
|
-
// so loop-driving callers can wait the right amount of time instead of dead-
|
|
206
|
-
// reckoning. Prefers a value the API already put in details; otherwise derives
|
|
207
|
-
// it from the RFC 6585 Retry-After header (or reset_at). Non-429 responses and
|
|
208
|
-
// unparseable values pass through untouched.
|
|
209
|
-
function withRetryAfterDetails(details, response) {
|
|
210
|
-
if (response.status !== 429)
|
|
211
|
-
return details;
|
|
212
|
-
const record = details && typeof details === "object" && !Array.isArray(details)
|
|
213
|
-
? details
|
|
214
|
-
: null;
|
|
215
|
-
if (record && typeof record.retry_after_seconds === "number")
|
|
216
|
-
return details;
|
|
217
|
-
const retryAfterSeconds = retryAfterSecondsFromResponse(response, record);
|
|
218
|
-
if (retryAfterSeconds === null)
|
|
219
|
-
return details;
|
|
220
|
-
if (record)
|
|
221
|
-
return { ...record, retry_after_seconds: retryAfterSeconds };
|
|
222
|
-
if (details === undefined)
|
|
223
|
-
return { retry_after_seconds: retryAfterSeconds };
|
|
224
|
-
return { details, retry_after_seconds: retryAfterSeconds };
|
|
225
|
-
}
|
|
226
|
-
function retryAfterSecondsFromResponse(response, details) {
|
|
227
|
-
const header = response.headers.get("retry-after");
|
|
228
|
-
if (header) {
|
|
229
|
-
const seconds = Number(header);
|
|
230
|
-
if (Number.isFinite(seconds) && seconds >= 0)
|
|
231
|
-
return Math.ceil(seconds);
|
|
232
|
-
}
|
|
233
|
-
const resetAt = details?.reset_at;
|
|
234
|
-
if (typeof resetAt === "string") {
|
|
235
|
-
const resetMs = Date.parse(resetAt);
|
|
236
|
-
if (!Number.isNaN(resetMs))
|
|
237
|
-
return Math.max(0, Math.ceil((resetMs - Date.now()) / 1000));
|
|
238
|
-
}
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
191
|
function withTraceDetails(details, traceId, compatibility, apiUrl) {
|
|
242
192
|
const serverVersion = compatibility.version;
|
|
243
193
|
const fields = {
|
|
@@ -266,21 +216,6 @@ function withTraceDetails(details, traceId, compatibility, apiUrl) {
|
|
|
266
216
|
...fields,
|
|
267
217
|
};
|
|
268
218
|
}
|
|
269
|
-
function addVercelProtectionBypassHeader(apiUrl, headers) {
|
|
270
|
-
const secret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();
|
|
271
|
-
if (!secret)
|
|
272
|
-
return;
|
|
273
|
-
let hostname;
|
|
274
|
-
try {
|
|
275
|
-
hostname = new URL(apiUrl).hostname;
|
|
276
|
-
}
|
|
277
|
-
catch {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (hostname === "vercel.app" || hostname.endsWith(".vercel.app")) {
|
|
281
|
-
headers["x-vercel-protection-bypass"] = secret;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
219
|
function resolveRequestTimeoutMs(value) {
|
|
285
220
|
if (value === undefined)
|
|
286
221
|
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
@@ -333,14 +268,3 @@ async function readEnvelope(response) {
|
|
|
333
268
|
exitCode: 1,
|
|
334
269
|
});
|
|
335
270
|
}
|
|
336
|
-
function isCliResult(value) {
|
|
337
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
338
|
-
return false;
|
|
339
|
-
const ok = value.ok;
|
|
340
|
-
if (ok === true)
|
|
341
|
-
return "data" in value;
|
|
342
|
-
if (ok !== false)
|
|
343
|
-
return false;
|
|
344
|
-
const error = value.error;
|
|
345
|
-
return Boolean(error) && typeof error === "object" && !Array.isArray(error);
|
|
346
|
-
}
|