dooers-agents-client 0.12.0 → 0.14.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 +68 -12
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +44 -4
- package/dist/main.d.ts +44 -4
- package/dist/main.js +68 -13
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -24,9 +24,6 @@ function apiMessagesUrlToWebSocketUrl(url) {
|
|
|
24
24
|
throw new Error("API Messages URL must start with http://, https://, ws://, or wss://");
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// src/version.ts
|
|
28
|
-
var PACKAGE_VERSION = "0.10.0";
|
|
29
|
-
|
|
30
27
|
// src/types.ts
|
|
31
28
|
function isSettingsFieldGroup(item) {
|
|
32
29
|
return "fields" in item && Array.isArray(item.fields);
|
|
@@ -171,6 +168,34 @@ function toFormResponseEventData(data) {
|
|
|
171
168
|
values: data.values ?? {}
|
|
172
169
|
};
|
|
173
170
|
}
|
|
171
|
+
function toChartSeries(w) {
|
|
172
|
+
return {
|
|
173
|
+
key: w.key,
|
|
174
|
+
label: w.label ?? null,
|
|
175
|
+
color: w.color ?? null
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function toChartEventData(data) {
|
|
179
|
+
const series = data.series ?? [];
|
|
180
|
+
return {
|
|
181
|
+
title: data.title ?? "",
|
|
182
|
+
message: data.message ?? "",
|
|
183
|
+
chartType: data.chart_type ?? "bar",
|
|
184
|
+
size: data.size ?? "medium",
|
|
185
|
+
xKey: data.x_key ?? "",
|
|
186
|
+
yKeys: data.y_keys ?? [],
|
|
187
|
+
data: data.data ?? [],
|
|
188
|
+
series: series.map(
|
|
189
|
+
(item) => toChartSeries({
|
|
190
|
+
key: item.key ?? "",
|
|
191
|
+
label: item.label ?? null,
|
|
192
|
+
color: item.color ?? null
|
|
193
|
+
})
|
|
194
|
+
),
|
|
195
|
+
xLabel: data.x_label ?? null,
|
|
196
|
+
yLabel: data.y_label ?? null
|
|
197
|
+
};
|
|
198
|
+
}
|
|
174
199
|
function toThreadEvent(w) {
|
|
175
200
|
return {
|
|
176
201
|
id: w.id,
|
|
@@ -282,6 +307,9 @@ function toWireContentPart(p) {
|
|
|
282
307
|
}
|
|
283
308
|
}
|
|
284
309
|
|
|
310
|
+
// src/version.ts
|
|
311
|
+
var PACKAGE_VERSION = "0.14.0";
|
|
312
|
+
|
|
285
313
|
// src/client.ts
|
|
286
314
|
var MAX_RECONNECT_ATTEMPTS = 5;
|
|
287
315
|
var RECONNECT_DELAYS = [1e3, 2e3, 4e3, 8e3, 16e3];
|
|
@@ -408,6 +436,13 @@ var AgentClient = class {
|
|
|
408
436
|
onError = null;
|
|
409
437
|
url = "";
|
|
410
438
|
httpBaseUrl = "";
|
|
439
|
+
/**
|
|
440
|
+
* Explicit HTTP base for resolving relative content URLs (e.g. `/audio/<id>`).
|
|
441
|
+
* When set (from the agent's canonical `hostUrl`), it takes precedence over
|
|
442
|
+
* deriving the base from the WS URL — which cannot know the Load Balancer
|
|
443
|
+
* path prefix (`/<agent-seg>`) and would otherwise drop it.
|
|
444
|
+
*/
|
|
445
|
+
httpBaseUrlOverride;
|
|
411
446
|
agentId = "";
|
|
412
447
|
/** Mirrors ``AgentProvider`` ``agentId`` so HTTP uploads work before WS ``connect`` completes. */
|
|
413
448
|
uploadAgentId = "";
|
|
@@ -451,6 +486,18 @@ var AgentClient = class {
|
|
|
451
486
|
setUploadUrl(url) {
|
|
452
487
|
this.uploadUrl = url;
|
|
453
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Set (or clear) the explicit HTTP base used to resolve relative content URLs.
|
|
491
|
+
* Pass the agent's canonical `hostUrl` (base incl. LB seg, no message path).
|
|
492
|
+
* Takes effect immediately and persists across reconnects.
|
|
493
|
+
*/
|
|
494
|
+
setHttpBaseUrl(url) {
|
|
495
|
+
const normalized = url?.trim().replace(/\/+$/, "");
|
|
496
|
+
this.httpBaseUrlOverride = normalized || void 0;
|
|
497
|
+
if (this.httpBaseUrlOverride) {
|
|
498
|
+
this.httpBaseUrl = this.httpBaseUrlOverride;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
454
501
|
/** Sync from ``AgentProvider`` ``agentId``; used for ``POST /uploads`` ``agent_id`` (non-WS). */
|
|
455
502
|
setUploadAgentId(agentId) {
|
|
456
503
|
this.uploadAgentId = (agentId ?? "").trim();
|
|
@@ -524,15 +571,19 @@ var AgentClient = class {
|
|
|
524
571
|
this.uploadAgentId = agentId.trim();
|
|
525
572
|
this.config = config ?? { organizationId: "", workspaceId: "", userId: "" };
|
|
526
573
|
this.isIntentionallyClosed = false;
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
574
|
+
if (this.httpBaseUrlOverride) {
|
|
575
|
+
this.httpBaseUrl = this.httpBaseUrlOverride;
|
|
576
|
+
} else {
|
|
577
|
+
try {
|
|
578
|
+
const parsed = new URL(this.url);
|
|
579
|
+
parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
|
|
580
|
+
parsed.pathname = "";
|
|
581
|
+
parsed.search = "";
|
|
582
|
+
parsed.hash = "";
|
|
583
|
+
this.httpBaseUrl = parsed.toString().replace(/\/$/, "");
|
|
584
|
+
} catch {
|
|
585
|
+
this.httpBaseUrl = "";
|
|
586
|
+
}
|
|
536
587
|
}
|
|
537
588
|
this.callbacks.setConnectionStatus("connecting");
|
|
538
589
|
this.createConnection();
|
|
@@ -1486,6 +1537,7 @@ function AgentProvider({
|
|
|
1486
1537
|
channel,
|
|
1487
1538
|
channelMeta,
|
|
1488
1539
|
uploadUrl,
|
|
1540
|
+
httpBaseUrl,
|
|
1489
1541
|
onError,
|
|
1490
1542
|
children
|
|
1491
1543
|
}) {
|
|
@@ -1501,6 +1553,9 @@ function AgentProvider({
|
|
|
1501
1553
|
react.useEffect(() => {
|
|
1502
1554
|
clientRef.current?.setUploadUrl(uploadUrl);
|
|
1503
1555
|
}, [uploadUrl]);
|
|
1556
|
+
react.useEffect(() => {
|
|
1557
|
+
clientRef.current?.setHttpBaseUrl(httpBaseUrl);
|
|
1558
|
+
}, [httpBaseUrl]);
|
|
1504
1559
|
react.useEffect(() => {
|
|
1505
1560
|
clientRef.current?.setUploadAgentId(agentId);
|
|
1506
1561
|
}, [agentId]);
|
|
@@ -2018,6 +2073,7 @@ exports.AgentServerClient = AgentServerClient;
|
|
|
2018
2073
|
exports.PACKAGE_VERSION = PACKAGE_VERSION;
|
|
2019
2074
|
exports.apiMessagesUrlToWebSocketUrl = apiMessagesUrlToWebSocketUrl;
|
|
2020
2075
|
exports.isSettingsFieldGroup = isSettingsFieldGroup;
|
|
2076
|
+
exports.toChartEventData = toChartEventData;
|
|
2021
2077
|
exports.toFormElement = toFormElement;
|
|
2022
2078
|
exports.toFormEventData = toFormEventData;
|
|
2023
2079
|
exports.toFormResponseEventData = toFormResponseEventData;
|