@semiont/make-meaning 0.5.12 → 0.5.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.
@@ -1,4 +1,4 @@
1
- import { createTomlConfigLoader, accessToken, baseUrl as baseUrl$1, errField, burstBuffer, busRequest, resourceId, didToAgent, annotationId, findBodyItem } from '@semiont/core';
1
+ import { createTomlConfigLoader, accessToken, baseUrl as baseUrl$1, retryWithBackoff, isTransientFetchError, STARTUP_FETCH_RETRY, errField, burstBuffer, busRequest, resourceId, didToAgent, annotationId, findBodyItem } from '@semiont/core';
2
2
  import { existsSync, readFileSync, promises } from 'fs';
3
3
  import * as path from 'path';
4
4
  import { join } from 'path';
@@ -10612,20 +10612,34 @@ async function authenticate() {
10612
10612
  logger.warn("No SEMIONT_WORKER_SECRET set \u2014 using empty token");
10613
10613
  return "";
10614
10614
  }
10615
- const response = await fetch(`${baseUrl}/api/tokens/agent`, {
10616
- method: "POST",
10617
- headers: { "Content-Type": "application/json" },
10618
- body: JSON.stringify({
10619
- secret: workerSecret,
10620
- provider: "semiont",
10621
- model: "weaver"
10622
- })
10623
- });
10624
- if (!response.ok) {
10625
- throw new Error(`Authentication failed: ${response.status} ${response.statusText}`);
10626
- }
10627
- const { token } = await response.json();
10628
- return token;
10615
+ return retryWithBackoff(
10616
+ async () => {
10617
+ const response = await fetch(`${baseUrl}/api/tokens/agent`, {
10618
+ method: "POST",
10619
+ headers: { "Content-Type": "application/json" },
10620
+ body: JSON.stringify({
10621
+ secret: workerSecret,
10622
+ provider: "semiont",
10623
+ model: "weaver"
10624
+ })
10625
+ });
10626
+ if (!response.ok) {
10627
+ throw new Error(`Authentication failed: ${response.status} ${response.statusText}`);
10628
+ }
10629
+ const { token } = await response.json();
10630
+ return token;
10631
+ },
10632
+ isTransientFetchError,
10633
+ STARTUP_FETCH_RETRY,
10634
+ ({ attempt, attempts, delayMs, error }) => {
10635
+ logger.warn("Backend unreachable, retrying authentication", {
10636
+ attempt,
10637
+ attempts,
10638
+ retryInMs: delayMs,
10639
+ error: error instanceof Error ? error.message : String(error)
10640
+ });
10641
+ }
10642
+ );
10629
10643
  }
10630
10644
  async function main() {
10631
10645
  const { initObservabilityNode } = await import('@semiont/observability/node');