@segmentstream/agent 0.77.1 → 0.79.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/CHANGELOG.md +36 -0
- package/README.md +4 -3
- package/dist/_chunks/{build-metadata-DeFy9vS5.mjs → build-metadata-BrWGOlRd.mjs} +1 -1
- package/dist/_chunks/{chat-archive-pVRDSPL2.mjs → chat-archive-BEk40gWe.mjs} +11 -1
- package/dist/_chunks/{chat-archive-CUMEaSqy.mjs → chat-archive-DavfKJDI.mjs} +20 -2
- package/dist/extension/config.d.ts +7 -0
- package/dist/extension/config.mjs +9 -2
- package/dist/extension/hooks/chat-context.mjs +1 -1
- package/dist/extension/hooks/chat-recorder.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-archive.d.ts +16 -0
- package/dist/extension/lib/chat-archive.mjs +1 -1
- package/dist/extension/lib/chat-context.d.ts +6 -0
- package/dist/extension/lib/chat-context.mjs +4 -2
- package/dist/extension/lib/chat-messages.d.ts +4 -0
- package/dist/extension/lib/chat-messages.mjs +3 -2
- package/dist/extension/lib/chat-recorder.mjs +6 -2
- package/dist/extension/lib/email/attachments-send.d.ts +6 -4
- package/dist/extension/lib/email/attachments-send.mjs +1 -0
- package/dist/extension/lib/email/channel.d.ts +16 -4
- package/dist/extension/lib/email/channel.mjs +29 -10
- package/dist/extension/lib/email/gmail.d.ts +7 -5
- package/dist/extension/lib/email/gmail.mjs +1 -0
- package/dist/extension/lib/email/message.d.ts +5 -0
- package/dist/extension/lib/email/message.mjs +10 -5
- package/dist/extension/lib/group-routing/routing-context.mjs +1 -1
- package/dist/extension/lib/model-service-alert.mjs +1 -1
- package/dist/extension/lib/review/client.mjs +57 -32
- package/dist/extension/lib/review/hold.d.ts +11 -0
- package/dist/extension/lib/review/hold.mjs +4 -0
- package/dist/extension/lib/review/judge.mjs +1 -1
- package/dist/extension/lib/review/reply.d.ts +5 -0
- package/dist/extension/lib/review/reply.mjs +1 -1
- package/dist/extension/lib/review/revision-channel.mjs +1 -1
- package/dist/extension/lib/slack/adapter.d.ts +16 -1
- package/dist/extension/lib/slack/adapter.mjs +64 -11
- package/dist/extension/lib/slack/callbacks.d.ts +6 -0
- package/dist/extension/lib/slack/callbacks.mjs +18 -4
- package/dist/extension/lib/slack/changes.d.ts +47 -0
- package/dist/extension/lib/slack/changes.mjs +101 -0
- package/dist/extension/lib/slack/thread-history.mjs +1 -4
- package/dist/extension/lib/telegram/adapter.mjs +3 -3
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +1 -1
- package/dist/extension/lib/telegram/delivery-diagnostics.mjs +1 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
- package/dist/extension/lib/telegram/reactions.d.ts +18 -0
- package/dist/extension/lib/telegram/reactions.mjs +35 -0
- package/dist/extension/lib/telegram/store-capture.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.mjs +2 -2
- package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
- package/dist/extension/lib/whatsapp/changes.d.ts +2 -1
- package/dist/extension/lib/whatsapp/changes.mjs +22 -11
- package/dist/extension/lib/whatsapp/sent.mjs +1 -1
- package/dist/extension/lib/workspace-channel/channel.mjs +1 -1
- package/dist/extension/lib/workspace-chat-archive.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +3 -1
- package/package.json +2 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __eveDirname } from "node:path";
|
|
3
|
+
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
+
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
+
__eveDirname(__filename);
|
|
6
|
+
__eveCreateRequire(import.meta.url);
|
|
7
|
+
import { currentChannel } from "../channel-scope.mjs";
|
|
8
|
+
import { p as storeOf } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
9
|
+
import { applyChatChange } from "../chat-messages.mjs";
|
|
10
|
+
import { defaultEmojiResolver } from "chat";
|
|
11
|
+
function record(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
13
|
+
}
|
|
14
|
+
function text(value) {
|
|
15
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
16
|
+
}
|
|
17
|
+
function slackTime(ts) {
|
|
18
|
+
const seconds = typeof ts === "string" && /^\d{1,12}(\.\d{1,9})?$/u.test(ts) ? Number(ts) : NaN;
|
|
19
|
+
return Number.isFinite(seconds) && seconds > 0 ? new Date(seconds * 1e3).toISOString() : void 0;
|
|
20
|
+
}
|
|
21
|
+
function slackEmoji(name) {
|
|
22
|
+
const base = name.replace(/^:|:$/gu, "").replace(/::skin-tone-\d$/u, "");
|
|
23
|
+
const value = defaultEmojiResolver.fromSlack(base);
|
|
24
|
+
const emoji = defaultEmojiResolver.toGChat(value);
|
|
25
|
+
return emoji === value.name ? `:${base}:` : emoji;
|
|
26
|
+
}
|
|
27
|
+
function slackChange(envelope) {
|
|
28
|
+
const callback = record(envelope);
|
|
29
|
+
const event = record(callback?.event);
|
|
30
|
+
if (callback?.type !== "event_callback" || event === void 0) return;
|
|
31
|
+
if (event.type === "reaction_added" || event.type === "reaction_removed") {
|
|
32
|
+
const item = record(event.item);
|
|
33
|
+
const chatId = text(item?.channel);
|
|
34
|
+
const target = text(item?.ts);
|
|
35
|
+
const senderId = text(event.user);
|
|
36
|
+
const reaction = text(event.reaction);
|
|
37
|
+
return item?.type !== "message" || chatId === void 0 || target === void 0 || senderId === void 0 || reaction === void 0 ? void 0 : {
|
|
38
|
+
chatId,
|
|
39
|
+
target,
|
|
40
|
+
change: "reaction",
|
|
41
|
+
senderId,
|
|
42
|
+
...event.type === "reaction_added" ? { emoji: slackEmoji(reaction) } : {
|
|
43
|
+
emoji: "",
|
|
44
|
+
removed: slackEmoji(reaction)
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const chatId = text(event.channel);
|
|
49
|
+
if (event.type !== "message" || chatId === void 0) return;
|
|
50
|
+
if (event.subtype === "message_deleted") {
|
|
51
|
+
const target = text(event.deleted_ts) ?? text(record(event.previous_message)?.ts);
|
|
52
|
+
const at = slackTime(event.ts);
|
|
53
|
+
return target === void 0 ? void 0 : {
|
|
54
|
+
chatId,
|
|
55
|
+
target,
|
|
56
|
+
change: "delete",
|
|
57
|
+
...at === void 0 ? {} : { at }
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (event.subtype !== "message_changed") return;
|
|
61
|
+
const message = record(event.message);
|
|
62
|
+
const target = text(message?.ts);
|
|
63
|
+
const at = slackTime(record(message?.edited)?.ts ?? event.ts);
|
|
64
|
+
if (message === void 0 || target === void 0) return;
|
|
65
|
+
if (message.subtype === "tombstone") return {
|
|
66
|
+
chatId,
|
|
67
|
+
target,
|
|
68
|
+
change: "delete",
|
|
69
|
+
...at === void 0 ? {} : { at }
|
|
70
|
+
};
|
|
71
|
+
const edited = typeof message.text === "string" ? message.text : "";
|
|
72
|
+
const previous = record(event.previous_message)?.text;
|
|
73
|
+
return typeof previous === "string" && previous === edited ? void 0 : {
|
|
74
|
+
chatId,
|
|
75
|
+
target,
|
|
76
|
+
change: "edit",
|
|
77
|
+
text: edited,
|
|
78
|
+
...at === void 0 ? {} : { at }
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async function recordSlackChange(archive, change) {
|
|
82
|
+
const channel = currentChannel("slack");
|
|
83
|
+
if (change.change !== "reaction" || change.removed === void 0) return applyChatChange(archive, {
|
|
84
|
+
...change,
|
|
85
|
+
channel
|
|
86
|
+
});
|
|
87
|
+
const store = await storeOf(archive);
|
|
88
|
+
if (store === void 0) return "dropped";
|
|
89
|
+
const { removed, ...reaction } = change;
|
|
90
|
+
const [message] = (await store.read({
|
|
91
|
+
channel,
|
|
92
|
+
chatId: change.chatId.slice(0, 256),
|
|
93
|
+
messageId: change.target.slice(0, 512),
|
|
94
|
+
limit: 1
|
|
95
|
+
})).messages;
|
|
96
|
+
return message?.reactions.find((kept) => kept.senderId === change.senderId)?.emoji === removed ? applyChatChange(archive, {
|
|
97
|
+
...reaction,
|
|
98
|
+
channel
|
|
99
|
+
}) : "unchanged";
|
|
100
|
+
}
|
|
101
|
+
export { recordSlackChange, slackChange, slackEmoji, slackTime };
|
|
@@ -5,11 +5,8 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { recordChatMessage } from "../chat-messages.mjs";
|
|
8
|
+
import { slackTime } from "./changes.mjs";
|
|
8
9
|
import { loadThreadContextMessages } from "eve/channels/slack";
|
|
9
|
-
function slackTime(ts) {
|
|
10
|
-
const seconds = Number(ts);
|
|
11
|
-
return Number.isFinite(seconds) && seconds > 0 ? new Date(seconds * 1e3).toISOString() : void 0;
|
|
12
|
-
}
|
|
13
10
|
async function recordThreadHistory(input) {
|
|
14
11
|
if (input.threadTs === input.messageTs) return;
|
|
15
12
|
const chat = {
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback } from "./callbacks.mjs";
|
|
12
12
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
13
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
13
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BrWGOlRd.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
@@ -19,8 +19,8 @@ import { Ct as withDeliveryLocale, S as fetchStoredAttachment, St as safeTelegra
|
|
|
19
19
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
20
20
|
import { appOrigin, channelsEnabled, proxyEnvironment, runtimeIdentityEnvironment, webhookSecret } from "../environment.mjs";
|
|
21
21
|
import { agentIdentities } from "../identities.mjs";
|
|
22
|
-
import {
|
|
23
|
-
import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-
|
|
22
|
+
import { h as topicContext, r as chatArchive } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
23
|
+
import { a as captureTelegramFetch, h as telegramChatCapture, i as captureRouteDecider, s as chatIdentities, u as recordGateDecision } from "../../../_chunks/chat-archive-BEk40gWe.mjs";
|
|
24
24
|
import { runtimeTokenVerifier } from "../runtime-identity.mjs";
|
|
25
25
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
26
26
|
import { botIdentityCache, proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
|
|
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
export { t as REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-
|
|
7
|
+
export { t as REVISION_CLAIM_TTL_MS, n as attachmentIdentity, r as attachmentRefs, i as captureRouteDecider, a as captureTelegramFetch, o as captureTelegramWebhook, s as chatIdentities, c as currentCapture, l as participants, u as recordGateDecision, d as recordInboundContent, f as recordRouteDecision, p as recordSessionFailure, m as registerCapture, h as telegramChatCapture } from "../../../_chunks/chat-archive-BEk40gWe.mjs";
|
|
@@ -9,7 +9,7 @@ import { F as confirmations, Ft as chatChannel, c as currentInboundRequest, i as
|
|
|
9
9
|
import { humanText } from "../confirmation-description.mjs";
|
|
10
10
|
import { withConfirmationPrompt } from "../group-routing/messages.mjs";
|
|
11
11
|
import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
|
|
12
|
-
import { a as chatEvent } from "../../../_chunks/chat-archive-
|
|
12
|
+
import { a as chatEvent } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
13
13
|
import { chatPostCard, chatPostCardStatus, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
|
|
14
14
|
import { answerMarker, isPendingQuestion, pendingQuestions, questionKey } from "../questions.mjs";
|
|
15
15
|
import { confirmationStatus, renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
|
|
8
|
-
import { a as chatEvent } from "../../../_chunks/chat-archive-
|
|
8
|
+
import { a as chatEvent } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
9
9
|
import { currentChannel } from "../channel-scope.mjs";
|
|
10
10
|
import { redactTelegramDiagnostic } from "./diagnostic-redaction.mjs";
|
|
11
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -4,7 +4,7 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BrWGOlRd.mjs";
|
|
8
8
|
import { runtimeRequestFailure } from "./runtime-request.mjs";
|
|
9
9
|
import { GET } from "eve/channels";
|
|
10
10
|
const HEALTH_ROUTE = "/eve/v1/telegram/health";
|
|
@@ -28,7 +28,7 @@ import { routingContext } from "./routing-context.mjs";
|
|
|
28
28
|
import { formatAddress, messageAddress, scopedAddress } from "./sessions.mjs";
|
|
29
29
|
import { voiceOf } from "./voice.mjs";
|
|
30
30
|
import { MAXIMUM_ROUTING_ATTACHMENT_BYTES, describeRoutingAttachment, routingAttachmentDeadline } from "./attachment-description.mjs";
|
|
31
|
-
import { d as recordInboundContent, f as recordRouteDecision, u as recordGateDecision } from "../../../_chunks/chat-archive-
|
|
31
|
+
import { d as recordInboundContent, f as recordRouteDecision, u as recordGateDecision } from "../../../_chunks/chat-archive-BEk40gWe.mjs";
|
|
32
32
|
import { contentShape, messageContent } from "./content.mjs";
|
|
33
33
|
import { messageAudience } from "./audience.mjs";
|
|
34
34
|
const MAXIMUM_QUOTE_LENGTH = 500;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-C7aAjyt4.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-BrWGOlRd.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChatChange } from "../chat-messages.js";
|
|
2
|
+
/**
|
|
3
|
+
* A person's reaction to a message in a Telegram chat (docs/agent.md, "Message changes"): Telegram
|
|
4
|
+
* reports it as a `message_reaction` update, which the bot receives only when its webhook lists
|
|
5
|
+
* that update, and in a group only while it is an administrator there. The update names the
|
|
6
|
+
* person's reactions before and after the change; the chat keeps one reaction per person, so the
|
|
7
|
+
* one the change added is kept, else the first the person still has, and none removes theirs.
|
|
8
|
+
* Only emoji reactions are kept: a custom emoji or a paid reaction has no emoji to show.
|
|
9
|
+
*/
|
|
10
|
+
/** A reaction the update reports, in the chat the store keys by Telegram's id of it. */
|
|
11
|
+
export type TelegramReaction = Omit<Extract<ChatChange, {
|
|
12
|
+
readonly change: "reaction";
|
|
13
|
+
}>, "channel">;
|
|
14
|
+
/**
|
|
15
|
+
* The reaction a `message_reaction` update reports, by the person who reacted, or by the chat
|
|
16
|
+
* they reacted on behalf of; undefined for an update that names no chat, message or sender.
|
|
17
|
+
*/
|
|
18
|
+
export declare function telegramReaction(update: unknown): TelegramReaction | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { fileURLToPath as __eveFileURLToPath } from "node:url";
|
|
2
|
+
import { dirname as __eveDirname } from "node:path";
|
|
3
|
+
import { createRequire as __eveCreateRequire } from "node:module";
|
|
4
|
+
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
|
+
__eveDirname(__filename);
|
|
6
|
+
__eveCreateRequire(import.meta.url);
|
|
7
|
+
function record(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
9
|
+
}
|
|
10
|
+
function id(value) {
|
|
11
|
+
return typeof value === "number" && Number.isSafeInteger(value) || typeof value === "string" && /^-?\d{1,20}$/u.test(value) ? String(value) : void 0;
|
|
12
|
+
}
|
|
13
|
+
function emoji(value) {
|
|
14
|
+
return (Array.isArray(value) ? value : []).flatMap((item) => {
|
|
15
|
+
const reaction = record(item);
|
|
16
|
+
return reaction?.type === "emoji" && typeof reaction.emoji === "string" && reaction.emoji !== "" ? [reaction.emoji] : [];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function telegramReaction(update) {
|
|
20
|
+
const reaction = record(record(update)?.message_reaction);
|
|
21
|
+
const chatId = id(record(reaction?.chat)?.id);
|
|
22
|
+
const target = id(reaction?.message_id);
|
|
23
|
+
const senderId = id(record(reaction?.user)?.id) ?? id(record(reaction?.actor_chat)?.id);
|
|
24
|
+
if (chatId === void 0 || target === void 0 || senderId === void 0) return;
|
|
25
|
+
const before = emoji(reaction?.old_reaction);
|
|
26
|
+
const after = emoji(reaction?.new_reaction);
|
|
27
|
+
return {
|
|
28
|
+
chatId,
|
|
29
|
+
target,
|
|
30
|
+
change: "reaction",
|
|
31
|
+
senderId,
|
|
32
|
+
emoji: after.find((added) => !before.includes(added)) ?? after[0] ?? ""
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export { telegramReaction };
|
|
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
export { g as captureInStore, _ as storeSend } from "../../../_chunks/chat-archive-
|
|
7
|
+
export { g as captureInStore, _ as storeSend } from "../../../_chunks/chat-archive-BEk40gWe.mjs";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
|
-
import { p as recordSessionFailure } from "../../../_chunks/chat-archive-
|
|
9
|
+
import { p as recordSessionFailure } from "../../../_chunks/chat-archive-BEk40gWe.mjs";
|
|
10
10
|
import { gt as customerCopy, ht as currentThreadId, i as memberIdOf, mt as currentLocale, xt as reportTelegramError, yt as failureText } from "../../../_chunks/principal-C7aAjyt4.mjs";
|
|
11
11
|
import { modelServiceFailure } from "../model-service-failure.mjs";
|
|
12
12
|
function telegramFailureEvents(input) {
|
|
@@ -20,7 +20,7 @@ import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs
|
|
|
20
20
|
import { appOrigin, channelsEnabled, proxyEnvironment, webhookSecret } from "../environment.mjs";
|
|
21
21
|
import { agentIdentities } from "../identities.mjs";
|
|
22
22
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
23
|
-
import { r as chatArchive } from "../../../_chunks/chat-archive-
|
|
23
|
+
import { r as chatArchive } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
24
24
|
import { recordHandledMessage, recordReceivedMessage, recordUnadmittedMessage, stagedFiles } from "../chat-messages.mjs";
|
|
25
25
|
import { handleWorkspaceButton } from "./callbacks.mjs";
|
|
26
26
|
import { recordWhatsAppChanges, whatsappChanges, whatsappParts } from "./changes.mjs";
|
|
@@ -30,9 +30,9 @@ import { collectSent, noteSent, recordSent } from "./sent.mjs";
|
|
|
30
30
|
import { STATUSES_HEADER, STATUSES_RECORDED } from "./statuses.mjs";
|
|
31
31
|
import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
|
|
32
32
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
33
|
+
import { Actions, Card, CardText, ConsoleLogger, LinkButton } from "chat";
|
|
33
34
|
import { createMemoryState } from "@chat-adapter/state-memory";
|
|
34
35
|
import { WhatsAppAdapter, WhatsAppApiError } from "@chat-adapter/whatsapp";
|
|
35
|
-
import { Actions, Card, CardText, ConsoleLogger, LinkButton } from "chat";
|
|
36
36
|
import { chatSdkChannel, messageContentOf } from "eve/channels/chat-sdk";
|
|
37
37
|
const WHATSAPP_AUTHENTICATOR = "segmentstream-whatsapp";
|
|
38
38
|
const WHATSAPP_PROXY_ORIGIN = "https://whatsapp.segmentstream.invalid";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { _ as AttachmentError } from "../../../_chunks/principal-C7aAjyt4.mjs";
|
|
8
8
|
import { sendStoredAttachments } from "../attachments-send.mjs";
|
|
9
|
-
import { r as chatArchive } from "../../../_chunks/chat-archive-
|
|
9
|
+
import { r as chatArchive } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
10
10
|
import { connectionProxy } from "../connection-proxy.mjs";
|
|
11
11
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
12
12
|
import { proxyEnvironment } from "../environment.mjs";
|
|
@@ -9,7 +9,8 @@ export declare const FAILURE_RETRY_MS: ReadonlyArray<number>;
|
|
|
9
9
|
* What a relayed WhatsApp delivery says of messages beside the people's new ones, which the Chat
|
|
10
10
|
* SDK adapter reads (`docs/agent.md`, "Message changes"): the delivery statuses of messages the
|
|
11
11
|
* number sent, people's reactions, and on a number in Coexistence with the WhatsApp Business app,
|
|
12
|
-
* edits and deletions by the person or by the business in the app
|
|
12
|
+
* edits and deletions by the person or by the business in the app, and the business's reactions
|
|
13
|
+
* there. Each is a change of a message
|
|
13
14
|
* in the person's chat, found by Meta's id of it, and starts no turn. A contact card a person
|
|
14
15
|
* sends, which the adapter reads as no message, is recorded in their chat with its parts.
|
|
15
16
|
*/
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { currentChannel, currentKey } from "../channel-scope.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { p as storeOf } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
9
9
|
import { applyChatChange, chatPart, recordUnreadMessage } from "../chat-messages.mjs";
|
|
10
10
|
import { WHATSAPP_REFUSALS } from "@segmentstream/ontology/whatsapp";
|
|
11
11
|
const FAILURE_RETRY_MS = [
|
|
@@ -93,6 +93,17 @@ function revision(chatId, message) {
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
function reaction(chatId, message, senderId) {
|
|
97
|
+
const reacted = record(message.reaction);
|
|
98
|
+
const target = text(reacted?.message_id);
|
|
99
|
+
return target === void 0 ? void 0 : {
|
|
100
|
+
chatId,
|
|
101
|
+
target,
|
|
102
|
+
change: "reaction",
|
|
103
|
+
senderId,
|
|
104
|
+
emoji: typeof reacted?.emoji === "string" ? reacted.emoji : ""
|
|
105
|
+
};
|
|
106
|
+
}
|
|
96
107
|
function whatsappChanges(payload) {
|
|
97
108
|
const changes = [];
|
|
98
109
|
const contacts = [];
|
|
@@ -103,6 +114,7 @@ function whatsappChanges(payload) {
|
|
|
103
114
|
const phoneNumberId = text(record(value?.metadata)?.phone_number_id);
|
|
104
115
|
if (value === void 0 || phoneNumberId === void 0) continue;
|
|
105
116
|
const chat = (person) => `whatsapp:${phoneNumberId}:${person}`;
|
|
117
|
+
const business = text(record(value.metadata)?.display_phone_number) ?? phoneNumberId;
|
|
106
118
|
if (field === "messages") {
|
|
107
119
|
for (const status of list(value.statuses).map(record)) {
|
|
108
120
|
const target = text(status?.id);
|
|
@@ -124,15 +136,8 @@ function whatsappChanges(payload) {
|
|
|
124
136
|
const id = text(message?.id);
|
|
125
137
|
if (message === void 0 || person === void 0 || id === void 0) continue;
|
|
126
138
|
if (message.type === "reaction") {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
if (target !== void 0) changes.push({
|
|
130
|
-
chatId: chat(person),
|
|
131
|
-
target,
|
|
132
|
-
change: "reaction",
|
|
133
|
-
senderId: person,
|
|
134
|
-
emoji: typeof reaction?.emoji === "string" ? reaction.emoji : ""
|
|
135
|
-
});
|
|
139
|
+
const reacted = reaction(chat(person), message, person);
|
|
140
|
+
if (reacted !== void 0) changes.push(reacted);
|
|
136
141
|
continue;
|
|
137
142
|
}
|
|
138
143
|
const revised = revision(chat(person), message);
|
|
@@ -157,7 +162,13 @@ function whatsappChanges(payload) {
|
|
|
157
162
|
}
|
|
158
163
|
if (field === "smb_message_echoes") for (const echo of list(value.message_echoes).map(record)) {
|
|
159
164
|
const person = text(echo?.to) ?? text(echo?.to_user_id);
|
|
160
|
-
|
|
165
|
+
if (echo === void 0 || person === void 0) continue;
|
|
166
|
+
if (echo.type === "reaction") {
|
|
167
|
+
const reacted = reaction(chat(person), echo, text(echo.from) ?? business);
|
|
168
|
+
if (reacted !== void 0) changes.push(reacted);
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const revised = revision(chat(person), echo);
|
|
161
172
|
if (revised !== void 0) changes.push(revised);
|
|
162
173
|
}
|
|
163
174
|
}
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { channelKey } from "../channel-scope.mjs";
|
|
8
|
-
import { a as chatEvent, t as AGENT_SENDER } from "../../../_chunks/chat-archive-
|
|
8
|
+
import { a as chatEvent, t as AGENT_SENDER } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
9
9
|
import { stampedChat } from "../chat-recorder.mjs";
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
11
|
const collected = new AsyncLocalStorage();
|
|
@@ -10,7 +10,7 @@ import { agentToolsAttribute } from "../agent-tools.mjs";
|
|
|
10
10
|
import { providerChat } from "../attachment-tools.mjs";
|
|
11
11
|
import { Bt as workspaceIdentityProvider, Pt as chatAddressOf, S as fetchStoredAttachment, b as agentAttachments, d as prepareInboundMedia, i as memberIdOf, m as turnContent, zt as withChatAddress } from "../../../_chunks/principal-C7aAjyt4.mjs";
|
|
12
12
|
import { CHANNEL_ATTRIBUTE, channelKey } from "../channel-scope.mjs";
|
|
13
|
-
import { a as chatEvent, r as chatArchive, t as AGENT_SENDER
|
|
13
|
+
import { S as reasonCode, a as chatEvent, r as chatArchive, t as AGENT_SENDER } from "../../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
14
14
|
import { applyChatChange, chatParts, recordHandledMessage, recordReceivedMessage, recordSentOutside, recordUnadmittedMessage, stagedFiles } from "../chat-messages.mjs";
|
|
15
15
|
import { connectionProxy } from "../connection-proxy.mjs";
|
|
16
16
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
@@ -4,4 +4,4 @@ import { createRequire as __eveCreateRequire } from "node:module";
|
|
|
4
4
|
const __filename = __eveFileURLToPath(import.meta.url);
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
|
-
export {
|
|
7
|
+
export { g as UNVERIFIED, _ as boundedMeta, v as cutText, y as eventOf, b as messageInput, x as metaOf, S as reasonCode, C as sendFingerprint, w as storedFiles, T as storedMessageId, E as workspaceChatArchive } from "../../_chunks/chat-archive-DavfKJDI.mjs";
|
|
@@ -9,6 +9,7 @@ import segmentstream from "../extension.mjs";
|
|
|
9
9
|
import { Ft as chatChannel, G as memberTool, Pt as chatAddressOf } from "../../_chunks/principal-C7aAjyt4.mjs";
|
|
10
10
|
import { channelOf } from "../config.mjs";
|
|
11
11
|
import { sendEmailAttachments } from "../lib/email/attachments-send.mjs";
|
|
12
|
+
import { replyCopies } from "../lib/email/channel.mjs";
|
|
12
13
|
import { sendSlackAttachments } from "../lib/slack/attachments-send.mjs";
|
|
13
14
|
import { sendAttachments, sendAttachmentsInput } from "../lib/telegram/attachments-send.mjs";
|
|
14
15
|
import { sendWhatsAppAttachments } from "../lib/whatsapp/attachments-send.mjs";
|
|
@@ -73,7 +74,8 @@ const tool = defineTool({
|
|
|
73
74
|
}) : provider === "email" ? await sendEmailAttachments({
|
|
74
75
|
...options,
|
|
75
76
|
callId: ctx.callId,
|
|
76
|
-
connection: channelOf(channels, "email", name)?.connection
|
|
77
|
+
connection: channelOf(channels, "email", name)?.connection,
|
|
78
|
+
cc: replyCopies(principal, channelOf(channels, "email", name))
|
|
77
79
|
}) : provider === "whatsapp" ? await sendWhatsAppAttachments({
|
|
78
80
|
...options,
|
|
79
81
|
turnId: ctx.session.turn.id,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.0",
|
|
4
4
|
"description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@chat-adapter/state-memory": "4.42.0",
|
|
85
85
|
"@chat-adapter/telegram": "4.41.0",
|
|
86
86
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
87
|
-
"@segmentstream/ontology": "0.
|
|
87
|
+
"@segmentstream/ontology": "0.154.0",
|
|
88
88
|
"@vercel/oidc": "^3.8.4",
|
|
89
89
|
"ai": "^7.0.172",
|
|
90
90
|
"chat": "4.42.0",
|