@agimon-ai/po-team 0.0.0-alpha.37 → 0.0.0-alpha.38
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.
|
@@ -4057,28 +4057,34 @@ function createHeadlessIntercomTool(channel, sessions) {
|
|
|
4057
4057
|
const teamMember = to !== void 0 && channel.snapshot().members.some((member) => member.name === to) && !knownId && !peers.some((peer) => peer.sessionId === to);
|
|
4058
4058
|
const peer = sessions === void 0 || to === void 0 || teamMember ? void 0 : knownId ? peers.find((candidate) => candidate.sessionId === to) : resolvePeer(peers, to);
|
|
4059
4059
|
const recipientId = knownId ? to : peer?.sessionId;
|
|
4060
|
+
if (sessions !== void 0 && to?.startsWith("peer/") && recipientId === void 0) throw invalidRequest("Remote session is not in a linked shared group.", "Use members to find current peers.");
|
|
4060
4061
|
if (sessions !== void 0 && recipientId !== void 0) {
|
|
4062
|
+
const remote = recipientId.startsWith("peer/");
|
|
4063
|
+
const metadata = remote ? sessions.metadataFor?.(recipientId) : void 0;
|
|
4064
|
+
if (remote && (metadata === void 0 || !sessions.canCommunicate(recipientId))) throw invalidRequest("Remote session is not in a linked shared group.", "Use members to find current peers.");
|
|
4061
4065
|
if (params.action !== "send") throw invalidRequest("Session peers support send only.", "Use send with the session name or ID.");
|
|
4062
4066
|
const message = validateMessage(params.message);
|
|
4063
4067
|
const delivery = sessions.delivery();
|
|
4064
4068
|
if (delivery === void 0) throw new Error("Session delivery is unavailable.");
|
|
4065
4069
|
const senderName = sessions.name?.()?.trim() || sessions.sessionId;
|
|
4070
|
+
const replyTo = metadata?.sourceReference ?? senderName;
|
|
4066
4071
|
const toName = peer?.name.trim() || recipientId;
|
|
4067
4072
|
const deliveryId = `intercom:${sessions.sessionId}:${toolCallId}`;
|
|
4068
4073
|
const receipt = await delivery.deliver({
|
|
4069
4074
|
deliveryId,
|
|
4070
4075
|
recipientKey: recipientId,
|
|
4071
4076
|
kind: TEAM_MESSAGE_CUSTOM_TYPE,
|
|
4072
|
-
prompt: `Message from session ${senderName} via intercom.\n\n${message}\n\nReply using intercom({ action: "send", to: ${JSON.stringify(
|
|
4077
|
+
prompt: `Message from session ${senderName} via intercom.\n\n${message}\n\nReply using intercom({ action: "send", to: ${JSON.stringify(replyTo)}, message: "..." }).`,
|
|
4073
4078
|
delivery: "steer",
|
|
4074
4079
|
metadata: {
|
|
4080
|
+
...metadata,
|
|
4075
4081
|
customType: TEAM_MESSAGE_CUSTOM_TYPE,
|
|
4076
4082
|
customDetails: JSON.stringify({
|
|
4077
4083
|
kind: "send",
|
|
4078
4084
|
from: {
|
|
4079
4085
|
name: senderName,
|
|
4080
4086
|
role: "session",
|
|
4081
|
-
sessionId: sessions.sessionId
|
|
4087
|
+
sessionId: metadata?.sourceReference ?? sessions.sessionId
|
|
4082
4088
|
},
|
|
4083
4089
|
message,
|
|
4084
4090
|
requestId: deliveryId
|
|
@@ -7026,7 +7032,8 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
|
|
|
7026
7032
|
deliveries = delivery.catch(() => void 0);
|
|
7027
7033
|
return delivery;
|
|
7028
7034
|
} });
|
|
7029
|
-
|
|
7035
|
+
let sessionGroupBridge;
|
|
7036
|
+
const listPeers = () => [...serverHost.context.sessionCommunication?.listPeers?.() ?? [], ...sessionGroupBridge?.peersFor(execution.sessionId) ?? []];
|
|
7030
7037
|
const roster = createTeamRosterDelivery(() => formatTeamRoster({
|
|
7031
7038
|
groups: serverHost.context.sessionCommunication?.groups ?? [],
|
|
7032
7039
|
peers: listPeers(),
|
|
@@ -7037,11 +7044,22 @@ const root = (0, _agimon_ai_po_core_extensionFile.defineRoot)(({ context, host:
|
|
|
7037
7044
|
sessionId: execution.sessionId,
|
|
7038
7045
|
name: () => serverHost.context.sessionCommunication?.sessionName,
|
|
7039
7046
|
peers: listPeers,
|
|
7040
|
-
canCommunicate: (id) => serverHost.context.sessionService?.canCommunicate?.(execution.sessionId, id) === true,
|
|
7047
|
+
canCommunicate: (id) => id.startsWith("peer/") ? sessionGroupBridge?.metadataFor(execution.sessionId, id) !== void 0 : serverHost.context.sessionService?.canCommunicate?.(execution.sessionId, id) === true,
|
|
7048
|
+
metadataFor: (id) => sessionGroupBridge?.metadataFor(execution.sessionId, id),
|
|
7041
7049
|
delivery: () => (0, _agimon_ai_po_session.readPoSessionDelivery)(context)
|
|
7042
7050
|
});
|
|
7043
7051
|
const serverService = (ctx) => {
|
|
7044
7052
|
ctx.plugin((providerContext) => {
|
|
7053
|
+
providerContext.inject([_agimon_ai_po_session.PO_SESSION_GROUP_BRIDGE_SERVICE], (bridgeContext) => {
|
|
7054
|
+
sessionGroupBridge = (0, _agimon_ai_po_session.readSessionGroupBridge)(bridgeContext);
|
|
7055
|
+
const unsubscribe = sessionGroupBridge?.subscribe(() => void roster.sync());
|
|
7056
|
+
roster.sync();
|
|
7057
|
+
return () => {
|
|
7058
|
+
unsubscribe?.();
|
|
7059
|
+
sessionGroupBridge = void 0;
|
|
7060
|
+
roster.sync();
|
|
7061
|
+
};
|
|
7062
|
+
});
|
|
7045
7063
|
providerContext.plugin(teamCollaborationPlugin, {
|
|
7046
7064
|
session: {
|
|
7047
7065
|
sessionId: execution.sessionId,
|