dooers-agents-client 0.9.2 → 0.9.3
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 +45 -11
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +21 -2
- package/dist/main.d.ts +21 -2
- package/dist/main.js +45 -12
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -24,6 +24,9 @@ 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.9.3";
|
|
29
|
+
|
|
27
30
|
// src/types.ts
|
|
28
31
|
function isSettingsFieldGroup(item) {
|
|
29
32
|
return "fields" in item && Array.isArray(item.fields);
|
|
@@ -34,6 +37,8 @@ function toUser(w) {
|
|
|
34
37
|
userId: w.user_id,
|
|
35
38
|
userName: w.user_name,
|
|
36
39
|
userEmail: w.user_email,
|
|
40
|
+
userMobileNumber: w.user_mobile_number,
|
|
41
|
+
userWhatsappNumber: w.user_whatsapp_number,
|
|
37
42
|
identityIds: w.identity_ids,
|
|
38
43
|
systemRole: w.system_role,
|
|
39
44
|
organizationRole: w.organization_role,
|
|
@@ -65,7 +70,8 @@ function toDisplayContentPart(w) {
|
|
|
65
70
|
url: w.url,
|
|
66
71
|
mimeType: w.mime_type,
|
|
67
72
|
duration: w.duration,
|
|
68
|
-
filename: w.filename
|
|
73
|
+
filename: w.filename,
|
|
74
|
+
...w.ref_id ? { refId: w.ref_id } : {}
|
|
69
75
|
};
|
|
70
76
|
case "image":
|
|
71
77
|
return {
|
|
@@ -75,7 +81,8 @@ function toDisplayContentPart(w) {
|
|
|
75
81
|
width: w.width,
|
|
76
82
|
height: w.height,
|
|
77
83
|
alt: w.alt,
|
|
78
|
-
filename: w.filename
|
|
84
|
+
filename: w.filename,
|
|
85
|
+
...w.ref_id ? { refId: w.ref_id } : {}
|
|
79
86
|
};
|
|
80
87
|
case "document":
|
|
81
88
|
return {
|
|
@@ -83,7 +90,8 @@ function toDisplayContentPart(w) {
|
|
|
83
90
|
url: w.url,
|
|
84
91
|
filename: w.filename,
|
|
85
92
|
mimeType: w.mime_type,
|
|
86
|
-
sizeBytes: w.size_bytes
|
|
93
|
+
sizeBytes: w.size_bytes,
|
|
94
|
+
...w.ref_id ? { refId: w.ref_id } : {}
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
97
|
}
|
|
@@ -410,7 +418,8 @@ var AgentClient = class {
|
|
|
410
418
|
config = {
|
|
411
419
|
organizationId: "",
|
|
412
420
|
workspaceId: "",
|
|
413
|
-
userId: ""
|
|
421
|
+
userId: "",
|
|
422
|
+
channel: "dooers-platform"
|
|
414
423
|
};
|
|
415
424
|
connectFrameId = "";
|
|
416
425
|
isIntentionallyClosed = false;
|
|
@@ -697,9 +706,7 @@ var AgentClient = class {
|
|
|
697
706
|
content
|
|
698
707
|
}
|
|
699
708
|
};
|
|
700
|
-
|
|
701
|
-
payload.metadata = params.metadata;
|
|
702
|
-
}
|
|
709
|
+
payload.metadata = this.withChannelMetadata(params.metadata);
|
|
703
710
|
this.sendRaw({
|
|
704
711
|
id: clientEventId,
|
|
705
712
|
type: "event.create",
|
|
@@ -727,7 +734,8 @@ var AgentClient = class {
|
|
|
727
734
|
values: params.values
|
|
728
735
|
}
|
|
729
736
|
}
|
|
730
|
-
}
|
|
737
|
+
},
|
|
738
|
+
metadata: this.withChannelMetadata(params.metadata)
|
|
731
739
|
});
|
|
732
740
|
return promise;
|
|
733
741
|
}
|
|
@@ -787,13 +795,15 @@ var AgentClient = class {
|
|
|
787
795
|
user_id: this.config.userId ?? "",
|
|
788
796
|
user_name: this.config.userName ?? null,
|
|
789
797
|
user_email: this.config.userEmail ?? null,
|
|
798
|
+
user_mobile_number: this.config.userMobileNumber ?? null,
|
|
799
|
+
user_whatsapp_number: this.config.userWhatsappNumber ?? null,
|
|
790
800
|
identity_ids: this.config.identityIds ?? [],
|
|
791
801
|
system_role: this.config.systemRole ?? "user",
|
|
792
802
|
organization_role: this.config.organizationRole ?? "member",
|
|
793
803
|
workspace_role: this.config.workspaceRole ?? "member"
|
|
794
804
|
},
|
|
795
805
|
auth_token: this.config.authToken,
|
|
796
|
-
client: { name: "dooers-agents-client", version:
|
|
806
|
+
client: { name: "dooers-agents-client", version: PACKAGE_VERSION }
|
|
797
807
|
}
|
|
798
808
|
});
|
|
799
809
|
}
|
|
@@ -971,6 +981,17 @@ var AgentClient = class {
|
|
|
971
981
|
send(type, payload) {
|
|
972
982
|
this.sendRaw({ id: crypto.randomUUID(), type, payload });
|
|
973
983
|
}
|
|
984
|
+
withChannelMetadata(metadata) {
|
|
985
|
+
const channel = (this.config.channel || "dooers-platform").trim() || "dooers-platform";
|
|
986
|
+
const base = metadata ? { ...metadata } : {};
|
|
987
|
+
if (!("channel" in base)) {
|
|
988
|
+
base.channel = channel;
|
|
989
|
+
}
|
|
990
|
+
if (this.config.channelMeta && !("channel_meta" in base)) {
|
|
991
|
+
base.channel_meta = this.config.channelMeta;
|
|
992
|
+
}
|
|
993
|
+
return Object.keys(base).length > 0 ? base : void 0;
|
|
994
|
+
}
|
|
974
995
|
sendRaw(frame) {
|
|
975
996
|
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
976
997
|
this.ws.send(JSON.stringify(frame));
|
|
@@ -1412,11 +1433,15 @@ function AgentProvider({
|
|
|
1412
1433
|
userId,
|
|
1413
1434
|
userName,
|
|
1414
1435
|
userEmail,
|
|
1436
|
+
userMobileNumber,
|
|
1437
|
+
userWhatsappNumber,
|
|
1415
1438
|
identityIds,
|
|
1416
1439
|
systemRole,
|
|
1417
1440
|
organizationRole,
|
|
1418
1441
|
workspaceRole,
|
|
1419
1442
|
authToken,
|
|
1443
|
+
channel,
|
|
1444
|
+
channelMeta,
|
|
1420
1445
|
uploadUrl,
|
|
1421
1446
|
onError,
|
|
1422
1447
|
children
|
|
@@ -1445,11 +1470,15 @@ function AgentProvider({
|
|
|
1445
1470
|
userId,
|
|
1446
1471
|
userName,
|
|
1447
1472
|
userEmail,
|
|
1473
|
+
userMobileNumber,
|
|
1474
|
+
userWhatsappNumber,
|
|
1448
1475
|
identityIds: identityIdsKey ? identityIdsKey.split(",") : void 0,
|
|
1449
1476
|
systemRole,
|
|
1450
1477
|
organizationRole,
|
|
1451
1478
|
workspaceRole,
|
|
1452
|
-
authToken
|
|
1479
|
+
authToken,
|
|
1480
|
+
channel,
|
|
1481
|
+
channelMeta
|
|
1453
1482
|
});
|
|
1454
1483
|
return () => clientRef.current?.disconnect();
|
|
1455
1484
|
}, [
|
|
@@ -1460,11 +1489,15 @@ function AgentProvider({
|
|
|
1460
1489
|
userId,
|
|
1461
1490
|
userName,
|
|
1462
1491
|
userEmail,
|
|
1492
|
+
userMobileNumber,
|
|
1493
|
+
userWhatsappNumber,
|
|
1463
1494
|
identityIdsKey,
|
|
1464
1495
|
systemRole,
|
|
1465
1496
|
organizationRole,
|
|
1466
1497
|
workspaceRole,
|
|
1467
|
-
authToken
|
|
1498
|
+
authToken,
|
|
1499
|
+
channel,
|
|
1500
|
+
channelMeta
|
|
1468
1501
|
]);
|
|
1469
1502
|
const contextValue = react.useMemo(
|
|
1470
1503
|
() => ({ store: storeRef.current, client: clientRef.current }),
|
|
@@ -1919,6 +1952,7 @@ function useUpload() {
|
|
|
1919
1952
|
|
|
1920
1953
|
exports.AgentProvider = AgentProvider;
|
|
1921
1954
|
exports.AgentServerClient = AgentServerClient;
|
|
1955
|
+
exports.PACKAGE_VERSION = PACKAGE_VERSION;
|
|
1922
1956
|
exports.apiMessagesUrlToWebSocketUrl = apiMessagesUrlToWebSocketUrl;
|
|
1923
1957
|
exports.isSettingsFieldGroup = isSettingsFieldGroup;
|
|
1924
1958
|
exports.toFormElement = toFormElement;
|