dooers-agents-client 0.12.0 → 0.13.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/dist/main.cjs CHANGED
@@ -25,7 +25,7 @@ function apiMessagesUrlToWebSocketUrl(url) {
25
25
  }
26
26
 
27
27
  // src/version.ts
28
- var PACKAGE_VERSION = "0.10.0";
28
+ var PACKAGE_VERSION = "0.13.0";
29
29
 
30
30
  // src/types.ts
31
31
  function isSettingsFieldGroup(item) {
@@ -408,6 +408,13 @@ var AgentClient = class {
408
408
  onError = null;
409
409
  url = "";
410
410
  httpBaseUrl = "";
411
+ /**
412
+ * Explicit HTTP base for resolving relative content URLs (e.g. `/audio/<id>`).
413
+ * When set (from the agent's canonical `hostUrl`), it takes precedence over
414
+ * deriving the base from the WS URL — which cannot know the Load Balancer
415
+ * path prefix (`/<agent-seg>`) and would otherwise drop it.
416
+ */
417
+ httpBaseUrlOverride;
411
418
  agentId = "";
412
419
  /** Mirrors ``AgentProvider`` ``agentId`` so HTTP uploads work before WS ``connect`` completes. */
413
420
  uploadAgentId = "";
@@ -451,6 +458,18 @@ var AgentClient = class {
451
458
  setUploadUrl(url) {
452
459
  this.uploadUrl = url;
453
460
  }
461
+ /**
462
+ * Set (or clear) the explicit HTTP base used to resolve relative content URLs.
463
+ * Pass the agent's canonical `hostUrl` (base incl. LB seg, no message path).
464
+ * Takes effect immediately and persists across reconnects.
465
+ */
466
+ setHttpBaseUrl(url) {
467
+ const normalized = url?.trim().replace(/\/+$/, "");
468
+ this.httpBaseUrlOverride = normalized || void 0;
469
+ if (this.httpBaseUrlOverride) {
470
+ this.httpBaseUrl = this.httpBaseUrlOverride;
471
+ }
472
+ }
454
473
  /** Sync from ``AgentProvider`` ``agentId``; used for ``POST /uploads`` ``agent_id`` (non-WS). */
455
474
  setUploadAgentId(agentId) {
456
475
  this.uploadAgentId = (agentId ?? "").trim();
@@ -524,15 +543,19 @@ var AgentClient = class {
524
543
  this.uploadAgentId = agentId.trim();
525
544
  this.config = config ?? { organizationId: "", workspaceId: "", userId: "" };
526
545
  this.isIntentionallyClosed = false;
527
- try {
528
- const parsed = new URL(this.url);
529
- parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
530
- parsed.pathname = "";
531
- parsed.search = "";
532
- parsed.hash = "";
533
- this.httpBaseUrl = parsed.toString().replace(/\/$/, "");
534
- } catch {
535
- this.httpBaseUrl = "";
546
+ if (this.httpBaseUrlOverride) {
547
+ this.httpBaseUrl = this.httpBaseUrlOverride;
548
+ } else {
549
+ try {
550
+ const parsed = new URL(this.url);
551
+ parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
552
+ parsed.pathname = "";
553
+ parsed.search = "";
554
+ parsed.hash = "";
555
+ this.httpBaseUrl = parsed.toString().replace(/\/$/, "");
556
+ } catch {
557
+ this.httpBaseUrl = "";
558
+ }
536
559
  }
537
560
  this.callbacks.setConnectionStatus("connecting");
538
561
  this.createConnection();
@@ -1486,6 +1509,7 @@ function AgentProvider({
1486
1509
  channel,
1487
1510
  channelMeta,
1488
1511
  uploadUrl,
1512
+ httpBaseUrl,
1489
1513
  onError,
1490
1514
  children
1491
1515
  }) {
@@ -1501,6 +1525,9 @@ function AgentProvider({
1501
1525
  react.useEffect(() => {
1502
1526
  clientRef.current?.setUploadUrl(uploadUrl);
1503
1527
  }, [uploadUrl]);
1528
+ react.useEffect(() => {
1529
+ clientRef.current?.setHttpBaseUrl(httpBaseUrl);
1530
+ }, [httpBaseUrl]);
1504
1531
  react.useEffect(() => {
1505
1532
  clientRef.current?.setUploadAgentId(agentId);
1506
1533
  }, [agentId]);