@amigo-ai/platform-sdk 0.4.3 → 0.4.5
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 +46 -13
- package/assets/readme/amigo-banner.png +0 -0
- package/assets/readme/platform-architecture.svg +103 -0
- package/dist/core/retry.js +29 -1
- package/dist/core/retry.js.map +1 -1
- package/dist/index.cjs +27 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +27 -1
- package/dist/index.mjs.map +2 -2
- package/dist/types/core/retry.d.ts.map +1 -1
- package/dist/types/generated/api.d.ts +1132 -244
- package/dist/types/generated/api.d.ts.map +1 -1
- package/dist/types/resources/actions.d.ts.map +1 -1
- package/dist/types/resources/agents.d.ts +4 -4
- package/dist/types/resources/agents.d.ts.map +1 -1
- package/dist/types/resources/analytics.d.ts +1 -3
- package/dist/types/resources/analytics.d.ts.map +1 -1
- package/dist/types/resources/api-keys.d.ts.map +1 -1
- package/dist/types/resources/audit.d.ts.map +1 -1
- package/dist/types/resources/billing.d.ts.map +1 -1
- package/dist/types/resources/calls.d.ts +1 -1
- package/dist/types/resources/calls.d.ts.map +1 -1
- package/dist/types/resources/context-graphs.d.ts.map +1 -1
- package/dist/types/resources/data-sources.d.ts.map +1 -1
- package/dist/types/resources/functions.d.ts.map +1 -1
- package/dist/types/resources/integrations.d.ts.map +1 -1
- package/dist/types/resources/memory.d.ts.map +1 -1
- package/dist/types/resources/operators.d.ts +18 -18
- package/dist/types/resources/operators.d.ts.map +1 -1
- package/dist/types/resources/personas.d.ts.map +1 -1
- package/dist/types/resources/phone-numbers.d.ts +8 -8
- package/dist/types/resources/phone-numbers.d.ts.map +1 -1
- package/dist/types/resources/review-queue.d.ts +6 -6
- package/dist/types/resources/review-queue.d.ts.map +1 -1
- package/dist/types/resources/safety.d.ts.map +1 -1
- package/dist/types/resources/services.d.ts.map +1 -1
- package/dist/types/resources/settings.d.ts.map +1 -1
- package/dist/types/resources/simulations.d.ts.map +1 -1
- package/dist/types/resources/skills.d.ts.map +1 -1
- package/dist/types/resources/triggers.d.ts +35 -35
- package/dist/types/resources/triggers.d.ts.map +1 -1
- package/dist/types/resources/webhook-destinations.d.ts +6 -6
- package/dist/types/resources/webhook-destinations.d.ts.map +1 -1
- package/dist/types/resources/workspaces.d.ts.map +1 -1
- package/dist/types/resources/world.d.ts.map +1 -1
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -321,6 +321,7 @@ function applyHeaders(target, source, onSet) {
|
|
|
321
321
|
// src/core/retry.ts
|
|
322
322
|
var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
323
323
|
var POST_RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429]);
|
|
324
|
+
var jitterCounter = 0;
|
|
324
325
|
function shouldRetry(ctx) {
|
|
325
326
|
const { method, attempt, response, options } = ctx;
|
|
326
327
|
if (attempt >= options.maxAttempts) return false;
|
|
@@ -340,7 +341,7 @@ function computeDelay(attempt, response, options) {
|
|
|
340
341
|
if (seconds !== void 0) return seconds * 1e3;
|
|
341
342
|
}
|
|
342
343
|
const exponential = Math.min(options.maxDelayMs, options.baseDelayMs * Math.pow(2, attempt));
|
|
343
|
-
return
|
|
344
|
+
return jitterFraction() * exponential;
|
|
344
345
|
}
|
|
345
346
|
function parseRetryAfterHeader(header) {
|
|
346
347
|
const seconds = Number(header);
|
|
@@ -359,6 +360,31 @@ function resolveRetryOptions(opts, maxRetries) {
|
|
|
359
360
|
maxDelayMs: opts?.maxDelayMs ?? 3e4
|
|
360
361
|
};
|
|
361
362
|
}
|
|
363
|
+
function jitterFraction() {
|
|
364
|
+
const cryptoApi = getCryptoApi();
|
|
365
|
+
if (cryptoApi) {
|
|
366
|
+
const value = new Uint32Array(1);
|
|
367
|
+
cryptoApi.getRandomValues(value);
|
|
368
|
+
return (value[0] ?? 0) / 4294967296;
|
|
369
|
+
}
|
|
370
|
+
jitterCounter = jitterCounter + 1 >>> 0;
|
|
371
|
+
const mixed = mixUint32((Date.now() ^ Math.imul(jitterCounter, 2654435769)) >>> 0);
|
|
372
|
+
return mixed / 4294967296;
|
|
373
|
+
}
|
|
374
|
+
function getCryptoApi() {
|
|
375
|
+
const cryptoApi = globalThis.crypto;
|
|
376
|
+
if (cryptoApi && typeof cryptoApi.getRandomValues === "function") {
|
|
377
|
+
return cryptoApi;
|
|
378
|
+
}
|
|
379
|
+
return void 0;
|
|
380
|
+
}
|
|
381
|
+
function mixUint32(value) {
|
|
382
|
+
let mixed = (value ^ value >>> 16) >>> 0;
|
|
383
|
+
mixed = Math.imul(mixed, 2146121005) >>> 0;
|
|
384
|
+
mixed = (mixed ^ mixed >>> 15) >>> 0;
|
|
385
|
+
mixed = Math.imul(mixed, 2221713035) >>> 0;
|
|
386
|
+
return (mixed ^ mixed >>> 16) >>> 0;
|
|
387
|
+
}
|
|
362
388
|
|
|
363
389
|
// src/core/utils.ts
|
|
364
390
|
function extractRequestId(response) {
|