@segmentstream/agent 0.42.1 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +1033 -0
  2. package/README.md +25 -24
  3. package/dist/_chunks/{build-metadata-BPEZ5XVM.mjs → build-metadata-BnufKOxq.mjs} +1 -1
  4. package/dist/_chunks/{inbound-request-DgQB4g1J.mjs → inbound-request-CK0QqEOP.mjs} +36 -1
  5. package/dist/_chunks/{principal-BIX7T6Hh.mjs → principal-BXvelsZk.mjs} +5 -5
  6. package/dist/extension/channels/telegram.mjs +1 -1
  7. package/dist/extension/channels/whatsapp.mjs +1 -1
  8. package/dist/extension/config.d.ts +26 -18
  9. package/dist/extension/config.mjs +65 -12
  10. package/dist/extension/conventions.d.ts +1 -1
  11. package/dist/extension/conventions.mjs +22 -19
  12. package/dist/extension/extension.d.ts +2 -2
  13. package/dist/extension/extension.mjs +3 -3
  14. package/dist/extension/hooks/authorization.mjs +1 -1
  15. package/dist/extension/hooks/{conversations.mjs → chat-recorder.mjs} +4 -4
  16. package/dist/extension/hooks/sandbox.d.ts +2 -2
  17. package/dist/extension/instructions/{conversations.mjs → chat-context.mjs} +2 -2
  18. package/dist/extension/instructions/persona.mjs +1 -1
  19. package/dist/extension/instructions/sandbox.mjs +2 -2
  20. package/dist/extension/instructions.md +10 -10
  21. package/dist/extension/lib/actor.mjs +1 -1
  22. package/dist/extension/lib/attachment-tools.d.ts +1 -1
  23. package/dist/extension/lib/attachment-tools.mjs +7 -7
  24. package/dist/extension/lib/attachments.d.ts +9 -4
  25. package/dist/extension/lib/attachments.mjs +9 -7
  26. package/dist/extension/lib/build-metadata.mjs +1 -1
  27. package/dist/extension/lib/chat-address.d.ts +33 -0
  28. package/dist/extension/lib/{conversation.mjs → chat-address.mjs} +13 -12
  29. package/dist/extension/lib/{conversations.d.ts → chat-archive.d.ts} +12 -12
  30. package/dist/extension/lib/{conversations.mjs → chat-archive.mjs} +9 -9
  31. package/dist/extension/lib/chat-context.d.ts +5 -5
  32. package/dist/extension/lib/chat-context.mjs +7 -7
  33. package/dist/extension/lib/{conversation-runtime.d.ts → chat-recorder.d.ts} +3 -3
  34. package/dist/extension/lib/{conversation-runtime.mjs → chat-recorder.mjs} +13 -13
  35. package/dist/extension/lib/confirmations.d.ts +3 -3
  36. package/dist/extension/lib/confirmations.mjs +8 -8
  37. package/dist/extension/lib/group-routing/addressing.d.ts +1 -1
  38. package/dist/extension/lib/group-routing/addressing.mjs +2 -2
  39. package/dist/extension/lib/group-routing/burst.mjs +2 -2
  40. package/dist/extension/lib/group-routing/{conversation-prompt.d.ts → chat-prompt.d.ts} +2 -2
  41. package/dist/extension/lib/group-routing/{conversation-prompt.mjs → chat-prompt.mjs} +3 -3
  42. package/dist/extension/lib/group-routing/{conversation-router.d.ts → chat-router.d.ts} +6 -6
  43. package/dist/extension/lib/group-routing/{conversation-router.mjs → chat-router.mjs} +9 -9
  44. package/dist/extension/lib/group-routing/engagement.mjs +2 -2
  45. package/dist/extension/lib/group-routing/messages.d.ts +1 -1
  46. package/dist/extension/lib/group-routing/policy.d.ts +6 -6
  47. package/dist/extension/lib/group-routing/policy.mjs +16 -16
  48. package/dist/extension/lib/group-routing/replay.mjs +36 -9
  49. package/dist/extension/lib/group-routing/router.d.ts +3 -3
  50. package/dist/extension/lib/group-routing/router.mjs +16 -16
  51. package/dist/extension/lib/group-routing/routing-context.d.ts +2 -2
  52. package/dist/extension/lib/group-routing/routing-context.mjs +2 -2
  53. package/dist/extension/lib/group-routing/signals.d.ts +3 -3
  54. package/dist/extension/lib/group-routing/signals.mjs +5 -5
  55. package/dist/extension/lib/model-service-alert.d.ts +2 -2
  56. package/dist/extension/lib/model-service-alert.mjs +2 -2
  57. package/dist/extension/lib/ontology-connection.mjs +1 -1
  58. package/dist/extension/lib/ontology-file-call.mjs +1 -1
  59. package/dist/extension/lib/ontology-tools.mjs +1 -1
  60. package/dist/extension/lib/review/hold.d.ts +7 -7
  61. package/dist/extension/lib/review/hold.mjs +12 -12
  62. package/dist/extension/lib/review/judge.d.ts +9 -9
  63. package/dist/extension/lib/review/judge.mjs +12 -12
  64. package/dist/extension/lib/review/reply.d.ts +13 -13
  65. package/dist/extension/lib/review/reply.mjs +20 -20
  66. package/dist/extension/lib/role-skill.mjs +1 -1
  67. package/dist/extension/lib/runtime-envelope.mjs +1 -1
  68. package/dist/extension/lib/sent-files.mjs +3 -2
  69. package/dist/extension/lib/slack/adapter.mjs +2 -2
  70. package/dist/extension/lib/slack/attachments-send.d.ts +2 -2
  71. package/dist/extension/lib/slack/attachments-send.mjs +6 -6
  72. package/dist/extension/lib/slack/files.mjs +4 -4
  73. package/dist/extension/lib/stored-files.mjs +1 -1
  74. package/dist/extension/lib/telegram/adapter.d.ts +4 -3
  75. package/dist/extension/lib/telegram/adapter.mjs +35 -15
  76. package/dist/extension/lib/telegram/app-links.d.ts +39 -0
  77. package/dist/extension/lib/telegram/app-links.mjs +53 -0
  78. package/dist/extension/lib/telegram/attachment-description.mjs +1 -1
  79. package/dist/extension/lib/telegram/attachments-send.mjs +2 -2
  80. package/dist/extension/lib/telegram/callbacks.mjs +2 -2
  81. package/dist/extension/lib/telegram/{conversations.d.ts → chat-archive.d.ts} +7 -7
  82. package/dist/extension/lib/telegram/{conversations.mjs → chat-archive.mjs} +11 -11
  83. package/dist/extension/lib/telegram/confirmation-text.mjs +1 -0
  84. package/dist/extension/lib/telegram/confirmations.d.ts +2 -2
  85. package/dist/extension/lib/telegram/confirmations.mjs +4 -4
  86. package/dist/extension/lib/telegram/customer-text.d.ts +2 -1
  87. package/dist/extension/lib/telegram/customer-text.mjs +1 -1
  88. package/dist/extension/lib/telegram/delivery-diagnostics.d.ts +3 -3
  89. package/dist/extension/lib/telegram/delivery-diagnostics.mjs +2 -2
  90. package/dist/extension/lib/telegram/files.d.ts +1 -1
  91. package/dist/extension/lib/telegram/files.mjs +9 -9
  92. package/dist/extension/lib/telegram/health.mjs +1 -1
  93. package/dist/extension/lib/telegram/images.mjs +1 -1
  94. package/dist/extension/lib/telegram/inbound-request.d.ts +1 -1
  95. package/dist/extension/lib/telegram/inbound-request.mjs +1 -1
  96. package/dist/extension/lib/telegram/inbound.d.ts +3 -3
  97. package/dist/extension/lib/telegram/inbound.mjs +37 -37
  98. package/dist/extension/lib/telegram/lifecycle.mjs +4 -4
  99. package/dist/extension/lib/telegram/media-policy.mjs +1 -1
  100. package/dist/extension/lib/telegram/principal.d.ts +2 -2
  101. package/dist/extension/lib/telegram/principal.mjs +1 -1
  102. package/dist/extension/lib/telegram/router.mjs +2 -2
  103. package/dist/extension/lib/telegram/session-recovery.mjs +1 -1
  104. package/dist/extension/lib/telegram/sessions.d.ts +1 -1
  105. package/dist/extension/lib/telegram/signals.mjs +1 -1
  106. package/dist/extension/lib/telegram/silent.d.ts +2 -2
  107. package/dist/extension/lib/telegram/silent.mjs +1 -1
  108. package/dist/extension/lib/telegram/structured.mjs +1 -1
  109. package/dist/extension/lib/telegram/turn-errors.d.ts +2 -2
  110. package/dist/extension/lib/telegram/turn-errors.mjs +3 -3
  111. package/dist/extension/lib/telegram/voice.d.ts +1 -1
  112. package/dist/extension/lib/telegram/voice.mjs +1 -1
  113. package/dist/extension/lib/whatsapp/adapter.d.ts +2 -2
  114. package/dist/extension/lib/whatsapp/adapter.mjs +4 -2
  115. package/dist/extension/lib/whatsapp/links.d.ts +12 -0
  116. package/dist/extension/lib/whatsapp/links.mjs +34 -0
  117. package/dist/extension/lib/workflow-serializable.d.ts +1 -1
  118. package/dist/extension/model.mjs +1 -1
  119. package/dist/extension/personas.d.ts +1 -1
  120. package/dist/extension/review.d.ts +23 -20
  121. package/dist/extension/review.mjs +21 -34
  122. package/dist/extension/tools/attachments_promote.mjs +1 -1
  123. package/dist/extension/tools/attachments_send.mjs +3 -3
  124. package/dist/extension/tools/no_reply.d.ts +1 -1
  125. package/dist/extension/tools/questions_ask.mjs +4 -4
  126. package/dist/extension/tools/sandbox.mjs +2 -2
  127. package/package.json +3 -2
  128. package/dist/extension/lib/conversation.d.ts +0 -33
  129. /package/dist/extension/hooks/{conversations.d.ts → chat-recorder.d.ts} +0 -0
  130. /package/dist/extension/instructions/{conversations.d.ts → chat-context.d.ts} +0 -0
