@segmentstream/agent 0.53.0 → 0.55.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 +72 -0
- package/README.md +21 -8
- package/dist/_chunks/{build-metadata-Bc9qfC4D.mjs → build-metadata-CYSFZe6f.mjs} +1 -1
- package/dist/_chunks/{principal-JoaOmdFL.mjs → principal-DIgU-kPR.mjs} +71 -29
- package/dist/extension/channels/email.d.ts +4 -3
- package/dist/extension/channels/email.mjs +2 -1
- package/dist/extension/channels/slack.d.ts +4 -3
- package/dist/extension/channels/slack.mjs +2 -1
- package/dist/extension/channels/telegram.d.ts +3 -1
- package/dist/extension/channels/telegram.mjs +2 -1
- package/dist/extension/channels/whatsapp.d.ts +3 -2
- package/dist/extension/channels/whatsapp.mjs +2 -1
- package/dist/extension/config.d.ts +188 -67
- package/dist/extension/config.mjs +173 -36
- package/dist/extension/connections/ontology.mjs +1 -1
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/hooks/guest-usage.d.ts +3 -0
- package/dist/extension/hooks/guest-usage.mjs +11 -0
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.d.ts +1 -1
- package/dist/extension/lib/attachment-tools.mjs +2 -2
- package/dist/extension/lib/attachments-send.mjs +1 -1
- package/dist/extension/lib/attachments.d.ts +1 -2
- package/dist/extension/lib/attachments.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/channel-scope.d.ts +67 -0
- package/dist/extension/lib/channel-scope.mjs +104 -0
- package/dist/extension/lib/chat-address.d.ts +27 -1
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-archive.d.ts +6 -0
- package/dist/extension/lib/chat-archive.mjs +7 -2
- package/dist/extension/lib/chat-context.mjs +3 -3
- package/dist/extension/lib/chat-post-confirmation.d.ts +13 -2
- package/dist/extension/lib/chat-post-confirmation.mjs +8 -3
- package/dist/extension/lib/chat-recorder.d.ts +17 -0
- package/dist/extension/lib/chat-recorder.mjs +18 -9
- package/dist/extension/lib/chats.d.ts +7 -0
- package/dist/extension/lib/chats.mjs +31 -1
- package/dist/extension/lib/confirmations.d.ts +6 -1
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/email/attachments-send.d.ts +1 -1
- package/dist/extension/lib/email/attachments-send.mjs +1 -1
- package/dist/extension/lib/email/channel.d.ts +11 -3
- package/dist/extension/lib/email/channel.mjs +53 -42
- package/dist/extension/lib/guest-usage.d.ts +53 -0
- package/dist/extension/lib/guest-usage.mjs +52 -0
- package/dist/extension/lib/inbound-media/files.mjs +1 -1
- package/dist/extension/lib/inbound-media/index.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +2 -1
- package/dist/extension/lib/ontology-tools.d.ts +2 -0
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/client.mjs +1 -0
- package/dist/extension/lib/review/hold.d.ts +7 -0
- package/dist/extension/lib/review/hold.mjs +2 -1
- package/dist/extension/lib/review/reply.mjs +3 -3
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +1 -1
- package/dist/extension/lib/sent-files.mjs +1 -1
- package/dist/extension/lib/slack/adapter.d.ts +5 -4
- package/dist/extension/lib/slack/adapter.mjs +19 -15
- package/dist/extension/lib/slack/attachments-send.d.ts +1 -1
- package/dist/extension/lib/slack/attachments-send.mjs +1 -1
- package/dist/extension/lib/stored-files.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.d.ts +8 -2
- package/dist/extension/lib/telegram/adapter.mjs +43 -31
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/callbacks.mjs +1 -1
- package/dist/extension/lib/telegram/chat-archive.mjs +11 -10
- package/dist/extension/lib/telegram/chat-post-card.mjs +4 -3
- package/dist/extension/lib/telegram/confirmations.mjs +3 -3
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -1
- package/dist/extension/lib/telegram/files.d.ts +4 -1
- package/dist/extension/lib/telegram/files.mjs +3 -2
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/held-approvals.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +4 -4
- package/dist/extension/lib/telegram/lifecycle.mjs +2 -2
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
- package/dist/extension/lib/telegram/signals.mjs +2 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/structured.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
- package/dist/extension/lib/telegram/workspace-action.mjs +1 -1
- package/dist/extension/lib/web/auth.d.ts +18 -4
- package/dist/extension/lib/web/auth.mjs +1 -1
- package/dist/extension/lib/web/channel.mjs +1 -1
- package/dist/extension/lib/whatsapp/adapter.d.ts +12 -6
- package/dist/extension/lib/whatsapp/adapter.mjs +17 -10
- package/dist/extension/lib/whatsapp/attachments-send.d.ts +1 -1
- package/dist/extension/lib/whatsapp/attachments-send.mjs +1 -1
- package/dist/extension/lib/whatsapp/files.mjs +1 -1
- package/dist/extension/lib/workspace-source.d.ts +1 -1
- package/dist/extension/lib/workspace-source.mjs +3 -2
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_discard.mjs +1 -1
- package/dist/extension/tools/attachments_list.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_read.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +10 -6
- package/dist/extension/tools/attachments_stage.mjs +1 -1
- package/dist/extension/tools/attachments_table.mjs +1 -1
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/dist/extension/tools/unanswered.d.ts +2 -0
- package/dist/extension/tools/unanswered.mjs +39 -0
- package/dist/extension/tools/workspace_source.mjs +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.mjs +2 -1
- package/package.json +2 -2
|
@@ -6,9 +6,10 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { admitMessage, localizedText } from "../admission.mjs";
|
|
8
8
|
import { agentToolsAttribute } from "../agent-tools.mjs";
|
|
9
|
-
import { agentChats } from "../chats.mjs";
|
|
9
|
+
import { agentChats, channelChats } from "../chats.mjs";
|
|
10
10
|
import { withButtonDecision } from "../confirmation-buttons.mjs";
|
|
11
|
-
import {
|
|
11
|
+
import { b as agentAttachments, bt as withChatAddress, d as prepareInboundMedia, m as turnContent } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
12
|
+
import { channelAttributes, currentChannel, withNamedRoutes, withSessionChannels } from "../channel-scope.mjs";
|
|
12
13
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
13
14
|
import { MAXIMUM_DOWNLOAD_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
14
15
|
import { appOrigin, channelsEnabled, proxyEnvironment, webhookSecret } from "../environment.mjs";
|
|
@@ -104,7 +105,8 @@ function slackPrincipal(member, user) {
|
|
|
104
105
|
roles: member.roles,
|
|
105
106
|
...agentToolsAttribute(member.agentTools),
|
|
106
107
|
...member.name === null ? {} : { memberName: member.name },
|
|
107
|
-
...member.locale === void 0 ? {} : { locale: member.locale }
|
|
108
|
+
...member.locale === void 0 ? {} : { locale: member.locale },
|
|
109
|
+
...channelAttributes("slack")
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
}
|
|
@@ -195,8 +197,9 @@ function segmentstreamSlack(options) {
|
|
|
195
197
|
const token = options.token ?? runtimeToken;
|
|
196
198
|
const proxies = new Map();
|
|
197
199
|
let identities = options.identities;
|
|
200
|
+
const settings = () => options.settings(currentChannel("slack"));
|
|
198
201
|
const proxy = () => {
|
|
199
|
-
const connection =
|
|
202
|
+
const connection = settings()?.connection;
|
|
200
203
|
if (connection === void 0) throw new Error("The Slack channel is not configured in agent/segmentstream.json.");
|
|
201
204
|
let existing = proxies.get(connection);
|
|
202
205
|
if (existing === void 0) {
|
|
@@ -215,10 +218,11 @@ function segmentstreamSlack(options) {
|
|
|
215
218
|
token,
|
|
216
219
|
...options.fetch === void 0 ? {} : { fetch: options.fetch }
|
|
217
220
|
});
|
|
218
|
-
const
|
|
219
|
-
provider
|
|
221
|
+
const registry = options.chats ?? channelChats("slack", (provider) => agentChats({
|
|
222
|
+
provider,
|
|
220
223
|
identities: pairing
|
|
221
|
-
});
|
|
224
|
+
}));
|
|
225
|
+
const chats = () => registry;
|
|
222
226
|
const slackFetch = proxiedSlackFetch(proxy);
|
|
223
227
|
const request = async (method, body) => {
|
|
224
228
|
return (await slackFetch(`${SLACK_API}${method}`, {
|
|
@@ -265,7 +269,7 @@ function segmentstreamSlack(options) {
|
|
|
265
269
|
admission: options.admission(),
|
|
266
270
|
identities: pairing(),
|
|
267
271
|
environment,
|
|
268
|
-
chats,
|
|
272
|
+
chats: chats(),
|
|
269
273
|
files,
|
|
270
274
|
...work === void 0 ? {} : {
|
|
271
275
|
waitUntil: work.waitUntil,
|
|
@@ -287,7 +291,7 @@ function segmentstreamSlack(options) {
|
|
|
287
291
|
}
|
|
288
292
|
waitUntil(reportMembership({
|
|
289
293
|
envelope,
|
|
290
|
-
chats,
|
|
294
|
+
chats: chats(),
|
|
291
295
|
identities: pairing(),
|
|
292
296
|
request
|
|
293
297
|
}).catch((error) => report("membership_report_failed", error)));
|
|
@@ -324,8 +328,8 @@ function segmentstreamSlack(options) {
|
|
|
324
328
|
}
|
|
325
329
|
});
|
|
326
330
|
return {
|
|
327
|
-
...channel,
|
|
328
|
-
routes: channel.routes.
|
|
331
|
+
...withSessionChannels("slack", channel),
|
|
332
|
+
routes: withNamedRoutes("slack", channel.routes.flatMap((route) => route.transport === "websocket" ? [] : [gatedRoute(route, settings, environment, observe)]), (name) => options.settings(name) !== null)
|
|
329
333
|
};
|
|
330
334
|
}
|
|
331
335
|
async function followsThreadReply(input) {
|
|
@@ -333,12 +337,11 @@ async function followsThreadReply(input) {
|
|
|
333
337
|
if (message.author?.isBot !== false || message.threadTs === message.ts || input.mode === "mention") return false;
|
|
334
338
|
return ctx.edit !== void 0 || await ctx.isSubscribed();
|
|
335
339
|
}
|
|
336
|
-
function gatedRoute(route,
|
|
337
|
-
if (route.transport === "websocket") return route;
|
|
340
|
+
function gatedRoute(route, settings, environment, observe) {
|
|
338
341
|
return {
|
|
339
342
|
...route,
|
|
340
343
|
handler: async (request, args) => {
|
|
341
|
-
if (!channelsEnabled(environment) ||
|
|
344
|
+
if (!channelsEnabled(environment) || settings() === null || webhookSecret(environment) === void 0) return new Response(null, { status: 404 });
|
|
342
345
|
const waitUntil = (task) => args.waitUntil(task);
|
|
343
346
|
const work = { waitUntil };
|
|
344
347
|
await observe(request, waitUntil);
|
|
@@ -403,6 +406,7 @@ async function receive(input) {
|
|
|
403
406
|
if (!turn) return null;
|
|
404
407
|
const auth = withChatAddress(slackPrincipal(resolution.member, user), {
|
|
405
408
|
provider: "slack",
|
|
409
|
+
...currentChannel("slack") === "slack" ? {} : { channel: currentChannel("slack") },
|
|
406
410
|
chatId: ctx.slack.channelId,
|
|
407
411
|
threadId: ctx.slack.threadTs,
|
|
408
412
|
kind: input.direct ? "private" : "group",
|
|
@@ -429,7 +433,7 @@ async function receive(input) {
|
|
|
429
433
|
store: {
|
|
430
434
|
attachments: input.files.attachments(),
|
|
431
435
|
memberId: resolution.member.id,
|
|
432
|
-
chat: providerChat("slack", channelId),
|
|
436
|
+
chat: providerChat(currentChannel("slack"), channelId),
|
|
433
437
|
source: "slack",
|
|
434
438
|
sourceRef: (index) => `${channelId}:${message.ts}:${index}`
|
|
435
439
|
}
|
|
@@ -26,7 +26,7 @@ export declare function sendSlackAttachments(options: {
|
|
|
26
26
|
readonly input: SendAttachmentsInput;
|
|
27
27
|
readonly principal: SessionAuthContext | null;
|
|
28
28
|
readonly sessionId: string;
|
|
29
|
-
/** The
|
|
29
|
+
/** The connection of the Slack channel the chat is on, such as `channels.slack.connection`. */
|
|
30
30
|
readonly connection: string | undefined;
|
|
31
31
|
readonly environment?: Environment;
|
|
32
32
|
readonly token?: RuntimeToken;
|
|
@@ -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 { _ as AttachmentError } from "../../../_chunks/principal-
|
|
7
|
+
import { _ as AttachmentError } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
8
8
|
import { sendStoredAttachments } from "../attachments-send.mjs";
|
|
9
9
|
import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
10
10
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { object } from "./confirmation-description.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { D as OntologyFileUnavailable, W as member, i as memberIdOf, j as ontologyTools } from "../../_chunks/principal-DIgU-kPR.mjs";
|
|
9
9
|
import { redactDiagnostic } from "./diagnostics.mjs";
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
async function readStoredFile(input, principal, options = {}) {
|
|
@@ -17,10 +17,16 @@ import { type ChannelReviewOptions } from "../review/reply.js";
|
|
|
17
17
|
* The SegmentStream Telegram adapter: eve's `telegramChannel`, with its credentials, identity,
|
|
18
18
|
* voice and routing replaced (`agent-design.md`, section 4). Everything it reads from the mount's
|
|
19
19
|
* configuration is read per request, because eve binds the mount after it loads the channel.
|
|
20
|
+
*
|
|
21
|
+
* Every Telegram channel the mount names is served here, each its own bot: `channels.telegram` at
|
|
22
|
+
* eve's `POST /eve/v1/telegram`, and every other channel of kind `telegram` at
|
|
23
|
+
* `POST /eve/segmentstream/v1/telegram/<name>`, where SegmentStream points that bot's webhook.
|
|
24
|
+
* Each request and delivery runs for its bot's channel: that bot's connection and settings, and
|
|
25
|
+
* keys that carry the channel's name.
|
|
20
26
|
*/
|
|
21
27
|
export interface TelegramAdapterOptions {
|
|
22
|
-
/** The
|
|
23
|
-
readonly settings: () => TelegramSettings | null;
|
|
28
|
+
/** The Telegram channel `name` the mount declares, or `null` when it declares no such channel. */
|
|
29
|
+
readonly settings: (name: string) => TelegramSettings | null;
|
|
24
30
|
readonly groups?: () => GroupPolicy;
|
|
25
31
|
readonly models: () => {
|
|
26
32
|
readonly stt: string | false;
|
|
@@ -10,12 +10,12 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback, isWorkspaceCallback } 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-CYSFZe6f.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
17
17
|
import { chooseModel } from "../../model.mjs";
|
|
18
|
-
import {
|
|
18
|
+
import { At as safeTelegramFetch, Dt as failureText, S as fetchStoredAttachment, St as currentLocale, b as agentAttachments, c as currentInboundRequest, jt as withDeliveryLocale, kt as reportTelegramError, l as runInboundRequest, n as chatLanguage, o as telegramPrincipal, s as InboundRequest, u as withReplacedText } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
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";
|
|
@@ -30,7 +30,8 @@ import { telegramAppLinkContext } from "./app-links.mjs";
|
|
|
30
30
|
import { gatewayImageDescriber } from "../inbound-media/images.mjs";
|
|
31
31
|
import { chatMediaPlan, gatewayMediaCapabilities, sessionModel } from "../inbound-media/plan.mjs";
|
|
32
32
|
import { gatewayTranscriber } from "../inbound-media/speech.mjs";
|
|
33
|
-
import { agentChats } from "../chats.mjs";
|
|
33
|
+
import { agentChats, channelChats } from "../chats.mjs";
|
|
34
|
+
import { currentChannel, withNamedRoutes, withSessionChannels } from "../channel-scope.mjs";
|
|
34
35
|
import { handleInboundMessage } from "./inbound.mjs";
|
|
35
36
|
import { recoverableSessions } from "./session-recovery.mjs";
|
|
36
37
|
import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
|
|
@@ -89,7 +90,7 @@ function segmentstreamTelegram(options) {
|
|
|
89
90
|
token,
|
|
90
91
|
fetch: options.fetch
|
|
91
92
|
});
|
|
92
|
-
const
|
|
93
|
+
const bots = new Map();
|
|
93
94
|
const proxies = new Map();
|
|
94
95
|
const interimDelivered = interimTexts();
|
|
95
96
|
const review = options.review === void 0 ? void 0 : channelReview({
|
|
@@ -103,8 +104,9 @@ function segmentstreamTelegram(options) {
|
|
|
103
104
|
}).review;
|
|
104
105
|
let identities;
|
|
105
106
|
let verify = options.verify;
|
|
107
|
+
const channelSettings = () => options.settings(currentChannel("telegram"));
|
|
106
108
|
function settings() {
|
|
107
|
-
const configured =
|
|
109
|
+
const configured = channelSettings();
|
|
108
110
|
if (configured === null) throw new Error("The Telegram channel is not configured in agent/segmentstream.json.");
|
|
109
111
|
return configured;
|
|
110
112
|
}
|
|
@@ -126,7 +128,13 @@ function segmentstreamTelegram(options) {
|
|
|
126
128
|
return proxiedBotRequest(proxy(), method, body);
|
|
127
129
|
}
|
|
128
130
|
function botIdentity() {
|
|
129
|
-
|
|
131
|
+
const connection = settings().connection;
|
|
132
|
+
let own = bots.get(connection);
|
|
133
|
+
if (own === void 0) {
|
|
134
|
+
own = botIdentityCache();
|
|
135
|
+
bots.set(connection, own);
|
|
136
|
+
}
|
|
137
|
+
return runtimeBotIdentity(telegramSendScope(environment, connection), own);
|
|
130
138
|
}
|
|
131
139
|
function pairing() {
|
|
132
140
|
identities ??= agentIdentities({
|
|
@@ -136,10 +144,10 @@ function segmentstreamTelegram(options) {
|
|
|
136
144
|
});
|
|
137
145
|
return identities;
|
|
138
146
|
}
|
|
139
|
-
const chats = agentChats({
|
|
140
|
-
provider
|
|
147
|
+
const chats = channelChats("telegram", (provider) => agentChats({
|
|
148
|
+
provider,
|
|
141
149
|
identities: pairing
|
|
142
|
-
});
|
|
150
|
+
}));
|
|
143
151
|
const capture = telegramChatCapture({
|
|
144
152
|
archive,
|
|
145
153
|
identities: pairing,
|
|
@@ -219,7 +227,7 @@ function segmentstreamTelegram(options) {
|
|
|
219
227
|
decisionModel: options.models().decision,
|
|
220
228
|
groups: options.groups?.(),
|
|
221
229
|
recentChat: async (chatId, threadId) => archivedRoutingMessages((await topicContext(archive, {
|
|
222
|
-
provider: "telegram",
|
|
230
|
+
provider: currentChannel("telegram"),
|
|
223
231
|
chatId,
|
|
224
232
|
threadId: threadId ?? null,
|
|
225
233
|
limit: 200,
|
|
@@ -446,7 +454,7 @@ function segmentstreamTelegram(options) {
|
|
|
446
454
|
async function fetchFile(url, context) {
|
|
447
455
|
return await fetchStoredAttachment(attachments(), url, context) ?? (fetchTelegramFile === void 0 ? null : fetchTelegramFile(url, context));
|
|
448
456
|
}
|
|
449
|
-
return {
|
|
457
|
+
return withSessionChannels("telegram", {
|
|
450
458
|
...channel,
|
|
451
459
|
async receive(input, operations) {
|
|
452
460
|
operations = recoverableSessions(operations, readHistory);
|
|
@@ -486,33 +494,37 @@ function segmentstreamTelegram(options) {
|
|
|
486
494
|
}, context.state.messageThreadId === null ? void 0 : String(context.state.messageThreadId), typeof principal?.attributes.replyToMessageId === "string" ? principal.attributes.replyToMessageId : void 0, typeof principal?.attributes.chatId === "string" ? principal.attributes.chatId : void 0);
|
|
487
495
|
}]))
|
|
488
496
|
} },
|
|
489
|
-
routes: [
|
|
490
|
-
route
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
497
|
+
routes: [
|
|
498
|
+
...withNamedRoutes("telegram", channel.routes.flatMap((route) => route.transport === "websocket" ? [] : [gatedRoute({
|
|
499
|
+
route,
|
|
500
|
+
options,
|
|
501
|
+
settings: channelSettings,
|
|
502
|
+
environment,
|
|
503
|
+
capture,
|
|
504
|
+
readHistory
|
|
505
|
+
})]), (name) => options.settings(name) !== null),
|
|
506
|
+
...channel.routes.filter((route) => route.transport === "websocket"),
|
|
507
|
+
healthRoute({
|
|
508
|
+
chats,
|
|
509
|
+
...options.groups === void 0 ? {} : { routing: groupRoutingHealth },
|
|
510
|
+
enabled: () => channelsEnabled(environment),
|
|
511
|
+
configured: () => channelSettings() !== null,
|
|
512
|
+
verify: () => verify ??= runtimeTokenVerifier(runtimeIdentityEnvironment(environment)),
|
|
513
|
+
configuration: () => ({
|
|
514
|
+
confirmationMode: options.confirmationMode?.() ?? null,
|
|
515
|
+
attachmentLifecycle: channelSettings()?.attachmentLifecycle !== void 0
|
|
516
|
+
})
|
|
504
517
|
})
|
|
505
|
-
|
|
506
|
-
};
|
|
518
|
+
]
|
|
519
|
+
});
|
|
507
520
|
}
|
|
508
521
|
function gatedRoute(input) {
|
|
509
522
|
const { route, options, environment } = input;
|
|
510
|
-
if (route.transport === "websocket") return route;
|
|
511
523
|
return {
|
|
512
524
|
...route,
|
|
513
525
|
handler: async (request, args) => {
|
|
514
526
|
if (!channelsEnabled(environment)) return new Response("ok");
|
|
515
|
-
if (
|
|
527
|
+
if (input.settings() === null) return new Response("not found", { status: 404 });
|
|
516
528
|
args = {
|
|
517
529
|
...args,
|
|
518
530
|
...recoverableSessions(args, input.readHistory)
|
|
@@ -520,7 +532,7 @@ function gatedRoute(input) {
|
|
|
520
532
|
let description;
|
|
521
533
|
const describe = () => description ??= args.describe();
|
|
522
534
|
const inbound = new InboundRequest(async () => (await describe()).description ?? "", async () => (await describe()).name);
|
|
523
|
-
if (
|
|
535
|
+
if (input.settings()?.attachmentLifecycle !== void 0 && telegramWebhookVerifier(() => webhookSecret(environment))(request)) console.info("[segmentstream] telegram.phase", {
|
|
524
536
|
phase: "webhook_received",
|
|
525
537
|
traceId: inbound.traceId,
|
|
526
538
|
at: new Date().toISOString(),
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { describableImage } from "../inbound-media/images.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
9
9
|
import { gateway, generateText } from "ai";
|
|
10
10
|
const MAXIMUM_ROUTING_ATTACHMENT_BYTES = 5242880;
|
|
11
11
|
const ROUTING_ATTACHMENT_TIMEOUT_MS = 15e3;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { attachmentOwner } from "../attachment-tools.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Dt as failureText, Ot as formattingRefused, Tt as customerMessage, _ as AttachmentError, kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
9
9
|
import { attachmentFailure } from "../attachments-send.mjs";
|
|
10
10
|
import { MAXIMUM_PROXY_BODY_BYTES, connectionProxy } from "../connection-proxy.mjs";
|
|
11
11
|
import { redactDiagnostic } from "../diagnostics.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { object } from "../confirmation-description.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { Ft as runtimeEnvelope, It as telegramRuntimeSource, c as currentInboundRequest, i as memberIdOf, kt as reportTelegramError, o as telegramPrincipal } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
9
9
|
import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
|
|
10
10
|
import { telegramText } from "./texts.mjs";
|
|
11
11
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
@@ -5,11 +5,12 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { parseArchivedMessage } from "./archive-message.mjs";
|
|
8
|
+
import { currentChannel, currentKey } from "../channel-scope.mjs";
|
|
8
9
|
import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
|
|
9
10
|
import { chatEvent, sessionFailureEventId } from "../chat-archive.mjs";
|
|
10
11
|
import { currentConfirmationPrompt } from "../group-routing/messages.mjs";
|
|
11
12
|
import { messageMetadata } from "./message-metadata.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { Ct as currentThreadId, c as currentInboundRequest, kt as reportTelegramError } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
13
14
|
import { reportMembership } from "./membership.mjs";
|
|
14
15
|
import { currentDeliveryScope } from "./delivery-diagnostics.mjs";
|
|
15
16
|
import { contentShape, messageContent } from "./content.mjs";
|
|
@@ -115,13 +116,13 @@ async function captureTelegramWebhook(input) {
|
|
|
115
116
|
const attachments = attachmentRefs(message);
|
|
116
117
|
let lookup;
|
|
117
118
|
const event = chatEvent({
|
|
118
|
-
eventId: [
|
|
119
|
+
eventId: currentKey("telegram", [
|
|
119
120
|
"telegram",
|
|
120
121
|
message.chat.id,
|
|
121
122
|
message.messageId,
|
|
122
123
|
edited === void 0 ? "message" : `edit:${id(update.update_id) ?? id(message.raw.edit_date)}`
|
|
123
|
-
].join(":"),
|
|
124
|
-
provider: "telegram",
|
|
124
|
+
].join(":")),
|
|
125
|
+
provider: currentChannel("telegram"),
|
|
125
126
|
chatId: message.chat.id,
|
|
126
127
|
chatType: message.chat.type === "supergroup" ? "group" : message.chat.type,
|
|
127
128
|
threadId: message.messageThreadId === void 0 ? null : String(message.messageThreadId),
|
|
@@ -156,13 +157,13 @@ async function captureTelegramWebhook(input) {
|
|
|
156
157
|
},
|
|
157
158
|
...lookup === void 0 ? {} : { lookup }
|
|
158
159
|
};
|
|
159
|
-
const revisionId = edited === void 0 ? void 0 : `telegram:${message.chat.id}:${message.messageId}:routing:${createHash("sha256").update(JSON.stringify({
|
|
160
|
+
const revisionId = edited === void 0 ? void 0 : `${currentKey("telegram", `telegram:${message.chat.id}:${message.messageId}`)}:routing:${createHash("sha256").update(JSON.stringify({
|
|
160
161
|
at: event.at,
|
|
161
162
|
content,
|
|
162
163
|
...structured === void 0 ? {} : { structured },
|
|
163
164
|
...event.attachments.length === 0 ? {} : { attachments: attachmentIdentity(event.attachments) }
|
|
164
165
|
})).digest("hex")}`;
|
|
165
|
-
const dispatchKey = `telegram:${message.chat.id}:${message.messageId}` + (structured === void 0 ? "" : `:structured:${revisionId ?? "initial"}`);
|
|
166
|
+
const dispatchKey = currentKey("telegram", `telegram:${message.chat.id}:${message.messageId}`) + (structured === void 0 ? "" : `:structured:${revisionId ?? "initial"}`);
|
|
166
167
|
const revisionEvents = [];
|
|
167
168
|
let revisionClaim;
|
|
168
169
|
const finishRevision = async (status) => {
|
|
@@ -180,7 +181,7 @@ async function captureTelegramWebhook(input) {
|
|
|
180
181
|
const automated = message.from === void 0 || message.from.isBot || message.chat.type === "channel";
|
|
181
182
|
if (automated || edited !== void 0 || message.raw.left_chat_member || message.raw.new_chat_members || message.raw.migrate_to_chat_id || message.raw.migrate_from_chat_id) await capture.persist();
|
|
182
183
|
const messageHistory = automated ? [] : (await input.archive.context({
|
|
183
|
-
provider: "telegram",
|
|
184
|
+
provider: currentChannel("telegram"),
|
|
184
185
|
chatId: message.chat.id,
|
|
185
186
|
messageId: message.messageId,
|
|
186
187
|
includeDecisions: true,
|
|
@@ -528,7 +529,7 @@ async function recordSessionFailure(input) {
|
|
|
528
529
|
const { chatType, participantIds } = await outboundAudience(input.chatId, input.identities);
|
|
529
530
|
await input.archive.append(chatEvent({
|
|
530
531
|
eventId: sessionId === null ? `eve:session.failed:${randomUUID()}` : sessionFailureEventId(sessionId),
|
|
531
|
-
provider: "telegram",
|
|
532
|
+
provider: currentChannel("telegram"),
|
|
532
533
|
chatId: input.chatId,
|
|
533
534
|
chatType,
|
|
534
535
|
threadId: input.threadId,
|
|
@@ -560,7 +561,7 @@ function captureTelegramFetch(fetchImpl, archive, identities) {
|
|
|
560
561
|
const own = delivery?.chatId === chatId && delivery.sessionId !== null;
|
|
561
562
|
const event = chatEvent({
|
|
562
563
|
eventId: `telegram:${edit ? "edit" : "send"}:${randomUUID()}`,
|
|
563
|
-
provider: "telegram",
|
|
564
|
+
provider: currentChannel("telegram"),
|
|
564
565
|
chatId,
|
|
565
566
|
chatType,
|
|
566
567
|
kind: "outbound",
|
|
@@ -682,7 +683,7 @@ function telegramChatCapture(input) {
|
|
|
682
683
|
const payload = record(update.edited_message ?? update.message);
|
|
683
684
|
const chatId = id(record(payload.chat).id);
|
|
684
685
|
const messageId = id(payload.message_id);
|
|
685
|
-
const key = chatId === null || messageId === null ? void 0 : `${chatId}:${messageId}
|
|
686
|
+
const key = chatId === null || messageId === null ? void 0 : currentKey("telegram", `${chatId}:${messageId}`);
|
|
686
687
|
const previous = key === void 0 ? void 0 : processing.get(key);
|
|
687
688
|
const task = (async () => {
|
|
688
689
|
await previous?.catch(() => void 0);
|
|
@@ -6,6 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
8
|
import { renderConfirmation } from "./confirmation-text.mjs";
|
|
9
|
+
import { chatPostKind } from "../chat-post-confirmation.mjs";
|
|
9
10
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
10
11
|
import { telegramMarkdownLinks, telegramTextLinks } from "@segmentstream/ontology/telegram";
|
|
11
12
|
import { escapeMarkdownV2 } from "@chat-adapter/telegram";
|
|
@@ -29,7 +30,7 @@ function chatPostHeading(description, copy) {
|
|
|
29
30
|
const preview = description.chatPost;
|
|
30
31
|
if (preview === void 0) throw new Error("An exact chat preview is required.");
|
|
31
32
|
const base = renderConfirmation(description, copy);
|
|
32
|
-
const group = preview
|
|
33
|
+
const group = chatPostKind(preview) === "telegram" ? preview.externalId.startsWith("-") : !preview.chatId.startsWith(`${preview.provider}:private:`);
|
|
33
34
|
const destination = telegramText("chatPost", group ? "previewGroup" : "previewPrivate")?.replace(/\{(recipient|signature|provider)\}/gu, (_, key) => key === "recipient" ? preview.title : key === "signature" ? preview.attribution : preview.provider);
|
|
34
35
|
return {
|
|
35
36
|
preview,
|
|
@@ -49,14 +50,14 @@ function chatPostCard(description, copy) {
|
|
|
49
50
|
const { preview, base, lines } = chatPostHeading(description, copy);
|
|
50
51
|
const separator = preview.attributionSeparator ?? "\n\n";
|
|
51
52
|
const literal = `${preview.text}${separator}${preview.attribution}`;
|
|
52
|
-
const message = preview
|
|
53
|
+
const message = chatPostKind(preview) === "telegram" ? preview.finalText : escapeMarkdownV2(literal);
|
|
53
54
|
const text = lines.map(escapeMarkdownV2).join("\n") + `\n\n${message}`;
|
|
54
55
|
const receiptSpace = RECEIPT_DATA_SPACE + Math.max(...["sent", "uncertain"].map((status) => escapeMarkdownV2(telegramText("chatPost", status) ?? "").length)) + escapeMarkdownV2(telegramText("chatPost", "historyNotRecorded") ?? "").length;
|
|
55
56
|
if (text.length > 4096 - receiptSpace) throw new Error("The full message and receipt cannot fit in one Telegram confirmation. Make a shorter draft.");
|
|
56
57
|
return {
|
|
57
58
|
...base,
|
|
58
59
|
text,
|
|
59
|
-
previewLinks: [...telegramTextLinks(`${preview.title}\n${preview.replyTo ?? ""}`), ...preview
|
|
60
|
+
previewLinks: [...telegramTextLinks(`${preview.title}\n${preview.replyTo ?? ""}`), ...chatPostKind(preview) === "telegram" ? [
|
|
60
61
|
...telegramMarkdownLinks(preview.text),
|
|
61
62
|
...telegramTextLinks(separator),
|
|
62
63
|
...telegramTextLinks(preview.attribution)
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { F as confirmations, _t as chatChannel, c as currentInboundRequest, i as memberIdOf, kt as reportTelegramError, o as telegramPrincipal } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
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";
|
|
@@ -218,11 +218,11 @@ function telegramConfirmationEvents(archive, scope) {
|
|
|
218
218
|
const source = saved.source;
|
|
219
219
|
const append = () => archive.append(chatEvent({
|
|
220
220
|
eventId: `chat-post:${operationId}:${phase}`,
|
|
221
|
-
provider:
|
|
221
|
+
provider: chatChannel(source),
|
|
222
222
|
chatId: source.chatId,
|
|
223
223
|
chatType: source.chatId.startsWith("-") ? "group" : "private",
|
|
224
224
|
threadId: source.threadId || null,
|
|
225
|
-
participantIds: [saved.memberId],
|
|
225
|
+
participantIds: saved.memberId === void 0 ? [] : [saved.memberId],
|
|
226
226
|
kind: "tool_result",
|
|
227
227
|
operationId,
|
|
228
228
|
toolCallId: operationId,
|
|
@@ -5,5 +5,5 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { isTechnicalText } from "../customer-text-safety.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { At as safeTelegramFetch, Ct as currentThreadId, Dt as failureText, Et as customerText, Ot as formattingRefused, St as currentLocale, Tt as customerMessage, jt as withDeliveryLocale, kt as reportTelegramError, wt as customerCopy, xt as TelegramDeliveryError } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
9
9
|
export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
|
|
@@ -6,6 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
|
|
8
8
|
import { chatEvent } from "../chat-archive.mjs";
|
|
9
|
+
import { currentChannel } from "../channel-scope.mjs";
|
|
9
10
|
import { redactTelegramDiagnostic } from "./diagnostic-redaction.mjs";
|
|
10
11
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
11
12
|
const pending = new AsyncLocalStorage();
|
|
@@ -27,7 +28,7 @@ async function withDeliveryDiagnostics(archive, scope, run) {
|
|
|
27
28
|
for (const diagnostic of diagnostics) try {
|
|
28
29
|
await archive.append(chatEvent({
|
|
29
30
|
...scope,
|
|
30
|
-
provider: "telegram",
|
|
31
|
+
provider: currentChannel("telegram"),
|
|
31
32
|
eventId: `telegram:diagnostic:${diagnostic.errorId}`,
|
|
32
33
|
kind: "decision",
|
|
33
34
|
decision: "silent",
|
|
@@ -9,7 +9,10 @@ import type { StagedFile } from "./inbound-request.js";
|
|
|
9
9
|
* "Attachments"), which stores each once as the member's attachment in this chat. The turn reads
|
|
10
10
|
* the stored copy in place of eve's Telegram file part.
|
|
11
11
|
*/
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* The chat an attachment belongs to: `telegram:<chat id>`, or `<name>:<chat id>` on another
|
|
14
|
+
* Telegram channel.
|
|
15
|
+
*/
|
|
13
16
|
export declare function telegramChat(chatId: string): string;
|
|
14
17
|
/** Eve normalizes photos/documents only. Keep other Telegram files available to attachment tools. */
|
|
15
18
|
export declare function inboundAttachments(message: TelegramMessage): ReadonlyArray<TelegramAttachment>;
|
|
@@ -4,9 +4,10 @@ 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 {
|
|
7
|
+
import { currentChannel } from "../channel-scope.mjs";
|
|
8
|
+
import { kt as reportTelegramError, p as storeFiles } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
8
9
|
function telegramChat(chatId) {
|
|
9
|
-
return
|
|
10
|
+
return `${currentChannel("telegram")}:${chatId}`;
|
|
10
11
|
}
|
|
11
12
|
function inboundAttachments(message) {
|
|
12
13
|
const files = [...message.attachments];
|
|
@@ -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-CYSFZe6f.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";
|
|
@@ -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 {
|
|
7
|
+
import { N as CONFIRMATION_TTL_MS } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
8
8
|
import { object } from "../confirmation-description.mjs";
|
|
9
9
|
import { SessionNotActiveError } from "eve/sessions";
|
|
10
10
|
function heldApprovals(events) {
|
|
@@ -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 { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-
|
|
7
|
+
export { s as InboundRequest, c as currentInboundRequest, l as runInboundRequest, u as withReplacedText } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { WorkspaceActionAlreadyDispatched } from "./workspace-action.mjs";
|
|
8
8
|
import { structuredMessage } from "./structured.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { Ft as runtimeEnvelope, It as telegramRuntimeSource, f as attachmentsContext, kt as reportTelegramError, n as chatLanguage, o as telegramPrincipal, x as attachmentUrl } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
10
10
|
import { routingBurst } from "../group-routing/burst.mjs";
|
|
11
11
|
import { telegramSignals } from "./signals.mjs";
|
|
12
12
|
import { addressingReason, chatKey, otherRecipient } from "../group-routing/signals.mjs";
|
|
@@ -17,7 +17,7 @@ import { admitMessage, localizedText } from "../admission.mjs";
|
|
|
17
17
|
import { chatContext } from "../chats.mjs";
|
|
18
18
|
import { questionAddress, questionFromHistory } from "./confirmations.mjs";
|
|
19
19
|
import { answerMarker } from "../questions.mjs";
|
|
20
|
-
import { inboundAttachments, stageFiles } from "./files.mjs";
|
|
20
|
+
import { inboundAttachments, stageFiles, telegramChat } from "./files.mjs";
|
|
21
21
|
import { MAXIMUM_NATIVE_IMAGE_BYTES } from "../inbound-media/images.mjs";
|
|
22
22
|
import { NATIVE_AUDIO_NOTE, transcribeSpeech } from "../inbound-media/speech.mjs";
|
|
23
23
|
import { heldApprovals, releaseHeldApproval } from "./held-approvals.mjs";
|
|
@@ -880,7 +880,7 @@ async function handleInboundMessage(input) {
|
|
|
880
880
|
try {
|
|
881
881
|
outcome = { result: (await dependencies.attachments.promote({
|
|
882
882
|
memberId: member.id,
|
|
883
|
-
chat:
|
|
883
|
+
chat: telegramChat(sent.chat.id)
|
|
884
884
|
}, file.attachment.id, {
|
|
885
885
|
...stored.retain,
|
|
886
886
|
runtime: runtimeEnvelope({ source: telegramRuntimeSource(sent, files) })
|
|
@@ -1027,7 +1027,7 @@ async function handleInboundMessage(input) {
|
|
|
1027
1027
|
data: attachmentUrl({
|
|
1028
1028
|
id: image.id,
|
|
1029
1029
|
memberId: member.id,
|
|
1030
|
-
chat:
|
|
1030
|
+
chat: telegramChat(sent.chat.id)
|
|
1031
1031
|
}),
|
|
1032
1032
|
mediaType: image.contentType,
|
|
1033
1033
|
filename: image.filename
|
|
@@ -4,8 +4,8 @@ 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 {
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
7
|
+
import { E as OntologyActionNotPermitted, Ft as runtimeEnvelope, It as telegramRuntimeSource, L as needsConfirmation, Pt as principalRuntimeSource, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName } from "../../../_chunks/principal-DIgU-kPR.mjs";
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-CYSFZe6f.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
|
@@ -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 TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-
|
|
7
|
+
export { t as TELEGRAM_AUTHENTICATOR, n as chatLanguage, r as identityProviderOf, i as memberIdOf, a as rolesOf, o as telegramPrincipal } from "../../../_chunks/principal-DIgU-kPR.mjs";
|