@alan-ai-hq/agent-manager-darwin-arm64 0.1.169 → 0.1.170

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/alan-agent.cjs CHANGED
@@ -58209,7 +58209,7 @@ var import_node_worker_threads2 = require("worker_threads");
58209
58209
  // package.json
58210
58210
  var package_default = {
58211
58211
  name: "@alan-ai-hq/agent-manager",
58212
- version: "0.1.169",
58212
+ version: "0.1.170",
58213
58213
  private: true,
58214
58214
  type: "module",
58215
58215
  description: "Alan machine runtime (alan-agent): identity, link, reconciler, session holders, run log, uploader, local API",
@@ -59044,10 +59044,21 @@ function credentialFailureMessage(response, fallback) {
59044
59044
  return fallback;
59045
59045
  }
59046
59046
  }
59047
+ function credentialRetryDelay(response, attempt2, now) {
59048
+ const hint = headerValue(response, "retry-after")?.trim();
59049
+ let minimum = 250 * 2 ** attempt2;
59050
+ if (hint) {
59051
+ const seconds = Number(hint);
59052
+ const delay4 = Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : Date.parse(hint) - now;
59053
+ if (Number.isFinite(delay4)) minimum = Math.max(minimum, delay4);
59054
+ }
59055
+ return minimum + Math.random() * minimum * 0.2;
59056
+ }
59047
59057
  function createHolderApiClient({
59048
59058
  apiUrl,
59049
59059
  accessToken,
59050
- transport
59060
+ transport,
59061
+ clock = systemClock
59051
59062
  }) {
59052
59063
  const request2 = (method, path4, signal, json2) => transport.send({
59053
59064
  method,
@@ -59059,6 +59070,18 @@ function createHolderApiClient({
59059
59070
  ...json2 === void 0 ? {} : { body: JSON.stringify(json2) },
59060
59071
  signal: AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS3)])
59061
59072
  });
59073
+ const readProviderCredential = async (runId, signal) => {
59074
+ const deadline = clock.monotonic() + REQUEST_TIMEOUT_MS3;
59075
+ const budgetSignal = AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS3)]);
59076
+ for (let attempt2 = 0; ; attempt2 += 1) {
59077
+ budgetSignal.throwIfAborted();
59078
+ const response = await request2("GET", runProviderCredentialPath(runId), budgetSignal);
59079
+ if (attempt2 >= 2 || ![429, 502, 503, 504].includes(response.status)) return response;
59080
+ const delay4 = credentialRetryDelay(response, attempt2, clock.now());
59081
+ if (clock.monotonic() + delay4 >= deadline) return response;
59082
+ await clock.sleep(delay4, budgetSignal);
59083
+ }
59084
+ };
59062
59085
  return {
59063
59086
  downloadAttachment: async (runId, attachmentId, signal) => {
59064
59087
  const response = await request2("GET", runAttachmentPath(runId, attachmentId), signal);
@@ -59071,7 +59094,7 @@ function createHolderApiClient({
59071
59094
  return response.body;
59072
59095
  },
59073
59096
  fetchProviderCredential: async (runId, signal) => {
59074
- const response = await request2("GET", runProviderCredentialPath(runId), signal);
59097
+ const response = await readProviderCredential(runId, signal);
59075
59098
  if (response.status === 404) return { env: {} };
59076
59099
  if (!isOk(response)) {
59077
59100
  throw new RuntimeFault(
package/alan-holder.cjs CHANGED
@@ -48411,10 +48411,21 @@ function credentialFailureMessage(response, fallback) {
48411
48411
  return fallback;
48412
48412
  }
48413
48413
  }
48414
+ function credentialRetryDelay(response, attempt, now) {
48415
+ const hint = headerValue(response, "retry-after")?.trim();
48416
+ let minimum = 250 * 2 ** attempt;
48417
+ if (hint) {
48418
+ const seconds = Number(hint);
48419
+ const delay4 = Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : Date.parse(hint) - now;
48420
+ if (Number.isFinite(delay4)) minimum = Math.max(minimum, delay4);
48421
+ }
48422
+ return minimum + Math.random() * minimum * 0.2;
48423
+ }
48414
48424
  function createHolderApiClient({
48415
48425
  apiUrl,
48416
48426
  accessToken,
48417
- transport
48427
+ transport,
48428
+ clock = systemClock
48418
48429
  }) {
48419
48430
  const request2 = (method, path, signal, json2) => transport.send({
48420
48431
  method,
@@ -48426,6 +48437,18 @@ function createHolderApiClient({
48426
48437
  ...json2 === void 0 ? {} : { body: JSON.stringify(json2) },
48427
48438
  signal: AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)])
48428
48439
  });
48440
+ const readProviderCredential = async (runId, signal) => {
48441
+ const deadline = clock.monotonic() + REQUEST_TIMEOUT_MS;
48442
+ const budgetSignal = AbortSignal.any([signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
48443
+ for (let attempt = 0; ; attempt += 1) {
48444
+ budgetSignal.throwIfAborted();
48445
+ const response = await request2("GET", runProviderCredentialPath(runId), budgetSignal);
48446
+ if (attempt >= 2 || ![429, 502, 503, 504].includes(response.status)) return response;
48447
+ const delay4 = credentialRetryDelay(response, attempt, clock.now());
48448
+ if (clock.monotonic() + delay4 >= deadline) return response;
48449
+ await clock.sleep(delay4, budgetSignal);
48450
+ }
48451
+ };
48429
48452
  return {
48430
48453
  downloadAttachment: async (runId, attachmentId, signal) => {
48431
48454
  const response = await request2("GET", runAttachmentPath(runId, attachmentId), signal);
@@ -48438,7 +48461,7 @@ function createHolderApiClient({
48438
48461
  return response.body;
48439
48462
  },
48440
48463
  fetchProviderCredential: async (runId, signal) => {
48441
- const response = await request2("GET", runProviderCredentialPath(runId), signal);
48464
+ const response = await readProviderCredential(runId, signal);
48442
48465
  if (response.status === 404) return { env: {} };
48443
48466
  if (!isOk(response)) {
48444
48467
  throw new RuntimeFault(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alan-ai-hq/agent-manager-darwin-arm64",
3
- "version": "0.1.169",
3
+ "version": "0.1.170",
4
4
  "description": "Alan machine runtime (alan-agent) for one platform: the official Node.js binary, the runtime bundle and its launcher. Installed by @alan-ai-hq/agent-manager.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://tryalan.ai",