@@ -12,10 +12,10 @@ 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-BIX7T6Hh.mjs";
15
+ import "../../../_chunks/principal-BXvelsZk.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-DgQB4g1J.mjs";
18
+ import { d as failureText, f as formattingRefused, l as customerMessage, p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
19
19
  import { TELEGRAM_PLACEHOLDER_TOKEN, TELEGRAM_PROXY_ORIGIN, telegramProxyFetch } from "./proxy-fetch.mjs";
20
20
  const MAXIMUM_PHOTO_BYTES = 10485760;
21
21
  const MAXIMUM_DOCUMENT_BYTES = 52428800;
@@ -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-BIX7T6Hh.mjs";
9
- import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-DgQB4g1J.mjs";
8
+ import { d as telegramRuntimeSource, i as memberIdOf, o as telegramPrincipal, u as runtimeEnvelope } from "../../../_chunks/principal-BXvelsZk.mjs";
9
+ import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.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";
@@ -1,6 +1,6 @@
1
1
  import type { StructuredMessage } from "./structured.js";
2
2
  import type { AgentIdentities } from "../identities.js";
3
- import { type Conversations } from "../conversations.js";
3
+ import { type ChatArchive } from "../chat-archive.js";
4
4
  import type { AgentChats } from "../chats.js";
5
5
  import type { DecodedAttachment } from "./attachment-description.js";
6
6
  import type { AddressingReason, RouteDecider, RouteDecision } from "./router.js";
@@ -11,7 +11,7 @@ export declare function captureTelegramWebhook(input: {
11
11
  readonly answerCallback?: (id: string, locale?: string) => Promise<unknown>;
12
12
  readonly structured?: (raw: Readonly<Record<string, unknown>>) => StructuredMessage | undefined;
13
13
  readonly request: Request;
14
- readonly archive: Conversations;
14
+ readonly archive: ChatArchive;
15
15
  readonly identities: AgentIdentities;
16
16
  readonly chats?: AgentChats;
17
17
  readonly next: (request?: Request) => Promise<Response>;
@@ -46,7 +46,7 @@ export declare function recordInboundContent(content: {
46
46
  * member's notice never depends on the archive.
47
47
  */
48
48
  export declare function recordSessionFailure(input: {
49
- readonly archive: Conversations;
49
+ readonly archive: ChatArchive;
50
50
  readonly identities: () => AgentIdentities;
51
51
  readonly chatId: string | null;
52
52
  readonly threadId: string | null;
@@ -57,14 +57,14 @@ export declare function recordSessionFailure(input: {
57
57
  };
58
58
  }): Promise<void>;
59
59
  /** Captures message sends and button/status edits, including pairing and proactive replies. */
60
- export declare function captureTelegramFetch(fetchImpl: typeof fetch, archive: Conversations, identities: () => AgentIdentities): typeof fetch;
60
+ export declare function captureTelegramFetch(fetchImpl: typeof fetch, archive: ChatArchive, identities: () => AgentIdentities): typeof fetch;
61
61
  /** Reuses the request's verified lookup; it never survives into another inbound request. */
62
- export declare function conversationIdentities(identities: AgentIdentities): AgentIdentities;
62
+ export declare function chatIdentities(identities: AgentIdentities): AgentIdentities;
63
63
  /** Verification and failure acknowledgement stay outside eve's swallowed onMessage failures. */
64
- export declare function telegramConversationCapture(input: {
64
+ export declare function telegramChatCapture(input: {
65
65
  readonly answerCallback?: (id: string, locale?: string) => Promise<unknown>;
66
66
  readonly structured?: (raw: Readonly<Record<string, unknown>>) => StructuredMessage | undefined;
67
- readonly archive: Conversations;
67
+ readonly archive: ChatArchive;
68
68
  readonly identities: () => AgentIdentities;
69
69
  readonly chats: AgentChats;
70
70
  readonly verify: (request: Request) => boolean;
@@ -6,10 +6,10 @@ __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { parseArchivedMessage } from "./archive-message.mjs";
8
8
  import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
9
- import { conversationEvent, sessionFailureEventId } from "../conversations.mjs";
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-DgQB4g1J.mjs";
12
+ import { n as currentInboundRequest, p as reportTelegramError, s as currentThreadId } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
13
13
  import { reportMembership } from "./membership.mjs";
14
14
  import { currentDeliveryScope } from "./delivery-diagnostics.mjs";
15
15
  import { contentShape, messageContent } from "./content.mjs";
@@ -68,7 +68,7 @@ async function participants(message, identities, resolved) {
68
68
  resolved(lookup);
69
69
  return lookup.status === "paired" ? [lookup.member.id] : [];
70
70
  } catch (error) {
71
- console.error("[segmentstream] conversation participant lookup failed", { error });
71
+ console.error("[segmentstream] chat participant lookup failed", { error });
72
72
  return [];
73
73
  }
74
74
  }
@@ -114,7 +114,7 @@ async function captureTelegramWebhook(input) {
114
114
  const senderChat = record(message.raw.sender_chat);
115
115
  const attachments = attachmentRefs(message);
116
116
  let lookup;
117
- const event = conversationEvent({
117
+ const event = chatEvent({
118
118
  eventId: [
119
119
  "telegram",
120
120
  message.chat.id,
@@ -526,7 +526,7 @@ async function recordSessionFailure(input) {
526
526
  return;
527
527
  }
528
528
  const { chatType, participantIds } = await outboundAudience(input.chatId, input.identities);
529
- await input.archive.append(conversationEvent({
529
+ await input.archive.append(chatEvent({
530
530
  eventId: sessionId === null ? `eve:session.failed:${randomUUID()}` : sessionFailureEventId(sessionId),
531
531
  provider: "telegram",
532
532
  chatId: input.chatId,
@@ -558,7 +558,7 @@ function captureTelegramFetch(fetchImpl, archive, identities) {
558
558
  const { capture, chatType, participantIds } = await outboundAudience(chatId, identities);
559
559
  const delivery = currentDeliveryScope();
560
560
  const own = delivery?.chatId === chatId && delivery.sessionId !== null;
561
- const event = conversationEvent({
561
+ const event = chatEvent({
562
562
  eventId: `telegram:${edit ? "edit" : "send"}:${randomUUID()}`,
563
563
  provider: "telegram",
564
564
  chatId,
@@ -633,7 +633,7 @@ function captureTelegramFetch(fetchImpl, archive, identities) {
633
633
  return response;
634
634
  };
635
635
  }
636
- function conversationIdentities(identities) {
636
+ function chatIdentities(identities) {
637
637
  return {
638
638
  ...identities,
639
639
  resolve: async (account) => {
@@ -673,7 +673,7 @@ function conversationIdentities(identities) {
673
673
  }
674
674
  };
675
675
  }
676
- function telegramConversationCapture(input) {
676
+ function telegramChatCapture(input) {
677
677
  const processing = new Map();
678
678
  return async (request, next) => {
679
679
  if (!input.verify(request)) return next();
@@ -700,9 +700,9 @@ function telegramConversationCapture(input) {
700
700
  if (key !== void 0 && processing.get(key) === task) processing.delete(key);
701
701
  }
702
702
  } catch (error) {
703
- console.error("[segmentstream] conversation capture failed", { error });
704
- return new Response("conversation storage unavailable", { status: 503 });
703
+ console.error("[segmentstream] chat capture failed", { error });
704
+ return new Response("chat storage unavailable", { status: 503 });
705
705
  }
706
706
  };
707
707
  }
708
- export { REVISION_CLAIM_TTL_MS, captureRouteDecider, captureTelegramFetch, captureTelegramWebhook, conversationIdentities, recordGateDecision, recordInboundContent, recordRouteDecision, recordSessionFailure, telegramConversationCapture };
708
+ export { REVISION_CLAIM_TTL_MS, captureRouteDecider, captureTelegramFetch, captureTelegramWebhook, chatIdentities, recordGateDecision, recordInboundContent, recordRouteDecision, recordSessionFailure, telegramChatCapture };
@@ -39,6 +39,7 @@ function composer(text = "", entities = []) {
39
39
  }
40
40
  function confirmationLocale(principal, fallback = "en") {
41
41
  for (const key of [
42
+ "chatLanguage",
42
43
  "conversationLanguage",
43
44
  "locale",
44
45
  "language",
@@ -1,7 +1,7 @@
1
1
  import type { ChannelEvents } from "eve/channels";
2
2
  import type { TelegramCallbackQuery, TelegramChannelEvents, TelegramContext, TelegramEventContext } from "eve/channels/telegram";
3
3
  import { type ConfirmationPrompt, type PendingConfirmation, type RecentMessage } from "../group-routing/messages.js";
4
- import { type Conversations } from "../conversations.js";
4
+ import { type ChatArchive } from "../chat-archive.js";
5
5
  import type { AgentIdentities } from "../identities.js";
6
6
  import { type PendingQuestion } from "../questions.js";
7
7
  import { type HistoryReader, type RecordedEvent } from "./sessions.js";
@@ -32,5 +32,5 @@ export declare function refusalReason(data: {
32
32
  readonly output?: unknown;
33
33
  readonly error?: unknown;
34
34
  }): string | undefined;
35
- export declare function telegramConfirmationEvents(archive?: Conversations, scope?: () => "chat" | "thread"): TelegramChannelEvents & Pick<ChannelEvents<TelegramEventContext>, "context.settled">;
35
+ export declare function telegramConfirmationEvents(archive?: ChatArchive, scope?: () => "chat" | "thread"): TelegramChannelEvents & Pick<ChannelEvents<TelegramEventContext>, "context.settled">;
36
36
  export declare const confirmationEvents: TelegramChannelEvents & Pick<ChannelEvents<TelegramEventContext>, "context.settled">;
@@ -9,12 +9,12 @@ import { confirmations } from "../confirmations.mjs";
9
9
  import { humanText } from "../confirmation-description.mjs";
10
10
  import { withConfirmationPrompt } from "../group-routing/messages.mjs";
11
11
  import { chatPostOperationId, isChatPost } from "../chat-post-confirmation.mjs";
12
- import { conversationEvent } from "../conversations.mjs";
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-DgQB4g1J.mjs";
15
+ import { n as currentInboundRequest, p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
16
16
  import { confirmationStatus, renderConfirmation, withConfirmationText } from "./confirmation-text.mjs";
17
- import { i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-BIX7T6Hh.mjs";
17
+ import { i as memberIdOf, o as telegramPrincipal } from "../../../_chunks/principal-BXvelsZk.mjs";
18
18
  import { formatAddress, scopedAddress } from "./sessions.mjs";
19
19
  import { createHash } from "node:crypto";
20
20
  import { telegramTextLinks } from "@segmentstream/ontology/telegram";
@@ -218,7 +218,7 @@ function telegramConfirmationEvents(archive, scope) {
218
218
  if (archive === void 0 || saved?.description?.chatPost === void 0 || saved.source === void 0) return;
219
219
  const operationId = chatPostOperationId(ctx.session.id, callId);
220
220
  const source = saved.source;
221
- const append = () => archive.append(conversationEvent({
221
+ const append = () => archive.append(chatEvent({
222
222
  eventId: `chat-post:${operationId}:${phase}`,
223
223
  provider: "telegram",
224
224
  chatId: source.chatId,
@@ -1,5 +1,6 @@
1
1
  import { type TelegramPreviewContext } from "@segmentstream/ontology/telegram";
2
2
  import { type TelegramText } from "./format.js";
3
+ import { type TelegramAppLinkContext } from "./app-links.js";
3
4
  export { isTechnicalText } from "../customer-text-safety.js";
4
5
  export declare function withDeliveryLocale<T>(locale: string, run: () => T, threadId?: string, replyTo?: string, chatId?: string): T;
5
6
  export declare function currentLocale(): string;
@@ -32,4 +33,4 @@ export declare class TelegramDeliveryError extends Error {
32
33
  constructor(reference: string, delivery: "failed" | "unknown", messageIds: readonly number[]);
33
34
  }
34
35
  /** Covers framework defaults, edits and callback notices as well as ordinary agent replies. */
35
- export declare function safeTelegramFetch(fetchImpl: typeof fetch, scope?: string, previews?: TelegramPreviewContext): typeof fetch;
36
+ export declare function safeTelegramFetch(fetchImpl: typeof fetch, scope?: string, previews?: TelegramPreviewContext, appLinks?: TelegramAppLinkContext): typeof fetch;
@@ -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-DgQB4g1J.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-CK0QqEOP.mjs";
9
9
  export { TelegramDeliveryError, currentLocale, currentThreadId, customerCopy, customerMessage, customerText, failureText, formattingRefused, isTechnicalText, reportTelegramError, safeTelegramFetch, withDeliveryLocale };
@@ -1,15 +1,15 @@
1
- import { type ConversationEvent, type Conversations } from "../conversations.js";
1
+ import { type ChatEvent, type ChatArchive } from "../chat-archive.js";
2
2
  interface Diagnostic {
3
3
  readonly errorId: string;
4
4
  readonly operation: string;
5
5
  readonly error: unknown;
6
6
  readonly metadata: Record<string, unknown>;
7
7
  }
8
- type DeliveryScope = Pick<ConversationEvent, "chatId" | "chatType" | "threadId" | "sessionId" | "turnId">;
8
+ type DeliveryScope = Pick<ChatEvent, "chatId" | "chatType" | "threadId" | "sessionId" | "turnId">;
9
9
  /** Receives the same credential-redacted payload as operator logs, never raw provider errors. */
10
10
  export declare function retainDeliveryDiagnostic(diagnostic: Diagnostic): void;
11
11
  /** The session and turn a channel callback delivers for, so its sends are archived as its own. */
12
12
  export declare function currentDeliveryScope(): DeliveryScope | undefined;
13
13
  /** Await archive writes inside the channel callback, including failed or restored callbacks. */
14
- export declare function withDeliveryDiagnostics<T>(archive: Conversations, scope: DeliveryScope, run: () => T | Promise<T>): Promise<T>;
14
+ export declare function withDeliveryDiagnostics<T>(archive: ChatArchive, scope: DeliveryScope, run: () => T | Promise<T>): Promise<T>;
15
15
  export {};
@@ -5,7 +5,7 @@ const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
7
  import { n as contentText, t as CONTENT_CAPS } from "../../../_chunks/content-cDtVnr8Y.mjs";
8
- import { conversationEvent } from "../conversations.mjs";
8
+ import { chatEvent } from "../chat-archive.mjs";
9
9
  import { redactTelegramDiagnostic } from "./diagnostic-redaction.mjs";
10
10
  import { AsyncLocalStorage } from "node:async_hooks";
11
11
  const pending = new AsyncLocalStorage();
@@ -25,7 +25,7 @@ async function withDeliveryDiagnostics(archive, scope, run) {
25
25
  return await run();
26
26
  } finally {
27
27
  for (const diagnostic of diagnostics) try {
28
- await archive.append(conversationEvent({
28
+ await archive.append(chatEvent({
29
29
  ...scope,
30
30
  provider: "telegram",
31
31
  eventId: `telegram:diagnostic:${diagnostic.errorId}`,
@@ -12,7 +12,7 @@ import type { MediaPlan } from "./media-policy.js";
12
12
  * gets a note saying why.
13
13
  */
14
14
  /** The chat an attachment belongs to: `telegram:<chat id>`. */
15
- export declare function telegramConversation(chatId: string): string;
15
+ export declare function telegramChat(chatId: string): string;
16
16
  /** Eve normalizes photos/documents only. Keep other Telegram files available to attachment tools. */
17
17
  export declare function inboundAttachments(message: TelegramMessage): ReadonlyArray<TelegramAttachment>;
18
18
  /** Stores the message's files one after another, so that a large album holds one file at a time. */
@@ -5,10 +5,10 @@ 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-DgQB4g1J.mjs";
9
- import { n as conversationLanguage } from "../../../_chunks/principal-BIX7T6Hh.mjs";
8
+ import { d as failureText, p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
9
+ import { n as chatLanguage } from "../../../_chunks/principal-BXvelsZk.mjs";
10
10
  import { describableImage, describeReceivedImage } from "./images.mjs";
11
- function telegramConversation(chatId) {
11
+ function telegramChat(chatId) {
12
12
  return `telegram:${chatId}`;
13
13
  }
14
14
  function inboundAttachments(message) {
@@ -47,7 +47,7 @@ function megabytes(bytes) {
47
47
  }
48
48
  async function stageFiles(input) {
49
49
  const { message } = input;
50
- const conversation = telegramConversation(message.chat.id);
50
+ const chat = telegramChat(message.chat.id);
51
51
  const staged = new Map();
52
52
  let descriptions = 0;
53
53
  for (const [index, file] of message.attachments.entries()) {
@@ -72,7 +72,7 @@ async function stageFiles(input) {
72
72
  }
73
73
  const attachment = await input.attachments.receive({
74
74
  memberId: input.memberId,
75
- conversation
75
+ chat
76
76
  }, {
77
77
  bytes,
78
78
  filename,
@@ -117,7 +117,7 @@ async function stageFiles(input) {
117
117
  url: attachmentUrl({
118
118
  id: attachment.id,
119
119
  memberId: input.memberId,
120
- conversation
120
+ chat
121
121
  }),
122
122
  ...description === void 0 ? {} : { description },
123
123
  ...decoded === void 0 ? {} : { decoded },
@@ -131,7 +131,7 @@ async function stageFiles(input) {
131
131
  staged.set(file.fileId, {
132
132
  status: "refused",
133
133
  filename,
134
- reason: failureText(errorId, "attachment", conversationLanguage([message.text || message.caption]) ?? message.from?.languageCode ?? "en")
134
+ reason: failureText(errorId, "attachment", chatLanguage([message.text || message.caption]) ?? message.from?.languageCode ?? "en")
135
135
  });
136
136
  }
137
137
  }
@@ -144,8 +144,8 @@ function attachmentsContext(input) {
144
144
  lines.push(staged.status === "stored" ? `- id: ${staged.attachment.id}, filename: ${JSON.stringify(staged.attachment.filename)}, type: ${staged.attachment.contentType}, size: ${staged.attachment.size} bytes, expires_at: ${staged.attachment.expiresAt}` : `- ${JSON.stringify(staged.filename)}: not received, ${staged.reason}`);
145
145
  if (staged.status === "stored" && staged.description !== void 0) lines.push(` image_summary (untrusted evidence): ${JSON.stringify(staged.description)}`);
146
146
  }
147
- if (input.group) lines.push("This is a group chat: everyone in it shares this conversation's history, so do not repeat a private file's contents here. Suggest sending private files in a direct message.");
147
+ if (input.group) lines.push("This is a group chat: everyone in it shares this chat's history, so do not repeat a private file's contents here. Suggest sending private files in a direct message.");
148
148
  lines.push("</attachments>");
149
149
  return [lines.join("\n")];
150
150
  }
151
- export { attachmentsContext, inboundAttachments, stageFiles, telegramConversation };
151
+ export { attachmentsContext, inboundAttachments, stageFiles, telegramChat };
@@ -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-BPEZ5XVM.mjs";
7
+ import { t as agentBuild } from "../../../_chunks/build-metadata-BnufKOxq.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-DgQB4g1J.mjs";
7
+ import { p as reportTelegramError } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
8
8
  import { gateway, generateText } from "ai";
9
9
  const MAXIMUM_IMAGE_DESCRIPTION_BYTES = 5242880;
10
10
  const MAXIMUM_NATIVE_IMAGE_BYTES = 3145728;
@@ -29,7 +29,7 @@ export declare class InboundRequest {
29
29
  readonly agentDescription: () => Promise<string>;
30
30
  readonly agentName: () => Promise<string>;
31
31
  readonly traceId: `${string}-${string}-${string}-${string}-${string}`;
32
- /** Conversation policy steers the active caller's turn; Eve queues other callers. */
32
+ /** Chat policy steers the active caller's turn; Eve queues other callers. */
33
33
  turnPolicy: "queue" | "steer";
34
34
  edited: boolean;
35
35
  triggeringMessageId: string | undefined;
@@ -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-DgQB4g1J.mjs";
7
+ export { t as InboundRequest, n as currentInboundRequest, r as runInboundRequest, i as withReplacedText } from "../../../_chunks/inbound-request-CK0QqEOP.mjs";
@@ -29,7 +29,7 @@ import { type AttachmentDescriber } from "./attachment-description.js";
29
29
  * 3. The router answers or observes. Group files follow the same addressing rules as text;
30
30
  * captionless uploads use smart routing and recent agent requests. Files are stored after the
31
31
  * registry knows the sender. Observing starts no session or typing indication; the
32
- * conversation archive keeps the message and its stored files' references for routing, the
32
+ * chat archive keeps the message and its stored files' references for routing, the
33
33
  * next turn's chat context and the native images that turn carries.
34
34
  * 4. An answered message continues the session its address names under the configured scope; eve
35
35
  * compacts and expires sessions itself.
@@ -49,8 +49,8 @@ export interface InboundDependencies {
49
49
  readonly policy: TelegramPolicy;
50
50
  readonly decisionModel?: string;
51
51
  readonly groups?: GroupPolicy;
52
- /** The chat's or forum topic's recent messages from the conversation archive, oldest first. */
53
- readonly recentConversation?: (chatId: string, threadId?: string) => Promise<ReadonlyArray<RecentMessage>>;
52
+ /** The chat's or forum topic's recent messages from the chat archive, oldest first. */
53
+ readonly recentChat?: (chatId: string, threadId?: string) => Promise<ReadonlyArray<RecentMessage>>;
54
54
  readonly signalSettings?: TelegramSettings["groups"];
55
55
  readonly lifecycle?: (principal: import("eve/context").SessionAuthContext, memberId: string, message: TelegramMessage) => ReturnType<typeof attachmentLifecycle>;
56
56
  readonly admission: () => AdmissionSettings;