@segmentstream/agent 0.73.0 → 0.73.2
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 +12 -0
- package/dist/_chunks/{build-metadata-CvUZSH8c.mjs → build-metadata-3mxf7v2b.mjs} +1 -1
- package/dist/extension/lib/build-metadata.mjs +1 -1
- package/dist/extension/lib/telegram/adapter.mjs +1 -1
- package/dist/extension/lib/telegram/attachments-send.mjs +4 -2
- package/dist/extension/lib/telegram/format.d.ts +6 -0
- package/dist/extension/lib/telegram/format.mjs +29 -1
- package/dist/extension/lib/telegram/health.mjs +1 -1
- package/dist/extension/lib/telegram/lifecycle.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.73.2
|
|
4
|
+
|
|
5
|
+
Pins @segmentstream/ontology 0.150.1.
|
|
6
|
+
|
|
7
|
+
## 0.73.1
|
|
8
|
+
|
|
9
|
+
A file sent with `segmentstream__attachments_send` to Telegram keeps its caption's links and
|
|
10
|
+
formatting where they belong after line breaks. A single file's caption goes in a multipart form,
|
|
11
|
+
which sends every line break as CRLF; Telegram counted the CRs, so each line break before a link
|
|
12
|
+
or a bold phrase moved it one character earlier, cutting a link short. The caption is now sent with
|
|
13
|
+
CRLF line breaks and its entities counted on them.
|
|
14
|
+
|
|
3
15
|
## 0.73.0
|
|
4
16
|
|
|
5
17
|
The agent keeps its chats in the workspace's own database, the chat store, once its ontology
|
|
@@ -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.73.
|
|
7
|
+
var version = "0.73.2";
|
|
8
8
|
function agentBuild(environment = process.env) {
|
|
9
9
|
return {
|
|
10
10
|
agent: version,
|
|
@@ -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-3mxf7v2b.mjs";
|
|
@@ -10,7 +10,7 @@ import { groupRoutingHealth } from "../group-routing/health.mjs";
|
|
|
10
10
|
import { dispatchStructuredMessage, structuredMessage } from "./structured.mjs";
|
|
11
11
|
import { handleWorkspaceCallback } from "./callbacks.mjs";
|
|
12
12
|
import { telegramText, withTelegramTexts } from "./texts.mjs";
|
|
13
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
13
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-3mxf7v2b.mjs";
|
|
14
14
|
import { attachmentLifecycle } from "./lifecycle.mjs";
|
|
15
15
|
import { manifestOf } from "../../config.mjs";
|
|
16
16
|
import { gatewayAttachmentDescriber } from "./attachment-description.mjs";
|
|
@@ -14,6 +14,7 @@ import { appOrigin, channelsEnabled, proxyEnvironment } from "../environment.mjs
|
|
|
14
14
|
import { runtimeToken } from "../runtime-token.mjs";
|
|
15
15
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
16
16
|
import { inTelegramSendQueue, telegramSendScope } from "./send-queue.mjs";
|
|
17
|
+
import { withCrlfLineBreaks } from "./format.mjs";
|
|
17
18
|
import { miniAppLinks, telegramAppLinkContext, withMiniAppLinks } from "./app-links.mjs";
|
|
18
19
|
import { proxiedBotRequest, runtimeBotIdentity } from "./bot.mjs";
|
|
19
20
|
import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
|
|
@@ -165,8 +166,9 @@ async function sendAttachmentsInOrder(options) {
|
|
|
165
166
|
const file = files[0];
|
|
166
167
|
form.set(file.type, file.blob, file.filename);
|
|
167
168
|
if (caption !== void 0) {
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
const sent = withCrlfLineBreaks(caption);
|
|
170
|
+
form.set("caption", sent.text);
|
|
171
|
+
if (sent.entities.length > 0) form.set("caption_entities", JSON.stringify(sent.entities));
|
|
170
172
|
}
|
|
171
173
|
} else {
|
|
172
174
|
form.set("media", JSON.stringify(files.map((file, index) => ({
|
|
@@ -13,6 +13,12 @@ export interface TelegramText {
|
|
|
13
13
|
readonly text: string;
|
|
14
14
|
readonly entities: readonly TelegramEntity[];
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The same text with every line break written CRLF, and its entities moved to match. A multipart
|
|
18
|
+
* form sends a text field's line breaks as CRLF, and Telegram counts the CR in entity offsets, so a
|
|
19
|
+
* caption sent in one keeps its links and formatting only once its line breaks are CRLF already.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withCrlfLineBreaks(message: TelegramText): TelegramText;
|
|
16
22
|
/** Render Markdown as visible text plus UTF-16 entities; no HTML/Markdown parse mode is needed. */
|
|
17
23
|
export declare function telegramMarkdown(markdown: string): TelegramText;
|
|
18
24
|
/** A failed renderer still produces customer prose, without obvious Markdown/decorative markers. */
|
|
@@ -5,6 +5,34 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { Lexer } from "marked";
|
|
8
|
+
function withCrlfLineBreaks(message) {
|
|
9
|
+
if (!/[\r\n]/u.test(message.text)) return message;
|
|
10
|
+
let text = "";
|
|
11
|
+
const at = [];
|
|
12
|
+
for (let index = 0; index < message.text.length; index++) {
|
|
13
|
+
const char = message.text[index];
|
|
14
|
+
at.push(text.length);
|
|
15
|
+
if (char === "\r" && message.text[index + 1] === "\n") {
|
|
16
|
+
text += "\r\n";
|
|
17
|
+
at.push(text.length - 1);
|
|
18
|
+
index++;
|
|
19
|
+
} else if (char === "\r" || char === "\n") text += "\r\n";
|
|
20
|
+
else text += char;
|
|
21
|
+
}
|
|
22
|
+
at.push(text.length);
|
|
23
|
+
return {
|
|
24
|
+
text,
|
|
25
|
+
entities: message.entities.map((entity) => {
|
|
26
|
+
const start = at[entity.offset] ?? text.length;
|
|
27
|
+
const end = at[entity.offset + entity.length] ?? text.length;
|
|
28
|
+
return {
|
|
29
|
+
...entity,
|
|
30
|
+
offset: start,
|
|
31
|
+
length: end - start
|
|
32
|
+
};
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}
|
|
8
36
|
function telegramMarkdown(markdown) {
|
|
9
37
|
const source = markdown.replace(/^[ \t]*[━─═]{3,}[ \t]*$/gmu, "");
|
|
10
38
|
const entities = [];
|
|
@@ -168,4 +196,4 @@ function splitTelegramText(message, maximum = 4096) {
|
|
|
168
196
|
}
|
|
169
197
|
return parts;
|
|
170
198
|
}
|
|
171
|
-
export { plainTelegramText, splitTelegramText, telegramMarkdown };
|
|
199
|
+
export { plainTelegramText, splitTelegramText, telegramMarkdown, withCrlfLineBreaks };
|
|
@@ -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-3mxf7v2b.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";
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { E as OntologyActionNotPermitted, Et as principalRuntimeSource, L as needsConfirmation, Ot as runtimeEnvelope, W as member, c as currentInboundRequest, j as ontologyTools, k as actionToolName, kt as telegramRuntimeSource } from "../../../_chunks/principal-Zf42Yf4r.mjs";
|
|
8
|
-
import { t as agentBuild } from "../../../_chunks/build-metadata-
|
|
8
|
+
import { t as agentBuild } from "../../../_chunks/build-metadata-3mxf7v2b.mjs";
|
|
9
9
|
import { object } from "../confirmation-description.mjs";
|
|
10
10
|
var AttachmentLifecycleNotPermitted = class extends Error {
|
|
11
11
|
code = "attachment_lifecycle_not_permitted";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.73.
|
|
3
|
+
"version": "0.73.2",
|
|
4
4
|
"description": "The SegmentStream workspace agent: the ontology as tools, acting as the member who writes, and the browser, Telegram, WhatsApp and Slack through the workspace's connections.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@chat-adapter/state-memory": "4.42.0",
|
|
85
85
|
"@chat-adapter/telegram": "4.41.0",
|
|
86
86
|
"@chat-adapter/whatsapp": "4.42.0",
|
|
87
|
-
"@segmentstream/ontology": "0.150.
|
|
87
|
+
"@segmentstream/ontology": "0.150.1",
|
|
88
88
|
"@vercel/oidc": "^3.8.4",
|
|
89
89
|
"ai": "^7.0.172",
|
|
90
90
|
"chat": "4.42.0",
|