@segmentstream/agent 0.6.11 → 0.6.12
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/README.md +10 -8
- package/dist/_chunks/{inbound-request-DRNPIIpb.mjs → inbound-request-DgyI7oR9.mjs} +11 -3
- package/dist/extension/config.d.ts +7 -8
- package/dist/extension/config.mjs +20 -2
- package/dist/extension/lib/telegram/adapter.mjs +6 -2
- package/dist/extension/lib/telegram/attachments-send.mjs +1 -1
- package/dist/extension/lib/telegram/chat-post-card.d.ts +2 -1
- package/dist/extension/lib/telegram/chat-post-card.mjs +17 -4
- package/dist/extension/lib/telegram/confirmation-text.d.ts +1 -0
- package/dist/extension/lib/telegram/confirmations.mjs +7 -5
- package/dist/extension/lib/telegram/content.d.ts +1 -1
- package/dist/extension/lib/telegram/conversations.mjs +1 -1
- package/dist/extension/lib/telegram/customer-text.d.ts +2 -1
- package/dist/extension/lib/telegram/customer-text.mjs +1 -1
- package/dist/extension/lib/telegram/files.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/media-policy.mjs +1 -1
- package/dist/extension/lib/telegram/silent.mjs +1 -1
- package/dist/extension/lib/telegram/turn-errors.mjs +1 -1
- package/dist/extension/lib/telegram/voice.mjs +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -79,14 +79,16 @@ Both entry points export the same handle: `@segmentstream/agent` and
|
|
|
79
79
|
}
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
| Field
|
|
83
|
-
|
|
|
84
|
-
| `channels.telegram.connection`
|
|
85
|
-
| `channels.telegram.policy`
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `models.
|
|
89
|
-
| `
|
|
82
|
+
| Field | Default | Meaning |
|
|
83
|
+
| ---------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
84
|
+
| `channels.telegram.connection` | none | The Connect key whose credential is the bot token. Without `channels.telegram`, no Telegram. |
|
|
85
|
+
| `channels.telegram.policy` | `"smart"` | Unaddressed group text: `smart` asks the decision model, `mention` observes; attachments always trigger a turn |
|
|
86
|
+
| `channels.telegram.linkPreviews` | `all` | Keep native first-link previews; opt into `external` to preview external links only, or `none` to disable previews. Caller options take precedence. |
|
|
87
|
+
| `channels.telegram.additionalOwnOrigins` | `[]` | Additional exact HTTP(S) workspace origins, including local ports; no paths or credentials. |
|
|
88
|
+
| `models.stt` | `"spacexai/grok-stt"` | The AI Gateway transcription model for voice messages; `false` leaves them untranscribed |
|
|
89
|
+
| `models.imageDescription` | automatic | A separate vision model for ingestion descriptions; omitted prefers native images, `false` disables description fallback |
|
|
90
|
+
| `models.decision` | `"typesafe-ai/jev"` | The AI Gateway decision model of the inbound router |
|
|
91
|
+
| `ontology.connection` | `true` | Whether the agent reaches the ontology over MCP |
|
|
90
92
|
|
|
91
93
|
An unknown field or an invalid value fails the mount with `SegmentStreamAgentConfigError`, naming
|
|
92
94
|
each path. `manifestOf(config)` returns the normalized configuration, defaults applied, for the
|
|
@@ -4,10 +4,11 @@ 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 { isExactChatPostCard } from "../extension/lib/telegram/chat-post-card.mjs";
|
|
7
|
+
import { chatPostCardLinks, isExactChatPostCard } from "../extension/lib/telegram/chat-post-card.mjs";
|
|
8
8
|
import { redactDiagnostic } from "../extension/lib/diagnostics.mjs";
|
|
9
9
|
import { plainTelegramText, splitTelegramText, telegramMarkdown } from "../extension/lib/telegram/format.mjs";
|
|
10
10
|
import { inTelegramSendQueue } from "../extension/lib/telegram/send-queue.mjs";
|
|
11
|
+
import { telegramPreviewOptions, telegramTextLinks } from "@segmentstream-cloud/ontology/telegram";
|
|
11
12
|
import { randomBytes } from "node:crypto";
|
|
12
13
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
13
14
|
const deliveryLocale = new AsyncLocalStorage();
|
|
@@ -126,7 +127,7 @@ var TelegramDeliveryError = class extends Error {
|
|
|
126
127
|
this.messageIds = messageIds;
|
|
127
128
|
}
|
|
128
129
|
};
|
|
129
|
-
function safeTelegramFetch(fetchImpl, scope = "telegram") {
|
|
130
|
+
function safeTelegramFetch(fetchImpl, scope = "telegram", previews = {}) {
|
|
130
131
|
const methods = new Set([
|
|
131
132
|
"sendMessage",
|
|
132
133
|
"editMessageText",
|
|
@@ -177,9 +178,16 @@ function safeTelegramFetch(fetchImpl, scope = "telegram") {
|
|
|
177
178
|
const messageIds = [];
|
|
178
179
|
const attempt = async (outgoing) => {
|
|
179
180
|
try {
|
|
181
|
+
const previewOptions = (url.endsWith("/sendMessage") || url.endsWith("/editMessageText")) && typeof outgoing.text === "string" ? telegramPreviewOptions(body, chatPostCardLinks(outgoing.text) ?? telegramTextLinks(outgoing.text, outgoing.entities ?? []), previews) : {};
|
|
182
|
+
const payload = { ...outgoing };
|
|
183
|
+
if (url.endsWith("/sendMessage") || url.endsWith("/editMessageText")) {
|
|
184
|
+
delete payload.link_preview_options;
|
|
185
|
+
delete payload.disable_web_page_preview;
|
|
186
|
+
Object.assign(payload, previewOptions);
|
|
187
|
+
}
|
|
180
188
|
return await fetchImpl(input, {
|
|
181
189
|
...init,
|
|
182
|
-
body: JSON.stringify(
|
|
190
|
+
body: JSON.stringify(payload)
|
|
183
191
|
});
|
|
184
192
|
} catch (error) {
|
|
185
193
|
throw new TelegramDeliveryError(reportTelegramError("telegram_send_unknown", error, { messageIds }), "unknown", messageIds);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* The extension's configuration: `agent/segmentstream.json`, mounted by
|
|
3
|
-
* `agent/agent/extensions/segmentstream.ts` and read by the platform at deploy.
|
|
4
|
-
*
|
|
5
|
-
* eve validates a mount's configuration with a Standard Schema. The schema below is written by
|
|
6
|
-
* hand, so the package adds no second schema library next to the Effect Schema the rest of the
|
|
7
|
-
* repository uses.
|
|
8
|
-
*/
|
|
1
|
+
import { type TelegramLinkPreviews } from "@segmentstream-cloud/ontology/telegram";
|
|
9
2
|
export declare const TELEGRAM_POLICIES: readonly ["mention", "smart"];
|
|
10
3
|
/**
|
|
11
4
|
* How the Telegram channel treats group messages that do not address the bot: `smart` asks the
|
|
@@ -28,6 +21,10 @@ export interface SegmentStreamAgentConfigInput {
|
|
|
28
21
|
readonly connection: string;
|
|
29
22
|
/** `smart` (default) or `mention`. */
|
|
30
23
|
readonly policy?: string;
|
|
24
|
+
/** Telegram’s native first link (default), external links only, or no previews. */
|
|
25
|
+
readonly linkPreviews?: string;
|
|
26
|
+
/** Additional exact HTTP(S) origins belonging to this workspace. */
|
|
27
|
+
readonly additionalOwnOrigins?: readonly string[];
|
|
31
28
|
};
|
|
32
29
|
};
|
|
33
30
|
readonly models?: {
|
|
@@ -72,6 +69,8 @@ export interface SegmentStreamAgentConfigInput {
|
|
|
72
69
|
export interface TelegramSettings {
|
|
73
70
|
readonly connection: string;
|
|
74
71
|
readonly policy: TelegramPolicy;
|
|
72
|
+
readonly linkPreviews?: TelegramLinkPreviews;
|
|
73
|
+
readonly additionalOwnOrigins?: readonly string[];
|
|
75
74
|
}
|
|
76
75
|
/** The chat models `segmentstream.model()` chooses between, as AI Gateway model ids. */
|
|
77
76
|
export interface ChatModelChoice {
|
|
@@ -4,6 +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 { TELEGRAM_LINK_PREVIEWS, isHttpOrigin } from "@segmentstream-cloud/ontology/telegram";
|
|
7
8
|
const CONNECTION_KEY = /^[a-z][a-z0-9_]{0,63}$/;
|
|
8
9
|
const TELEGRAM_POLICIES = ["mention", "smart"];
|
|
9
10
|
const DEFAULT_STT_MODEL = "spacexai/grok-stt";
|
|
@@ -44,7 +45,12 @@ function telegramSettings(value, issues) {
|
|
|
44
45
|
const telegram = section({
|
|
45
46
|
value,
|
|
46
47
|
path,
|
|
47
|
-
allowed: [
|
|
48
|
+
allowed: [
|
|
49
|
+
"connection",
|
|
50
|
+
"policy",
|
|
51
|
+
"linkPreviews",
|
|
52
|
+
"additionalOwnOrigins"
|
|
53
|
+
],
|
|
48
54
|
issues
|
|
49
55
|
});
|
|
50
56
|
if (telegram === void 0) return null;
|
|
@@ -58,9 +64,21 @@ function telegramSettings(value, issues) {
|
|
|
58
64
|
message: "must be \"smart\" or \"mention\"",
|
|
59
65
|
path: [...path, "policy"]
|
|
60
66
|
});
|
|
67
|
+
const linkPreviews = telegram.linkPreviews === void 0 ? "all" : telegram.linkPreviews;
|
|
68
|
+
const additionalOwnOrigins = telegram.additionalOwnOrigins === void 0 ? [] : telegram.additionalOwnOrigins;
|
|
69
|
+
if (!TELEGRAM_LINK_PREVIEWS.some((mode) => mode === linkPreviews)) issues.push({
|
|
70
|
+
message: "must be \"external\", \"none\" or \"all\"",
|
|
71
|
+
path: [...path, "linkPreviews"]
|
|
72
|
+
});
|
|
73
|
+
if (!Array.isArray(additionalOwnOrigins) || !additionalOwnOrigins.every(isHttpOrigin)) issues.push({
|
|
74
|
+
message: "must be an array of HTTP(S) origins without paths, credentials, queries or fragments",
|
|
75
|
+
path: [...path, "additionalOwnOrigins"]
|
|
76
|
+
});
|
|
61
77
|
return typeof connection === "string" && isTelegramPolicy(policy) ? {
|
|
62
78
|
connection,
|
|
63
|
-
policy
|
|
79
|
+
policy,
|
|
80
|
+
linkPreviews,
|
|
81
|
+
additionalOwnOrigins
|
|
64
82
|
} : null;
|
|
65
83
|
}
|
|
66
84
|
function modelId(input) {
|
|
@@ -14,7 +14,7 @@ import { agentIdentities } from "../identities.mjs";
|
|
|
14
14
|
import { conversations } from "../conversations.mjs";
|
|
15
15
|
import { observedMessages } from "./observed.mjs";
|
|
16
16
|
import { telegramSendScope } from "./send-queue.mjs";
|
|
17
|
-
import { d as failureText, g as withDeliveryLocale, h as safeTelegramFetch, i as withReplacedText, m as reportTelegramError, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-
|
|
17
|
+
import { d as failureText, g as withDeliveryLocale, h as safeTelegramFetch, i as withReplacedText, m as reportTelegramError, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
18
18
|
import { captureRouteDecider, captureTelegramFetch, conversationIdentities, recordGateDecision, telegramConversationCapture } from "./conversations.mjs";
|
|
19
19
|
import { runtimeTokenVerifier } from "../runtime-identity.mjs";
|
|
20
20
|
import { botIdentityCache } from "./bot.mjs";
|
|
@@ -32,6 +32,7 @@ import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch }
|
|
|
32
32
|
import { healthRoute } from "./health.mjs";
|
|
33
33
|
import { telegramFailureEvents } from "./turn-errors.mjs";
|
|
34
34
|
import { telegramWebhookVerifier } from "./webhook.mjs";
|
|
35
|
+
import { telegramPreviewEnvironment } from "@segmentstream-cloud/ontology/telegram";
|
|
35
36
|
import { telegramChannel } from "eve/channels/telegram";
|
|
36
37
|
const eveHistory = async (sessionId) => {
|
|
37
38
|
const { sessions } = await import("eve/server");
|
|
@@ -128,7 +129,10 @@ function segmentstreamTelegram(options) {
|
|
|
128
129
|
api: {
|
|
129
130
|
apiBaseUrl: TELEGRAM_PROXY_ORIGIN,
|
|
130
131
|
fileBaseUrl: TELEGRAM_PROXY_ORIGIN,
|
|
131
|
-
fetch: (input, init) => safeTelegramFetch(captureTelegramFetch(telegramProxyFetch(proxy(), telegramSendScope(environment, settings().connection)), archive, pairing), telegramSendScope(environment, settings().connection)
|
|
132
|
+
fetch: (input, init) => safeTelegramFetch(captureTelegramFetch(telegramProxyFetch(proxy(), telegramSendScope(environment, settings().connection)), archive, pairing), telegramSendScope(environment, settings().connection), {
|
|
133
|
+
settings: settings(),
|
|
134
|
+
ownOrigins: telegramPreviewEnvironment(environment).appOrigins
|
|
135
|
+
})(input, init)
|
|
132
136
|
},
|
|
133
137
|
credentials: {
|
|
134
138
|
botToken: TELEGRAM_PLACEHOLDER_TOKEN,
|
|
@@ -12,7 +12,7 @@ import { runtimeToken } from "../runtime-token.mjs";
|
|
|
12
12
|
import { ACT_AS_HEADER } from "../ontology-connection.mjs";
|
|
13
13
|
import { AttachmentError, CONVERSATION_HEADER, SESSION_HEADER } from "../attachments.mjs";
|
|
14
14
|
import { inTelegramSendQueue, telegramSendScope } from "./send-queue.mjs";
|
|
15
|
-
import { c as customerCopy, f as formattingRefused, l as customerMessage, m as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
15
|
+
import { c as customerCopy, f as formattingRefused, l as customerMessage, m as reportTelegramError } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
16
16
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
17
17
|
import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
|
|
18
18
|
import { attachmentOwner } from "../attachment-tools.mjs";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ChatPostPreview } from "../chat-post-confirmation.js";
|
|
2
2
|
import type { ConfirmationText } from "./confirmation-text.js";
|
|
3
3
|
/** Only the frozen deterministic card may bypass the generic technical-prose filter. */
|
|
4
|
-
export declare function withChatPostCard<T>(text: string, run: () => T): T;
|
|
4
|
+
export declare function withChatPostCard<T>(text: string, run: () => T, links?: readonly string[]): T;
|
|
5
5
|
export declare function isExactChatPostCard(text: string): boolean;
|
|
6
|
+
export declare function chatPostCardLinks(text: string): readonly string[] | undefined;
|
|
6
7
|
export declare function chatPostCopy(locale: string): {
|
|
7
8
|
edit: string;
|
|
8
9
|
changes: string;
|
|
@@ -4,16 +4,24 @@ 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 { telegramMarkdownLinks, telegramTextLinks } from "@segmentstream-cloud/ontology/telegram";
|
|
7
8
|
import { escapeMarkdownV2 } from "@chat-adapter/telegram";
|
|
8
9
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
10
|
const MAX_PREVIEW_LENGTH = 3584;
|
|
10
11
|
const exactText = new AsyncLocalStorage();
|
|
11
|
-
function withChatPostCard(text, run) {
|
|
12
|
+
function withChatPostCard(text, run, links = []) {
|
|
12
13
|
if (text.length > 4096) throw new Error("The complete chat confirmation cannot fit in one Telegram message.");
|
|
13
|
-
return exactText.run(
|
|
14
|
+
return exactText.run({
|
|
15
|
+
text,
|
|
16
|
+
links
|
|
17
|
+
}, run);
|
|
14
18
|
}
|
|
15
19
|
function isExactChatPostCard(text) {
|
|
16
|
-
return exactText.getStore() === text;
|
|
20
|
+
return exactText.getStore()?.text === text;
|
|
21
|
+
}
|
|
22
|
+
function chatPostCardLinks(text) {
|
|
23
|
+
const card = exactText.getStore();
|
|
24
|
+
return card?.text === text ? card.links : void 0;
|
|
17
25
|
}
|
|
18
26
|
function chatPostCopy(locale) {
|
|
19
27
|
return locale.startsWith("ru") ? {
|
|
@@ -43,6 +51,11 @@ function chatPostCard(preview, locale) {
|
|
|
43
51
|
if (text.length > MAX_PREVIEW_LENGTH) throw new Error("The full message and receipt cannot fit in one Telegram confirmation. Make a shorter draft.");
|
|
44
52
|
return {
|
|
45
53
|
text,
|
|
54
|
+
previewLinks: [
|
|
55
|
+
...telegramTextLinks(`${preview.title}\n${preview.replyTo ?? ""}`),
|
|
56
|
+
...telegramMarkdownLinks(preview.text),
|
|
57
|
+
...telegramTextLinks(preview.attribution)
|
|
58
|
+
],
|
|
46
59
|
confirm: russian ? "Отправить" : "Confirm",
|
|
47
60
|
cancel: russian ? "Отмена" : "Cancel",
|
|
48
61
|
executing: russian ? "Подтверждено." : "Confirmed.",
|
|
@@ -65,4 +78,4 @@ function chatPostReceipt(output, locale) {
|
|
|
65
78
|
...value.history_recorded ? [] : [copy.history]
|
|
66
79
|
].join("\n");
|
|
67
80
|
}
|
|
68
|
-
export { chatPostCard, chatPostCardStatus, chatPostCopy, chatPostReceipt, isExactChatPostCard, withChatPostCard };
|
|
81
|
+
export { chatPostCard, chatPostCardLinks, chatPostCardStatus, chatPostCopy, chatPostReceipt, isExactChatPostCard, withChatPostCard };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SessionAuthContext } from "eve/context";
|
|
2
2
|
import { type ConfirmationDescription } from "../confirmation-description.js";
|
|
3
3
|
export interface ConfirmationText {
|
|
4
|
+
readonly previewLinks?: readonly string[];
|
|
4
5
|
readonly text: string;
|
|
5
6
|
readonly confirm: string;
|
|
6
7
|
readonly cancel: string;
|
|
@@ -9,10 +9,11 @@ import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
|
|
|
9
9
|
import { chatPostCard, chatPostCardStatus, chatPostCopy, chatPostReceipt, withChatPostCard } from "./chat-post-card.mjs";
|
|
10
10
|
import { confirmations } from "../confirmations.mjs";
|
|
11
11
|
import { conversationEvent } from "../conversations.mjs";
|
|
12
|
-
import { d as failureText, m as reportTelegramError, n as currentInboundRequest, o as currentLocale } from "../../../_chunks/inbound-request-
|
|
12
|
+
import { d as failureText, m as reportTelegramError, n as currentInboundRequest, o as currentLocale } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
13
13
|
import { answerMarker, isPendingQuestion, pendingQuestions, questionKey } from "../questions.mjs";
|
|
14
14
|
import { confirmationCopy, confirmationLocale, fallbackConfirmation } from "./confirmation-text.mjs";
|
|
15
15
|
import { formatAddress, scopedAddress } from "./sessions.mjs";
|
|
16
|
+
import { telegramTextLinks } from "@segmentstream-cloud/ontology/telegram";
|
|
16
17
|
import { registerTelegramFreeformPrompt, renderTelegramInputRequest } from "eve/channels/telegram";
|
|
17
18
|
import { createHash } from "node:crypto";
|
|
18
19
|
const PREFIX = "ss-confirm:";
|
|
@@ -264,7 +265,7 @@ function telegramConfirmationEvents(render = async (description, locale) => fall
|
|
|
264
265
|
}
|
|
265
266
|
]] }
|
|
266
267
|
});
|
|
267
|
-
const sent = await (exactPost ? withChatPostCard(text, send) : send());
|
|
268
|
+
const sent = await (exactPost ? withChatPostCard(text, send, copy.previewLinks) : send());
|
|
268
269
|
const state = channel.state;
|
|
269
270
|
state.confirmationMessages = {
|
|
270
271
|
...state.confirmationMessages,
|
|
@@ -274,7 +275,8 @@ function telegramConfirmationEvents(render = async (description, locale) => fall
|
|
|
274
275
|
text,
|
|
275
276
|
copy,
|
|
276
277
|
locale: confirmationLocale(ctx.session.auth.current),
|
|
277
|
-
exactPost
|
|
278
|
+
exactPost,
|
|
279
|
+
previewLinks: copy.previewLinks
|
|
278
280
|
}
|
|
279
281
|
};
|
|
280
282
|
}
|
|
@@ -307,7 +309,7 @@ function telegramConfirmationEvents(render = async (description, locale) => fall
|
|
|
307
309
|
replyMarkup: { inline_keyboard: [] },
|
|
308
310
|
text
|
|
309
311
|
});
|
|
310
|
-
await (message.exactPost ? withChatPostCard(text, edit) : edit());
|
|
312
|
+
await (message.exactPost ? withChatPostCard(text, edit, [...message.previewLinks ?? [], ...telegramTextLinks(status)]) : edit());
|
|
311
313
|
await record(callId, reason ?? resolution.outcome, text, resolution.outcome === "approved" ? "completed" : "cancelled", ctx);
|
|
312
314
|
const question = chatPostEditQuestion(resolution);
|
|
313
315
|
if (message.exactPost && reason === "edit" && question !== void 0) {
|
|
@@ -394,7 +396,7 @@ function telegramConfirmationEvents(render = async (description, locale) => fall
|
|
|
394
396
|
messageId: message.messageId,
|
|
395
397
|
replyMarkup: { inline_keyboard: [] },
|
|
396
398
|
text
|
|
397
|
-
}));
|
|
399
|
+
}), [...message.previewLinks ?? [], ...telegramTextLinks(status)]);
|
|
398
400
|
await record(data.result.callId, "receipt", text, failed ? "failed" : object(data.result.kind === "tool-result" ? data.result.output : void 0).status === "sent" ? "completed" : "unknown", ctx);
|
|
399
401
|
} else if (failed) {
|
|
400
402
|
const errorId = reportTelegramError("confirmed_action_failed", data, { callId: data.result.callId });
|
|
@@ -17,7 +17,7 @@ export declare function telegramRecord(value: unknown): Readonly<Record<string,
|
|
|
17
17
|
export declare function messageContent(raw: Readonly<Record<string, unknown>>): MessageContent;
|
|
18
18
|
/** Only shape/size diagnostics: do not retain/log raw webhook bodies, URLs or credential values. */
|
|
19
19
|
export declare function contentShape(raw: Readonly<Record<string, unknown>>, content?: MessageContent): {
|
|
20
|
-
contentSource: "
|
|
20
|
+
contentSource: "none" | "text" | "caption" | "rich_message";
|
|
21
21
|
textType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
22
22
|
captionType: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
23
23
|
hasRichMessage: boolean;
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { collapseConversationEvents, conversationEvent } from "../conversations.mjs";
|
|
8
8
|
import { observedChatKey } from "./observed.mjs";
|
|
9
|
-
import { n as currentInboundRequest, s as currentThreadId } from "../../../_chunks/inbound-request-
|
|
9
|
+
import { n as currentInboundRequest, s as currentThreadId } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
10
10
|
import { reportMembership } from "./membership.mjs";
|
|
11
11
|
import { contentShape, messageContent } from "./content.mjs";
|
|
12
12
|
import { parseTelegramUpdate } from "eve/channels/telegram";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TelegramPreviewContext } from "@segmentstream-cloud/ontology/telegram";
|
|
1
2
|
import { type TelegramText } from "./format.js";
|
|
2
3
|
export declare function withDeliveryLocale<T>(locale: string, run: () => T, threadId?: string): T;
|
|
3
4
|
export declare function currentLocale(): string;
|
|
@@ -29,4 +30,4 @@ export declare class TelegramDeliveryError extends Error {
|
|
|
29
30
|
constructor(reference: string, delivery: "failed" | "unknown", messageIds: readonly number[]);
|
|
30
31
|
}
|
|
31
32
|
/** Covers framework defaults, edits and callback notices as well as ordinary agent replies. */
|
|
32
|
-
export declare function safeTelegramFetch(fetchImpl: typeof fetch, scope?: string): typeof fetch;
|
|
33
|
+
export declare function safeTelegramFetch(fetchImpl: typeof fetch, scope?: string, previews?: TelegramPreviewContext): typeof fetch;
|
|
@@ -4,5 +4,5 @@ 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 TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, g as withDeliveryLocale, h as safeTelegramFetch, l as customerMessage, m as reportTelegramError, o as currentLocale, p as isTechnicalText, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { a as TelegramDeliveryError, c as customerCopy, d as failureText, f as formattingRefused, g as withDeliveryLocale, h as safeTelegramFetch, l as customerMessage, m as reportTelegramError, o as currentLocale, p as isTechnicalText, s as currentThreadId, u as customerText } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
8
8
|
export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
|
|
@@ -6,7 +6,7 @@ __eveDirname(__filename);
|
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { conversationLanguage } from "./principal.mjs";
|
|
8
8
|
import { MAXIMUM_ATTACHMENT_BYTES, attachmentUrl } from "../attachments.mjs";
|
|
9
|
-
import { d as failureText, m as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
9
|
+
import { d as failureText, m as reportTelegramError } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
10
10
|
import { describableImage, describeReceivedImage } from "./images.mjs";
|
|
11
11
|
function telegramConversation(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 { m as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { m as reportTelegramError } from "../../../_chunks/inbound-request-DgyI7oR9.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,5 +4,5 @@ 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 { i as withReplacedText, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-
|
|
7
|
+
import { i as withReplacedText, n as currentInboundRequest, r as runInboundRequest, t as InboundRequest } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
8
8
|
export { InboundRequest, currentInboundRequest, runInboundRequest, withReplacedText };
|
|
@@ -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 { m as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { m as reportTelegramError } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
9
9
|
function planMedia(capabilities, descriptionModel = null) {
|
|
10
10
|
if (typeof descriptionModel === "string") return {
|
|
11
11
|
images: "describe",
|
|
@@ -8,7 +8,7 @@ import "./principal.mjs";
|
|
|
8
8
|
import { agentMessage, observedChatKey } from "./observed.mjs";
|
|
9
9
|
import { splitTelegramText } from "./format.mjs";
|
|
10
10
|
import { inTelegramSendQueue } from "./send-queue.mjs";
|
|
11
|
-
import { a as TelegramDeliveryError, l as customerMessage, m as reportTelegramError, o as currentLocale } from "../../../_chunks/inbound-request-
|
|
11
|
+
import { a as TelegramDeliveryError, l as customerMessage, m as reportTelegramError, o as currentLocale } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
12
12
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
13
13
|
const SILENT_MARKERS = new Set(["[silent]", "no_reply"]);
|
|
14
14
|
function isSilentReply(text) {
|
|
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
|
|
|
5
5
|
__eveDirname(__filename);
|
|
6
6
|
__eveCreateRequire(import.meta.url);
|
|
7
7
|
import { memberIdOf } from "./principal.mjs";
|
|
8
|
-
import { c as customerCopy, d as failureText, m as reportTelegramError, o as currentLocale } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { c as customerCopy, d as failureText, m as reportTelegramError, o as currentLocale } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
9
9
|
import { confirmationLocale } from "./confirmation-text.mjs";
|
|
10
10
|
const telegramFailureEvents = {
|
|
11
11
|
async "turn.cancelled"(event, channel, context) {
|
|
@@ -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 { m as reportTelegramError } from "../../../_chunks/inbound-request-
|
|
8
|
+
import { m as reportTelegramError } from "../../../_chunks/inbound-request-DgyI7oR9.mjs";
|
|
9
9
|
import { gateway, transcribe } from "ai";
|
|
10
10
|
const LABELS = {
|
|
11
11
|
voice: "voice message",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segmentstream/agent",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.12",
|
|
4
4
|
"description": "Mount a SegmentStream workspace's agent on eve: the ontology as tools, acting as the member who writes, and Telegram through the workspace's connection.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "SegmentStream",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@chat-adapter/telegram": "4.41.0",
|
|
64
|
+
"@segmentstream-cloud/ontology": "0.31.3",
|
|
64
65
|
"@vercel/oidc": "^3.8.4",
|
|
65
66
|
"ai": "^7.0.128",
|
|
66
67
|
"csv-parse": "^7.0.3",
|