@segmentstream/agent 0.45.0 → 0.45.1
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 +13 -0
- package/dist/_chunks/{build-metadata-s0t4FPPK.mjs → build-metadata-DpMnVUed.mjs} +1 -1
- package/dist/_chunks/{inbound-request-CK0QqEOP.mjs → inbound-request-B3RhCuOw.mjs} +6 -11
- package/dist/_chunks/{principal-BXvelsZk.mjs → principal-Dzs8hUDB.mjs} +1 -1
- package/dist/extension/hooks/authorization.mjs +1 -1
- package/dist/extension/instructions/persona.mjs +1 -1
- package/dist/extension/lib/actor.mjs +1 -1
- package/dist/extension/lib/attachment-tools.mjs +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/chat-address.mjs +1 -1
- package/dist/extension/lib/chat-context.mjs +1 -1
- package/dist/extension/lib/chat-recorder.mjs +1 -1
- package/dist/extension/lib/confirmations.mjs +1 -1
- package/dist/extension/lib/ontology-connection.mjs +1 -1
- package/dist/extension/lib/ontology-file-call.mjs +1 -1
- package/dist/extension/lib/ontology-tools.mjs +1 -1
- package/dist/extension/lib/review/hold.mjs +1 -1
- package/dist/extension/lib/review/reply.mjs +1 -1
- package/dist/extension/lib/role-skill.mjs +1 -1
- package/dist/extension/lib/runtime-envelope.mjs +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.mjs +15 -28
- package/dist/extension/lib/telegram/app-links.d.ts +22 -0
- package/dist/extension/lib/telegram/app-links.mjs +27 -1
- package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.d.ts +3 -0
- package/dist/extension/lib/telegram/attachments-send.mjs +16 -4
- package/dist/extension/lib/telegram/bot.d.ts +17 -0
- package/dist/extension/lib/telegram/bot.mjs +21 -1
- package/dist/extension/lib/telegram/callbacks.mjs +2 -2
- package/dist/extension/lib/telegram/chat-archive.mjs +1 -1
- package/dist/extension/lib/telegram/confirmations.mjs +2 -2
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.mjs +2 -2
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/images.mjs +1 -1
- package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
- package/dist/extension/lib/telegram/inbound.mjs +2 -2
- package/dist/extension/lib/telegram/lifecycle.mjs +3 -3
- package/dist/extension/lib/telegram/media-policy.mjs +1 -1
- package/dist/extension/lib/telegram/principal.mjs +1 -1
- package/dist/extension/lib/telegram/session-recovery.mjs +1 -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 +2 -2
- package/dist/extension/lib/telegram/voice.mjs +1 -1
- package/dist/extension/model.mjs +1 -1
- package/dist/extension/tools/attachments_promote.mjs +1 -1
- package/dist/extension/tools/attachments_send.mjs +2 -1
- package/dist/extension/tools/questions_ask.mjs +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.45.1
|
|
4
|
+
|
|
5
|
+
With `channels.telegram.appLinks: "miniApp"`, the captions of files the agent sends with
|
|
6
|
+
`segmentstream__attachments_send` open their links to the app's pages in the bot's Main Mini App
|
|
7
|
+
too, by the same rules and with the same bot username as replies. They kept their links as written
|
|
8
|
+
before.
|
|
9
|
+
|
|
10
|
+
With `channels.telegram.linkPreviews: "all"`, a message whose first link opens in the Mini App
|
|
11
|
+
previews the app's page that link was written as, as it did before the link was rewritten, instead
|
|
12
|
+
of the bot's `t.me` page: the message's `link_preview_options.url` names that page, unless the
|
|
13
|
+
message's own preview options disable the preview or name another URL. `external` and `none` choose
|
|
14
|
+
previews as before, and with the default, `"web"`, nothing changes.
|
|
15
|
+
|
|
3
16
|
## 0.45.0
|
|
4
17
|
|
|
5
18
|
The Agent SDK now builds on eve 1.0.1, eve's first stable release, and requires `ai` 7.0.172 or
|
|
@@ -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
|
-
var version = "0.45.
|
|
7
|
+
var version = "0.45.1";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -12,7 +12,7 @@ import { confirmationEntities } from "../extension/lib/telegram/confirmation-tex
|
|
|
12
12
|
import { plainTelegramText, splitTelegramText, telegramMarkdown } from "../extension/lib/telegram/format.mjs";
|
|
13
13
|
import { inTelegramSendQueue } from "../extension/lib/telegram/send-queue.mjs";
|
|
14
14
|
import { retainDeliveryDiagnostic } from "../extension/lib/telegram/delivery-diagnostics.mjs";
|
|
15
|
-
import { miniAppLinks } from "../extension/lib/telegram/app-links.mjs";
|
|
15
|
+
import { miniAppLinks, originalLinkPreview, withMiniAppLinks } from "../extension/lib/telegram/app-links.mjs";
|
|
16
16
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
17
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
18
18
|
import { telegramPreviewOptions, telegramTextLinks } from "@segmentstream/ontology/telegram";
|
|
@@ -135,12 +135,6 @@ function linkDestinations(body) {
|
|
|
135
135
|
...Array.isArray(markup?.inline_keyboard) ? markup.inline_keyboard.flatMap(records) : []
|
|
136
136
|
].flatMap((item) => typeof item.url === "string" ? [item.url] : []);
|
|
137
137
|
}
|
|
138
|
-
function withAppLinks(items, links) {
|
|
139
|
-
return links.size === 0 || !Array.isArray(items) ? items : items.map((item) => isFields(item) && typeof item.url === "string" && links.has(item.url) ? {
|
|
140
|
-
...item,
|
|
141
|
-
url: links.get(item.url)
|
|
142
|
-
} : item);
|
|
143
|
-
}
|
|
144
138
|
function safeTelegramFetch(fetchImpl, scope = "telegram", previews = {}, appLinks) {
|
|
145
139
|
const methods = new Set([
|
|
146
140
|
"sendMessage",
|
|
@@ -207,10 +201,10 @@ function safeTelegramFetch(fetchImpl, scope = "telegram", previews = {}, appLink
|
|
|
207
201
|
}
|
|
208
202
|
const links = appLinks === void 0 || fixed ? new Map() : await miniAppLinks(appLinks, linkDestinations(body));
|
|
209
203
|
if (links.size > 0) {
|
|
210
|
-
if (Array.isArray(markup?.inline_keyboard) && body.reply_markup !== void 0) markup.inline_keyboard = markup.inline_keyboard.map((row) =>
|
|
204
|
+
if (Array.isArray(markup?.inline_keyboard) && body.reply_markup !== void 0) markup.inline_keyboard = markup.inline_keyboard.map((row) => withMiniAppLinks(row, links));
|
|
211
205
|
if (Array.isArray(body.media)) body.media = body.media.map((item) => isFields(item) && item.caption_entities !== void 0 ? {
|
|
212
206
|
...item,
|
|
213
|
-
caption_entities:
|
|
207
|
+
caption_entities: withMiniAppLinks(item.caption_entities, links)
|
|
214
208
|
} : item);
|
|
215
209
|
}
|
|
216
210
|
const send = async () => {
|
|
@@ -222,14 +216,15 @@ function safeTelegramFetch(fetchImpl, scope = "telegram", previews = {}, appLink
|
|
|
222
216
|
const messageIds = [];
|
|
223
217
|
const attempt = async (outgoing) => {
|
|
224
218
|
try {
|
|
225
|
-
const
|
|
219
|
+
const written = (url.endsWith("/sendMessage") || url.endsWith("/editMessageText")) && typeof outgoing.text === "string" ? chatPostCardLinks(outgoing.text) ?? telegramTextLinks(outgoing.text, outgoing.entities ?? []) : void 0;
|
|
220
|
+
const previewOptions = written === void 0 ? {} : originalLinkPreview(telegramPreviewOptions(body, written, previews), written, links);
|
|
226
221
|
const payload = { ...outgoing };
|
|
227
222
|
if (url.endsWith("/sendMessage") || url.endsWith("/editMessageText")) {
|
|
228
223
|
delete payload.link_preview_options;
|
|
229
224
|
delete payload.disable_web_page_preview;
|
|
230
225
|
Object.assign(payload, previewOptions);
|
|
231
226
|
}
|
|
232
|
-
for (const field of ["entities", "caption_entities"]) if (payload[field] !== void 0) payload[field] =
|
|
227
|
+
for (const field of ["entities", "caption_entities"]) if (payload[field] !== void 0) payload[field] = withMiniAppLinks(payload[field], links);
|
|
233
228
|
return await fetchImpl(input, {
|
|
234
229
|
...init,
|
|
235
230
|
body: JSON.stringify(payload)
|
|
@@ -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 { n as currentInboundRequest } from "./inbound-request-
|
|
7
|
+
import { n as currentInboundRequest } from "./inbound-request-B3RhCuOw.mjs";
|
|
8
8
|
import "../extension/lib/agent-task.mjs";
|
|
9
9
|
import { randomUUID } from "node:crypto";
|
|
10
10
|
function telegramRuntimeSource(message, files, callbackQueryId) {
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
8
|
import { localizedText } from "../lib/admission.mjs";
|
|
9
9
|
import { confirmationLocale } from "../lib/telegram/confirmation-text.mjs";
|
|
10
|
-
import "../../_chunks/principal-
|
|
10
|
+
import "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
11
11
|
import { defineHook } from "eve/hooks";
|
|
12
12
|
var authorization_default = defineHook({ events: { "interaction.opened": (event, context) => {
|
|
13
13
|
const principal = context.session.auth.current;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import segmentstream from "../extension.mjs";
|
|
8
|
-
import { a as rolesOf } from "../../_chunks/principal-
|
|
8
|
+
import { a as rolesOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
9
|
import { personaFor } from "../personas.mjs";
|
|
10
10
|
import { defineDynamic, defineInstructions } from "eve/instructions";
|
|
11
11
|
var persona_default = defineDynamic((context) => {
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { AGENT_TASK_HEADER, agentTaskIdOf, taskSecret } from "./agent-task.mjs";
|
|
8
|
-
import { i as memberIdOf, r as identityProviderOf } from "../../_chunks/principal-
|
|
8
|
+
import { i as memberIdOf, r as identityProviderOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
9
|
import { defineDynamic } from "eve/tools";
|
|
10
10
|
const ACT_AS_HEADER = "X-SegmentStream-Act-As";
|
|
11
11
|
function member(memberId) {
|
|
@@ -10,7 +10,7 @@ import { readSheets, typedTable } from "./attachment-tables.mjs";
|
|
|
10
10
|
import { appOrigin } from "./environment.mjs";
|
|
11
11
|
import { runtimeToken } from "./runtime-token.mjs";
|
|
12
12
|
import { chatAddressOf } from "./chat-address.mjs";
|
|
13
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
13
|
+
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
14
14
|
const MAXIMUM_TEXT_CHARACTERS = 5e4;
|
|
15
15
|
const MAXIMUM_INLINE_BYTES = 5242880;
|
|
16
16
|
var AttachmentOwnerError = class extends Error {
|
|
@@ -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 agentBuild } from "../../_chunks/build-metadata-
|
|
7
|
+
export { t as agentBuild } from "../../_chunks/build-metadata-DpMnVUed.mjs";
|
|
@@ -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 "../../_chunks/principal-
|
|
7
|
+
import "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
const CHAT_ATTRIBUTE = "segmentstreamChat";
|
|
9
9
|
const EARLIER_CHAT_ATTRIBUTE = "segmentstreamConversation";
|
|
10
10
|
function withChatAddress(principal, chat) {
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
8
8
|
import { chatCoordinates } from "./chat-recorder.mjs";
|
|
9
9
|
import { chatArchive, collapseChatEvents, topicContext } from "./chat-archive.mjs";
|
|
10
|
-
import { p as reportTelegramError } from "../../_chunks/inbound-request-
|
|
10
|
+
import { p as reportTelegramError } from "../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
11
11
|
import { createHash } from "node:crypto";
|
|
12
12
|
import { deliveries, runs, turns } from "eve/events";
|
|
13
13
|
import { defineState } from "eve/context";
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { n as contentText, t as CONTENT_CAPS } from "../../_chunks/content-cDtVnr8Y.mjs";
|
|
8
8
|
import { chatArchive, chatEvent, sessionFailureEventId, summarizeArguments } from "./chat-archive.mjs";
|
|
9
9
|
import { agentTaskIdOf } from "./agent-task.mjs";
|
|
10
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
10
|
+
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
11
11
|
import { parseAddress } from "./telegram/sessions.mjs";
|
|
12
12
|
import { completionKind } from "./telegram/silent.mjs";
|
|
13
13
|
import { recordModelServiceAlert } from "./model-service-alert.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { actorOf, member } from "./actor.mjs";
|
|
8
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
8
|
+
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
9
|
import { ConfirmationRefused, UnsafeConfirmationTarget } from "./confirmation-description.mjs";
|
|
10
10
|
import { chatPostDigest, isChatPost } from "./chat-post-confirmation.mjs";
|
|
11
11
|
import { promptFits } from "./confirmation-buttons.mjs";
|
|
@@ -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 { c as compatibleRuntimeEnvelope, u as runtimeEnvelope } from "../../_chunks/principal-
|
|
7
|
+
import { c as compatibleRuntimeEnvelope, u as runtimeEnvelope } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
import { appOrigin } from "./environment.mjs";
|
|
9
9
|
import { actionApproval, confirmations } from "./confirmations.mjs";
|
|
10
10
|
import { CHAT_POST_ENVELOPE, CHAT_POST_TOOL, chatPostDigest, chatPostOperationId, isChatPost } from "./chat-post-confirmation.mjs";
|
|
@@ -7,7 +7,7 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { actionApproval, confirmations, inputHash } from "./confirmations.mjs";
|
|
8
8
|
import { isChatPost } from "./chat-post-confirmation.mjs";
|
|
9
9
|
import { ontologyTools } from "./ontology-tools.mjs";
|
|
10
|
-
import { u as runtimeEnvelope } from "../../_chunks/principal-
|
|
10
|
+
import { u as runtimeEnvelope } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
11
11
|
import { sandboxFile } from "./sandbox-session.mjs";
|
|
12
12
|
import { saveOntologyResult } from "./ontology-result-file.mjs";
|
|
13
13
|
import { actorKey, actorOf } from "./actor.mjs";
|
|
@@ -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 { c as compatibleRuntimeEnvelope, s as RUNTIME_SOURCE_PROTOCOL, u as runtimeEnvelope } from "../../_chunks/principal-
|
|
7
|
+
import { c as compatibleRuntimeEnvelope, s as RUNTIME_SOURCE_PROTOCOL, u as runtimeEnvelope } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
import "./agent-task.mjs";
|
|
9
9
|
import { actorHeaders, actorKey, actorOf } from "./actor.mjs";
|
|
10
10
|
import { CONFIRMATION_FACTS, CONFIRMATION_PREVIEW_METHOD, ConfirmationRefused, confirmationCard, describeConfirmation, factsConfirmation, object } from "./confirmation-description.mjs";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { reviewFor } from "../../review.mjs";
|
|
8
8
|
import { chatAddressOf } from "../chat-address.mjs";
|
|
9
|
-
import { a as rolesOf, i as memberIdOf } from "../../../_chunks/principal-
|
|
9
|
+
import { a as rolesOf, i as memberIdOf } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
10
10
|
function reviewOf(settings, principal) {
|
|
11
11
|
return reviewFor(settings, rolesOf(principal));
|
|
12
12
|
}
|
|
@@ -8,7 +8,7 @@ import { chatAddressOf } from "../chat-address.mjs";
|
|
|
8
8
|
import { chatArchive, chatEvent } from "../chat-archive.mjs";
|
|
9
9
|
import { appOrigin } from "../environment.mjs";
|
|
10
10
|
import { agentReviews } from "./client.mjs";
|
|
11
|
-
import { i as memberIdOf } from "../../../_chunks/principal-
|
|
11
|
+
import { i as memberIdOf } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
12
12
|
import { heldReply, repliesReviewed, reviewOf, reviewOutcome } from "./hold.mjs";
|
|
13
13
|
import { judgeReply, readChat } from "./judge.mjs";
|
|
14
14
|
const VERDICTS_REMEMBERED = 512;
|
|
@@ -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 { a as rolesOf } from "../../_chunks/principal-
|
|
7
|
+
import { a as rolesOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
import { defineDynamic, defineSkill } from "eve/skills";
|
|
9
9
|
function forRoles(roles, skill) {
|
|
10
10
|
if (!Array.isArray(roles) || roles.length === 0 || !roles.every((role) => typeof role === "string" && role.trim() !== "")) throw new TypeError("forRoles() needs at least one role name; a skill for everyone is an ordinary skill file.");
|
|
@@ -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 RUNTIME_SOURCE_PROTOCOL, c as compatibleRuntimeEnvelope, l as principalRuntimeSource, u as runtimeEnvelope, d as telegramRuntimeSource } from "../../_chunks/principal-
|
|
7
|
+
export { s as RUNTIME_SOURCE_PROTOCOL, c as compatibleRuntimeEnvelope, l as principalRuntimeSource, u as runtimeEnvelope, d as telegramRuntimeSource } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
@@ -14,7 +14,7 @@ import { transientFileStatus } from "../file-grant.mjs";
|
|
|
14
14
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
15
15
|
import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
|
|
16
16
|
import { confirmationLocale } from "../telegram/confirmation-text.mjs";
|
|
17
|
-
import { d as failureText } from "../../../_chunks/inbound-request-
|
|
17
|
+
import { d as failureText } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
18
18
|
import { proxiedSlackFetch } from "./adapter.mjs";
|
|
19
19
|
import { randomUUID } from "node:crypto";
|
|
20
20
|
const SLACK_API = "https://slack.com/api/";
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { object } from "./confirmation-description.mjs";
|
|
8
8
|
import { OntologyFileUnavailable, ontologyTools } from "./ontology-tools.mjs";
|
|
9
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
9
|
+
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
10
10
|
import { member } from "./actor.mjs";
|
|
11
11
|
import { redactDiagnostic } from "./diagnostics.mjs";
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
@@ -10,7 +10,7 @@ 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-DpMnVUed.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
@@ -23,11 +23,12 @@ import { chatArchive, topicContext } from "../chat-archive.mjs";
|
|
|
23
23
|
import { captureRouteDecider, captureTelegramFetch, chatIdentities, recordGateDecision, telegramChatCapture } from "./chat-archive.mjs";
|
|
24
24
|
import { runtimeTokenVerifier } from "../runtime-identity.mjs";
|
|
25
25
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
26
|
-
import { botIdentityCache } from "./bot.mjs";
|
|
26
|
+
import { botIdentityCache, proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
|
|
27
27
|
import { handleConfirmationCallback, telegramConfirmationEvents } from "./confirmations.mjs";
|
|
28
28
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
29
|
-
import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, o as currentLocale, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-
|
|
30
|
-
import {
|
|
29
|
+
import { d as failureText, h as withDeliveryLocale, i as withReplacedText, m as safeTelegramFetch, n as currentInboundRequest, o as currentLocale, p as reportTelegramError, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
30
|
+
import { telegramAppLinkContext } from "./app-links.mjs";
|
|
31
|
+
import { n as chatLanguage, o as telegramPrincipal } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
31
32
|
import { gatewayImageDescriber } from "./images.mjs";
|
|
32
33
|
import { gatewayMediaCapabilities, planMedia } from "./media-policy.mjs";
|
|
33
34
|
import { agentChats } from "../chats.mjs";
|
|
@@ -122,19 +123,11 @@ function segmentstreamTelegram(options) {
|
|
|
122
123
|
}
|
|
123
124
|
return existing;
|
|
124
125
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
headers: [["content-type", "application/json"]],
|
|
131
|
-
body: new TextEncoder().encode(JSON.stringify(body))
|
|
132
|
-
});
|
|
133
|
-
return {
|
|
134
|
-
ok: reply.status >= 200 && reply.status < 300,
|
|
135
|
-
status: reply.status,
|
|
136
|
-
body: JSON.parse(new TextDecoder().decode(reply.body))
|
|
137
|
-
};
|
|
126
|
+
function botRequest(method, body) {
|
|
127
|
+
return proxiedBotRequest(proxy(), method, body);
|
|
128
|
+
}
|
|
129
|
+
function botIdentity() {
|
|
130
|
+
return runtimeBotIdentity(telegramSendScope(environment, settings().connection), bot);
|
|
138
131
|
}
|
|
139
132
|
function pairing() {
|
|
140
133
|
identities ??= agentIdentities({
|
|
@@ -201,16 +194,10 @@ function segmentstreamTelegram(options) {
|
|
|
201
194
|
api: {
|
|
202
195
|
apiBaseUrl: TELEGRAM_PROXY_ORIGIN,
|
|
203
196
|
fileBaseUrl: TELEGRAM_PROXY_ORIGIN,
|
|
204
|
-
fetch: (input, init) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
ownOrigins
|
|
209
|
-
}, settings().appLinks === "miniApp" ? {
|
|
210
|
-
origins: [...ownOrigins, ...settings().additionalOwnOrigins ?? []],
|
|
211
|
-
botUsername: async () => (await bot({ request: botRequest }))?.username
|
|
212
|
-
} : void 0)(input, init);
|
|
213
|
-
}
|
|
197
|
+
fetch: (input, init) => safeTelegramFetch(captureTelegramFetch(telegramProxyFetch(proxy(), telegramSendScope(environment, settings().connection)), archive, pairing), telegramSendScope(environment, settings().connection), {
|
|
198
|
+
settings: settings(),
|
|
199
|
+
ownOrigins: telegramPreviewEnvironment(environment).appOrigins
|
|
200
|
+
}, telegramAppLinkContext(settings(), environment, async () => (await botIdentity()({ request: botRequest }))?.username))(input, init)
|
|
214
201
|
},
|
|
215
202
|
credentials: {
|
|
216
203
|
botToken: TELEGRAM_PLACEHOLDER_TOKEN,
|
|
@@ -300,7 +287,7 @@ function segmentstreamTelegram(options) {
|
|
|
300
287
|
} : await capabilities(selected), options.models().imageDescription ?? null);
|
|
301
288
|
},
|
|
302
289
|
identities: chatIdentities(pairing()),
|
|
303
|
-
bot,
|
|
290
|
+
bot: botIdentity(),
|
|
304
291
|
decide: captureRouteDecider(decisionRouter({
|
|
305
292
|
decide: options.decide,
|
|
306
293
|
model: options.models().decision
|
|
@@ -19,6 +19,17 @@ export interface TelegramAppLinkContext {
|
|
|
19
19
|
/** The bot's username, from a cached lookup; without one, links stay as they are. */
|
|
20
20
|
readonly botUsername: () => Promise<string | undefined>;
|
|
21
21
|
}
|
|
22
|
+
/** The Telegram channel settings that decide where links to the app open. */
|
|
23
|
+
export interface TelegramAppLinkSettings {
|
|
24
|
+
readonly appLinks?: string;
|
|
25
|
+
readonly additionalOwnOrigins?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The context that opens a channel's links to the app in the Mini App, or `undefined` while they
|
|
29
|
+
* stay as written. Replies, edits and buttons through the delivery guard and the captions of the
|
|
30
|
+
* attachment tool use the same one, so both open the same links.
|
|
31
|
+
*/
|
|
32
|
+
export declare function telegramAppLinkContext(settings: TelegramAppLinkSettings | null | undefined, environment: Readonly<Record<string, string | undefined>>, botUsername: () => Promise<string | undefined>): TelegramAppLinkContext | undefined;
|
|
22
33
|
/**
|
|
23
34
|
* Whether a link may open the app's page at `pathname`: a local path, also once decoded, that is
|
|
24
35
|
* not an API, an asset, or a page where the member decides something.
|
|
@@ -37,3 +48,14 @@ export declare function miniAppLink(url: string, origins: ReadonlySet<string>, b
|
|
|
37
48
|
* link as it is.
|
|
38
49
|
*/
|
|
39
50
|
export declare function miniAppLinks(context: TelegramAppLinkContext, urls: Iterable<string>): Promise<ReadonlyMap<string, string>>;
|
|
51
|
+
/** `items` with each one whose `url` has a Mini App link in `links` pointing there instead. */
|
|
52
|
+
export declare function withMiniAppLinks<T>(items: T, links: ReadonlyMap<string, string>): T;
|
|
53
|
+
/**
|
|
54
|
+
* A message's preview options, kept on the page its first link was written as. Telegram previews
|
|
55
|
+
* the first link it delivers unless the options disable the preview or name a URL, so once that
|
|
56
|
+
* link opens in the Mini App it would preview the bot's `t.me` page. When `links`, the message's
|
|
57
|
+
* links as written in order, begin with one that `rewritten` maps, the options name it instead;
|
|
58
|
+
* options that disable the preview or already name a URL stay as they are, and any others are
|
|
59
|
+
* kept beside it.
|
|
60
|
+
*/
|
|
61
|
+
export declare function originalLinkPreview(options: Readonly<Record<string, unknown>>, links: readonly string[], rewritten: ReadonlyMap<string, string>): Readonly<Record<string, unknown>>;
|
|
@@ -4,7 +4,14 @@ 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 { telegramPreviewEnvironment } from "@segmentstream/ontology/telegram";
|
|
7
8
|
const TELEGRAM_APP_LINKS = ["web", "miniApp"];
|
|
9
|
+
function telegramAppLinkContext(settings, environment, botUsername) {
|
|
10
|
+
return settings?.appLinks === "miniApp" ? {
|
|
11
|
+
origins: [...telegramPreviewEnvironment(environment).appOrigins, ...settings.additionalOwnOrigins ?? []],
|
|
12
|
+
botUsername
|
|
13
|
+
} : void 0;
|
|
14
|
+
}
|
|
8
15
|
const START_PARAM_PREFIX = "p_";
|
|
9
16
|
const MAXIMUM_START_PARAM_LENGTH = 512;
|
|
10
17
|
const NOT_LINKED_PATHS = [
|
|
@@ -50,4 +57,23 @@ async function miniAppLinks(context, urls) {
|
|
|
50
57
|
if (username === void 0 || !/^[A-Za-z0-9_]{1,64}$/u.test(username)) return new Map();
|
|
51
58
|
return new Map(candidates.map((url) => [url, miniAppLink(url, origins, username)]));
|
|
52
59
|
}
|
|
53
|
-
|
|
60
|
+
function withMiniAppLinks(items, links) {
|
|
61
|
+
return links.size === 0 || !Array.isArray(items) ? items : items.map((item) => typeof item === "object" && item !== null && "url" in item && typeof item.url === "string" && links.has(item.url) ? {
|
|
62
|
+
...item,
|
|
63
|
+
url: links.get(item.url)
|
|
64
|
+
} : item);
|
|
65
|
+
}
|
|
66
|
+
function originalLinkPreview(options, links, rewritten) {
|
|
67
|
+
const first = links[0];
|
|
68
|
+
if (first === void 0 || !rewritten.has(first)) return options;
|
|
69
|
+
const explicit = options.link_preview_options;
|
|
70
|
+
if (explicit !== void 0) return typeof explicit === "object" && explicit !== null && !Array.isArray(explicit) && !("is_disabled" in explicit && explicit.is_disabled === true) && !("url" in explicit && explicit.url !== void 0) ? {
|
|
71
|
+
...options,
|
|
72
|
+
link_preview_options: {
|
|
73
|
+
...explicit,
|
|
74
|
+
url: first
|
|
75
|
+
}
|
|
76
|
+
} : options;
|
|
77
|
+
return options.disable_web_page_preview === true ? options : { link_preview_options: { url: first } };
|
|
78
|
+
}
|
|
79
|
+
export { TELEGRAM_APP_LINKS, isAppContentPage, miniAppLink, miniAppLinks, originalLinkPreview, telegramAppLinkContext, telegramStartParam, withMiniAppLinks };
|
|
@@ -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 "./images.mjs";
|
|
8
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
9
|
import { gateway, generateText } from "ai";
|
|
10
10
|
const MAXIMUM_ROUTING_ATTACHMENT_BYTES = 5242880;
|
|
11
11
|
const ROUTING_ATTACHMENT_TIMEOUT_MS = 15e3;
|
|
@@ -2,6 +2,7 @@ import type { SessionAuthContext } from "eve/context";
|
|
|
2
2
|
import { type DocumentReference } from "../sent-files.js";
|
|
3
3
|
import { type Environment } from "../environment.js";
|
|
4
4
|
import { type RuntimeToken } from "../runtime-token.js";
|
|
5
|
+
import { type TelegramAppLinkSettings } from "./app-links.js";
|
|
5
6
|
export declare const MAXIMUM_PHOTO_BYTES: number;
|
|
6
7
|
export declare const MAXIMUM_DOCUMENT_BYTES: number;
|
|
7
8
|
export type { DocumentReference } from "../sent-files.js";
|
|
@@ -29,6 +30,8 @@ interface SendOptions {
|
|
|
29
30
|
readonly principal: SessionAuthContext | null;
|
|
30
31
|
readonly sessionId: string;
|
|
31
32
|
readonly connection: string | undefined;
|
|
33
|
+
/** The channel's settings for links to the app, which the caption's links follow. */
|
|
34
|
+
readonly appLinks?: TelegramAppLinkSettings | null;
|
|
32
35
|
readonly environment?: Environment;
|
|
33
36
|
readonly token?: RuntimeToken;
|
|
34
37
|
readonly fetch?: typeof fetch;
|
|
@@ -12,10 +12,12 @@ import { transientFileStatus } from "../file-grant.mjs";
|
|
|
12
12
|
import { StoredFileError, fetchStoredFile } from "../sent-files.mjs";
|
|
13
13
|
import { appOrigin, channelsEnabled, proxyEnvironment } from "../environment.mjs";
|
|
14
14
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
15
|
-
import "../../../_chunks/principal-
|
|
15
|
+
import "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
16
16
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
17
17
|
import { inTelegramSendQueue, telegramSendScope } from "./send-queue.mjs";
|
|
18
|
-
import { d as failureText, f as formattingRefused, l as customerMessage, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
18
|
+
import { d as failureText, f as formattingRefused, l as customerMessage, p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
19
|
+
import { miniAppLinks, telegramAppLinkContext, withMiniAppLinks } from "./app-links.mjs";
|
|
20
|
+
import { proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
|
|
19
21
|
import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
|
|
20
22
|
const MAXIMUM_PHOTO_BYTES = 10485760;
|
|
21
23
|
const MAXIMUM_DOCUMENT_BYTES = 52428800;
|
|
@@ -103,12 +105,14 @@ async function sendAttachmentsInOrder(options) {
|
|
|
103
105
|
};
|
|
104
106
|
const fetchImpl = options.fetch ?? fetch;
|
|
105
107
|
const origin = appOrigin(environment);
|
|
106
|
-
const
|
|
108
|
+
const scope = telegramSendScope(environment, options.connection);
|
|
109
|
+
const proxy = connectionProxy({
|
|
107
110
|
environment: proxyEnvironment(environment),
|
|
108
111
|
connection: options.connection,
|
|
109
112
|
token,
|
|
110
113
|
fetch: fetchImpl
|
|
111
|
-
})
|
|
114
|
+
});
|
|
115
|
+
const telegram = telegramProxyFetch(proxy, scope);
|
|
112
116
|
const results = options.input.documentIds.map(({ id }) => ({
|
|
113
117
|
id,
|
|
114
118
|
filename: ""
|
|
@@ -187,6 +191,14 @@ async function sendAttachmentsInOrder(options) {
|
|
|
187
191
|
});
|
|
188
192
|
}
|
|
189
193
|
let caption = options.input.caption === void 0 ? void 0 : customerMessage(options.input.caption, locale);
|
|
194
|
+
const appLinks = caption === void 0 ? void 0 : telegramAppLinkContext(options.appLinks, environment, async () => (await runtimeBotIdentity(scope)({ request: (method, body) => proxiedBotRequest(proxy, method, body) }))?.username);
|
|
195
|
+
if (caption !== void 0 && appLinks !== void 0) {
|
|
196
|
+
const links = await miniAppLinks(appLinks, caption.entities.flatMap((entity) => entity.url === void 0 ? [] : [entity.url]));
|
|
197
|
+
caption = {
|
|
198
|
+
text: caption.text,
|
|
199
|
+
entities: withMiniAppLinks(caption.entities, links)
|
|
200
|
+
};
|
|
201
|
+
}
|
|
190
202
|
let cursor = 0;
|
|
191
203
|
while (cursor < uploads.length) {
|
|
192
204
|
const batch = [uploads[cursor++]];
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
import type { TelegramHandle } from "eve/channels/telegram";
|
|
2
|
+
import type { ConnectionProxy } from "../connection-proxy.js";
|
|
2
3
|
import type { BotIdentity } from "./router.js";
|
|
3
4
|
export type BotIdentityLookup = (telegram: Pick<TelegramHandle, "request">) => Promise<BotIdentity | undefined>;
|
|
4
5
|
export declare function botIdentityCache(now?: () => number): BotIdentityLookup;
|
|
6
|
+
/**
|
|
7
|
+
* A Bot API call outside any chat, through the connection proxy, for the bot identity cache when it
|
|
8
|
+
* is asked before an inbound message has filled it. The cache logs a failure, such as an answer
|
|
9
|
+
* that is not JSON, and asks again later.
|
|
10
|
+
*/
|
|
11
|
+
export declare function proxiedBotRequest(proxy: ConnectionProxy, method: string, body?: Readonly<Record<string, unknown>>): Promise<{
|
|
12
|
+
ok: boolean;
|
|
13
|
+
status: number;
|
|
14
|
+
body: unknown;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* The identity cache of the bot behind a send scope in this runtime. The Telegram channel puts its
|
|
18
|
+
* own cache here as it uses it (`own`), so the attachment tool reads the username the channel
|
|
19
|
+
* already holds; where the channel has not run yet, the tool keeps a cache for the scope itself.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runtimeBotIdentity(scope: string, own?: BotIdentityLookup): BotIdentityLookup;
|
|
@@ -44,4 +44,24 @@ function botIdentityCache(now = Date.now) {
|
|
|
44
44
|
return identity;
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
async function proxiedBotRequest(proxy, method, body = {}) {
|
|
48
|
+
const reply = await proxy.request({
|
|
49
|
+
api: "bot",
|
|
50
|
+
method: "POST",
|
|
51
|
+
path: `/${method}`,
|
|
52
|
+
headers: [["content-type", "application/json"]],
|
|
53
|
+
body: new TextEncoder().encode(JSON.stringify(body))
|
|
54
|
+
});
|
|
55
|
+
return {
|
|
56
|
+
ok: reply.status >= 200 && reply.status < 300,
|
|
57
|
+
status: reply.status,
|
|
58
|
+
body: JSON.parse(new TextDecoder().decode(reply.body))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const runtimeIdentities = new Map();
|
|
62
|
+
function runtimeBotIdentity(scope, own) {
|
|
63
|
+
const lookup = own ?? runtimeIdentities.get(scope) ?? botIdentityCache();
|
|
64
|
+
runtimeIdentities.set(scope, lookup);
|
|
65
|
+
return lookup;
|
|
66
|
+
}
|
|
67
|
+
export { botIdentityCache, proxiedBotRequest, runtimeBotIdentity };
|
|
@@ -5,8 +5,8 @@ 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 { d as telegramRuntimeSource, i as memberIdOf, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-
|
|
9
|
-
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { d as telegramRuntimeSource, i as memberIdOf, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
9
|
+
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
10
10
|
import { formatAddress, parseAddress, scopedAddress } from "./sessions.mjs";
|
|
11
11
|
import { telegramText } from "./texts.mjs";
|
|
12
12
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
@@ -9,7 +9,7 @@ import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cD
|
|
|
9
9
|
import { chatEvent, sessionFailureEventId } from "../chat-archive.mjs";
|
|
10
10
|
import { currentConfirmationPrompt } from "../group-routing/messages.mjs";
|
|
11
11
|
import { messageMetadata } from "./message-metadata.mjs";
|
|
12
|
-
import { n as currentInboundRequest, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-
|
|
12
|
+
import { n as currentInboundRequest, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
13
13
|
import { reportMembership } from "./membership.mjs";
|
|
14
14
|
import { currentDeliveryScope } from "./delivery-diagnostics.mjs";
|
|
15
15
|
import { contentShape, messageContent } from "./content.mjs";
|
|
@@ -12,9 +12,9 @@ import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
|
|
|
12
12
|
import { chatEvent } from "../chat-archive.mjs";
|
|
13
13
|
import { chatPostCard, chatPostCardStatus, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
|
|
14
14
|
import { answerMarker, isPendingQuestion, pendingQuestions, questionKey } from "../questions.mjs";
|
|
15
|
-
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
15
|
+
import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
16
16
|
import { confirmationStatus, renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
|
|
17
|
-
import { i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-
|
|
17
|
+
import { i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
18
18
|
import { formatAddress, scopedAddress } from "./sessions.mjs";
|
|
19
19
|
import { createHash } from "node:crypto";
|
|
20
20
|
import { telegramTextLinks } from "@segmentstream/ontology/telegram";
|
|
@@ -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 { a as TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, h as withDeliveryLocale, l as customerMessage, m as safeTelegramFetch, o as currentLocale, p as reportTelegramError, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { a as TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, h as withDeliveryLocale, l as customerMessage, m as safeTelegramFetch, o as currentLocale, p as reportTelegramError, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
9
|
export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
|
|
@@ -5,8 +5,8 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { MAXIMUM_ATTACHMENT_BYTES, attachmentUrl } from "../attachments.mjs";
|
|
8
|
-
import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
9
|
-
import { n as chatLanguage } from "../../../_chunks/principal-
|
|
8
|
+
import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
|
+
import { n as chatLanguage } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
10
10
|
import { describableImage, describeReceivedImage } from "./images.mjs";
|
|
11
11
|
function telegramChat(chatId) {
|
|
12
12
|
return `telegram:${chatId}`;
|
|
@@ -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-DpMnVUed.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 { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
8
8
|
import { gateway, generateText } from "ai";
|
|
9
9
|
const MAXIMUM_IMAGE_DESCRIPTION_BYTES = 5242880;
|
|
10
10
|
const MAXIMUM_NATIVE_IMAGE_BYTES = 3145728;
|
|
@@ -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 InboundRequest, n as currentInboundRequest, r as runInboundRequest, i as withReplacedText } from "../../../_chunks/inbound-request-
|
|
7
|
+
export { t as InboundRequest, n as currentInboundRequest, r as runInboundRequest, i as withReplacedText } from "../../../_chunks/inbound-request-B3RhCuOw.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 { d as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-
|
|
9
|
+
import { d as telegramRuntimeSource, n as chatLanguage, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-Dzs8hUDB.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";
|
|
@@ -30,7 +30,7 @@ import { MAXIMUM_ROUTING_ATTACHMENT_BYTES, describeRoutingAttachment, routingAtt
|
|
|
30
30
|
import { recordGateDecision, recordInboundContent, recordRouteDecision } from "./chat-archive.mjs";
|
|
31
31
|
import { contentShape, messageContent } from "./content.mjs";
|
|
32
32
|
import { messageAudience } from "./audience.mjs";
|
|
33
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
33
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
34
34
|
const MAXIMUM_QUOTE_LENGTH = 500;
|
|
35
35
|
function buttonTo(text, url) {
|
|
36
36
|
return { inline_keyboard: [[{
|
|
@@ -4,9 +4,9 @@ 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 { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
9
|
-
import { n as currentInboundRequest } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { d as telegramRuntimeSource, l as principalRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-DpMnVUed.mjs";
|
|
9
|
+
import { n as currentInboundRequest } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
10
10
|
import { object } from "../confirmation-description.mjs";
|
|
11
11
|
import { needsConfirmation } from "../confirmations.mjs";
|
|
12
12
|
import { OntologyActionNotPermitted, actionToolName, ontologyTools } from "../ontology-tools.mjs";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { DEFAULT_IMAGE_DESCRIPTION_MODEL } from "../../config.mjs";
|
|
8
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
9
|
function planMedia(capabilities, descriptionModel = null) {
|
|
10
10
|
if (typeof descriptionModel === "string") return {
|
|
11
11
|
images: "describe",
|
|
@@ -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-Dzs8hUDB.mjs";
|
|
@@ -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 { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
8
8
|
import { createHash } from "node:crypto";
|
|
9
9
|
function strandedRun(error) {
|
|
10
10
|
if (!(error instanceof Error) || error.name !== "RunKeyFetchError" || !("status" in error) || error.status !== 404) return;
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
8
|
-
import { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { a as TelegramDeliveryError, l as customerMessage, o as currentLocale, p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
9
|
import { splitTelegramText } from "./format.mjs";
|
|
10
10
|
import { inTelegramSendQueue } from "./send-queue.mjs";
|
|
11
11
|
const NO_REPLY_TOOL = "no_reply";
|
|
@@ -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 { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-
|
|
7
|
+
import { d as telegramRuntimeSource, u as runtimeEnvelope } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
import { workspaceAction } from "./workspace-action.mjs";
|
|
9
9
|
import { STRUCTURED_KINDS } from "./structured-settings.mjs";
|
|
10
10
|
const record = (value) => {
|
|
@@ -7,8 +7,8 @@ __eveCreateRequire(import.meta.url);
|
|
|
7
7
|
import { telegramText } from "./texts.mjs";
|
|
8
8
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
9
9
|
import { recordSessionFailure } from "./chat-archive.mjs";
|
|
10
|
-
import { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-
|
|
11
|
-
import { i as memberIdOf } from "../../../_chunks/principal-
|
|
10
|
+
import { c as customerCopy, d as failureText, o as currentLocale, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
11
|
+
import { i as memberIdOf } from "../../../_chunks/principal-Dzs8hUDB.mjs";
|
|
12
12
|
import { modelServiceFailure } from "../model-service-failure.mjs";
|
|
13
13
|
function telegramFailureEvents(input) {
|
|
14
14
|
return {
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import "../connection-proxy.mjs";
|
|
8
|
-
import { p as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { p as reportTelegramError } from "../../../_chunks/inbound-request-B3RhCuOw.mjs";
|
|
9
9
|
import { gateway, transcribe } from "ai";
|
|
10
10
|
const LABELS = {
|
|
11
11
|
voice: "voice message",
|
package/dist/extension/model.mjs
CHANGED
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { chatModelChoiceOf } from "./config.mjs";
|
|
8
8
|
import { isPreview } from "./lib/environment.mjs";
|
|
9
|
-
import { a as rolesOf } from "../_chunks/principal-
|
|
9
|
+
import { a as rolesOf } from "../_chunks/principal-Dzs8hUDB.mjs";
|
|
10
10
|
import { defineDynamic } from "eve";
|
|
11
11
|
import { runs } from "eve/events";
|
|
12
12
|
function chooseModel(input) {
|
|
@@ -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 { u as runtimeEnvelope } from "../../_chunks/principal-
|
|
7
|
+
import { u as runtimeEnvelope } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
8
8
|
import segmentstream from "../extension.mjs";
|
|
9
9
|
import { n as workflowToolResult } from "../../_chunks/workflow-serializable-DU7WeCIW.mjs";
|
|
10
10
|
import { actionApproval } from "../lib/confirmations.mjs";
|
|
@@ -63,7 +63,8 @@ const tool = defineTool({
|
|
|
63
63
|
connection: segmentstream.config.channels.slack?.connection
|
|
64
64
|
}) : await sendAttachments({
|
|
65
65
|
...options,
|
|
66
|
-
connection: segmentstream.config.channels.telegram?.connection
|
|
66
|
+
connection: segmentstream.config.channels.telegram?.connection,
|
|
67
|
+
appLinks: segmentstream.config.channels.telegram
|
|
67
68
|
}), ctx);
|
|
68
69
|
}
|
|
69
70
|
});
|
|
@@ -9,7 +9,7 @@ import { agentTaskIdOf, agentTaskSessions } from "../lib/agent-task.mjs";
|
|
|
9
9
|
import { stringArgument } from "../lib/attachment-tools.mjs";
|
|
10
10
|
import { chatAddressOf } from "../lib/chat-address.mjs";
|
|
11
11
|
import { pendingQuestions, questionKey } from "../lib/questions.mjs";
|
|
12
|
-
import { i as memberIdOf } from "../../_chunks/principal-
|
|
12
|
+
import { i as memberIdOf } from "../../_chunks/principal-Dzs8hUDB.mjs";
|
|
13
13
|
import { defineTool } from "eve/tools";
|
|
14
14
|
var questions_ask_default = defineTool({
|
|
15
15
|
availableInSubagents: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.1",
|
|
4
4
|
"description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|